Bug 1154313 - Move sUsingHwc to gfxPrefs r=mwu,nical
authorSotaro Ikeda <sikeda@mozilla.com>
Wed, 15 Apr 2015 06:39:44 -0700
changeset 239294 b2704413af48
parent 239293 48e6aadb772b
child 239295 5da7f3f0c559
push id28588
push userryanvm@gmail.com
push date2015-04-15 19:01 +0000
treeherdermozilla-central@fdaea6d81a14 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmwu, nical
bugs1154313
milestone40.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 1154313 - Move sUsingHwc to gfxPrefs r=mwu,nical
gfx/layers/composite/LayerManagerComposite.cpp
gfx/thebes/gfxPrefs.h
widget/gonk/nsWindow.cpp
--- a/gfx/layers/composite/LayerManagerComposite.cpp
+++ b/gfx/layers/composite/LayerManagerComposite.cpp
@@ -663,17 +663,20 @@ LayerManagerComposite::Render()
   nsRefPtr<Composer2D> composer2D;
 
   // We can't use composert2D if we have layer effects, so only get it
   // when we don't have any effects.
   if (!haveLayerEffects) {
     composer2D = mCompositor->GetWidget()->GetComposer2D();
   }
 
-  if (!mTarget && composer2D && composer2D->TryRender(mRoot, mGeometryChanged)) {
+  if (!mTarget &&
+      gfxPrefs::Composer2DCompositionEnabled() &&
+      composer2D && composer2D->TryRender(mRoot, mGeometryChanged))
+  {
     LayerScope::SetHWComposed();
     if (mFPS) {
       double fps = mFPS->mCompositionFps.AddFrameAndGetFps(TimeStamp::Now());
       if (gfxPrefs::LayersDrawFPS()) {
         printf_stderr("HWComposer: FPS is %g\n", fps);
       }
     }
     mCompositor->EndFrameForExternalComposition(Matrix());
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -277,16 +277,17 @@ private:
   // If MOZ_GFX_OPTIMIZE_MOBILE is defined, we force component alpha off
   // and ignore the preference.
   DECL_GFX_PREF(Skip, "layers.componentalpha.enabled",         ComponentAlphaEnabled, bool, false);
 #else
   // If MOZ_GFX_OPTIMIZE_MOBILE is not defined, we actually take the
   // preference value, defaulting to true.
   DECL_GFX_PREF(Once, "layers.componentalpha.enabled",         ComponentAlphaEnabled, bool, true);
 #endif
+  DECL_GFX_PREF(Live, "layers.composer2d.enabled",             Composer2DCompositionEnabled, bool, false);
   DECL_GFX_PREF(Once, "layers.d3d11.disable-warp",             LayersD3D11DisableWARP, bool, false);
   DECL_GFX_PREF(Once, "layers.d3d11.force-warp",               LayersD3D11ForceWARP, bool, false);
   DECL_GFX_PREF(Live, "layers.draw-bigimage-borders",          DrawBigImageBorders, bool, false);
   DECL_GFX_PREF(Live, "layers.draw-borders",                   DrawLayerBorders, bool, false);
   DECL_GFX_PREF(Live, "layers.draw-tile-borders",              DrawTileBorders, bool, false);
   DECL_GFX_PREF(Live, "layers.draw-layer-info",                DrawLayerInfo, bool, false);
   DECL_GFX_PREF(Live, "layers.dump",                           LayersDump, bool, false);
   DECL_GFX_PREF(Live, "layers.dump-texture",                   LayersDumpTexture, bool, false);
--- a/widget/gonk/nsWindow.cpp
+++ b/widget/gonk/nsWindow.cpp
@@ -72,17 +72,16 @@ using namespace mozilla::widget;
 
 nsIntRect gScreenBounds;
 static uint32_t sScreenRotation;
 static uint32_t sPhysicalScreenRotation;
 static nsIntRect sVirtualBounds;
 
 static nsTArray<nsWindow *> sTopWindows;
 static nsWindow *gFocusedWindow = nullptr;
-static bool sUsingHwc;
 static bool sScreenInitialized;
 
 namespace {
 
 static uint32_t
 EffectiveScreenRotation()
 {
     return (sScreenRotation + sPhysicalScreenRotation) % (360 / 90);
@@ -178,18 +177,16 @@ nsWindow::nsWindow()
     //
     // NB: GetPlatform() will create the gfxPlatform, which wants
     // to know the color depth, which asks our native window.
     // This has to happen after other init has finished.
     gfxPlatform::GetPlatform();
     if (!ShouldUseOffMainThreadCompositing()) {
         MOZ_CRASH("How can we render apps, then?");
     }
-    // Update sUsingHwc whenever layers.composer2d.enabled changes
-    Preferences::AddBoolVarCache(&sUsingHwc, "layers.composer2d.enabled");
 }
 
 nsWindow::~nsWindow()
 {
     HwcComposer2D::GetInstance()->SetCompositorParent(nullptr);
 }
 
 void
@@ -855,20 +852,16 @@ nsWindow::NeedsPaint()
     return false;
   }
   return nsIWidget::NeedsPaint();
 }
 
 Composer2D*
 nsWindow::GetComposer2D()
 {
-    if (!sUsingHwc) {
-        return nullptr;
-    }
-
     if (HwcComposer2D* hwc = HwcComposer2D::GetInstance()) {
         return hwc->Initialized() ? hwc : nullptr;
     }
 
     return nullptr;
 }
 
 // nsScreenGonk.cpp