Title: [144110] trunk
Revision
144110
Author
[email protected]
Date
2013-02-26 14:33:28 -0800 (Tue, 26 Feb 2013)

Log Message

feDisplacementMap filter gets color space wrong
https://bugs.webkit.org/show_bug.cgi?id=105929

Reviewed by Dirk Schulze.

Source/WebCore: 

Tests: svg/filters/feDisplacementMap-color-interpolation-filters-expected.svg
       svg/filters/feDisplacementMap-color-interpolation-filters.svg
       svg/filters/feDisplacementMap-filterUnits-expected.svg
       svg/filters/feDisplacementMap-filterUnits.svg

According to the spec, the SVG feDisplacementMap filter should not
change the color space on its first input, and other vendors seem to
agree that this also means that the output should be in the first
input's color space. That makes sense: we are displacing the input,
not otherwise manipulating colors.

This change improves color space handling for filters by more
explicitly tracking which color space is used for the filter's
operation and which is used for the filter's result. It provides a
means for filter effects to override the color-interpolation-filters
property as defined by the spec. feFlood and feDisplacementMap use
this new feature to enforce the spec requirements.

* platform/graphics/filters/FEDisplacementMap.cpp:
(WebCore::FEDisplacementMap::setResultColorSpace): Override the default color space with the
    same color space as the first input filter.
(WebCore):
(WebCore::FEDisplacementMap::transformResultColorSpace): Only transform the color space on
    the second filter input.
(WebCore::FEDisplacementMap::platformApplySoftware): Make the application code more efficient,
    and give slightly better numerical accuracy.
* platform/graphics/filters/FEDisplacementMap.h:
(FEDisplacementMap): Declare setResultColorSpace.
* platform/graphics/filters/FEFlood.cpp:
(WebCore::FEFlood::platformApplySoftware): Remove the call that forces
    the result color space. We do it now in the setResultColorSpace.
* platform/graphics/filters/FEFlood.h:
(FEFlood): Add setResultColorSPace override that enforces sRGB color space. But not if using
    CG, which apparently does this this already internally.
* platform/graphics/filters/FilterEffect.cpp:
(WebCore::FilterEffect::FilterEffect): Rename m_colorSpace to m_operatingColorSpace.
(WebCore::FilterEffect::apply): Allow filter effects to
    override the color space conversion of their inputs.
(WebCore::FilterEffect::createImageBufferResult): Always create the
    image buffer with the result color space.
* platform/graphics/filters/FilterEffect.h:
(WebCore::FilterEffect::operatingColorSpace): New accessor.
(WebCore::FilterEffect::setOperatingColorSpace): New accessor.
(WebCore::FilterEffect::resultColorSpace): New accessor.
(WebCore::FilterEffect::setResultColorSpace): New accessor.
(FilterEffect):
(WebCore::FilterEffect::transformResultColorSpace): A new virtual
    method that allows filter effects individual control over the color
    space conversion of their inputs.
* platform/graphics/filters/SourceGraphic.h:
(WebCore::SourceGraphic::SourceGraphic): Variable rename.
* rendering/FilterEffectRenderer.cpp:
(WebCore::FilterEffectRenderer::build): Use accessors to set color
    space to enable per-effect overrides.
* rendering/svg/RenderSVGResourceFilter.cpp:
(WebCore::RenderSVGResourceFilter::buildPrimitives): Use accessors to set color.

LayoutTests: 

       Add two new feDisplacementMap tests to get better coverage. And update some results.

* platform/chromium-linux/svg/W3C-SVG-1.1/filters-displace-01-f-expected.png:
* platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-dom-in-attr-expected.png:
* platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-dom-in2-attr-expected.png:
* platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-dom-scale-attr-expected.png:
* platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-dom-xChannelSelector-attr-expected.png:
* platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-dom-yChannelSelector-attr-expected.png:
* platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-svgdom-in-prop-expected.png:
* platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-svgdom-in2-prop-expected.png:
* platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-svgdom-scale-prop-expected.png:
* platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-svgdom-xChannelSelector-prop-expected.png:
* platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-svgdom-yChannelSelector-prop-expected.png:
* platform/chromium-linux/svg/filters/feDisplacementMap-expected.png:
* platform/chromium-linux/svg/filters/filterRes-expected.png:
* svg/filters/feDisplacementMap-color-interpolation-filters-expected.svg: Added.
* svg/filters/feDisplacementMap-color-interpolation-filters.svg: Added.
* svg/filters/feDisplacementMap-filterUnits-expected.svg: Added.
* svg/filters/feDisplacementMap-filterUnits.svg: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (144109 => 144110)


