feMorphology stops applying if either x or y radius is 0 but should not.
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Jan 2018 21:39:12 +0000 (21:39 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Jan 2018 21:39:12 +0000 (21:39 +0000)
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.

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

LayoutTests/ChangeLog
LayoutTests/svg/filters/feMorphology-zero-radius-one-axis-expected.svg [new file with mode: 0644]
LayoutTests/svg/filters/feMorphology-zero-radius-one-axis.svg [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/filters/FEMorphology.cpp
Source/WebCore/platform/graphics/filters/FilterEffect.cpp

index 960e52a..f264fe5 100644 (file)
@@ -1,3 +1,13 @@
+2018-01-23  Simon Fraser  <simon.fraser@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  <jfernandez@igalia.com>
 
         [css-align] 'left' and 'right' should parse as invalid in block/cross-axis alignment
diff --git a/LayoutTests/svg/filters/feMorphology-zero-radius-one-axis-expected.svg b/LayoutTests/svg/filters/feMorphology-zero-radius-one-axis-expected.svg
new file mode 100644 (file)
index 0000000..ca306e9
--- /dev/null
@@ -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>
diff --git a/LayoutTests/svg/filters/feMorphology-zero-radius-one-axis.svg b/LayoutTests/svg/filters/feMorphology-zero-radius-one-axis.svg
new file mode 100644 (file)
index 0000000..f692f1f
--- /dev/null
@@ -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>
index 354861b..357eeba 100644 (file)
@@ -1,3 +1,23 @@
+2018-01-23  Simon Fraser  <simon.fraser@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  <achristensen@webkit.org>
 
         Remove unused MediaPlayerSupportsTypeClient
index 283ac93..7ea7cce 100644 (file)
@@ -221,15 +221,7 @@ void FEMorphology::platformApply(const PaintingData& paintingData)
 
 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;
index 9354be0..babca40 100644 (file)
@@ -442,7 +442,7 @@ void FilterEffect::copyPremultipliedResult(Uint8ClampedArray& destination, const
 
 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());