Bug 1426191 - Update test_acceleration to check for webrender windows. r=dvander
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 21 Dec 2017 09:25:07 -0500
changeset 448914 3ac75a8a4e8cc3fe6ab57872106c8749d2c4eac1
parent 448913 3294f56c46c2c652072ecb0d809def04fb27b068
child 448915 cb60de4bfc7af48c400a26517b1e1bba08a64fac
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs1426191
milestone59.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 1426191 - Update test_acceleration to check for webrender windows. r=dvander MozReview-Commit-ID: gbBJs4OR9f
dom/base/nsDOMWindowUtils.cpp
dom/interfaces/base/nsIDOMWindowUtils.idl
gfx/tests/mochitest/test_acceleration.html
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPlatform.h
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -2333,16 +2333,24 @@ nsDOMWindowUtils::GetUsingAdvancedLayers
   *retval = false;
   if (KnowsCompositor* fwd = mgr->AsKnowsCompositor()) {
     *retval = fwd->GetTextureFactoryIdentifier().mUsingAdvancedLayers;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
+nsDOMWindowUtils::GetIsWebRenderRequested(bool* retval)
+{
+  *retval = gfxPlatform::WebRenderPrefEnabled() ||
+            gfxPlatform::WebRenderEnvvarEnabled();
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 nsDOMWindowUtils::GetCurrentAudioBackend(nsAString& aBackend)
 {
   CubebUtils::GetCurrentBackend(aBackend);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::GetCurrentMaxAudioChannels(uint32_t* aChannels)
--- a/dom/interfaces/base/nsIDOMWindowUtils.idl
+++ b/dom/interfaces/base/nsIDOMWindowUtils.idl
@@ -1327,16 +1327,23 @@ interface nsIDOMWindowUtils : nsISupport
   readonly attribute boolean layerManagerRemote;
 
   /**
    * True if advanced layers is enabled on this window, false otherwise.
    */
   readonly attribute boolean usingAdvancedLayers;
 
   /**
+   * True if webrender was requested by the user (via pref or env-var), false
+   * otherwise. Note that this doesn't represent whether or not webrender is
+   * *actually* enabled, just whether or not it was requested.
+   */
+  readonly attribute boolean isWebRenderRequested;
+
+  /**
    * Returns the current audio backend as a free-form string.
    */
   readonly attribute AString currentAudioBackend;
 
   /**
    * Returns the max channel counts of the current audio device.
    */
   readonly attribute unsigned long currentMaxAudioChannels;
--- a/gfx/tests/mochitest/test_acceleration.html
+++ b/gfx/tests/mochitest/test_acceleration.html
@@ -30,24 +30,28 @@ function runTest() {
 
   var sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
   var xr = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime);
 
   var windows = SpecialPowers.Services.ww.getWindowEnumerator();
   var windowutils;
   var acceleratedWindows = 0;
   var advancedLayersWindows = 0;
+  var webrenderWindows = 0;
   var layerManagerLog = [];
   while (windows.hasMoreElements()) {
     windowutils = windows.getNext().QueryInterface(Ci.nsIInterfaceRequestor)
                                    .getInterface(Ci.nsIDOMWindowUtils);
     try {
       if (windowutils.layerManagerType != "Basic") {
         acceleratedWindows++;
       }
+      if (windowutils.layerManagerType == "WebRender") {
+        webrenderWindows++;
+      }
       if (windowutils.usingAdvancedLayers) {
         advancedLayersWindows++;
       }
       layerManagerLog.push(windowutils.layerManagerType + ":" +
                            windowutils.usingAdvancedLayers);
     } catch (e) {
       // The window may not have a layer manager, in which case we get an error.
       // Don't count it as an accelerated window.
@@ -103,32 +107,47 @@ function runTest() {
         } else {
           ok(gfxInfo.DWriteEnabled, "DirectWrite enabled on Windows 7 or newer");
         }
       } else {
         ok(gfxInfo.D2DEnabled, "Direct2D enabled on Windows 8 or newer");
         ok(gfxInfo.DWriteEnabled, "DirectWrite enabled on Windows 7 or newer");
       }
 
+      var shouldGetWR = false;
+      try {
+        shouldGetWR = SpecialPowers.DOMWindowUtils.isWebRenderRequested;
+      } catch (e) {}
+
       var advancedLayersEnabled = false;
       var advancedLayersEnabledOnWin7 = false;
       try {
         advancedLayersEnabled = SpecialPowers.getBoolPref("layers.mlgpu.enabled");
         advancedLayersEnabledOnWin7 = SpecialPowers.getBoolPref("layers.mlgpu.enable-on-windows7");
       } catch (e) {}
       var shouldGetAL = advancedLayersEnabled;
       if (version < 6.2) {
         shouldGetAL &= advancedLayersEnabledOnWin7;
       }
+      if (shouldGetWR) {
+        shouldGetAL = false;
+      }
+
       if (shouldGetAL) {
         isnot(advancedLayersWindows, 0, "Advanced Layers enabled on Windows; "
                                         + layerManagerLog.join(","));
       } else {
         is(advancedLayersWindows, 0, "Advanced Layers disabled on Windows");
       }
+
+      if (shouldGetWR) {
+        isnot(webrenderWindows, 0, "WebRender enabled on Windows");
+      } else {
+        is(webrenderWindows, 0, "WebRender disabled on Windows");
+      }
       break;
 
     case "Linux":
       todo(false, "Acceleration supported on Linux, but only on taskcluster instances (bug 1296086)");
       break;
 
     default:
       if (xr.OS == "Android") {
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -2455,20 +2455,33 @@ gfxPlatform::InitCompositorAccelerationP
                          NS_LITERAL_CSTRING("FEATURE_FAILURE_COMP_SAFEMODE"));
   }
   if (IsHeadless()) {
     feature.ForceDisable(FeatureStatus::Blocked, "Acceleration blocked by headless mode",
                          NS_LITERAL_CSTRING("FEATURE_FAILURE_COMP_HEADLESSMODE"));
   }
 }
 
+/*static*/ bool
+gfxPlatform::WebRenderPrefEnabled()
+{
+  return Preferences::GetBool("gfx.webrender.enabled", false);
+}
+
+/*static*/ bool
+gfxPlatform::WebRenderEnvvarEnabled()
+{
+  const char* env = PR_GetEnv("MOZ_WEBRENDER");
+  return (env && *env == '1');
+}
+
 void
 gfxPlatform::InitWebRenderConfig()
 {
-  bool prefEnabled = Preferences::GetBool("gfx.webrender.enabled", false);
+  bool prefEnabled = WebRenderPrefEnabled();
 
   ScopedGfxFeatureReporter reporter("WR", prefEnabled);
   if (!XRE_IsParentProcess()) {
     // The parent process runs through all the real decision-making code
     // later in this function. For other processes we still want to report
     // the state of the feature for crash reports.
     if (gfxVars::UseWebRender()) {
       reporter.SetSuccessful();
@@ -2480,21 +2493,18 @@ gfxPlatform::InitWebRenderConfig()
 
   featureWebRender.DisableByDefault(
       FeatureStatus::OptIn,
       "WebRender is an opt-in feature",
       NS_LITERAL_CSTRING("FEATURE_FAILURE_DEFAULT_OFF"));
 
   if (prefEnabled) {
     featureWebRender.UserEnable("Enabled by pref");
-  } else {
-    const char* env = PR_GetEnv("MOZ_WEBRENDER");
-    if (env && *env == '1') {
-      featureWebRender.UserEnable("Enabled by envvar");
-    }
+  } else if (WebRenderEnvvarEnabled()) {
+    featureWebRender.UserEnable("Enabled by envvar");
   }
 
   // HW_COMPOSITING being disabled implies interfacing with the GPU might break
   if (!gfxConfig::IsEnabled(Feature::HW_COMPOSITING)) {
     featureWebRender.ForceDisable(
       FeatureStatus::Unavailable,
       "Hardware compositing is disabled",
       NS_LITERAL_CSTRING("FEATURE_FAILURE_WEBRENDER_NEED_HWCOMP"));
--- a/gfx/thebes/gfxPlatform.h
+++ b/gfx/thebes/gfxPlatform.h
@@ -705,16 +705,21 @@ public:
      * GPUProcessManager, in the UI process.
      */
     virtual void ImportGPUDeviceData(const mozilla::gfx::GPUDeviceData& aData);
 
     virtual FT_Library GetFTLibrary() {
       return nullptr;
     }
 
+    // you probably want to use gfxVars::UseWebRender() instead of this
+    static bool WebRenderPrefEnabled();
+    // you probably want to use gfxVars::UseWebRender() instead of this
+    static bool WebRenderEnvvarEnabled();
+
 protected:
     gfxPlatform();
     virtual ~gfxPlatform();
 
     virtual void InitAcceleration();
 
     /**
      * Called immediately before deleting the gfxPlatform object.