haikuwebkit/LayoutTests/svg/filters/feSpecularLighting-fePointL...

18 lines
819 B
XML
Raw Permalink Normal View History

feLighting is broken with primitiveUnits="objectBoundingBox" https://bugs.webkit.org/show_bug.cgi?id=181197 Reviewed by Tim Horton. Source/WebCore: With <filter primitiveUnits="objectBoundingBox"> we need to convert the coordinates of fePointLights and feSpotLights into user space coordinates. Following https://www.w3.org/TR/SVG/filters.html#FilterElementPrimitiveUnitsAttribute this is done by treating them as fractions of the bounding box on the referencing element, with treatment for z following https://www.w3.org/TR/SVG/coords.html#Units_viewport_percentage To do this, store the bounds of the referencing elemenet on SVGFilterBuilder as targetBoundingBox, and store the primitiveUnits type. Then do the conversion of lighting coordinates in SVGFESpecularLightingElement::build() and SVGFEDiffuseLightingElement::build(). Remove SVGFELightElement::findLightSource(), since we need to be able to pass the SVGFilterBuilder to the lightSource() function so hoist the code up. Tests: svg/filters/feDiffuseLighting-fePointLight-primitiveUnits-objectBoundingBox-expected.svg svg/filters/feDiffuseLighting-fePointLight-primitiveUnits-objectBoundingBox.svg svg/filters/feDiffuseLighting-feSpotLight-primitiveUnits-objectBoundingBox-expected.svg svg/filters/feDiffuseLighting-feSpotLight-primitiveUnits-objectBoundingBox.svg svg/filters/feSpecularLighting-fePointLight-primitiveUnits-objectBoundingBox-expected.svg svg/filters/feSpecularLighting-fePointLight-primitiveUnits-objectBoundingBox.svg * rendering/svg/RenderSVGResourceFilter.cpp: (WebCore::RenderSVGResourceFilter::buildPrimitives const): * svg/SVGFEDiffuseLightingElement.cpp: (WebCore::SVGFEDiffuseLightingElement::build): * svg/SVGFEDistantLightElement.cpp: (WebCore::SVGFEDistantLightElement::lightSource const): * svg/SVGFEDistantLightElement.h: * svg/SVGFELightElement.cpp: (WebCore::SVGFELightElement::findLightSource): Deleted. * svg/SVGFELightElement.h: * svg/SVGFEPointLightElement.cpp: (WebCore::SVGFEPointLightElement::lightSource const): * svg/SVGFEPointLightElement.h: * svg/SVGFESpecularLightingElement.cpp: (WebCore::SVGFESpecularLightingElement::build): * svg/SVGFESpotLightElement.cpp: (WebCore::SVGFESpotLightElement::lightSource const): * svg/SVGFESpotLightElement.h: * svg/graphics/filters/SVGFilterBuilder.h: (WebCore::SVGFilterBuilder::setTargetBoundingBox): (WebCore::SVGFilterBuilder::targetBoundingBox const): (WebCore::SVGFilterBuilder::primitiveUnits const): (WebCore::SVGFilterBuilder::setPrimitiveUnits): LayoutTests: Ref tests with primitiveUnits=objectBoundingBox for feSpotLight and fePointLight. * svg/filters/feDiffuseLighting-fePointLight-primitiveUnits-objectBoundingBox-expected.svg: Added. * svg/filters/feDiffuseLighting-fePointLight-primitiveUnits-objectBoundingBox.svg: Added. * svg/filters/feDiffuseLighting-feSpotLight-primitiveUnits-objectBoundingBox-expected.svg: Added. * svg/filters/feDiffuseLighting-feSpotLight-primitiveUnits-objectBoundingBox.svg: Added. * svg/filters/feSpecularLighting-fePointLight-primitiveUnits-objectBoundingBox-expected.svg: Added. * svg/filters/feSpecularLighting-fePointLight-primitiveUnits-objectBoundingBox.svg: Added. Canonical link: https://commits.webkit.org/197096@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226373 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-03 21:56:00 +00:00
<svg width="500px" height="580px" xmlns="http://www.w3.org/2000/svg">
<defs>
<filter id="filter" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox">
<feFlood/>
<feSpecularLighting surfaceScale="10" specularExponent="10" specularConstant="2" lighting-color="rgb(0, 255, 0)">
<fePointLight x="0.35" y="0.5" z="0.2"/>
</feSpecularLighting>
<feComponentTransfer>
<feFuncG type="discrete" tableValues="0 1"/>
<feFuncA type="discrete" tableValues="0 1"/>
</feComponentTransfer>
</filter>
</defs>
<rect x="110" y="150" width="400" height="320" fill="none" filter="url(#filter)"/>
<!-- Mask off slight differences in point light radius -->
<circle cx="250" cy="310" r="112" fill="none" stroke="gray" stroke-width="20"/>
</svg>