Bug 1520682 - Limit the amount of filter ops per stacking context in WebRender. r=jrmuizel

Differential Revision: https://phabricator.services.mozilla.com/D17415

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Matt Woodrow 2019-01-24 03:02:17 +00:00
parent 6b33b8f6a1
commit d4ecd598da
3 changed files with 17 additions and 0 deletions

View File

@ -552,6 +552,7 @@ class gfxPrefs final {
DECL_GFX_PREF(Once, "gfx.webrender.force-disabled", WebRenderForceDisabled, bool, false);
DECL_GFX_PREF(Live, "gfx.webrender.highlight-painted-layers",WebRenderHighlightPaintedLayers, bool, false);
DECL_GFX_PREF(Live, "gfx.webrender.late-scenebuild-threshold", WebRenderLateSceneBuildThreshold, int32_t, 4);
DECL_GFX_PREF(Live, "gfx.webrender.max-filter-ops-per-chain", WebRenderMaxFilterOpsPerChain, uint32_t, 64);
DECL_GFX_PREF(Live, "gfx.webrender.picture-caching", WebRenderPictureCaching, bool, false);
// Use vsync events generated by hardware

View File

@ -9276,6 +9276,14 @@ bool nsDisplayFilters::CreateWebRenderCSSFilters(
// All CSS filters are supported by WebRender. SVG filters are not fully
// supported, those use NS_STYLE_FILTER_URL and are handled separately.
const nsTArray<nsStyleFilter>& filters = mFrame->StyleEffects()->mFilters;
// If there are too many filters to render, then just pretend that we
// succeeded, and don't render any of them.
if (filters.Length() > gfxPrefs::WebRenderMaxFilterOpsPerChain()) {
return true;
}
wrFilters.SetCapacity(filters.Length());
for (const nsStyleFilter& filter : filters) {
switch (filter.GetType()) {
case NS_STYLE_FILTER_BRIGHTNESS:

View File

@ -15,6 +15,7 @@
#include "gfx2DGlue.h"
#include "gfxContext.h"
#include "gfxPlatform.h"
#include "gfxPrefs.h"
#include "gfxUtils.h"
#include "mozilla/gfx/Helpers.h"
#include "mozilla/gfx/PatternHelpers.h"
@ -120,6 +121,13 @@ bool nsFilterInstance::BuildWebRenderFilters(nsIFrame* aFilteredFrame,
return false;
}
// If there are too many filters to render, then just pretend that we
// succeeded, and don't render any of them.
if (instance.mFilterDescription.mPrimitives.Length() >
gfxPrefs::WebRenderMaxFilterOpsPerChain()) {
return true;
}
Maybe<IntRect> finalClip;
bool srgb = true;
// We currently apply the clip on the stacking context after applying filters,