Bug 1333122 - Remove gfxPrefs::WebRenderEnabled() to avoid it being used inappopriately; do WR and APZ decision-making during compositor creation. r?dvander draft
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 23 Jan 2017 14:58:17 -0500
changeset 465094 b755d8febcf8634d90017a1172597cd65a4fe4e8
parent 465093 858feb665ee88f212b6f57efc6210e7babd605a7
child 465095 46e1478f8822cc004ccd25d115977dcba4434bd2
push id42545
push userkgupta@mozilla.com
push dateMon, 23 Jan 2017 19:58:54 +0000
reviewersdvander
bugs1333122
milestone53.0a1
Bug 1333122 - Remove gfxPrefs::WebRenderEnabled() to avoid it being used inappopriately; do WR and APZ decision-making during compositor creation. r?dvander MozReview-Commit-ID: 3If8vjrftHt
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPrefs.h
widget/nsBaseWidget.cpp
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -2459,22 +2459,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
@@ -420,23 +420,16 @@ 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);
-#else
-public:
-  static bool WebRenderEnabled() { 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
   DECL_GFX_PREF(Live, "gl.require-hardware",                   RequireHardwareGL, bool, false);
 
--- 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 = Preferences::GetBool("gfx.webrender.enabled", false);
+  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);
   }