Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Filters] LightSource should keep its points in <length-percentage> units #1462

Conversation

shallawa
Copy link
Contributor

@shallawa shallawa commented Jun 12, 2022

ab59722

[Filters] LightSource should keep its points in <length-percentage > units
https://bugs.webkit.org/show_bug.cgi?id=241535
<rdar://problem/94973414 >

Reviewed by Cameron McCormack.

PointLightSource and SpotLightSource are created with points in user space coordinates.
See SVGFEPointLightElement::lightSource() and SVGFESpotLightElement::lightSource().
But this requires knowing the filter targetBoundingBox and the primitiveUnits at
the LightSource creation time.

When dynamically updating these points through SVGFEDiffuseLightingElement::
setFilterEffectAttribute() or SVGFESpecularLightingElement::setFilterEffectAttribute()
the SVGFilter is not available and these points are stored as <length-percentage >
coordinates. This means if the primitiveUnits is SVG_UNIT_TYPE_OBJECTBOUNDINGBOX,
fractions of the targetBoundingBox will be treated as lengths in user space.

The fix is to store the LightSources points in <length-percentage > units and to
resolve them to user space coordinates in initPaintingData().

* LayoutTests/svg/filters/feDiffuseLighting-feSpotLight-dynamic-update-expected.svg: Added.
* LayoutTests/svg/filters/feDiffuseLighting-feSpotLight-dynamic-update.svg: Added.
* LayoutTests/svg/filters/feSpecularLighting-fePointLight-dynamic-update-expected.svg: Added.
* LayoutTests/svg/filters/feSpecularLighting-fePointLight-dynamic-update.svg: Added.
* Source/WebCore/platform/graphics/filters/Filter.h:
(WebCore::Filter::resolvedPoint3D const):
* Source/WebCore/platform/graphics/filters/PointLightSource.cpp:
(WebCore::PointLightSource::PointLightSource):
(WebCore::PointLightSource::initPaintingData const):
(WebCore::PointLightSource::setX):
(WebCore::PointLightSource::setY):
(WebCore::PointLightSource::setZ):
* Source/WebCore/platform/graphics/filters/PointLightSource.h:
(WebCore::PointLightSource::position const):
(WebCore::PointLightSource::encode const):
* Source/WebCore/platform/graphics/filters/SpotLightSource.cpp:
(WebCore::SpotLightSource::SpotLightSource):
(WebCore::SpotLightSource::initPaintingData const):
(WebCore::SpotLightSource::setX):
(WebCore::SpotLightSource::setY):
(WebCore::SpotLightSource::setZ):
(WebCore::SpotLightSource::setPointsAtX):
(WebCore::SpotLightSource::setPointsAtY):
(WebCore::SpotLightSource::setPointsAtZ):
* Source/WebCore/platform/graphics/filters/SpotLightSource.h:
(WebCore::SpotLightSource::position const):
(WebCore::SpotLightSource::direction const):
(WebCore::SpotLightSource::encode const):
* Source/WebCore/svg/SVGFEBlendElement.cpp:
(WebCore::SVGFEBlendElement::filterEffect const):
* Source/WebCore/svg/SVGFEBlendElement.h:
* Source/WebCore/svg/SVGFEColorMatrixElement.cpp:
(WebCore::SVGFEColorMatrixElement::filterEffect const):
* Source/WebCore/svg/SVGFEColorMatrixElement.h:
* Source/WebCore/svg/SVGFEComponentTransferElement.cpp:
(WebCore::SVGFEComponentTransferElement::filterEffect const):
* Source/WebCore/svg/SVGFEComponentTransferElement.h:
* Source/WebCore/svg/SVGFECompositeElement.cpp:
(WebCore::SVGFECompositeElement::filterEffect const):
* Source/WebCore/svg/SVGFECompositeElement.h:
* Source/WebCore/svg/SVGFEConvolveMatrixElement.cpp:
(WebCore::SVGFEConvolveMatrixElement::filterEffect const):
* Source/WebCore/svg/SVGFEConvolveMatrixElement.h:
* Source/WebCore/svg/SVGFEDiffuseLightingElement.cpp:
(WebCore::SVGFEDiffuseLightingElement::filterEffect const):
* Source/WebCore/svg/SVGFEDiffuseLightingElement.h:
* Source/WebCore/svg/SVGFEDisplacementMapElement.cpp:
(WebCore::SVGFEDisplacementMapElement::filterEffect const):
* Source/WebCore/svg/SVGFEDisplacementMapElement.h:
* Source/WebCore/svg/SVGFEDistantLightElement.cpp:
(WebCore::SVGFEDistantLightElement::lightSource const):
* Source/WebCore/svg/SVGFEDistantLightElement.h:
* Source/WebCore/svg/SVGFEDropShadowElement.cpp:
(WebCore::SVGFEDropShadowElement::filterEffect const):
* Source/WebCore/svg/SVGFEDropShadowElement.h:
* Source/WebCore/svg/SVGFEFloodElement.cpp:
(WebCore::SVGFEFloodElement::filterEffect const):
* Source/WebCore/svg/SVGFEFloodElement.h:
* Source/WebCore/svg/SVGFEGaussianBlurElement.cpp:
(WebCore::SVGFEGaussianBlurElement::filterEffect const):
* Source/WebCore/svg/SVGFEGaussianBlurElement.h:
* Source/WebCore/svg/SVGFEImageElement.cpp:
(WebCore::SVGFEImageElement::filterEffect const):
* Source/WebCore/svg/SVGFEImageElement.h:
* Source/WebCore/svg/SVGFELightElement.h:
* Source/WebCore/svg/SVGFEMergeElement.cpp:
(WebCore::SVGFEMergeElement::filterEffect const):
* Source/WebCore/svg/SVGFEMergeElement.h:
* Source/WebCore/svg/SVGFEMorphologyElement.cpp:
(WebCore::SVGFEMorphologyElement::filterEffect const):
* Source/WebCore/svg/SVGFEMorphologyElement.h:
* Source/WebCore/svg/SVGFEOffsetElement.cpp:
(WebCore::SVGFEOffsetElement::filterEffect const):
* Source/WebCore/svg/SVGFEOffsetElement.h:
* Source/WebCore/svg/SVGFEPointLightElement.cpp:
(WebCore::SVGFEPointLightElement::lightSource const):
* Source/WebCore/svg/SVGFEPointLightElement.h:
* Source/WebCore/svg/SVGFESpecularLightingElement.cpp:
(WebCore::SVGFESpecularLightingElement::filterEffect const):
* Source/WebCore/svg/SVGFESpecularLightingElement.h:
* Source/WebCore/svg/SVGFESpotLightElement.cpp:
(WebCore::SVGFESpotLightElement::lightSource const):
* Source/WebCore/svg/SVGFESpotLightElement.h:
* Source/WebCore/svg/SVGFETileElement.cpp:
(WebCore::SVGFETileElement::filterEffect const):
* Source/WebCore/svg/SVGFETileElement.h:
* Source/WebCore/svg/SVGFETurbulenceElement.cpp:
(WebCore::SVGFETurbulenceElement::filterEffect const):
* Source/WebCore/svg/SVGFETurbulenceElement.h:
* Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h:
* Source/WebCore/svg/graphics/filters/SVGFilter.cpp:
(WebCore::SVGFilter::resolvedPoint3D const):
* Source/WebCore/svg/graphics/filters/SVGFilter.h:
* Source/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp:
(WebCore::SVGFilterBuilder::buildFilterExpression):