--- trunk/LayoutTests/ChangeLog	2013-02-26 22:29:41 UTC (rev 144109)
+++ trunk/LayoutTests/ChangeLog	2013-02-26 22:33:28 UTC (rev 144110)
@@ -1,3 +1,30 @@
+2013-02-26  Stephen Chenney  <[email protected]>
+
+        feDisplacementMap filter gets color space wrong
+        https://bugs.webkit.org/show_bug.cgi?id=105929
+
+        Reviewed by Dirk Schulze.
+
+       Add two new feDisplacementMap tests to get better coverage. And update some results.
+
+        * platform/chromium-linux/svg/W3C-SVG-1.1/filters-displace-01-f-expected.png:
+        * platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-dom-in-attr-expected.png:
+        * platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-dom-in2-attr-expected.png:
+        * platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-dom-scale-attr-expected.png:
+        * platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-dom-xChannelSelector-attr-expected.png:
+        * platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-dom-yChannelSelector-attr-expected.png:
+        * platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-svgdom-in-prop-expected.png:
+        * platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-svgdom-in2-prop-expected.png:
+        * platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-svgdom-scale-prop-expected.png:
+        * platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-svgdom-xChannelSelector-prop-expected.png:
+        * platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-svgdom-yChannelSelector-prop-expected.png:
+        * platform/chromium-linux/svg/filters/feDisplacementMap-expected.png:
+        * platform/chromium-linux/svg/filters/filterRes-expected.png:
+        * svg/filters/feDisplacementMap-color-interpolation-filters-expected.svg: Added.
+        * svg/filters/feDisplacementMap-color-interpolation-filters.svg: Added.
+        * svg/filters/feDisplacementMap-filterUnits-expected.svg: Added.
+        * svg/filters/feDisplacementMap-filterUnits.svg: Added.
+
 2013-02-26  Mike West  <[email protected]>
 
         X-Frame-Options should accept ALLOWALL as a valid value.

Modified: trunk/LayoutTests/platform/chromium-linux/svg/W3C-SVG-1.1/filters-displace-01-f-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-dom-in-attr-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-dom-in2-attr-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-dom-scale-attr-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-dom-xChannelSelector-attr-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-dom-yChannelSelector-attr-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-svgdom-in-prop-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-svgdom-in2-prop-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-svgdom-scale-prop-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-svgdom-xChannelSelector-prop-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/chromium-linux/svg/dynamic-updates/SVGFEDisplacementMapElement-svgdom-yChannelSelector-prop-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/chromium-linux/svg/filters/feDisplacementMap-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/chromium-linux/svg/filters/filterRes-expected.png


(Binary files differ)

Added: trunk/LayoutTests/svg/filters/feDisplacementMap-color-interpolation-filters-expected.svg (0 => 144110)


--- trunk/LayoutTests/svg/filters/feDisplacementMap-color-interpolation-filters-expected.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/filters/feDisplacementMap-color-interpolation-filters-expected.svg	2013-02-26 22:33:28 UTC (rev 144110)
@@ -0,0 +1,4 @@
+<svg version="1.2" width="600" height="300" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+  <rect fill="rgb(50%,50%,50%)" stroke="green" x="50" y="50" width="200" height="200"/>
+  <rect fill="rgb(50%,50%,50%)" stroke="green" x="350" y="50" width="200" height="200"/>
+</svg>
\ No newline at end of file
Property changes on: trunk/LayoutTests/svg/filters/feDisplacementMap-color-interpolation-filters-expected.svg
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/svg/filters/feDisplacementMap-color-interpolation-filters.svg (0 => 144110)


