Incorrect large-area clipping
authorfmalita@chromium.org <fmalita@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Aug 2012 12:24:49 +0000 (12:24 +0000)
committerfmalita@chromium.org <fmalita@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Aug 2012 12:24:49 +0000 (12:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=95197

Reviewed by Nikolas Zimmermann.

Source/WebCore:

ImageBuffers allocated for clipping and masking are clamped to kMaxImageBufferSize max
(4096x4096). In order to properly account for the scaling factor introduced by this
clamping, the repaintRect translation component needs to be pushed after the scaling
transform.

Tests: svg/custom/clamped-masking-clipping-expected.svg
       svg/custom/clamped-masking-clipping.svg

* rendering/svg/SVGRenderingContext.cpp:
(WebCore::SVGRenderingContext::createImageBuffer):

LayoutTests:

* svg/custom/clamped-masking-clipping-expected.svg: Added.
* svg/custom/clamped-masking-clipping.svg: Added.

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

LayoutTests/ChangeLog
LayoutTests/svg/custom/clamped-masking-clipping-expected.svg [new file with mode: 0644]
LayoutTests/svg/custom/clamped-masking-clipping.svg [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/svg/SVGRenderingContext.cpp

index e0d2730..b25f59a 100644 (file)
@@ -1,3 +1,13 @@
+2012-08-29  Florin Malita  <fmalita@chromium.org>
+
+        Incorrect large-area clipping
+        https://bugs.webkit.org/show_bug.cgi?id=95197
+
+        Reviewed by Nikolas Zimmermann.
+
+        * svg/custom/clamped-masking-clipping-expected.svg: Added.
+        * svg/custom/clamped-masking-clipping.svg: Added.
+
 2012-08-29  Dominik Röttsches  <dominik.rottsches@intel.com>
 
         [EFL] Move known crash issue to TestExpectations
diff --git a/LayoutTests/svg/custom/clamped-masking-clipping-expected.svg b/LayoutTests/svg/custom/clamped-masking-clipping-expected.svg
new file mode 100644 (file)
index 0000000..881904a
--- /dev/null
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="10000" height="400">
+    <rect x="100" width="100" height="100" fill="green"/>
+    <rect x="300" width="100" height="100" fill="green"/>
+</svg>
diff --git a/LayoutTests/svg/custom/clamped-masking-clipping.svg b/LayoutTests/svg/custom/clamped-masking-clipping.svg
new file mode 100644 (file)
index 0000000..7265e2a
--- /dev/null
@@ -0,0 +1,33 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="10000" height="400">
+  <!-- test for https://bugs.webkit.org/show_bug.cgi?id=95197 -->
+  <defs>
+    <mask id="mask">
+      <!-- forcing a repaintRect offset -->
+      <rect x="100" width="1" height="1" fill="black"/>
+      <rect x="200" width="8092" height="100" fill="white"/>
+    </mask>
+
+    <clipPath id="clip1">
+      <!-- forcing clipping via masking -->
+      <path d="M 0 0 V 100 H 10000 V 0 Z"/>
+    </clipPath>
+
+    <clipPath id="clip2" clip-path="url(#clip1)">
+      <path d="M 100 0 H 200 V 200 H 8292 V 0 Z"/>
+    </clipPath>
+
+    <mask id="crop">
+      <rect width="300" height="100" fill="white"/>
+    </mask>
+  </defs>
+
+  <g mask="url(#crop)" transform="translate(-100, 0)">
+    <rect width="10000" height="400" fill="red" mask="url(#mask)"/>
+    <rect x="200" width="100" height="100" fill="green"/>
+  </g>
+
+  <g mask="url(#crop)" transform="translate(100, 0)">
+    <rect width="10000" height="400" fill="red" clip-path="url(#clip2)"/>
+    <rect x="200" width="100" height="100" fill="green"/>
+  </g>
+</svg>
index 66f11b2..d9cf114 100644 (file)
@@ -1,3 +1,21 @@
+2012-08-29  Florin Malita  <fmalita@chromium.org>
+
+        Incorrect large-area clipping
+        https://bugs.webkit.org/show_bug.cgi?id=95197
+
+        Reviewed by Nikolas Zimmermann.
+
+        ImageBuffers allocated for clipping and masking are clamped to kMaxImageBufferSize max
+        (4096x4096). In order to properly account for the scaling factor introduced by this
+        clamping, the repaintRect translation component needs to be pushed after the scaling
+        transform.
+
+        Tests: svg/custom/clamped-masking-clipping-expected.svg
+               svg/custom/clamped-masking-clipping.svg
+
+        * rendering/svg/SVGRenderingContext.cpp:
+        (WebCore::SVGRenderingContext::createImageBuffer):
+
 2012-08-29  Yury Semikhatsky  <yurys@chromium.org>
 
         Web Inspector: unsafe static_cast in RetainedDOMInfo::IsEquivalent
index e2adb30..136315e 100644 (file)
@@ -205,14 +205,10 @@ bool SVGRenderingContext::createImageBuffer(const FloatRect& targetRect, const A
     GraphicsContext* imageContext = image->context();
     ASSERT(imageContext);
 
-    // This is done in absolute coordinates.
-    imageContext->translate(-paintRect.x(), -paintRect.y());
-
-    imageContext->concatCTM(absoluteTransform);
-
-    // This happens in local coordinates.
     imageContext->scale(FloatSize(static_cast<float>(clampedSize.width()) / paintRect.width(),
                                   static_cast<float>(clampedSize.height()) / paintRect.height()));
+    imageContext->translate(-paintRect.x(), -paintRect.y());
+    imageContext->concatCTM(absoluteTransform);
 
     imageBuffer = image.release();
     return true;