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
This commit is contained in:
sotaro 2021-10-08 13:11:52 +00:00
Родитель ab0821f70c
Коммит d0f572a6ea
4 изменённых файлов: 31 добавлений и 1 удалений

Просмотреть файл

@ -38,6 +38,7 @@ namespace gfx {
_(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 {

Просмотреть файл

@ -27,6 +27,7 @@
#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"
@ -899,6 +900,7 @@ void gfxPlatform::Init() {
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
@ -2758,6 +2760,31 @@ void gfxPlatform::InitWebGPUConfig() {
}
}
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.

Просмотреть файл

@ -811,6 +811,7 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener {
virtual void InitWebRenderConfig();
virtual void InitWebGLConfig();
virtual void InitWebGPUConfig();
virtual void InitWindowOcclusionConfig();
virtual void GetPlatformDisplayInfo(mozilla::widget::InfoObject& aObj) {}

Просмотреть файл

@ -14,6 +14,7 @@
#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"
@ -349,7 +350,7 @@ 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;
}