Bug 1734505 - Add Feature::WINDOW_OCCLUSION r=gfx-reviewers,nical
authorsotaro <sotaro.ikeda.g@gmail.com>
Fri, 08 Oct 2021 13:11:52 +0000
changeset 595213 5978a0227866e70113b3594e7feed95d669cca47
parent 595212 86a7c7ce13bc3a43dc355c8b96358d4f042ce797
child 595214 6591695e856aa17b95375b92e4e9003256f87e8a
push id38862
push userctuns@mozilla.com
push dateFri, 08 Oct 2021 21:42:24 +0000
treeherdermozilla-central@798c43651cb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfx-reviewers, nical
bugs1734505, 1733955
milestone95.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 1734505 - Add Feature::WINDOW_OCCLUSION r=gfx-reviewers,nical With Feature::WINDOW_OCCLUSION, about:support could show if window occlusion is enabled. And Feature::WINDOW_OCCLUSION could be used to override windows occlusion setting. It could be used for Bug 1733955. Differential Revision: https://phabricator.services.mozilla.com/D127752
gfx/config/gfxFeature.h
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPlatform.h
widget/windows/WinWindowOcclusionTracker.cpp
--- a/gfx/config/gfxFeature.h
+++ b/gfx/config/gfxFeature.h
@@ -33,16 +33,17 @@ namespace gfx {
   _(WEBRENDER_OPTIMIZED_SHADERS, Feature, "WebRender optimized shaders") \
   _(WEBRENDER_ANGLE, Feature, "WebRender ANGLE")                         \
   _(WEBRENDER_DCOMP_PRESENT, Feature, "WebRender DirectComposition")     \
   _(WEBRENDER_SOFTWARE, Feature, "WebRender software fallback")          \
   _(OMTP, Feature, "Off Main Thread Painting")                           \
   _(WEBGPU, Feature, "WebGPU")                                           \
   _(X11_EGL, Feature, "X11 EGL")                                         \
   _(DMABUF, Feature, "DMABUF")                                           \
+  _(WINDOW_OCCLUSION, Feature, "WINDOW_OCCLUSION")                       \
   /* Add new entries above this comment */
 
 enum class Feature : uint32_t {
 #define MAKE_ENUM(name, type, desc) name,
   GFX_FEATURE_MAP(MAKE_ENUM)
 #undef MAKE_ENUM
       NumValues
 };
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -22,16 +22,17 @@
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/StaticPrefs_accessibility.h"
 #include "mozilla/StaticPrefs_apz.h"
 #include "mozilla/StaticPrefs_gfx.h"
 #include "mozilla/StaticPrefs_layout.h"
 #include "mozilla/StaticPrefs_layers.h"
 #include "mozilla/StaticPrefs_media.h"
 #include "mozilla/StaticPrefs_webgl.h"
+#include "mozilla/StaticPrefs_widget.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/Unused.h"
 #include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Base64.h"
 
 #include "mozilla/Logging.h"
 #include "mozilla/Components.h"
@@ -894,16 +895,17 @@ void gfxPlatform::Init() {
 #  error "No gfxPlatform implementation available"
 #endif
   gPlatform->PopulateScreenInfo();
   gPlatform->InitAcceleration();
   gPlatform->InitWebRenderConfig();
 
   gPlatform->InitWebGLConfig();
   gPlatform->InitWebGPUConfig();
+  gPlatform->InitWindowOcclusionConfig();
 
   // When using WebRender, we defer initialization of the D3D11 devices until
   // the (rare) cases where they're used. Note that the GPU process where
   // WebRender runs doesn't initialize gfxPlatform and performs explicit
   // initialization of the bits it needs.
   if (!UseWebRender()
 #if defined(XP_WIN)
       || (UseWebRender() && XRE_IsParentProcess() &&
@@ -2753,16 +2755,41 @@ void gfxPlatform::InitWebGPUConfig() {
 #endif
   if (!UseWebRender()) {
     feature.ForceDisable(FeatureStatus::UnavailableNoWebRender,
                          "WebGPU can't present without WebRender",
                          "FEATURE_FAILURE_WEBGPU_NEED_WEBRENDER"_ns);
   }
 }
 
+void gfxPlatform::InitWindowOcclusionConfig() {
+  if (!XRE_IsParentProcess()) {
+    return;
+  }
+#ifdef XP_WIN
+  FeatureState& feature = gfxConfig::GetFeature(Feature::WINDOW_OCCLUSION);
+  feature.SetDefaultFromPref(
+      StaticPrefs::
+          GetPrefName_widget_windows_window_occlusion_tracking_enabled(),
+      true,
+      StaticPrefs::
+          GetPrefDefault_widget_windows_window_occlusion_tracking_enabled());
+
+  const char* env = PR_GetEnv("MOZ_WINDOW_OCCLUSION");
+  if (env) {
+    if (*env == '1') {
+      feature.UserForceEnable("Force enabled by envvar");
+    } else {
+      feature.UserDisable("Force disabled by envvar",
+                          "FEATURE_FAILURE_OCCL_ENV"_ns);
+    }
+  }
+#endif
+}
+
 bool gfxPlatform::CanUseHardwareVideoDecoding() {
   // this function is called from the compositor thread, so it is not
   // safe to init the prefs etc. from here.
   MOZ_ASSERT(sLayersAccelerationPrefsInitialized);
   return sLayersSupportsHardwareVideoDecoding &&
          !sLayersHardwareVideoDecodingFailed;
 }
 
--- a/gfx/thebes/gfxPlatform.h
+++ b/gfx/thebes/gfxPlatform.h
@@ -806,16 +806,17 @@ class gfxPlatform : public mozilla::laye
  protected:
   gfxPlatform();
   virtual ~gfxPlatform();
 
   virtual void InitAcceleration();
   virtual void InitWebRenderConfig();
   virtual void InitWebGLConfig();
   virtual void InitWebGPUConfig();
+  virtual void InitWindowOcclusionConfig();
 
   virtual void GetPlatformDisplayInfo(mozilla::widget::InfoObject& aObj) {}
 
   /**
    * Called immediately before deleting the gfxPlatform object.
    */
   virtual void WillShutdown();
 
--- a/widget/windows/WinWindowOcclusionTracker.cpp
+++ b/widget/windows/WinWindowOcclusionTracker.cpp
@@ -9,16 +9,17 @@
 #include <winuser.h>
 #include <wtsapi32.h>
 
 #include "WinWindowOcclusionTracker.h"
 
 #include "base/thread.h"
 #include "base/message_loop.h"
 #include "base/platform_thread.h"
+#include "gfxConfig.h"
 #include "nsThreadUtils.h"
 #include "mozilla/DataMutex.h"
 #include "mozilla/gfx/Logging.h"
 #include "mozilla/layers/SynchronousTask.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/Logging.h"
 #include "mozilla/StaticPrefs_widget.h"
 #include "mozilla/StaticPtr.h"
@@ -344,17 +345,17 @@ RefPtr<WinWindowOcclusionTracker> WinWin
   return sTracker;
 }
 
 /* static */
 void WinWindowOcclusionTracker::Start() {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(!sTracker);
 
-  if (!StaticPrefs::widget_windows_window_occlusion_tracking_enabled()) {
+  if (!gfx::gfxConfig::IsEnabled(gfx::Feature::WINDOW_OCCLUSION)) {
     return;
   }
 
   LOG(LogLevel::Info, "WinWindowOcclusionTracker::Start()");
 
   base::Thread* thread = new base::Thread("WinWindowOcclusionCalc");
 
   base::Thread::Options options;