From 9ce92083926a85e849b76aa28d2741b867018a98 Mon Sep 17 00:00:00 2001 From: Robert Longson Date: Fri, 24 Mar 2023 21:16:41 +0000 Subject: [PATCH] Bug 1824025 - transformed patterns may be blurry r=jfkthame a=reland Differential Revision: https://phabricator.services.mozilla.com/D173545 --- .../svg/pattern-transformed-02-ref.svg | 20 +++++++++++++ .../reftests/svg/pattern-transformed-02.svg | 29 +++++++++++++++++++ layout/reftests/svg/reftest.list | 9 +++--- layout/svg/SVGPatternFrame.cpp | 10 +++---- 4 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 layout/reftests/svg/pattern-transformed-02-ref.svg create mode 100644 layout/reftests/svg/pattern-transformed-02.svg diff --git a/layout/reftests/svg/pattern-transformed-02-ref.svg b/layout/reftests/svg/pattern-transformed-02-ref.svg new file mode 100644 index 000000000000..b09904281033 --- /dev/null +++ b/layout/reftests/svg/pattern-transformed-02-ref.svg @@ -0,0 +1,20 @@ + + + Both patterns should render without blurriness + + + + + + + + + + + + + + + + diff --git a/layout/reftests/svg/pattern-transformed-02.svg b/layout/reftests/svg/pattern-transformed-02.svg new file mode 100644 index 000000000000..078f3c66dd67 --- /dev/null +++ b/layout/reftests/svg/pattern-transformed-02.svg @@ -0,0 +1,29 @@ + + + Both patterns should render without blurriness + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/layout/reftests/svg/reftest.list b/layout/reftests/svg/reftest.list index b20722355273..796798fba71e 100644 --- a/layout/reftests/svg/reftest.list +++ b/layout/reftests/svg/reftest.list @@ -394,11 +394,12 @@ fuzzy(0-128,0-100) == pattern-big-image.html pattern-big-image-ref.html fuzzy(0-1,0-5) == pattern-live-01a.svg pattern-live-01-ref.svg fuzzy(0-1,0-5) == pattern-live-01b.svg pattern-live-01-ref.svg fuzzy(0-1,0-5) == pattern-live-01c.svg pattern-live-01-ref.svg -fuzzy(0-1,0-5) == pattern-scale-01a.svg pattern-scale-01-ref.svg +== pattern-scale-01a.svg pattern-scale-01-ref.svg == pattern-scale-01b.svg pattern-scale-01-ref.svg -fuzzy(0-3,0-5) == pattern-scale-01c.svg pattern-scale-01-ref.svg -fuzzy(0-2,0-227) == pattern-transform-presence-01.svg pattern-transform-presence-01-ref.svg -fuzzy(0-72,0-1255) == pattern-transformed-01.svg pattern-transformed-01-ref.svg +== pattern-scale-01c.svg pattern-scale-01-ref.svg +== pattern-transform-presence-01.svg pattern-transform-presence-01-ref.svg +fuzzy(0-67,0-805) == pattern-transformed-01.svg pattern-transformed-01-ref.svg +fuzzy(0-17,0-2375) == pattern-transformed-02.svg pattern-transformed-02-ref.svg == polygon-01.svg polygon-01-ref.svg == polygon-marker-01.svg pass.svg diff --git a/layout/svg/SVGPatternFrame.cpp b/layout/svg/SVGPatternFrame.cpp index de580d276fd6..a6f7035ce227 100644 --- a/layout/svg/SVGPatternFrame.cpp +++ b/layout/svg/SVGPatternFrame.cpp @@ -304,12 +304,11 @@ already_AddRefed SVGPatternFrame::PaintPattern( // Now that we have all of the necessary geometries, we can // create our surface. - gfxRect transformedBBox = - ThebesRect(patternTransform.TransformBounds(ToRect(bbox))); + gfxSize scaledSize = bbox.Size() * MaxExpansion(patternTransform); bool resultOverflows; IntSize surfaceSize = - SVGUtils::ConvertToSurfaceSize(transformedBBox.Size(), &resultOverflows); + SVGUtils::ConvertToSurfaceSize(scaledSize, &resultOverflows); // 0 disables rendering, < 0 is an error if (surfaceSize.width <= 0 || surfaceSize.height <= 0) { @@ -322,9 +321,8 @@ already_AddRefed SVGPatternFrame::PaintPattern( if (resultOverflows || patternWidth != surfaceSize.width || patternHeight != surfaceSize.height) { // scale drawing to pattern surface size - gfxMatrix tempTM = gfxMatrix(surfaceSize.width / patternWidth, 0.0, 0.0, - surfaceSize.height / patternHeight, 0.0, 0.0); - patternWithChildren->mCTM->PreMultiply(tempTM); + patternWithChildren->mCTM->PreScale(surfaceSize.width / patternWidth, + surfaceSize.height / patternHeight); // and rescale pattern to compensate patternMatrix->PreScale(patternWidth / surfaceSize.width,