--- trunk/LayoutTests/svg/filters/feDisplacementMap-color-interpolation-filters.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/filters/feDisplacementMap-color-interpolation-filters.svg	2013-02-26 22:33:28 UTC (rev 144110)
@@ -0,0 +1,18 @@
+<svg version="1.2" width="600" height="300" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+  <defs>
+    <filter id="sRGB" filterUnits="objectBoundingBox" primitiveUnits="userSpaceOnUse" x="0" y="0" width="1" height="1">
+      <feFlood flood-color="rgb(50%,50%,50%)" flood-opacity="1.0" x="50" y="50" height="200" width="200" result="grey-input"/>
+      <feFlood flood-color="rgb(50%,50%,50%)" flood-opacity="1.0" x="50" y="50" width="200" height="200" result="displacement-map"/>
+      <feDisplacementMap color-interpolation-filters="sRGB" scale ="1.0" in="grey-input" in2="displacement-map" xChannelSelector="R" yChannelSelector="G"/>
+    </filter>
+    <filter id="linearRGB" filterUnits="objectBoundingBox" primitiveUnits="userSpaceOnUse" x="0" y="0" width="1" height="1">
+      <feFlood flood-color="rgb(50%,50%,50%)" flood-opacity="1.0" x="350" y="50" height="200" width="200" result="grey-input"/>
+      <feFlood flood-color="rgb(187,187,187)" flood-opacity="1.0" x="350" y="50" width="200" height="200" result="displacement-map"/>
+      <feDisplacementMap color-interpolation-filters="linearRGB" scale ="1.0" in="grey-input" in2="displacement-map" xChannelSelector="R" yChannelSelector="G"/>
+    </filter>
+  </defs>
+  <rect filter="url(#sRGB)" fill="none" stroke="green" x="50" y="50" width="200" height="200"/>
+  <rect fill="none" stroke="green" x="50" y="50" width="200" height="200"/>
+  <rect filter="url(#linearRGB)" fill="none" stroke="green" x="350" y="50" width="200" height="200"/>
+  <rect fill="none" stroke="green" x="350" y="50" width="200" height="200"/>
+</svg>
Property changes on: trunk/LayoutTests/svg/filters/feDisplacementMap-color-interpolation-filters.svg
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/svg/filters/feDisplacementMap-filterUnits-expected.svg (0 => 144110)


--- trunk/LayoutTests/svg/filters/feDisplacementMap-filterUnits-expected.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/filters/feDisplacementMap-filterUnits-expected.svg	2013-02-26 22:33:28 UTC (rev 144110)
@@ -0,0 +1,9 @@
+<svg version="1.2" width="500" height="300" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+  <rect fill="rgb(50%,50%,50%)" stroke="green" x="20" y="20" width="75" height="75"/>
+  <rect fill="rgb(50%,50%,50%)" stroke="green" x="186" y="20" width="54" height="75"/>
+  <rect fill="rgb(50%,50%,50%)" stroke="green" x="304" y="64" width="56" height="56"/>
+
+  <rect fill="rgb(50%,50%,50%)" stroke="green" x="44" y="164" width="76" height="76"/>
+  <rect fill="rgb(50%,50%,50%)" stroke="green" x="140" y="140" width="75" height="75"/>
+  <rect fill="rgb(50%,50%,50%)" stroke="green" x="287" y="167" width="73" height="73"/>
+</svg>
Property changes on: trunk/LayoutTests/svg/filters/feDisplacementMap-filterUnits-expected.svg
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/svg/filters/feDisplacementMap-filterUnits.svg (0 => 144110)


--- trunk/LayoutTests/svg/filters/feDisplacementMap-filterUnits.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/filters/feDisplacementMap-filterUnits.svg	2013-02-26 22:33:28 UTC (rev 144110)
@@ -0,0 +1,49 @@
+<svg version="1.2" width="500" height="300" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+  <defs>
+    <filter id="oBBoBBWhiteScale" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox" x="0" y="0" width="1" height="1">
+      <feFlood flood-color="rgb(50%,50%,50%)" flood-opacity="1.0" x="0" y="0" height="1" width="1" result="grey-input"/>
+      <feFlood flood-color="rgb(100%,100%,0%)" flood-opacity="1.0" x="0" y="0" width="1" height="1" result="displacement-map"/>
+      <feDisplacementMap x="0" y="0" width="1" height="1" scale ="0.5" in="grey-input" in2="displacement-map" xChannelSelector="R" yChannelSelector="G"/>
+    </filter>
+    <filter id="oBBoBBLight" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox" x="0" y="0" width="1" height="1">
+      <feFlood flood-color="rgb(50%,50%,50%)" flood-opacity="1.0" x="0" y="0" height="1" width="1" result="grey-input"/>
+      <feFlood flood-color="rgb(0%,0%,19%)" flood-opacity="0.75" x="0" y="0" width="1" height="1" result="displacement-map"/>
+      <feDisplacementMap x="0" y="0" width="1" height="1" scale ="1.0" in="grey-input" in2="displacement-map" xChannelSelector="B" yChannelSelector="A"/>
+    </filter>
+    <filter id="oBBoBBDark" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox" x="0" y="0" width="1" height="1">
+      <feFlood flood-color="rgb(50%,50%,50%)" flood-opacity="1.0" x="0" y="0" height="1" width="1" result="grey-input"/>
+      <feFlood flood-color="rgb(25%,100%,25%)" flood-opacity="1.0" x="0" y="0" width="1" height="1" result="displacement-map"/>
+      <feDisplacementMap x="0" y="0" width="1" height="1" scale ="1.0" in="grey-input" in2="displacement-map" xChannelSelector="R" yChannelSelector="B"/>
+    </filter>
+
+    <filter id="USOUOBBBlackScale" filterUnits="userSpaceOnUse" primitiveUnits="objectBoundingBox" x="20" y="140" width="100" height="100">
+      <feFlood flood-color="rgb(50%,50%,50%)" flood-opacity="1.0" x="0" y="0" height="1" width="1" result="grey-input"/>
+      <feFlood flood-color="rgb(100%,0%,0%)" flood-opacity="1.0" x="0" y="0" width="1" height="1" result="displacement-map"/>
+      <feDisplacementMap x="0" y="0" width="1" height="1" scale ="0.5" in="grey-input" in2="displacement-map" xChannelSelector="G" yChannelSelector="B"/>
+    </filter>
+    <filter id="OBBUSOUWhite" filterUnits="objectBoundingBox" primitiveUnits="userSpaceOnUse" x="0" y="0" width="1" height="1">
+      <feFlood flood-color="rgb(50%,50%,50%)" flood-opacity="1.0" x="140" y="140" height="100" width="100" result="grey-input"/>
+      <feFlood flood-color="rgb(100%,100%,50%)" flood-opacity="1.0" x="140" y="140" width="100" height="100" result="displacement-map"/>
+      <feDisplacementMap x="140" y="140" height="100" width="100" scale ="50.0" in="grey-input" in2="displacement-map" xChannelSelector="R" yChannelSelector="G"/>
+    </filter>
+    <filter id="USOUUSOUGrey" filterUnits="userSpaceOnUse" primitiveUnits="userSpaceOnUse" x="260" y="140" width="100" height="100">
+      <feFlood flood-color="rgb(50%,50%,50%)" flood-opacity="1.0" x="260" y="140" height="100" width="100" result="grey-input"/>
+      <feFlood flood-color="rgb(50%,50%,50%)" flood-opacity="1.0" x="260" y="140" width="100" height="100" result="displacement-map"/>
+      <feDisplacementMap x="260" y="140" width="100" height="100" scale ="100" in="grey-input" in2="displacement-map" xChannelSelector="R" yChannelSelector="G"/>
+    </filter>
+  </defs>
+
+  <rect filter="url(#oBBoBBWhiteScale)" fill="none" stroke="none" x="20" y="20" width="100" height="100"/>
+  <rect fill="none" stroke="green" x="20" y="20" width="75" height="75"/>
+  <rect filter="url(#oBBoBBLight)" fill="none" stroke="none" x="140" y="20" width="100" height="100"/>
+  <rect fill="none" stroke="green" x="186" y="20" width="54" height="75"/>
+  <rect filter="url(#oBBoBBDark)" fill="none" stroke="none" x="260" y="20" width="100" height="100"/>
+  <rect fill="none" stroke="green" x="304" y="64" width="56" height="56"/>
+
+  <rect filter="url(#USOUOBBBlackScale)" fill="none" stroke="green" x="20" y="140" width="100" height="100"/>
+  <rect fill="none" stroke="green" x="44" y="164" width="76" height="76"/>
+  <rect filter="url(#OBBUSOUWhite)" fill="none" stroke="none" x="140" y="140" width="100" height="100"/>
+  <rect fill="none" stroke="green" x="140" y="140" width="75" height="75"/>
+  <rect filter="url(#USOUUSOUGrey)" fill="none" stroke="none" x="260" y="140" width="100" height="100"/>
+  <rect fill="none" stroke="green" x="287" y="167" width="73" height="73"/>
+</svg>
Property changes on: trunk/LayoutTests/svg/filters/feDisplacementMap-filterUnits.svg
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (144109 => 144110)


