зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1806058 - Add blocklist for Accelerated Canvas2D. r=jrmuizel
Differential Revision: https://phabricator.services.mozilla.com/D164881
This commit is contained in:
Родитель
c18b24369d
Коммит
e599e9d352
|
@ -12,6 +12,7 @@
|
|||
#include "mozilla/gfx/AAStroke.h"
|
||||
#include "mozilla/gfx/Blur.h"
|
||||
#include "mozilla/gfx/DrawTargetSkia.h"
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
#include "mozilla/gfx/Helpers.h"
|
||||
#include "mozilla/gfx/HelpersSkia.h"
|
||||
#include "mozilla/gfx/Logging.h"
|
||||
|
@ -716,7 +717,7 @@ bool DrawTargetWebgl::IsValid() const {
|
|||
|
||||
already_AddRefed<DrawTargetWebgl> DrawTargetWebgl::Create(
|
||||
const IntSize& aSize, SurfaceFormat aFormat) {
|
||||
if (!StaticPrefs::gfx_canvas_accelerated()) {
|
||||
if (!gfxVars::UseAcceleratedCanvas2D()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,8 @@ namespace gfx {
|
|||
_(DMABUF_SURFACE_EXPORT, Feature, "WebGL DMABuf surface export") \
|
||||
_(REUSE_DECODER_DEVICE, Feature, "Reuse decoder device") \
|
||||
_(BACKDROP_FILTER, Feature, "Backdrop filter") \
|
||||
_(CANVAS_RENDERER_THREAD, Feature, "canvas renderer thread")
|
||||
_(CANVAS_RENDERER_THREAD, Feature, "canvas renderer thread") \
|
||||
_(ACCELERATED_CANVAS2D, Feature, "Accelerated Canvas2D")
|
||||
/* Add new entries above this comment */
|
||||
|
||||
enum class Feature : uint32_t {
|
||||
|
|
|
@ -94,7 +94,8 @@ class gfxVarReceiver;
|
|||
_(ReuseDecoderDevice, bool, false) \
|
||||
_(UseCanvasRenderThread, bool, false) \
|
||||
_(AllowBackdropFilter, bool, true) \
|
||||
_(WebglOopAsyncPresentForceSync, bool, true)
|
||||
_(WebglOopAsyncPresentForceSync, bool, true) \
|
||||
_(UseAcceleratedCanvas2D, bool, false)
|
||||
|
||||
/* Add new entries above this line. */
|
||||
|
||||
|
|
|
@ -924,6 +924,7 @@ void gfxPlatform::Init() {
|
|||
gPlatform->InitWebGPUConfig();
|
||||
gPlatform->InitWindowOcclusionConfig();
|
||||
gPlatform->InitBackdropFilterConfig();
|
||||
gPlatform->InitAcceleratedCanvas2DConfig();
|
||||
|
||||
#if defined(XP_WIN)
|
||||
// When using WebRender, we defer initialization of the D3D11 devices until
|
||||
|
@ -3087,6 +3088,53 @@ void gfxPlatform::InitBackdropFilterConfig() {
|
|||
StaticPrefs::GetPrefName_layout_css_backdrop_filter_force_enabled()));
|
||||
}
|
||||
|
||||
static void AcceleratedCanvas2DPrefChangeCallback(const char*, void*) {
|
||||
FeatureState& feature = gfxConfig::GetFeature(Feature::ACCELERATED_CANVAS2D);
|
||||
|
||||
// Reset to track toggling prefs and ensure force-enable does not happen
|
||||
// after blocklist.
|
||||
feature.Reset();
|
||||
|
||||
// gfx.canvas.accelerated pref controls whether platform enables the feature,
|
||||
// but it still allows blocklisting to override it later.
|
||||
feature.SetDefaultFromPref(
|
||||
StaticPrefs::GetPrefName_gfx_canvas_accelerated(), true,
|
||||
StaticPrefs::GetPrefDefault_gfx_canvas_accelerated());
|
||||
|
||||
// gfx.canvas.accelerated.force-enabled overrides the blocklist.
|
||||
if (StaticPrefs::gfx_canvas_accelerated_force_enabled()) {
|
||||
feature.UserForceEnable("Force-enabled by pref");
|
||||
}
|
||||
|
||||
// Check if blocklisted despite the default pref.
|
||||
nsCString message;
|
||||
nsCString failureId;
|
||||
if (!gfxPlatform::IsGfxInfoStatusOkay(
|
||||
nsIGfxInfo::FEATURE_ACCELERATED_CANVAS2D, &message, failureId)) {
|
||||
feature.Disable(FeatureStatus::Blocklisted, message.get(), failureId);
|
||||
}
|
||||
|
||||
gfxVars::SetUseAcceleratedCanvas2D(feature.IsEnabled());
|
||||
}
|
||||
|
||||
void gfxPlatform::InitAcceleratedCanvas2DConfig() {
|
||||
if (!XRE_IsParentProcess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Decide during pref changes whether or not to enable acceleration. This
|
||||
// allows easily toggling acceleration on and off to test performance.
|
||||
AcceleratedCanvas2DPrefChangeCallback(nullptr, nullptr);
|
||||
|
||||
Preferences::RegisterCallback(
|
||||
AcceleratedCanvas2DPrefChangeCallback,
|
||||
nsDependentCString(StaticPrefs::GetPrefName_gfx_canvas_accelerated()));
|
||||
Preferences::RegisterCallback(
|
||||
AcceleratedCanvas2DPrefChangeCallback,
|
||||
nsDependentCString(
|
||||
StaticPrefs::GetPrefName_gfx_canvas_accelerated_force_enabled()));
|
||||
}
|
||||
|
||||
bool gfxPlatform::CanUseHardwareVideoDecoding() {
|
||||
// this function is called from the compositor thread, so it is not
|
||||
// safe to init the prefs etc. from here.
|
||||
|
|
|
@ -818,6 +818,7 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener {
|
|||
virtual void InitWebGPUConfig();
|
||||
virtual void InitWindowOcclusionConfig();
|
||||
void InitBackdropFilterConfig();
|
||||
void InitAcceleratedCanvas2DConfig();
|
||||
|
||||
virtual void GetPlatformDisplayInfo(mozilla::widget::InfoObject& aObj) {}
|
||||
|
||||
|
|
|
@ -5576,7 +5576,7 @@
|
|||
#endif
|
||||
|
||||
- name: gfx.canvas.accelerated
|
||||
type: RelaxedAtomicBool
|
||||
type: bool
|
||||
#if defined(XP_MACOSX) || defined(XP_LINUX) && !defined(ANDROID)
|
||||
value: @IS_NIGHTLY_BUILD@
|
||||
#else
|
||||
|
@ -5584,6 +5584,12 @@
|
|||
#endif
|
||||
mirror: always
|
||||
|
||||
# Whether to attempt to enable Accelerated Canvas2D regardless of blocklisting.
|
||||
- name: gfx.canvas.accelerated.force-enabled
|
||||
type: bool
|
||||
value: false
|
||||
mirror: always
|
||||
|
||||
- name: gfx.canvas.accelerated.async-present
|
||||
type: RelaxedAtomicBool
|
||||
value: true
|
||||
|
|
|
@ -260,6 +260,9 @@ static const char* GetPrefNameForFeature(int32_t aFeature) {
|
|||
case nsIGfxInfo::FEATURE_BACKDROP_FILTER:
|
||||
name = BLOCKLIST_PREF_BRANCH "backdrop.filter";
|
||||
break;
|
||||
case nsIGfxInfo::FEATURE_ACCELERATED_CANVAS2D:
|
||||
name = BLOCKLIST_PREF_BRANCH "accelerated-canvas2d";
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Unexpected nsIGfxInfo feature?!");
|
||||
break;
|
||||
|
@ -533,6 +536,9 @@ static int32_t BlocklistFeatureToGfxFeature(const nsAString& aFeature) {
|
|||
if (aFeature.EqualsLiteral("BACKDROP_FILTER")) {
|
||||
return nsIGfxInfo::FEATURE_BACKDROP_FILTER;
|
||||
}
|
||||
if (aFeature.EqualsLiteral("ACCELERATED_CANVAS2D")) {
|
||||
return nsIGfxInfo::FEATURE_ACCELERATED_CANVAS2D;
|
||||
}
|
||||
|
||||
// If we don't recognize the feature, it may be new, and something
|
||||
// this version doesn't understand. So, nothing to do. This is
|
||||
|
|
|
@ -180,8 +180,10 @@ interface nsIGfxInfo : nsISupports
|
|||
const long FEATURE_REUSE_DECODER_DEVICE = 41;
|
||||
/* Whether to allow backdrop filter, starting in 105. */
|
||||
const long FEATURE_BACKDROP_FILTER = 42;
|
||||
/* Whether to use Accelerated Canvas2D, starting in 110. */
|
||||
const long FEATURE_ACCELERATED_CANVAS2D = 43;
|
||||
/* the maximum feature value. */
|
||||
const long FEATURE_MAX_VALUE = FEATURE_BACKDROP_FILTER;
|
||||
const long FEATURE_MAX_VALUE = FEATURE_ACCELERATED_CANVAS2D;
|
||||
|
||||
/*
|
||||
* A set of return values from GetFeatureStatus
|
||||
|
|
Загрузка…
Ссылка в новой задаче