Bug 876208: only evaluate the preference for gfx.direct2d.* once, and require restart before any further changes to the preferences take effect in the code, r=bas
authorMilan Sreckovic <msreckovic@mozilla.com>
Thu, 30 May 2013 16:53:37 -0400
changeset 146074 574f888ef8de68cedc43c38374ab23325acb75ed
parent 146073 f53bf9672936a50be90bab11db918a358e7192f9
child 146075 28b1754105fd4e5d67749208f9b039c081480df6
push id368
push userbbajaj@mozilla.com
push dateMon, 09 Sep 2013 22:57:58 +0000
treeherdermozilla-release@5a4f47ae1217 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbas
bugs876208
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 876208: only evaluate the preference for gfx.direct2d.* once, and require restart before any further changes to the preferences take effect in the code, r=bas
gfx/thebes/gfxWindowsPlatform.cpp
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -75,16 +75,34 @@ NS_MEMORY_REPORTER_IMPLEMENT(
     KIND_OTHER,
     UNITS_BYTES,
     cairo_d2d_get_image_surface_cache_usage,
     "Memory used by the Direct2D internal surface cache.")
 
 namespace
 {
 
+bool OncePreferenceDirect2DDisabled()
+{
+  static int preferenceValue = -1;
+  if (preferenceValue < 0) {
+    preferenceValue = Preferences::GetBool("gfx.direct2d.disabled", false);
+  }
+  return !!preferenceValue;
+}
+
+bool OncePreferenceDirect2DForceEnabled()
+{
+  static int preferenceValue = -1;
+  if (preferenceValue < 0) {
+    preferenceValue = Preferences::GetBool("gfx.direct2d.force-enabled", false);
+  }
+  return !!preferenceValue;
+}
+
 int64_t GetD2DSurfaceVramUsage() {
   cairo_device_t *device =
       gfxWindowsPlatform::GetPlatform()->GetD2DDevice();
   if (device) {
       return cairo_d2d_get_surface_vram_usage(device);
   }
   return 0;
 }
@@ -413,18 +431,20 @@ gfxWindowsPlatform::UpdateRenderMode()
         int32_t status;
         if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_DIRECT2D, &status))) {
             if (status != nsIGfxInfo::FEATURE_NO_INFO) {
                 d2dBlocked = true;
             }
         }
     }
 
-    d2dDisabled = Preferences::GetBool("gfx.direct2d.disabled", false);
-    d2dForceEnabled = Preferences::GetBool("gfx.direct2d.force-enabled", false);
+    // These will only be evaluated once, and any subsequent changes to
+    // the preferences will be ignored until restart.
+    d2dDisabled = OncePreferenceDirect2DDisabled();
+    d2dForceEnabled = OncePreferenceDirect2DForceEnabled();
 
 #ifdef MOZ_METRO
     // In Metro mode there is no fallback available
     d2dForceEnabled |= IsRunningInWindowsMetro();
 #endif
 
     bool tryD2D = !d2dBlocked || d2dForceEnabled;