From 4dd3275fd06857a9a36e60a63642fcc78c4082cb Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Sun, 25 Jul 2021 08:31:25 +0000 Subject: [PATCH] Bug 1720986 - Reinstate clipping filters within SVG to the building rect. r=jrmuizel Differential Revision: https://phabricator.services.mozilla.com/D120695 --- gfx/layers/wr/WebRenderCommandBuilder.cpp | 12 ++++++++++-- layout/reftests/svg/filters/filter-giant.svg | 12 ++++++++++++ layout/reftests/svg/filters/reftest.list | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 layout/reftests/svg/filters/filter-giant.svg diff --git a/gfx/layers/wr/WebRenderCommandBuilder.cpp b/gfx/layers/wr/WebRenderCommandBuilder.cpp index 666cf2c7cf44..a561e75c42d2 100644 --- a/gfx/layers/wr/WebRenderCommandBuilder.cpp +++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp @@ -259,6 +259,12 @@ static bool IsContainerLayerItem(nsDisplayItem* aItem) { static bool DetectContainerLayerPropertiesBoundsChange( nsDisplayItem* aItem, BlobItemData* aData, nsDisplayItemGeometry& aGeometry) { + if (aItem->GetType() == DisplayItemType::TYPE_FILTER) { + // Filters get clipped to the BuildingRect since they can + // have huge bounds outside of the visible area. + aGeometry.mBounds = aGeometry.mBounds.Intersect(aItem->GetBuildingRect()); + } + return !aGeometry.mBounds.IsEqualEdges(aData->mGeometry->mBounds); } @@ -1010,8 +1016,10 @@ void Grouper::PaintContainerItem(DIGroup* aGroup, nsDisplayItem* aItem, // outside the invalid rect. if (aDirty) { auto filterItem = static_cast(aItem); - filterItem->SetPaintRect( - filterItem->GetClippedBounds(mDisplayListBuilder)); + + nsRegion visible(aItem->GetClippedBounds(mDisplayListBuilder)); + visible.And(visible, aItem->GetBuildingRect()); + aItem->SetPaintRect(visible.GetBounds()); filterItem->Paint(mDisplayListBuilder, aContext); TakeExternalSurfaces(aRecorder, aData->mExternalSurfaces, aRootManager, diff --git a/layout/reftests/svg/filters/filter-giant.svg b/layout/reftests/svg/filters/filter-giant.svg new file mode 100644 index 000000000000..e0a373a89218 --- /dev/null +++ b/layout/reftests/svg/filters/filter-giant.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/layout/reftests/svg/filters/reftest.list b/layout/reftests/svg/filters/reftest.list index 24d60b81944b..ec699011034a 100644 --- a/layout/reftests/svg/filters/reftest.list +++ b/layout/reftests/svg/filters/reftest.list @@ -139,3 +139,4 @@ fuzzy(0-1,0-10000) == feTurbulence-zero-baseFreq-01.svg feTurbulence-zero-baseFr fails-if(!useDrawSnapshot&&webrender) == outside-sourcegraphic-2.svg outside-sourcegraphic-ref.svg fails-if(!useDrawSnapshot&&webrender) == outside-sourcegraphic-3.svg outside-sourcegraphic-ref.svg == nested-filter.html nested-filter-ref.html +== filter-giant.svg pass.svg