feColorMatrix saturation is not limited to range 0..1 anymore
authorkrit@webkit.org <krit@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Oct 2011 14:27:24 +0000 (14:27 +0000)
committerkrit@webkit.org <krit@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Oct 2011 14:27:24 +0000 (14:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=69245

Source/WebCore:

Reviewed by Nikolas Zimmermann.

Opera doesn't limit the range of values for saturation on feColorMatrix from 0 to 1. The limitation
was also removed from the new Filter Effects 1.0 specification. Values outside this range lead to
under- or oversaturation of the filter input image.
https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/publish/Filters.html#feColorMatrixElement

Test: svg/filters/feColorMatrix-saturate.svg

* svg/SVGFEColorMatrixElement.cpp:
(WebCore::SVGFEColorMatrixElement::build):

LayoutTests:

Reviewed by Nikolas Zimmermann.

Added new test case to test under- or oversaturation of the filter input image if the value
is not in the range of 0..1.
feColorMatrix-values needed a change, since it relies to the old specification text.

* platform/mac/svg/filters/feColorMatrix-values-expected.png:
* platform/mac/svg/filters/feColorMatrix-values-expected.txt:
* svg/filters/feColorMatrix-saturate-expected.png: Added.
* svg/filters/feColorMatrix-saturate-expected.txt: Added.
* svg/filters/feColorMatrix-saturate.svg: Added.
* svg/filters/feColorMatrix-values.svg:

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

LayoutTests/ChangeLog
LayoutTests/platform/mac/svg/filters/feColorMatrix-values-expected.png
LayoutTests/platform/mac/svg/filters/feColorMatrix-values-expected.txt
LayoutTests/svg/filters/feColorMatrix-saturate-expected.png [new file with mode: 0644]
LayoutTests/svg/filters/feColorMatrix-saturate-expected.txt [new file with mode: 0644]
LayoutTests/svg/filters/feColorMatrix-saturate.svg [new file with mode: 0644]
LayoutTests/svg/filters/feColorMatrix-values.svg
Source/WebCore/ChangeLog
Source/WebCore/svg/SVGFEColorMatrixElement.cpp

index 8abbbc4..2ad6931 100644 (file)
@@ -1,3 +1,21 @@
+2011-10-03  Dirk Schulze  <krit@webkit.org>
+
+        feColorMatrix saturation is not limited to range 0..1 anymore
+        https://bugs.webkit.org/show_bug.cgi?id=69245
+
+        Reviewed by Nikolas Zimmermann.
+
+        Added new test case to test under- or oversaturation of the filter input image if the value
+        is not in the range of 0..1.
+        feColorMatrix-values needed a change, since it relies to the old specification text.
+
+        * platform/mac/svg/filters/feColorMatrix-values-expected.png:
+        * platform/mac/svg/filters/feColorMatrix-values-expected.txt:
+        * svg/filters/feColorMatrix-saturate-expected.png: Added.
+        * svg/filters/feColorMatrix-saturate-expected.txt: Added.
+        * svg/filters/feColorMatrix-saturate.svg: Added.
+        * svg/filters/feColorMatrix-values.svg:
+
 2011-10-03  Zsolt FehĂ©r  <feherzs@inf.u-szeged.hu>
 
         Unreviewed gardening after r96257.
index 3e69adc..4785959 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/filters/feColorMatrix-values-expected.png and b/LayoutTests/platform/mac/svg/filters/feColorMatrix-values-expected.png differ
index d3fa8e8..09f7c9d 100644 (file)
@@ -96,13 +96,13 @@ layer at (0,0) size 800x600
           chunk 1 text run 1 at (210.00,270.00) startOffset 0 endOffset 17 width 156.00: "values attribute."
       RenderSVGPath {rect} at (182,292) size 236x116 [fill={[type=SOLID] [color=#FF0000]}] [x=202.00] [y=302.00] [width=196.00] [height=96.00]
         [filter="satrange"] RenderSVGResourceFilter {filter} at (182.40,292.40) size 235.20x115.20
-      RenderSVGText {text} at (210,318) size 162x28 contains 1 chunk(s)
-        [filter="satrange"] RenderSVGResourceFilter {filter} at (193.80,315.20) size 194.40x33.60
-        RenderSVGInlineText {#text} at (0,0) size 162x28
+      RenderSVGText {text} at (210,318) size 133x28 contains 1 chunk(s)
+        [filter="satrange"] RenderSVGResourceFilter {filter} at (196.70,315.20) size 159.60x33.60
+        RenderSVGInlineText {#text} at (0,0) size 133x28
           [filter="satrange"] RenderSVGResourceFilter {filter} at (0,0) size 0x0
-          chunk 1 text run 1 at (210.00,340.00) startOffset 0 endOffset 16 width 162.00: "Saturate must be"
-      RenderSVGText {text} at (210,348) size 164x28 contains 1 chunk(s)
-        [filter="satrange"] RenderSVGResourceFilter {filter} at (193.60,345.20) size 196.80x33.60
-        RenderSVGInlineText {#text} at (0,0) size 164x28
+          chunk 1 text run 1 at (210.00,340.00) startOffset 0 endOffset 13 width 133.00: "Saturate must"
+      RenderSVGText {text} at (210,348) size 152x28 contains 1 chunk(s)
+        [filter="satrange"] RenderSVGResourceFilter {filter} at (194.80,345.20) size 182.40x33.60
+        RenderSVGInlineText {#text} at (0,0) size 152x28
           [filter="satrange"] RenderSVGResourceFilter {filter} at (0,0) size 0x0
-          chunk 1 text run 1 at (210.00,370.00) startOffset 0 endOffset 16 width 164.00: "between 0 and 1."
+          chunk 1 text run 1 at (210.00,370.00) startOffset 0 endOffset 15 width 152.00: "have one value."
diff --git a/LayoutTests/svg/filters/feColorMatrix-saturate-expected.png b/LayoutTests/svg/filters/feColorMatrix-saturate-expected.png
new file mode 100644 (file)
index 0000000..39d7ba5
Binary files /dev/null and b/LayoutTests/svg/filters/feColorMatrix-saturate-expected.png differ
diff --git a/LayoutTests/svg/filters/feColorMatrix-saturate-expected.txt b/LayoutTests/svg/filters/feColorMatrix-saturate-expected.txt
new file mode 100644 (file)
index 0000000..9be3b33
--- /dev/null
@@ -0,0 +1,32 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (0,0) size 250x250
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+      RenderSVGResourceFilter {filter} [id="f1"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
+        [feColorMatrix type="SATURATE" values="-100.00"]
+          [SourceGraphic]
+      RenderSVGResourceFilter {filter} [id="f2"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
+        [feColorMatrix type="SATURATE" values="0.00"]
+          [SourceGraphic]
+      RenderSVGResourceFilter {filter} [id="f3"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
+        [feColorMatrix type="SATURATE" values="1.00"]
+          [SourceGraphic]
+      RenderSVGResourceFilter {filter} [id="f4"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
+        [feColorMatrix type="SATURATE" values="100.00"]
+          [SourceGraphic]
+      RenderSVGResourceLinearGradient {linearGradient} [id="gradient"] [gradientUnits=objectBoundingBox] [start=(0,0)] [end=(1,1)]
+        RenderSVGGradientStop {stop} [offset=0.00] [color=#EE82EE]
+        RenderSVGGradientStop {stop} [offset=0.20] [color=#0000FF]
+        RenderSVGGradientStop {stop} [offset=0.40] [color=#00FF00]
+        RenderSVGGradientStop {stop} [offset=0.60] [color=#FFFF00]
+        RenderSVGGradientStop {stop} [offset=0.80] [color=#FFA500]
+        RenderSVGGradientStop {stop} [offset=1.00] [color=#008000]
+    RenderSVGPath {rect} at (0,0) size 121x121 [fill={[type=LINEAR-GRADIENT] [id="gradient"]}] [x=10.00] [y=10.00] [width=100.00] [height=100.00]
+      [filter="f1"] RenderSVGResourceFilter {filter} at (0,0) size 120x120
+    RenderSVGPath {rect} at (130,0) size 120x121 [fill={[type=LINEAR-GRADIENT] [id="gradient"]}] [x=140.00] [y=10.00] [width=100.00] [height=100.00]
+      [filter="f2"] RenderSVGResourceFilter {filter} at (130,0) size 120x120
+    RenderSVGPath {rect} at (0,130) size 121x120 [fill={[type=LINEAR-GRADIENT] [id="gradient"]}] [x=10.00] [y=140.00] [width=100.00] [height=100.00]
+      [filter="f3"] RenderSVGResourceFilter {filter} at (0,130) size 120x120
+    RenderSVGPath {rect} at (130,130) size 120x120 [fill={[type=LINEAR-GRADIENT] [id="gradient"]}] [x=140.00] [y=140.00] [width=100.00] [height=100.00]
+      [filter="f4"] RenderSVGResourceFilter {filter} at (130,130) size 120x120
diff --git a/LayoutTests/svg/filters/feColorMatrix-saturate.svg b/LayoutTests/svg/filters/feColorMatrix-saturate.svg
new file mode 100644 (file)
index 0000000..86e3ab9
--- /dev/null
@@ -0,0 +1,28 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<defs>
+<filter id="f1">
+    <feColorMatrix type="saturate" values="-100"/>
+</filter>
+<filter id="f2">
+    <feColorMatrix type="saturate" values="0"/>
+</filter>
+<filter id="f3">
+    <feColorMatrix type="saturate" values="1"/>
+</filter>
+<filter id="f4">
+    <feColorMatrix type="saturate" values="100"/>
+</filter>
+<linearGradient id="gradient" gradientUnits="objectBoundingBox" x1="0" y1="0" x2="1" y2="1">
+       <stop stop-color="rgb(238,130,238)" offset="0"/>
+       <stop stop-color="blue" offset="0.2"/>
+       <stop stop-color="lime" offset="0.4"/>
+       <stop stop-color="yellow" offset="0.6"/>
+       <stop stop-color="rgb(255,165,0)" offset="0.8"/>
+       <stop stop-color="green" offset="1"/>
+</linearGradient>
+</defs>
+<rect x="10" y="10" width="100" height="100" filter="url(#f1)" fill="url(#gradient)"/>
+<rect x="140" y="10" width="100" height="100" filter="url(#f2)" fill="url(#gradient)"/>
+<rect x="10" y="140" width="100" height="100" filter="url(#f3)" fill="url(#gradient)"/>
+<rect x="140" y="140" width="100" height="100" filter="url(#f4)" fill="url(#gradient)"/>
+</svg>
\ No newline at end of file
index fe67e71..d444225 100644 (file)
@@ -25,7 +25,7 @@
     </filter>
 
     <filter id="satrange">
-        <feColorMatrix type="saturate" values="2" />
+        <feColorMatrix type="saturate" values="1 1" />
     </filter>
     <filter id="huerange">
         <feColorMatrix type="hueRotate" values="720" />
@@ -62,7 +62,7 @@
     <text y="240" x="210" style="filter:url(#satbad)">Invalid hueRotate</text>
     <text y="270" x="210" style="filter:url(#satbad)">values attribute.</text>
     <rect y="302" x="202" width="196" height="96" fill="red" style="filter:url(#satrange)" />
-    <text y="340" x="210" style="filter:url(#satrange)">Saturate must be </text>
-    <text y="370" x="210" style="filter:url(#satrange)">between 0 and 1.</text>
+    <text y="340" x="210" style="filter:url(#satrange)">Saturate must  </text>
+    <text y="370" x="210" style="filter:url(#satrange)">have one value.</text>
 </g>
 </svg>
index e9d9d56..463dfc3 100644 (file)
@@ -1,3 +1,20 @@
+2011-10-03  Dirk Schulze  <krit@webkit.org>
+
+        feColorMatrix saturation is not limited to range 0..1 anymore
+        https://bugs.webkit.org/show_bug.cgi?id=69245
+
+        Reviewed by Nikolas Zimmermann.
+        
+        Opera doesn't limit the range of values for saturation on feColorMatrix from 0 to 1. The limitation
+        was also removed from the new Filter Effects 1.0 specification. Values outside this range lead to
+        under- or oversaturation of the filter input image.
+        https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/publish/Filters.html#feColorMatrixElement
+
+        Test: svg/filters/feColorMatrix-saturate.svg
+
+        * svg/SVGFEColorMatrixElement.cpp:
+        (WebCore::SVGFEColorMatrixElement::build):
+
 2011-10-03  Andreas Kling  <kling@webkit.org>
 
         Shrink HTMLLIElement.
index 47b57f3..22a297f 100644 (file)
@@ -147,13 +147,13 @@ PassRefPtr<FilterEffect> SVGFEColorMatrixElement::build(SVGFilterBuilder* filter
         switch (filterType) {
         case FECOLORMATRIX_TYPE_MATRIX:
             for (size_t i = 0; i < 20; i++)
-                filterValues.append((i % 6) ? 0.0f : 1.0f);
+                filterValues.append((i % 6) ? 0 : 1);
             break;
         case FECOLORMATRIX_TYPE_HUEROTATE:
-            filterValues.append(0.0f);
+            filterValues.append(0);
             break;
         case FECOLORMATRIX_TYPE_SATURATE:
-            filterValues.append(1.0f);
+            filterValues.append(1);
             break;
         default:
             break;
@@ -164,8 +164,7 @@ PassRefPtr<FilterEffect> SVGFEColorMatrixElement::build(SVGFilterBuilder* filter
 
         if ((filterType == FECOLORMATRIX_TYPE_MATRIX && size != 20)
             || (filterType == FECOLORMATRIX_TYPE_HUEROTATE && size != 1)
-            || (filterType == FECOLORMATRIX_TYPE_SATURATE && (size != 1
-                || filterValues[0] < 0.0f || filterValues[0] > 1.0f)))
+            || (filterType == FECOLORMATRIX_TYPE_SATURATE && size != 1))
             return 0;
     }