diff --git a/content/html/content/src/nsHTMLCanvasElement.cpp b/content/html/content/src/nsHTMLCanvasElement.cpp index ed47529dc69..78eb1fa898e 100644 --- a/content/html/content/src/nsHTMLCanvasElement.cpp +++ b/content/html/content/src/nsHTMLCanvasElement.cpp @@ -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); +}