--- trunk/Source/WebCore/ChangeLog	2013-02-26 22:29:41 UTC (rev 144109)
+++ trunk/Source/WebCore/ChangeLog	2013-02-26 22:33:28 UTC (rev 144110)
@@ -1,3 +1,67 @@
+2013-02-26  Stephen Chenney  <[email protected]>
+
+        feDisplacementMap filter gets color space wrong
+        https://bugs.webkit.org/show_bug.cgi?id=105929
+
+        Reviewed by Dirk Schulze.
+
+        Tests: svg/filters/feDisplacementMap-color-interpolation-filters-expected.svg
+               svg/filters/feDisplacementMap-color-interpolation-filters.svg
+               svg/filters/feDisplacementMap-filterUnits-expected.svg
+               svg/filters/feDisplacementMap-filterUnits.svg
+
+        According to the spec, the SVG feDisplacementMap filter should not
+        change the color space on its first input, and other vendors seem to
+        agree that this also means that the output should be in the first
+        input's color space. That makes sense: we are displacing the input,
+        not otherwise manipulating colors.
+
+        This change improves color space handling for filters by more
+        explicitly tracking which color space is used for the filter's
+        operation and which is used for the filter's result. It provides a
+        means for filter effects to override the color-interpolation-filters
+        property as defined by the spec. feFlood and feDisplacementMap use
+        this new feature to enforce the spec requirements.
+
+        * platform/graphics/filters/FEDisplacementMap.cpp:
+        (WebCore::FEDisplacementMap::setResultColorSpace): Override the default color space with the
+            same color space as the first input filter.
+        (WebCore):
+        (WebCore::FEDisplacementMap::transformResultColorSpace): Only transform the color space on
+            the second filter input.
+        (WebCore::FEDisplacementMap::platformApplySoftware): Make the application code more efficient,
+            and give slightly better numerical accuracy.
+        * platform/graphics/filters/FEDisplacementMap.h:
+        (FEDisplacementMap): Declare setResultColorSpace.
+        * platform/graphics/filters/FEFlood.cpp:
+        (WebCore::FEFlood::platformApplySoftware): Remove the call that forces
+            the result color space. We do it now in the setResultColorSpace.
+        * platform/graphics/filters/FEFlood.h:
+        (FEFlood): Add setResultColorSPace override that enforces sRGB color space. But not if using
+            CG, which apparently does this this already internally.
+        * platform/graphics/filters/FilterEffect.cpp:
+        (WebCore::FilterEffect::FilterEffect): Rename m_colorSpace to m_operatingColorSpace.
+        (WebCore::FilterEffect::apply): Allow filter effects to
+            override the color space conversion of their inputs.
+        (WebCore::FilterEffect::createImageBufferResult): Always create the
+            image buffer with the result color space.
+        * platform/graphics/filters/FilterEffect.h:
+        (WebCore::FilterEffect::operatingColorSpace): New accessor.
+        (WebCore::FilterEffect::setOperatingColorSpace): New accessor.
+        (WebCore::FilterEffect::resultColorSpace): New accessor.
+        (WebCore::FilterEffect::setResultColorSpace): New accessor.
+        (FilterEffect):
+        (WebCore::FilterEffect::transformResultColorSpace): A new virtual
+            method that allows filter effects individual control over the color
+            space conversion of their inputs.
+        * platform/graphics/filters/SourceGraphic.h:
+        (WebCore::SourceGraphic::SourceGraphic): Variable rename.
+        * rendering/FilterEffectRenderer.cpp:
+        (WebCore::FilterEffectRenderer::build): Use accessors to set color
+            space to enable per-effect overrides.
+        * rendering/svg/RenderSVGResourceFilter.cpp:
+        (WebCore::RenderSVGResourceFilter::buildPrimitives): Use accessors to set color.
+
 2013-02-26  Mike West  <[email protected]>
 
         X-Frame-Options should accept ALLOWALL as a valid value.