Canonical link: https://commits.webkit.org/251486@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295481 268f45cc-cd09-0410-ab3c-d52691b4dbfc

@shallawa shallawa self-assigned this Jun 12, 2022
@shallawa shallawa added Layout and Rendering For bugs with layout and rendering of Web pages. WebKit Nightly Build labels Jun 12, 2022
@shallawa shallawa requested review from heycam and smfr June 12, 2022 07:38
Copy link
Contributor

@heycam heycam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patch looks good, but in the commit message you write:

When dynamically updating these points through SVGFEDiffuseLightingElement::
setFilterEffectAttribute() or SVGFESpecularLightingElement::setFilterEffectAttribute()
the filter is not available and these points are set in logical coordinates. This means these points will have values between -1 and 1 in user space coordinates.

Should "logical coordinates" be "filter primitive region coordinates" or something like that? Not sure "logical coordinates" is a term used in SVG filters.

I know it's just descriptive of the current bug, but regarding ending up with values in the [-1, 1] range in user space, couldn't values greater than that range be stored? It just depends what specific values are assigned to the attributes in the script.

@shallawa shallawa force-pushed the eng/Filters-LightSource-should-keep-its-points-in-logical-units branch from 6ed06ce to ba59aa9 Compare June 13, 2022 03:26
@shallawa shallawa changed the title [Filters] LightSource should keep its points in logical units [Filters] LightSource should keep its points in <length-percentage> units Jun 13, 2022
@shallawa shallawa added the merge-queue Applied to send a pull request to merge-queue label Jun 13, 2022
@webkit-early-warning-system webkit-early-warning-system force-pushed the eng/Filters-LightSource-should-keep-its-points-in-logical-units branch from ba59aa9 to ab59722 Compare June 13, 2022 04:27
@webkit-early-warning-system webkit-early-warning-system merged commit ab59722 into WebKit:main Jun 13, 2022
@webkit-early-warning-system
Copy link
Collaborator

Committed r295481 (251486@main): https://commits.webkit.org/251486@main

Reviewed commits have been landed. Closing PR #1462 and removing active labels.

@webkit-early-warning-system webkit-early-warning-system removed the merge-queue Applied to send a pull request to merge-queue label Jun 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Layout and Rendering For bugs with layout and rendering of Web pages.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants