haikuwebkit/LayoutTests/svg/filters/feDisplacementMap-color-int...

19 lines
1.6 KiB
XML
Raw Permalink Normal View History

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. Canonical link: https://commits.webkit.org/129198@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@144110 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-02-26 22:33:28 +00:00
<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>