Bug 1824025 - transformed patterns may be blurry r=jfkthame a=reland

Differential Revision: https://phabricator.services.mozilla.com/D173545
This commit is contained in:
Robert Longson 2023-03-24 21:16:41 +00:00
Родитель 31ed1c67cc
Коммит 9ce9208392
4 изменённых файлов: 58 добавлений и 10 удалений

Просмотреть файл

@ -0,0 +1,20 @@
<svg width="800" height="500" xmlns="http://www.w3.org/2000/svg">
<text x="25" y="25">Both patterns should render without blurriness</text>
<pattern id="pattern1" viewBox="0 0 100 20" width="100" height="20"
patternUnits="userSpaceOnUse">
<circle r="2" cx="10" cy="10" fill="green"/>
<circle r="4" cx="30" cy="10" fill="green"/>
<circle r="6" cx="50" cy="10" fill="green"/>
<circle r="8" cx="70" cy="10" fill="green"/>
<circle r="10" cx="90" cy="10" fill="green"/>
</pattern>
<circle r="150" cx="200" cy="200" stroke="gray" fill="none"/>
<circle r="150" cx="200" cy="200" fill="url(#pattern1)"/>
<circle r="150" cx="600" cy="200" stroke="gray" fill="none"/>
<circle r="150" cx="600" cy="200" fill="url(#pattern1)"/>
</svg>

После

Ширина:  |  Высота:  |  Размер: 773 B

Просмотреть файл

@ -0,0 +1,29 @@
<svg width="800" height="500" xmlns="http://www.w3.org/2000/svg">
<text x="25" y="25">Both patterns should render without blurriness</text>
<pattern id="pattern1" viewBox="0 0 100 20" width="100" height="20"
patternUnits="userSpaceOnUse">
<circle r="2" cx="10" cy="10" fill="green"/>
<circle r="4" cx="30" cy="10" fill="green"/>
<circle r="6" cx="50" cy="10" fill="green"/>
<circle r="8" cx="70" cy="10" fill="green"/>
<circle r="10" cx="90" cy="10" fill="green"/>
</pattern>
<circle r="150" cx="200" cy="200" stroke="gray" fill="none"/>
<circle r="150" cx="200" cy="200" fill="url(#pattern1)"/>
<pattern id="pattern2" viewBox="0 0 20 100" width="20" height="100"
patternUnits="userSpaceOnUse" patternTransform="rotate(270)">
<circle r="2" cx="10" cy="10" fill="green"/>
<circle r="4" cx="10" cy="30" fill="green"/>
<circle r="6" cx="10" cy="50" fill="green"/>
<circle r="8" cx="10" cy="70" fill="green"/>
<circle r="10" cx="10" cy="90" fill="green"/>
</pattern>
<circle r="150" cx="600" cy="200" stroke="gray" fill="none"/>
<circle r="150" cx="600" cy="200" fill="url(#pattern2)"/>
</svg>

После

Ширина:  |  Высота:  |  Размер: 1.1 KiB

Просмотреть файл

@ -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-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-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-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 == pattern-scale-01b.svg pattern-scale-01-ref.svg
fuzzy(0-3,0-5) == pattern-scale-01c.svg pattern-scale-01-ref.svg == 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 == 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 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-01.svg polygon-01-ref.svg
== polygon-marker-01.svg pass.svg == polygon-marker-01.svg pass.svg

Просмотреть файл

@ -304,12 +304,11 @@ already_AddRefed<SourceSurface> SVGPatternFrame::PaintPattern(
// Now that we have all of the necessary geometries, we can // Now that we have all of the necessary geometries, we can
// create our surface. // create our surface.
gfxRect transformedBBox = gfxSize scaledSize = bbox.Size() * MaxExpansion(patternTransform);
ThebesRect(patternTransform.TransformBounds(ToRect(bbox)));
bool resultOverflows; bool resultOverflows;
IntSize surfaceSize = IntSize surfaceSize =
SVGUtils::ConvertToSurfaceSize(transformedBBox.Size(), &resultOverflows); SVGUtils::ConvertToSurfaceSize(scaledSize, &resultOverflows);
// 0 disables rendering, < 0 is an error // 0 disables rendering, < 0 is an error
if (surfaceSize.width <= 0 || surfaceSize.height <= 0) { if (surfaceSize.width <= 0 || surfaceSize.height <= 0) {
@ -322,9 +321,8 @@ already_AddRefed<SourceSurface> SVGPatternFrame::PaintPattern(
if (resultOverflows || patternWidth != surfaceSize.width || if (resultOverflows || patternWidth != surfaceSize.width ||
patternHeight != surfaceSize.height) { patternHeight != surfaceSize.height) {
// scale drawing to pattern surface size // scale drawing to pattern surface size
gfxMatrix tempTM = gfxMatrix(surfaceSize.width / patternWidth, 0.0, 0.0, patternWithChildren->mCTM->PreScale(surfaceSize.width / patternWidth,
surfaceSize.height / patternHeight, 0.0, 0.0); surfaceSize.height / patternHeight);
patternWithChildren->mCTM->PreMultiply(tempTM);
// and rescale pattern to compensate // and rescale pattern to compensate
patternMatrix->PreScale(patternWidth / surfaceSize.width, patternMatrix->PreScale(patternWidth / surfaceSize.width,