Bug 1326421 - Clean up remaining uses of gfxPrefs::WebRenderEnabled. r?dvander draft
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 12 Jan 2017 15:08:01 -0500
changeset 460012 e66a53271cca3df6187849b3240681c19b89f859
parent 460011 7c01a61aaba94d897061f01f31bdcdd128ab39c3
child 542009 0aabca942dc62bb3e507f6609fd1965859a9ee6d
push id41343
push userkgupta@mozilla.com
push dateThu, 12 Jan 2017 20:13:44 +0000
reviewersdvander
bugs1326421
milestone53.0a1
Bug 1326421 - Clean up remaining uses of gfxPrefs::WebRenderEnabled. r?dvander MozReview-Commit-ID: 5PqILhx9Abx
gfx/layers/ipc/CompositorBridgeParent.cpp
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPrefs.h
widget/nsBaseWidget.cpp
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -385,17 +385,17 @@ CompositorBridgeParent::Initialize()
 
   { // scope lock
     MonitorAutoLock lock(*sIndirectLayerTreesLock);
     sIndirectLayerTrees[mRootLayerTreeID].mParent = this;
   }
 
   LayerScope::SetPixelScale(mScale.scale);
 
-  if (!gfxPrefs::WebRenderEnabled()) {
+  if (!mOptions.UseWebRender()) {
     mCompositorScheduler = new CompositorVsyncScheduler(this, mWidget);
   }
 }
 
 mozilla::ipc::IPCResult
 CompositorBridgeParent::RecvReset(nsTArray<LayersBackend>&& aBackendHints,
                                   const uint64_t& aSeqNo,
                                   bool* aResult,
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -935,19 +935,19 @@ gfxPlatform::InitLayersIPC()
 {
     if (sLayersIPCIsUp) {
       return;
     }
     sLayersIPCIsUp = true;
 
     if (XRE_IsParentProcess())
     {
-        if (gfxPrefs::WebRenderEnabled()) {
-            RenderThread::Start();
-        }
+#ifdef MOZ_ENABLE_WEBRENDER
+        RenderThread::Start();
+#endif
         layers::CompositorThreadHolder::Start();
     }
 }
 
 /* static */ void
 gfxPlatform::ShutdownLayersIPC()
 {
     if (!sLayersIPCIsUp) {
@@ -964,19 +964,19 @@ gfxPlatform::ShutdownLayersIPC()
         }
     } else if (XRE_IsParentProcess()) {
         gfx::VRManagerChild::ShutDown();
         layers::CompositorBridgeChild::ShutDown();
         layers::ImageBridgeChild::ShutDown();
 
         // This has to happen after shutting down the child protocols.
         layers::CompositorThreadHolder::Shutdown();
-        if (gfxPrefs::WebRenderEnabled()) {
-            RenderThread::ShutDown();
-        }
+#ifdef MOZ_ENABLE_WEBRENDER
+        RenderThread::ShutDown();
+#endif
     } else {
       // TODO: There are other kind of processes and we should make sure gfx
       // stuff is either not created there or shut down properly.
     }
 }
 
 void
 gfxPlatform::WillShutdown()
@@ -2461,22 +2461,16 @@ gfxPlatform::AsyncPanZoomEnabled()
 #if !defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_UIKIT)
   // For XUL applications (everything but Firefox on Android)
   // we only want to use APZ when E10S is enabled. If
   // we ever get input events off the main thread we can consider relaxing
   // this requirement.
   if (!BrowserTabsRemoteAutostart()) {
     return false;
   }
-#ifdef MOZ_ENABLE_WEBRENDER
-  // For webrender hacking we have a special pref to disable APZ even with e10s
-  if (gfxPrefs::WebRenderEnabled() && !gfxPrefs::APZAllowWithWebRender()) {
-    return false;
-  }
-#endif // MOZ_ENABLE_WEBRENDER
 #endif
 #ifdef MOZ_WIDGET_ANDROID
   return true;
 #else
   return gfxPrefs::AsyncPanZoomEnabledDoNotUseDirectly();
 #endif
 }
 
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -421,20 +421,20 @@ private:
   DECL_GFX_PREF(Once, "gfx.vr.openvr-runtime",                 VROpenVRRuntime, std::string, "");
   DECL_GFX_PREF(Live, "gfx.vsync.collect-scroll-transforms",   CollectScrollTransforms, bool, false);
   DECL_GFX_PREF(Once, "gfx.vsync.compositor.unobserve-count",  CompositorUnobserveCount, int32_t, 10);
   DECL_GFX_PREF(Live, "gfx.webrender.profiler.enable",         WebRenderProfilerEnabled, bool, false);
   // Use vsync events generated by hardware
   DECL_GFX_PREF(Once, "gfx.work-around-driver-bugs",           WorkAroundDriverBugs, bool, true);
   DECL_GFX_PREF(Once, "gfx.screen-mirroring.enabled",          ScreenMirroringEnabled, bool, false);
 #ifdef MOZ_ENABLE_WEBRENDER
-  DECL_GFX_PREF(Once, "gfx.webrender.enabled",                 WebRenderEnabled, bool, false);
+  DECL_GFX_PREF(Live, "gfx.webrender.enabled",                 WebRenderEnabledDoNotUseDirectly, bool, false);
 #else
 public:
-  static bool WebRenderEnabled() { return false; }
+  static bool WebRenderEnabledDoNotUseDirectly() { return false; }
 private:
 #endif
 
   DECL_GFX_PREF(Live, "gl.ignore-dx-interop2-blacklist",       IgnoreDXInterop2Blacklist, bool, false);
   DECL_GFX_PREF(Live, "gl.msaa-level",                         MSAALevel, uint32_t, 2);
 #if defined(XP_MACOSX)
   DECL_GFX_PREF(Live, "gl.multithreaded",                      GLMultithreaded, bool, false);
 #endif
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -1293,17 +1293,28 @@ void nsBaseWidget::CreateCompositor(int 
   // If we've already received a shutdown notification, don't try
   // create a new compositor.
   if (!mShutdownObserver) {
     return;
   }
 
   CreateCompositorVsyncDispatcher();
 
-  CompositorOptions options(UseAPZ(), gfxPrefs::WebRenderEnabled());
+  // For now we decide whether or not to enable WR on this widget by the current
+  // value of the pref (this is the only place in the code allowed to check the
+  // value of the pref). We might want to change this eventually and drop the
+  // pref entirely.
+  bool enableWR = gfxPrefs::WebRenderEnabledDoNotUseDirectly();
+  bool enableAPZ = UseAPZ();
+  if (enableWR && !gfxPrefs::APZAllowWithWebRender()) {
+    // Disable APZ on widgets using WebRender, since it doesn't work yet. Allow
+    // it on non-WR widgets or if the pref forces it on.
+    enableAPZ = false;
+  }
+  CompositorOptions options(enableAPZ, enableWR);
 
   RefPtr<LayerManager> lm;
   if (options.UseWebRender()) {
     lm = new WebRenderLayerManager(this);
   } else {
     lm = new ClientLayerManager(this);
   }