Title: [227440] trunk
Revision
227440
Author
simon.fra...@apple.com
Date
2018-01-23 13:39:12 -0800 (Tue, 23 Jan 2018)

Log Message

feMorphology stops applying if either x or y radius is 0 but should not.
https://bugs.webkit.org/show_bug.cgi?id=181903

Reviewed by Dean Jackson.
Source/WebCore:

feMorphology should allow the radius on one axis to be zero but still apply the effect
(it's akin to a blur on just one axis). Also, any negative radius, or zero on both axes
should act like a pass-through, rather than outputting transparent blank (this is a spec
change from SVG 1.1 to SVG 2).

Tests: svg/filters/feMorphology-zero-radius-one-axis-expected.svg
       svg/filters/feMorphology-zero-radius-one-axis.svg

* platform/graphics/filters/FEMorphology.cpp:
(WebCore::FEMorphology::platformApplyDegenerate):
* platform/graphics/filters/FilterEffect.cpp:
(WebCore::FilterEffect::createImageBufferResult):

LayoutTests:

* svg/filters/feMorphology-zero-radius-one-axis-expected.svg: Added.
* svg/filters/feMorphology-zero-radius-one-axis.svg: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (227439 => 227440)


--- trunk/LayoutTests/ChangeLog	2018-01-23 21:33:35 UTC (rev 227439)
+++ trunk/LayoutTests/ChangeLog	2018-01-23 21:39:12 UTC (rev 227440)
@@ -1,3 +1,13 @@
+2018-01-23  Simon Fraser  <simon.fra...@apple.com>
+
+        feMorphology stops applying if either x or y radius is 0 but should not.
+        https://bugs.webkit.org/show_bug.cgi?id=181903
+
+        Reviewed by Dean Jackson.
+
+        * svg/filters/feMorphology-zero-radius-one-axis-expected.svg: Added.
+        * svg/filters/feMorphology-zero-radius-one-axis.svg: Added.
+
 2018-01-23  Javier Fernandez  <jfernan...@igalia.com>
 
         [css-align] 'left' and 'right' should parse as invalid in block/cross-axis alignment

Added: trunk/LayoutTests/svg/filters/feMorphology-zero-radius-one-axis-expected.svg (0 => 227440)


--- trunk/LayoutTests/svg/filters/feMorphology-zero-radius-one-axis-expected.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/filters/feMorphology-zero-radius-one-axis-expected.svg	2018-01-23 21:39:12 UTC (rev 227440)
@@ -0,0 +1,5 @@
+<svg id="svg" width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+    <rect x="50" y="30" width="200" height="160" fill="black" stroke-width="8" stroke="gray"/>
+    <rect x="250" y="230" width="200" height="160" fill="black" stroke-width="8" stroke="gray"/>
+    <rect x="249" y="190" width="2" height="40" fill="none" stroke-width="8" stroke="gray"/>
+</svg>

Added: trunk/LayoutTests/svg/filters/feMorphology-zero-radius-one-axis.svg (0 => 227440)


--- trunk/LayoutTests/svg/filters/feMorphology-zero-radius-one-axis.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/filters/feMorphology-zero-radius-one-axis.svg	2018-01-23 21:39:12 UTC (rev 227440)
@@ -0,0 +1,17 @@
+<svg id="svg" width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<defs>
+    <filter id="morph">
+        <feMorphology operator="erode" radius="0 20"/>
+    </filter>
+</defs>
+
+<g filter="url(#morph)">
+    <rect x="50" y="10" width="200" height="200" fill="black"/>
+    <rect x="250" y="210" width="200" height="200" fill="black"/>
+</g>
+
+<rect x="50" y="30" width="200" height="160" fill="none" stroke-width="8" stroke="gray"/>
+<rect x="250" y="230" width="200" height="160" fill="none" stroke-width="8" stroke="gray"/>
+<rect x="249" y="190" width="2" height="40" fill="none" stroke-width="8" stroke="gray"/>
+
+</svg>

Modified: trunk/Source/WebCore/ChangeLog (227439 => 227440)


--- trunk/Source/WebCore/ChangeLog	2018-01-23 21:33:35 UTC (rev 227439)
+++ trunk/Source/WebCore/ChangeLog	2018-01-23 21:39:12 UTC (rev 227440)
@@ -1,3 +1,23 @@
+2018-01-23  Simon Fraser  <simon.fra...@apple.com>
+
+        feMorphology stops applying if either x or y radius is 0 but should not.
+        https://bugs.webkit.org/show_bug.cgi?id=181903
+
+        Reviewed by Dean Jackson.
+        
+        feMorphology should allow the radius on one axis to be zero but still apply the effect
+        (it's akin to a blur on just one axis). Also, any negative radius, or zero on both axes
+        should act like a pass-through, rather than outputting transparent blank (this is a spec
+        change from SVG 1.1 to SVG 2).
+
+        Tests: svg/filters/feMorphology-zero-radius-one-axis-expected.svg
+               svg/filters/feMorphology-zero-radius-one-axis.svg
+
+        * platform/graphics/filters/FEMorphology.cpp:
+        (WebCore::FEMorphology::platformApplyDegenerate):
+        * platform/graphics/filters/FilterEffect.cpp:
+        (WebCore::FilterEffect::createImageBufferResult):
+
 2018-01-23  Alex Christensen  <achristen...@webkit.org>
 
         Remove unused MediaPlayerSupportsTypeClient

Modified: trunk/Source/WebCore/platform/graphics/filters/FEMorphology.cpp (227439 => 227440)


--- trunk/Source/WebCore/platform/graphics/filters/FEMorphology.cpp	2018-01-23 21:33:35 UTC (rev 227439)
+++ trunk/Source/WebCore/platform/graphics/filters/FEMorphology.cpp	2018-01-23 21:39:12 UTC (rev 227440)
@@ -221,15 +221,7 @@
 
 bool FEMorphology::platformApplyDegenerate(Uint8ClampedArray& dstPixelArray, const IntRect& imageRect, int radiusX, int radiusY)
 {
-    // Input radius is less than zero or an overflow happens when scaling it.
-    if (radiusX < 0 || radiusY < 0) {
-        dstPixelArray.zeroFill();
-        return true;
-    }
-
-    // FIXME: this should allow erode/dilate on one axis. webkit.org/b/181903.
-    // Also if both x radiusX and radiusY are zero, the result should be transparent black.
-    if (!radiusX || !radiusY) {
+    if (radiusX < 0 || radiusY < 0 || (!radiusX && !radiusY)) {
         FilterEffect* in = inputEffect(0);
         in->copyPremultipliedResult(dstPixelArray, imageRect);
         return true;

Modified: trunk/Source/WebCore/platform/graphics/filters/FilterEffect.cpp (227439 => 227440)


--- trunk/Source/WebCore/platform/graphics/filters/FilterEffect.cpp	2018-01-23 21:33:35 UTC (rev 227439)
+++ trunk/Source/WebCore/platform/graphics/filters/FilterEffect.cpp	2018-01-23 21:39:12 UTC (rev 227440)
@@ -442,7 +442,7 @@
 
 ImageBuffer* FilterEffect::createImageBufferResult()
 {
-    LOG(Filters, "FilterEffect %s %p createImageBufferResult", filterName(), this);
+    LOG(Filters, "FilterEffect %s %p createImageBufferResult %dx%d", filterName(), this, m_absolutePaintRect.size().width(), m_absolutePaintRect.size().height());
 
     // Only one result type is allowed.
     ASSERT(!hasResult());
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to