Bug 651858 - Part 7: Allow choosing the Azure canvas implementation. r=roc

This commit is contained in:
Bas Schouten 2011-06-24 19:41:18 +02:00
parent 50ad28ab7f
commit 001a090937

View File

@ -48,6 +48,7 @@
#include "jsapi.h"
#include "nsJSUtils.h"
#include "nsMathUtils.h"
#include "mozilla/Preferences.h"
#include "nsFrameManager.h"
#include "nsDisplayList.h"
@ -722,3 +723,23 @@ nsHTMLCanvasElement::RenderContextsExternal(gfxContext *aContext, gfxPattern::Gr
return mCurrentContext->Render(aContext, aFilter);
}
nsresult NS_NewCanvasRenderingContext2DThebes(nsIDOMCanvasRenderingContext2D** aResult);
nsresult NS_NewCanvasRenderingContext2DAzure(nsIDOMCanvasRenderingContext2D** aResult);
nsresult
NS_NewCanvasRenderingContext2D(nsIDOMCanvasRenderingContext2D** aResult)
{
PRBool azure = PR_FALSE;
nsresult rv = mozilla::Preferences::GetBool("gfx.canvas.azure.enabled", &azure);
if (azure) {
nsresult rv = NS_NewCanvasRenderingContext2DAzure(aResult);
// If Azure fails, fall back to a classic canvas.
if (NS_SUCCEEDED(rv)) {
return rv;
}
}
return NS_NewCanvasRenderingContext2DThebes(aResult);
}