From 282b791acb826de9b537fce88bf49472d8e19977 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 25 Jan 2020 21:26:24 +0100 Subject: Issue #1360 - Part 1: Simplify layers acceleration prefs. This gets rid of platform-dependent hard-coded defaults, but keeps build-time blocking if there is no GL provider (in which case layers acceleration almost certainly won't work because it needs a GL compositor and would likely crash without) New prefs are - layers.acceleration.enabled to enable HWA - layers.acceleration.force to force it enabled (requires .enabled to be set as well) This is the platform part of this issue. The rest will be front-end work (Preference UI integration and pref migration) --- gfx/thebes/gfxAndroidPlatform.h | 5 ----- gfx/thebes/gfxPlatform.cpp | 41 ++++------------------------------------- gfx/thebes/gfxPlatform.h | 2 +- gfx/thebes/gfxPlatformGtk.h | 4 ---- gfx/thebes/gfxPlatformMac.cpp | 6 ------ gfx/thebes/gfxPlatformMac.h | 3 --- gfx/thebes/gfxPrefs.h | 4 ++-- gfx/thebes/gfxWindowsPlatform.h | 3 --- 8 files changed, 7 insertions(+), 61 deletions(-) (limited to 'gfx') diff --git a/gfx/thebes/gfxAndroidPlatform.h b/gfx/thebes/gfxAndroidPlatform.h index 30e7c89ba..8975d0ab9 100644 --- a/gfx/thebes/gfxAndroidPlatform.h +++ b/gfx/thebes/gfxAndroidPlatform.h @@ -72,11 +72,6 @@ public: return true; } -protected: - bool AccelerateLayersByDefault() override { - return true; - } - private: gfxImageFormat mOffscreenFormat; }; diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 50d1fcb46..4cd044f90 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -571,40 +571,6 @@ gfxPlatform::Init() } } - // Drop a note in the crash report if we end up forcing an option that could - // destabilize things. New items should be appended at the end (of an existing - // or in a new section), so that we don't have to know the version to interpret - // these cryptic strings. - { - nsAutoCString forcedPrefs; - // D2D prefs - forcedPrefs.AppendPrintf("FP(D%d%d", - gfxPrefs::Direct2DDisabled(), - gfxPrefs::Direct2DForceEnabled()); - // Layers prefs - forcedPrefs.AppendPrintf("-L%d%d%d%d", - gfxPrefs::LayersAMDSwitchableGfxEnabled(), - gfxPrefs::LayersAccelerationDisabledDoNotUseDirectly(), - gfxPrefs::LayersAccelerationForceEnabledDoNotUseDirectly(), - gfxPrefs::LayersD3D11ForceWARP()); - // WebGL prefs - forcedPrefs.AppendPrintf("-W%d%d%d%d%d%d%d%d", - gfxPrefs::WebGLANGLEForceD3D11(), - gfxPrefs::WebGLANGLEForceWARP(), - gfxPrefs::WebGLDisabled(), - gfxPrefs::WebGLDisableANGLE(), - gfxPrefs::WebGLDXGLEnabled(), - gfxPrefs::WebGLForceEnabled(), - gfxPrefs::WebGLForceLayersReadback(), - gfxPrefs::WebGLForceMSAA()); - // Prefs that don't fit into any of the other sections - forcedPrefs.AppendPrintf("-T%d%d%d%d) ", - gfxPrefs::AndroidRGB16Force(), - gfxPrefs::CanvasAzureAccelerated(), - gfxPrefs::DisableGralloc(), - gfxPrefs::ForceShmemTiles()); - } - InitMoz2DLogging(); gGfxPlatformPrefsLock = new Mutex("gfxPlatform::gGfxPlatformPrefsLock"); @@ -2171,7 +2137,7 @@ gfxPlatform::InitCompositorAccelerationPrefs() FeatureStatus::Blocked, "Acceleration blocked by platform")) { - if (gfxPrefs::LayersAccelerationDisabledDoNotUseDirectly()) { + if (!gfxPrefs::LayersAccelerationEnabledDoNotUseDirectly()) { feature.UserDisable("Disabled by pref", NS_LITERAL_CSTRING("FEATURE_FAILURE_COMP_PREF")); } else if (acceleratedEnv && *acceleratedEnv == '0') { @@ -2185,8 +2151,9 @@ gfxPlatform::InitCompositorAccelerationPrefs() } // This has specific meaning elsewhere, so we always record it. - if (gfxPrefs::LayersAccelerationForceEnabledDoNotUseDirectly()) { - feature.UserForceEnable("Force-enabled by pref"); + if (gfxPrefs::LayersAccelerationEnabledDoNotUseDirectly() && + gfxPrefs::LayersAccelerationForceEnabledDoNotUseDirectly()) { + feature.UserForceEnable("Force-enabled by prefs"); } // Safe mode trumps everything. diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 68bb99ea4..642cf909f 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -698,7 +698,7 @@ protected: virtual already_AddRefed CreateHardwareVsyncSource(); // Returns whether or not layers should be accelerated by default on this platform. - virtual bool AccelerateLayersByDefault(); + bool AccelerateLayersByDefault(); // Returns a prioritized list of available compositor backends for acceleration. virtual void GetAcceleratedCompositorBackends(nsTArray& aBackends); diff --git a/gfx/thebes/gfxPlatformGtk.h b/gfx/thebes/gfxPlatformGtk.h index 9959c0e13..22ed4b08f 100644 --- a/gfx/thebes/gfxPlatformGtk.h +++ b/gfx/thebes/gfxPlatformGtk.h @@ -132,10 +132,6 @@ public: return true; } - bool AccelerateLayersByDefault() override { - return true; - } - #ifdef GL_PROVIDER_GLX already_AddRefed CreateHardwareVsyncSource() override; #endif diff --git a/gfx/thebes/gfxPlatformMac.cpp b/gfx/thebes/gfxPlatformMac.cpp index 79684dd19..75c5236a8 100644 --- a/gfx/thebes/gfxPlatformMac.cpp +++ b/gfx/thebes/gfxPlatformMac.cpp @@ -372,12 +372,6 @@ gfxPlatformMac::ReadAntiAliasingThreshold() return threshold; } -bool -gfxPlatformMac::AccelerateLayersByDefault() -{ - return true; -} - // This is the renderer output callback function, called on the vsync thread static CVReturn VsyncCallback(CVDisplayLinkRef aDisplayLink, const CVTimeStamp* aNow, diff --git a/gfx/thebes/gfxPlatformMac.h b/gfx/thebes/gfxPlatformMac.h index 0807614f6..ea4c1a101 100644 --- a/gfx/thebes/gfxPlatformMac.h +++ b/gfx/thebes/gfxPlatformMac.h @@ -81,9 +81,6 @@ public: // lower threshold on font anti-aliasing uint32_t GetAntiAliasingThreshold() { return mFontAntiAliasingThreshold; } -protected: - bool AccelerateLayersByDefault() override; - private: virtual void GetPlatformCMSOutputProfile(void* &mem, size_t &size) override; diff --git a/gfx/thebes/gfxPrefs.h b/gfx/thebes/gfxPrefs.h index 1253fdb48..d02f15699 100644 --- a/gfx/thebes/gfxPrefs.h +++ b/gfx/thebes/gfxPrefs.h @@ -448,11 +448,11 @@ private: DECL_GFX_PREF(Once, "image.multithreaded_decoding.limit", ImageMTDecodingLimit, int32_t, -1); DECL_GFX_PREF(Live, "image.webp.enabled", ImageWebPEnabled, bool, true); - DECL_GFX_PREF(Once, "layers.acceleration.disabled", LayersAccelerationDisabledDoNotUseDirectly, bool, false); + DECL_GFX_PREF(Once, "layers.acceleration.enabled", LayersAccelerationEnabledDoNotUseDirectly, bool, true); DECL_GFX_PREF(Live, "layers.acceleration.draw-fps", LayersDrawFPS, bool, false); DECL_GFX_PREF(Live, "layers.acceleration.draw-fps.print-histogram", FPSPrintHistogram, bool, false); DECL_GFX_PREF(Live, "layers.acceleration.draw-fps.write-to-file", WriteFPSToFile, bool, false); - DECL_GFX_PREF(Once, "layers.acceleration.force-enabled", LayersAccelerationForceEnabledDoNotUseDirectly, bool, false); + DECL_GFX_PREF(Once, "layers.acceleration.force", LayersAccelerationForceEnabledDoNotUseDirectly, bool, false); DECL_GFX_PREF(Once, "layers.allow-d3d9-fallback", LayersAllowD3D9Fallback, bool, false); DECL_GFX_PREF(Once, "layers.amd-switchable-gfx.enabled", LayersAMDSwitchableGfxEnabled, bool, false); DECL_GFX_PREF(Once, "layers.async-pan-zoom.enabled", AsyncPanZoomEnabledDoNotUseDirectly, bool, true); diff --git a/gfx/thebes/gfxWindowsPlatform.h b/gfx/thebes/gfxWindowsPlatform.h index 129365f82..b56dab338 100644 --- a/gfx/thebes/gfxWindowsPlatform.h +++ b/gfx/thebes/gfxWindowsPlatform.h @@ -226,9 +226,6 @@ public: bool SupportsPluginDirectDXGIDrawing(); protected: - bool AccelerateLayersByDefault() override { - return true; - } void GetAcceleratedCompositorBackends(nsTArray& aBackends) override; virtual void GetPlatformCMSOutputProfile(void* &mem, size_t &size) override; -- cgit v1.2.3