From adafdb308ecf09f7a81732f754596fed88b58a23 Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Wed, 23 Feb 2022 16:19:07 +0000 Subject: [PATCH] Bug 1756197. Avoid clipping if we're just going to fill the path. r=gfx-reviewers,nical This avoids having to rasterize the path twice. Once for the clip path and once for the fill. It will also give us correct antialiasing on the edges. Differential Revision: https://phabricator.services.mozilla.com/D139137 --- layout/reftests/svg/svg-integration/clip-path/reftest.list | 2 +- layout/svg/SVGIntegrationUtils.cpp | 7 +++++-- .../css-masking/clip-path/clip-path-geometryBox-2.html.ini | 2 -- 3 files changed, 6 insertions(+), 5 deletions(-) delete mode 100644 testing/web-platform/meta/css/css-masking/clip-path/clip-path-geometryBox-2.html.ini diff --git a/layout/reftests/svg/svg-integration/clip-path/reftest.list b/layout/reftests/svg/svg-integration/clip-path/reftest.list index 367ce311ff1d..94c13c2b4766 100644 --- a/layout/reftests/svg/svg-integration/clip-path/reftest.list +++ b/layout/reftests/svg/svg-integration/clip-path/reftest.list @@ -14,7 +14,7 @@ == clip-path-polygon-010.html clip-path-stripes-001-ref.html == clip-path-polygon-011.html clip-path-stripes-001-ref.html == clip-path-polygon-012.html clip-path-stripes-001-ref.html -fuzzy(0-1,0-20) fails-if(!gtkWidget) == clip-path-polygon-013.html clip-path-stripes-003-ref.html +fuzzy(0-1,0-20) == clip-path-polygon-013.html clip-path-stripes-003-ref.html fuzzy-if(!useDrawSnapshot,35-70,699-800) == clip-path-circle-001.html clip-path-circle-001-ref.html fuzzy-if(!useDrawSnapshot,35-70,699-800) == clip-path-circle-002.html clip-path-circle-001-ref.html diff --git a/layout/svg/SVGIntegrationUtils.cpp b/layout/svg/SVGIntegrationUtils.cpp index 276c622ee16f..5d2e78af3f84 100644 --- a/layout/svg/SVGIntegrationUtils.cpp +++ b/layout/svg/SVGIntegrationUtils.cpp @@ -758,16 +758,19 @@ bool SVGIntegrationUtils::PaintMask(const PaintFramesParams& aParams, MoveContextOriginToUserSpace(firstFrame, aParams); basicShapeSR.SetContext(&ctx); - CSSClipPathInstance::ApplyBasicShapeOrPathClip( - ctx, frame, SVGUtils::GetCSSPxToDevPxMatrix(frame)); + gfxMatrix mat = SVGUtils::GetCSSPxToDevPxMatrix(frame); if (!maskUsage.shouldGenerateMaskLayer) { // Only have basic-shape clip-path effect. Fill clipped region by // opaque white. ctx.SetDeviceColor(DeviceColor::MaskOpaqueWhite()); + RefPtr path = CSSClipPathInstance::CreateClipPathForFrame( + ctx.GetDrawTarget(), frame, mat); + ctx.SetPath(path); ctx.Fill(); return true; } + CSSClipPathInstance::ApplyBasicShapeOrPathClip(ctx, frame, mat); } // Paint mask onto ctx. diff --git a/testing/web-platform/meta/css/css-masking/clip-path/clip-path-geometryBox-2.html.ini b/testing/web-platform/meta/css/css-masking/clip-path/clip-path-geometryBox-2.html.ini deleted file mode 100644 index 7b223a75164f..000000000000 --- a/testing/web-platform/meta/css/css-masking/clip-path/clip-path-geometryBox-2.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[clip-path-geometryBox-2.html] - expected: FAIL