Bug 764125; sort out preferred and fallback Azure backends for all platforms (canvas and prefs). r=Bas
authorNicholas Cameron <ncameron@mozilla.com>
Tue, 24 Jul 2012 22:18:40 +1200
changeset 100548 fe9da23f093b314cbed92bd74b354fb94ea5ead6
parent 100547 904e9e5125fd4ee59c959ebf63bf2b49a84fb9b4
child 100549 300d4bfb68d9d606279302fcb28e30a51650d8ea
push idunknown
push userunknown
push dateunknown
reviewersBas
bugs764125
milestone17.0a1
Bug 764125; sort out preferred and fallback Azure backends for all platforms (canvas and prefs). r=Bas
content/canvas/src/nsCanvasRenderingContext2DAzure.cpp
modules/libpref/src/init/all.js
--- a/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp
+++ b/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp
@@ -544,56 +544,39 @@ NS_INTERFACE_MAP_END
 // Initialize our static variables.
 PRUint32 nsCanvasRenderingContext2DAzure::sNumLivingContexts = 0;
 PRUint8 (*nsCanvasRenderingContext2DAzure::sUnpremultiplyTable)[256] = nsnull;
 PRUint8 (*nsCanvasRenderingContext2DAzure::sPremultiplyTable)[256] = nsnull;
 
 namespace mozilla {
 namespace dom {
 
-static bool
-AzureCanvasEnabledOnPlatform()
-{
-#ifdef XP_WIN
-  if (gfxWindowsPlatform::GetPlatform()->GetRenderMode() !=
-      gfxWindowsPlatform::RENDER_DIRECT2D ||
-      !gfxWindowsPlatform::GetPlatform()->DWriteEnabled()) {
-    static bool checkedPref = false;
-    static bool preferSkia;
-    if (!checkedPref) {
-      preferSkia = Preferences::GetBool("gfx.canvas.azure.prefer-skia", false);
-      checkedPref = true;
-    }
-    return preferSkia;
-  }
-#elif !defined(XP_MACOSX) && !defined(ANDROID) && !defined(LINUX)
-  return false;
-#endif
-  return true;
-}
-
 bool
 AzureCanvasEnabled()
 {
   static bool checkedPref = false;
   static bool azureEnabled;
   if (!checkedPref) {
     azureEnabled = Preferences::GetBool("gfx.canvas.azure.enabled", false);
     checkedPref = true;
   }
-  return azureEnabled && AzureCanvasEnabledOnPlatform();
+
+  BackendType dontCare;
+  return azureEnabled && gfxPlatform::GetPlatform()->SupportsAzure(dontCare);
 }
 
 }
 }
 
 nsresult
 NS_NewCanvasRenderingContext2DAzure(nsIDOMCanvasRenderingContext2D** aResult)
 {
-  if (!AzureCanvasEnabledOnPlatform()) {
+  // XXX[nrc] remove this check when Thebes canvas is removed
+  // (because we will always support Azure)
+  if (!AzureCanvasEnabled()) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   nsRefPtr<nsIDOMCanvasRenderingContext2D> ctx = new nsCanvasRenderingContext2DAzure();
   if (!ctx)
     return NS_ERROR_OUT_OF_MEMORY;
 
   *aResult = ctx.forget().get();
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -220,20 +220,27 @@ pref("gfx.font_rendering.harfbuzz.script
 
 #ifdef XP_WIN
 pref("gfx.font_rendering.directwrite.enabled", false);
 pref("gfx.font_rendering.directwrite.use_gdi_table_loading", true);
 #endif
 
 #ifdef XP_WIN
 pref("gfx.canvas.azure.enabled", true);
+// comma separated list of backends to use in order of preference
+// e.g., pref("gfx.canvas.azure.backends", "direct2d,skia,cairo");
+pref("gfx.canvas.azure.backends", "direct2d");
 pref("gfx.content.azure.enabled", true);
 #else
 #ifdef XP_MACOSX
 pref("gfx.canvas.azure.enabled", true);
+pref("gfx.canvas.azure.backends", "cg");
+#else
+pref("gfx.canvas.azure.enabled", false);
+pref("gfx.canvas.azure.backends", "cairo,skia");
 #endif
 #endif
 
 #ifdef ANDROID
 pref("gfx.textures.poweroftwo.force-enabled", false);
 #endif
 
 pref("gfx.work-around-driver-bugs", true);