Modified: trunk/Source/WebCore/platform/graphics/filters/FEDisplacementMap.cpp (144109 => 144110)


--- trunk/Source/WebCore/platform/graphics/filters/FEDisplacementMap.cpp	2013-02-26 22:29:41 UTC (rev 144109)
+++ trunk/Source/WebCore/platform/graphics/filters/FEDisplacementMap.cpp	2013-02-26 22:33:28 UTC (rev 144110)
@@ -88,6 +88,22 @@
     return true;
 }
 
+void FEDisplacementMap::setResultColorSpace(ColorSpace)
+{
+    // Spec: The 'color-interpolation-filters' property only applies to the 'in2' source image
+    // and does not apply to the 'in' source image. The 'in' source image must remain in its
+    // current color space.
+    // The result is in that smae color space because it is a displacement of the 'in' image.
+    FilterEffect::setResultColorSpace(inputEffect(0)->resultColorSpace());
+}
+
+void FEDisplacementMap::transformResultColorSpace(FilterEffect* in, const int index)
+{
+    // Do not transform the first primitive input, as per the spec.
+    if (index)
+        in->transformResultColorSpace(operatingColorSpace());
+}
+
 void FEDisplacementMap::platformApplySoftware()
 {
     FilterEffect* in = inputEffect(0);
@@ -110,17 +126,19 @@
 
     Filter* filter = this->filter();
     IntSize paintSize = absolutePaintRect().size();
-    float scaleX = filter->applyHorizontalScale(m_scale / 255);
-    float scaleY = filter->applyVerticalScale(m_scale / 255);
-    float scaleAdjustmentX = filter->applyHorizontalScale(0.5f - 0.5f * m_scale);
-    float scaleAdjustmentY = filter->applyVerticalScale(0.5f - 0.5f * m_scale);
+    float scaleX = filter->applyHorizontalScale(m_scale);
+    float scaleY = filter->applyVerticalScale(m_scale);
+    float scaleForColorX = scaleX / 255.0;
+    float scaleForColorY = scaleY / 255.0;
+    float scaledOffsetX = 0.5 - scaleX * 0.5;
+    float scaledOffsetY = 0.5 - scaleY * 0.5;
     int stride = paintSize.width() * 4;
     for (int y = 0; y < paintSize.height(); ++y) {
         int line = y * stride;
         for (int x = 0; x < paintSize.width(); ++x) {
             int dstIndex = line + x * 4;
-            int srcX = x + static_cast<int>(scaleX * srcPixelArrayB->item(dstIndex + m_xChannelSelector - 1) + scaleAdjustmentX);
-            int srcY = y + static_cast<int>(scaleY * srcPixelArrayB->item(dstIndex + m_yChannelSelector - 1) + scaleAdjustmentY);
+            int srcX = x + static_cast<int>(scaleForColorX * srcPixelArrayB->item(dstIndex + m_xChannelSelector - 1) + scaledOffsetX);
+            int srcY = y + static_cast<int>(scaleForColorY * srcPixelArrayB->item(dstIndex + m_yChannelSelector - 1) + scaledOffsetY);
             for (unsigned channel = 0; channel < 4; ++channel) {
                 if (srcX < 0 || srcX >= paintSize.width() || srcY < 0 || srcY >= paintSize.height())
                     dstPixelArray->set(dstIndex + channel, static_cast<unsigned char>(0));

Modified: trunk/Source/WebCore/platform/graphics/filters/FEDisplacementMap.h (144109 => 144110)


--- trunk/Source/WebCore/platform/graphics/filters/FEDisplacementMap.h	2013-02-26 22:29:41 UTC (rev 144109)
+++ trunk/Source/WebCore/platform/graphics/filters/FEDisplacementMap.h	2013-02-26 22:33:28 UTC (rev 144110)
@@ -50,6 +50,9 @@
     float scale() const;
     bool setScale(float);
 
+    void setResultColorSpace(ColorSpace) OVERRIDE;
+    virtual void transformResultColorSpace(FilterEffect*, const int) OVERRIDE;
+
     virtual void platformApplySoftware();
     virtual void dump();
 

Modified: trunk/Source/WebCore/platform/graphics/filters/FEFlood.cpp (144109 => 144110)


--- trunk/Source/WebCore/platform/graphics/filters/FEFlood.cpp	2013-02-26 22:29:41 UTC (rev 144109)
+++ trunk/Source/WebCore/platform/graphics/filters/FEFlood.cpp	2013-02-26 22:33:28 UTC (rev 144110)
@@ -78,9 +78,6 @@
 
     Color color = colorWithOverrideAlpha(floodColor().rgb(), floodOpacity());
     resultImage->context()->fillRect(FloatRect(FloatPoint(), absolutePaintRect().size()), color, ColorSpaceDeviceRGB);
-    // feFlood does not perform color interpolation of any kind, so the result is always in ColorSpaceDeviceRGB
-    // regardless of the value of color-interpolation-filters.
-    setResultColorSpace(ColorSpaceDeviceRGB);
 }
 
 void FEFlood::dump()

Modified: trunk/Source/WebCore/platform/graphics/filters/FEFlood.h (144109 => 144110)


--- trunk/Source/WebCore/platform/graphics/filters/FEFlood.h	2013-02-26 22:29:41 UTC (rev 144109)
+++ trunk/Source/WebCore/platform/graphics/filters/FEFlood.h	2013-02-26 22:33:28 UTC (rev 144110)
@@ -39,6 +39,13 @@
     float floodOpacity() const;
     bool setFloodOpacity(float);
 
+#if !USE(CG)
+    // feFlood does not perform color interpolation of any kind, so the result is always in the current
+    // color space regardless of the value of color-interpolation-filters.
+    void setOperatingColorSpace(ColorSpace) OVERRIDE { FilterEffect::setResultColorSpace(ColorSpaceDeviceRGB); }
+    void setResultColorSpace(ColorSpace) OVERRIDE { FilterEffect::setResultColorSpace(ColorSpaceDeviceRGB); }
+#endif
+
     virtual void platformApplySoftware();
 #if ENABLE(OPENCL)
     virtual bool platformApplyOpenCL();

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


--- trunk/Source/WebCore/platform/graphics/filters/FilterEffect.cpp	2013-02-26 22:29:41 UTC (rev 144109)
+++ trunk/Source/WebCore/platform/graphics/filters/FilterEffect.cpp	2013-02-26 22:33:28 UTC (rev 144110)
@@ -44,7 +44,7 @@
     , m_hasWidth(false)
     , m_hasHeight(false)
     , m_clipsToBounds(true)
-    , m_colorSpace(ColorSpaceLinearRGB)
+    , m_operatingColorSpace(ColorSpaceLinearRGB)
     , m_resultColorSpace(ColorSpaceDeviceRGB)
 {
     ASSERT(m_filter);
@@ -127,11 +127,11 @@
             return;
 
         // Convert input results to the current effect's color space.
-        in->transformResultColorSpace(m_colorSpace);
+        transformResultColorSpace(in, i);
     }
 
     determineAbsolutePaintRect();
-    m_resultColorSpace = m_colorSpace;
+    setResultColorSpace(m_operatingColorSpace);
 
     if (!isFilterSizeValid(m_absolutePaintRect))
         return;
@@ -428,7 +428,7 @@
     ASSERT(!hasResult());
     if (m_absolutePaintRect.isEmpty())
         return 0;
-    m_imageBufferResult = ImageBuffer::create(m_absolutePaintRect.size(), 1, m_colorSpace, m_filter->renderingMode());
+    m_imageBufferResult = ImageBuffer::create(m_absolutePaintRect.size(), 1, m_resultColorSpace, m_filter->renderingMode());
     if (!m_imageBufferResult)
         return 0;
     ASSERT(m_imageBufferResult->context());

Modified: trunk/Source/WebCore/platform/graphics/filters/FilterEffect.h (144109 => 144110)


--- trunk/Source/WebCore/platform/graphics/filters/FilterEffect.h	2013-02-26 22:29:41 UTC (rev 144109)
+++ trunk/Source/WebCore/platform/graphics/filters/FilterEffect.h	2013-02-26 22:33:28 UTC (rev 144110)
@@ -164,15 +164,17 @@
     bool clipsToBounds() const { return m_clipsToBounds; }
     void setClipsToBounds(bool value) { m_clipsToBounds = value; }
 
-    ColorSpace colorSpace() const { return m_colorSpace; }
-    void setColorSpace(ColorSpace colorSpace) { m_colorSpace = colorSpace; }
+    ColorSpace operatingColorSpace() const { return m_operatingColorSpace; }
+    virtual void setOperatingColorSpace(ColorSpace colorSpace) { m_operatingColorSpace = colorSpace; }
+    ColorSpace resultColorSpace() const { return m_resultColorSpace; }
+    virtual void setResultColorSpace(ColorSpace colorSpace) { m_resultColorSpace = colorSpace; }
+
+    virtual void transformResultColorSpace(FilterEffect* in, const int) { in->transformResultColorSpace(m_operatingColorSpace); }
     void transformResultColorSpace(ColorSpace);
 
 protected:
     FilterEffect(Filter*);
 
-    void setResultColorSpace(ColorSpace colorSpace) { m_resultColorSpace = colorSpace; }
-
     ImageBuffer* createImageBufferResult();
     Uint8ClampedArray* createUnmultipliedImageResult();
     Uint8ClampedArray* createPremultipliedImageResult();
@@ -226,7 +228,7 @@
     // Should the effect clip to its primitive region, or expand to use the combined region of its inputs.
     bool m_clipsToBounds;
 
-    ColorSpace m_colorSpace;
+    ColorSpace m_operatingColorSpace;
     ColorSpace m_resultColorSpace;
 };
 

Modified: trunk/Source/WebCore/platform/graphics/filters/SourceGraphic.h (144109 => 144110)


--- trunk/Source/WebCore/platform/graphics/filters/SourceGraphic.h	2013-02-26 22:29:41 UTC (rev 144109)
+++ trunk/Source/WebCore/platform/graphics/filters/SourceGraphic.h	2013-02-26 22:33:28 UTC (rev 144110)
@@ -49,7 +49,7 @@
     SourceGraphic(Filter* filter)
         : FilterEffect(filter)
     {
-        setColorSpace(ColorSpaceDeviceRGB);
+        setOperatingColorSpace(ColorSpaceDeviceRGB);
     }
 };
 

Modified: trunk/Source/WebCore/rendering/FilterEffectRenderer.cpp (144109 => 144110)


--- trunk/Source/WebCore/rendering/FilterEffectRenderer.cpp	2013-02-26 22:29:41 UTC (rev 144109)
+++ trunk/Source/WebCore/rendering/FilterEffectRenderer.cpp	2013-02-26 22:33:28 UTC (rev 144110)
@@ -363,7 +363,7 @@
         if (effect) {
             // Unlike SVG, filters applied here should not clip to their primitive subregions.
             effect->setClipsToBounds(false);
-            effect->setColorSpace(ColorSpaceDeviceRGB);
+            effect->setOperatingColorSpace(ColorSpaceDeviceRGB);
             
             if (filterOperation->getOperationType() != FilterOperation::REFERENCE) {
                 effect->inputEffects().append(previousEffect);

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp (144109 => 144110)


--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp	2013-02-26 22:29:41 UTC (rev 144109)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp	2013-02-26 22:33:28 UTC (rev 144110)
@@ -121,8 +121,8 @@
         builder->appendEffectToEffectReferences(effect, effectElement->renderer());
         effectElement->setStandardAttributes(effect.get());
         effect->setEffectBoundaries(SVGLengthContext::resolveRectangle<SVGFilterPrimitiveStandardAttributes>(effectElement, filterElement->primitiveUnits(), targetBoundingBox));
-        effect->setColorSpace(effectElement->renderer()->style()->svgStyle()->colorInterpolationFilters() == CI_LINEARRGB
-                ? ColorSpaceLinearRGB : ColorSpaceDeviceRGB);
+        effect->setOperatingColorSpace(
+            effectElement->renderer()->style()->svgStyle()->colorInterpolationFilters() == CI_LINEARRGB ? ColorSpaceLinearRGB : ColorSpaceDeviceRGB);
         builder->add(effectElement->result(), effect);
     }
     return builder.release();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to