haikuwebkit/LayoutTests/svg/filters/fePointLight-coordinates.svg

17 lines
677 B
XML
Raw Permalink Normal View History

SVG lighting filter lights are in the wrong coordinate system https://bugs.webkit.org/show_bug.cgi?id=181147 Reviewed by Zalan Bujtas. Source/WebCore: Point and spot light coordinates weren't being converted into buffer-relative coordinates before being fed into the lighting math, resulting in incorrect light rendering on Retina devices, and when the filter primitive region was clipped. Fix by storing absoluteUnclippedSubregion on FilterEffect, which allows us to map lighting points from user space coordinates into the coordinates of the buffer being used for rendering. Also scale the light z coordinate by doing a dummy point mapping in x. Rename members of PointLightSource and SpotLightSource to make it clear which coordinate system they are in. Tests include HiDPI tests. Tests: svg/filters/fePointLight-coordinates-expected.svg svg/filters/fePointLight-coordinates.svg svg/filters/feSpotLight-coordinates-expected.svg svg/filters/feSpotLight-coordinates.svg svg/filters/hidpi/fePointLight-coordinates-expected.svg svg/filters/hidpi/fePointLight-coordinates.svg svg/filters/hidpi/feSpotLight-coordinates-expected.svg svg/filters/hidpi/feSpotLight-coordinates.svg * platform/graphics/FloatPoint3D.h: Make it easy to get and set the X and Y coords as a FloatPoint. (WebCore::FloatPoint3D::xy const): (WebCore::FloatPoint3D::setXY): * platform/graphics/GeometryUtilities.cpp: (WebCore::mapPoint): (WebCore::mapRect): * platform/graphics/GeometryUtilities.h: Helper to make a point between rects. * platform/graphics/filters/DistantLightSource.cpp: (WebCore::DistantLightSource::initPaintingData): * platform/graphics/filters/DistantLightSource.h: * platform/graphics/filters/FELighting.cpp: (WebCore::FELighting::drawLighting): * platform/graphics/filters/FilterEffect.cpp: (WebCore::FilterEffect::mapPointFromUserSpaceToBuffer const): * platform/graphics/filters/FilterEffect.h: (WebCore::FilterEffect::setUnclippedAbsoluteSubregion): * platform/graphics/filters/LightSource.h: * platform/graphics/filters/PointLightSource.cpp: (WebCore::PointLightSource::initPaintingData): (WebCore::PointLightSource::computePixelLightingData const): (WebCore::PointLightSource::setX): (WebCore::PointLightSource::setY): (WebCore::PointLightSource::setZ): * platform/graphics/filters/PointLightSource.h: (WebCore::PointLightSource::position const): (WebCore::PointLightSource::PointLightSource): * platform/graphics/filters/SpotLightSource.cpp: (WebCore::SpotLightSource::initPaintingData): (WebCore::SpotLightSource::computePixelLightingData const): (WebCore::SpotLightSource::setX): (WebCore::SpotLightSource::setY): (WebCore::SpotLightSource::setZ): (WebCore::SpotLightSource::setPointsAtX): (WebCore::SpotLightSource::setPointsAtY): (WebCore::SpotLightSource::setPointsAtZ): * platform/graphics/filters/SpotLightSource.h: (WebCore::SpotLightSource::position const): (WebCore::SpotLightSource::direction const): (WebCore::SpotLightSource::SpotLightSource): * rendering/svg/RenderSVGResourceFilter.cpp: (WebCore::RenderSVGResourceFilter::buildPrimitives const): * rendering/svg/RenderSVGResourceFilterPrimitive.cpp: (WebCore::RenderSVGResourceFilterPrimitive::determineFilterPrimitiveSubregion): LayoutTests: * svg/filters/fePointLight-coordinates-expected.svg: Added. * svg/filters/fePointLight-coordinates.svg: Added. * svg/filters/feSpotLight-coordinates-expected.svg: Added. * svg/filters/feSpotLight-coordinates.svg: Added. * svg/filters/hidpi/fePointLight-coordinates-expected.svg: Added. * svg/filters/hidpi/fePointLight-coordinates.svg: Added. * svg/filters/hidpi/feSpotLight-coordinates-expected.svg: Added. * svg/filters/hidpi/feSpotLight-coordinates.svg: Added. Canonical link: https://commits.webkit.org/197087@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226363 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-03 17:58:05 +00:00
<svg width="500px" height="610px" xmlns="http://www.w3.org/2000/svg">
<defs>
<filter id="filter" filterUnits="objectBoundingBox">
<feFlood/>
<feDiffuseLighting lighting-color="rgb(0, 255, 0)" x="-120" y="85">
<fePointLight x="250" y="200" z="50"/>
</feDiffuseLighting>
<feComponentTransfer>
<feFuncG 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="200" r="85" fill="none" stroke="gray" stroke-width="20"/>
</svg>