SVG Pattern tile pixelated on patternTransform
authorkrit@webkit.org <krit@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Oct 2011 19:54:45 +0000 (19:54 +0000)
committerkrit@webkit.org <krit@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Oct 2011 19:54:45 +0000 (19:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=69261

Source/WebCore:

Reviewed by Rob Buis.

Scale the SVG pattern tile by the scale level of patternTransform to avoid pixelation.

Test: svg/custom/pattern-scaled-pattern-space.svg

* rendering/svg/RenderSVGResourcePattern.cpp:
(WebCore::RenderSVGResourcePattern::applyResource):

LayoutTests:

Reviewed by Rob Buis.

Add a new test to check that SVG pattern tiles are not pixelated on
scaling with patternTransform.
Updated two more pixel tests. Both changes are progressions.

* platform/mac/svg/W3C-SVG-1.1/pservers-grad-06-b-expected.png:
* platform/mac/svg/custom/non-scaling-stroke-expected.png:
* svg/custom/pattern-scaled-pattern-space-expected.png: Added.
* svg/custom/pattern-scaled-pattern-space-expected.txt: Added.
* svg/custom/pattern-scaled-pattern-space.svg: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96530 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/mac/svg/W3C-SVG-1.1/pservers-grad-06-b-expected.png
LayoutTests/platform/mac/svg/custom/non-scaling-stroke-expected.png
LayoutTests/svg/custom/pattern-scaled-pattern-space-expected.png [new file with mode: 0644]
LayoutTests/svg/custom/pattern-scaled-pattern-space-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/pattern-scaled-pattern-space.svg [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp

index a1e951d..925bcc8 100644 (file)
@@ -1,3 +1,20 @@
+2011-10-03  Dirk Schulze  <krit@webkit.org>
+
+        SVG Pattern tile pixelated on patternTransform
+        https://bugs.webkit.org/show_bug.cgi?id=69261
+
+        Reviewed by Rob Buis.
+        
+        Add a new test to check that SVG pattern tiles are not pixelated on
+        scaling with patternTransform.
+        Updated two more pixel tests. Both changes are progressions.
+
+        * platform/mac/svg/W3C-SVG-1.1/pservers-grad-06-b-expected.png:
+        * platform/mac/svg/custom/non-scaling-stroke-expected.png:
+        * svg/custom/pattern-scaled-pattern-space-expected.png: Added.
+        * svg/custom/pattern-scaled-pattern-space-expected.txt: Added.
+        * svg/custom/pattern-scaled-pattern-space.svg: Added.
+
 2011-10-03  Adam Barth  <abarth@webkit.org>
 
         Another round of updates after http://trac.webkit.org/changeset/96509.
index 0da8067..d1b01be 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/pservers-grad-06-b-expected.png and b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/pservers-grad-06-b-expected.png differ
index a85ed29..39186d1 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/custom/non-scaling-stroke-expected.png and b/LayoutTests/platform/mac/svg/custom/non-scaling-stroke-expected.png differ
diff --git a/LayoutTests/svg/custom/pattern-scaled-pattern-space-expected.png b/LayoutTests/svg/custom/pattern-scaled-pattern-space-expected.png
new file mode 100644 (file)
index 0000000..15e6c91
Binary files /dev/null and b/LayoutTests/svg/custom/pattern-scaled-pattern-space-expected.png differ
diff --git a/LayoutTests/svg/custom/pattern-scaled-pattern-space-expected.txt b/LayoutTests/svg/custom/pattern-scaled-pattern-space-expected.txt
new file mode 100644 (file)
index 0000000..a77bc02
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (0,0) size 200x200
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+      RenderSVGResourcePattern {pattern} [id="pattern"] [patternUnits=userSpaceOnUse] [patternContentUnits=userSpaceOnUse] [patternTransform={m=((40.00,0.00)(0.00,40.00)) t=(0.00,0.00)}]
+        RenderSVGPath {circle} at (0,0) size 5x5 [fill={[type=SOLID] [color=#00FF00]}] [cx=2.50] [cy=2.50] [r=2.50]
+    RenderSVGPath {rect} at (0,0) size 200x200 [fill={[type=PATTERN] [id="pattern"]}] [x=0.00] [y=0.00] [width=200.00] [height=200.00]
diff --git a/LayoutTests/svg/custom/pattern-scaled-pattern-space.svg b/LayoutTests/svg/custom/pattern-scaled-pattern-space.svg
new file mode 100644 (file)
index 0000000..6599992
--- /dev/null
@@ -0,0 +1,8 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<defs>
+<pattern id="pattern" width="5" height="5" patternUnits="userSpaceOnUse" patternTransform="scale(40)">
+       <circle cx="2.5" cy="2.5" r="2.5" fill="lime" />
+</pattern>
+</defs>
+<rect width="200" height="200" fill="url(#pattern)"/>
+</svg>
index 55d615d..208c8fe 100644 (file)
@@ -1,3 +1,17 @@
+2011-10-03  Dirk Schulze  <krit@webkit.org>
+
+        SVG Pattern tile pixelated on patternTransform
+        https://bugs.webkit.org/show_bug.cgi?id=69261
+
+        Reviewed by Rob Buis.
+
+        Scale the SVG pattern tile by the scale level of patternTransform to avoid pixelation.
+
+        Test: svg/custom/pattern-scaled-pattern-space.svg
+
+        * rendering/svg/RenderSVGResourcePattern.cpp:
+        (WebCore::RenderSVGResourcePattern::applyResource):
+
 2011-10-03  Jer Noble  <jer.noble@apple.com>
 
         Enable WEB_AUDIO by default in the WebKit/mac port.
index 2f7ff52..4db563a 100644 (file)
@@ -122,6 +122,9 @@ bool RenderSVGResourcePattern::applyResource(RenderObject* object, RenderStyle*
         FloatRect absoluteTileBoundaries = absoluteTransformIgnoringRotation.mapRect(tileBoundaries);
         FloatRect clampedAbsoluteTileBoundaries;
 
+        // Scale the tile size to match the scale level of the patternTransform.
+        absoluteTileBoundaries.scale(m_attributes.patternTransform().xScale(), m_attributes.patternTransform().yScale());
+
         // Build tile image.
         OwnPtr<ImageBuffer> tileImage = createTileImage(m_attributes, tileBoundaries, absoluteTileBoundaries, tileImageTransform, clampedAbsoluteTileBoundaries);
         if (!tileImage)