From 53d7d2f7fe23c98733dd70ceec597b3e98f72602 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 25 Jan 2020 21:26:24 +0100 Subject: Issue mcp-graveyard/UXP#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 --- modules/libpref/init/all.js | 23 ++++++++++------------- 9 files changed, 17 insertions(+), 74 deletions(-) diff --git a/gfx/thebes/gfxAndroidPlatform.h b/gfx/thebes/gfxAndroidPlatform.h index 30e7c89bab..8975d0ab96 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 50d1fcb465..4cd044f904 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 68bb99ea44..642cf909f4 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 9959c0e13d..22ed4b08fd 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 79684dd19a..75c5236a87 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 0807614f6f..ea4c1a1011 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 1253fdb488..d02f156999 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 129365f820..b56dab338a 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; diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index c5daf92131..ada4dbc5f6 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -4497,7 +4497,16 @@ pref("network.tcp.keepalive.probe_count", 4); #endif // Whether to disable acceleration for all widgets. -pref("layers.acceleration.disabled", false); +#if defined(XP_UNIX) && !defined(XP_MACOSX) +// On Linux this is disabled by default for known issues with "free" drivers +pref("layers.acceleration.enabled", false); +#else +pref("layers.acceleration.enabled", true); +#endif +// Whether to force acceleration on, ignoring blacklists. +// This requires layers.acceleration.enabled to be set to true +pref("layers.acceleration.force", false); + // Preference that when switched at runtime will run a series of benchmarks // and output the result to stderr. pref("layers.bench.enabled", false); @@ -4506,18 +4515,6 @@ pref("layers.bench.enabled", false); pref("layers.gpu-process.dev.enabled", true); #endif -// Whether to force acceleration on, ignoring blacklists. -#ifdef ANDROID -// bug 838603 -- on Android, accidentally blacklisting OpenGL layers -// means a startup crash for everyone. -// Temporarily force-enable GL compositing. This is default-disabled -// deep within the bowels of the widgetry system. Remove me when GL -// compositing isn't default disabled in widget/android. -pref("layers.acceleration.force-enabled", true); -#else -pref("layers.acceleration.force-enabled", false); -#endif - pref("layers.acceleration.draw-fps", false); // Enable DEAA antialiasing for transformed layers in the compositor -- cgit v1.2.3