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

[LBSE] Implement support for filters #25087

Conversation

shallawa
Copy link
Contributor

@shallawa shallawa commented Feb 26, 2024

2e6697f

[LBSE] Implement support for filters
https://bugs.webkit.org/show_bug.cgi?id=265140
rdar://118834403

Reviewed by Nikolas Zimmermann.

Implement support for filters, based on the new paint server logic. The SVG
<filter> element will be handled as CSS filter with one ReferenceFilterOperation.

In future patches, the geometry of CSSFilter will be similar to the geometry of
the current SVGFilter.

* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/rendering/RenderLayerFilters.cpp:
(WebCore::RenderLayerFilters::beginFilterEffect):
* Source/WebCore/rendering/RenderLayerModelObject.cpp:
(WebCore::RenderLayerModelObject::svgFilterResourceFromStyle const):
* Source/WebCore/rendering/RenderLayerModelObject.h:
* Source/WebCore/rendering/RenderObject.h:
(WebCore::RenderObject::isRenderSVGHiddenContainer const):
(WebCore::RenderObject::isLegacyRenderSVGResourceFilter const):
(WebCore::RenderObject::isRenderSVGResourcePaintServer const):
(WebCore::RenderObject::isLegacyRenderSVGResourceFilterPrimitive const):
(WebCore::RenderObject::isRenderOrLegacyRenderSVGResourceFilterPrimitive const):
* Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp: Copied from Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceFilterPrimitive.h.
(WebCore::RenderSVGResourceFilter::RenderSVGResourceFilter):
(WebCore::RenderSVGResourceFilter::resourceBoundingBox):
(WebCore::RenderSVGResourceFilter::invalidateFilter):
* Source/WebCore/rendering/svg/RenderSVGResourceFilter.h: Copied from Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceFilterPrimitive.h.
* Source/WebCore/rendering/svg/RenderSVGResourceFilterInlines.h: Added.
(WebCore::RenderSVGResourceFilter::filterElement const):
(WebCore::RenderSVGResourceFilter::protectedFilterElement const):
(WebCore::RenderSVGResourceFilter::filterUnits const):
(WebCore::RenderSVGResourceFilter::primitiveUnits const):
* Source/WebCore/rendering/svg/RenderSVGResourceFilterPrimitive.cpp: Copied from Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceFilterPrimitive.h.
(WebCore::RenderSVGResourceFilterPrimitive::RenderSVGResourceFilterPrimitive):
(WebCore::RenderSVGResourceFilterPrimitive::markFilterEffectForRepaint):
(WebCore::RenderSVGResourceFilterPrimitive::markFilterEffectForRebuild):
* Source/WebCore/rendering/svg/RenderSVGResourceFilterPrimitive.h: Copied from Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceFilterPrimitive.h.
* Source/WebCore/rendering/svg/RenderSVGResourcePaintServer.h:
(WebCore::RenderSVGResourcePaintServer::prepareFillOperation):
(WebCore::RenderSVGResourcePaintServer::prepareStrokeOperation):
* Source/WebCore/rendering/svg/SVGBoundingBoxComputation.cpp:
(WebCore::SVGBoundingBoxComputation::adjustBoxForClippingAndEffects const):
* Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp:
(WebCore::writeSVGContainer):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceFilter.cpp:
(WebCore::LegacyRenderSVGResourceFilter::LegacyRenderSVGResourceFilter):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceFilter.h:
(isType):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceFilterPrimitive.cpp:
(WebCore::LegacyRenderSVGResourceFilterPrimitive::LegacyRenderSVGResourceFilterPrimitive):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceFilterPrimitive.h:
* Source/WebCore/rendering/svg/legacy/SVGResourcesCache.cpp:
(WebCore::SVGResourcesCache::clientStyleChanged):
* Source/WebCore/svg/SVGElement.cpp:
(WebCore::isSVGLayerAwareElement):
* Source/WebCore/svg/SVGFEConvolveMatrixElement.cpp:
* Source/WebCore/svg/SVGFEDiffuseLightingElement.cpp:
* Source/WebCore/svg/SVGFEDropShadowElement.cpp:
* Source/WebCore/svg/SVGFEGaussianBlurElement.cpp:
* Source/WebCore/svg/SVGFELightElement.cpp:
(WebCore::SVGFELightElement::svgAttributeChanged):
* Source/WebCore/svg/SVGFEMorphologyElement.cpp:
* Source/WebCore/svg/SVGFESpecularLightingElement.cpp:
* Source/WebCore/svg/SVGFilterElement.cpp:
(WebCore::SVGFilterElement::childrenChanged):
(WebCore::SVGFilterElement::createElementRenderer):
* Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp:
(WebCore::SVGFilterPrimitiveStandardAttributes::primitiveAttributeChanged):
(WebCore::SVGFilterPrimitiveStandardAttributes::primitiveAttributeOnChildChanged):
(WebCore::SVGFilterPrimitiveStandardAttributes::markFilterEffectForRepaint):
(WebCore::SVGFilterPrimitiveStandardAttributes::markFilterEffectForRebuild):
(WebCore::SVGFilterPrimitiveStandardAttributes::createElementRenderer):
(WebCore::SVGFilterPrimitiveStandardAttributes::invalidateFilterPrimitiveParent):
* Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h:

Canonical link: https://commits.webkit.org/280190@main

5195f54

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ§ͺ wpe-wk2 βœ… πŸ§ͺ wincairo-tests
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ§ͺ api-wpe
βœ… πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ mac-wk1 βœ… πŸ›  wpe-cairo
  πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ›  gtk
⏳ πŸ›  vision βœ… πŸ§ͺ mac-AS-debug-wk2 βœ… πŸ§ͺ gtk-wk2
⏳ πŸ›  vision-sim βœ… πŸ§ͺ mac-wk2-stress βœ… πŸ§ͺ api-gtk
βœ… πŸ›  πŸ§ͺ merge ⏳ πŸ§ͺ vision-wk2
βœ… πŸ›  tv
βœ… πŸ›  tv-sim
βœ… πŸ›  watch
βœ… πŸ›  watch-sim

@shallawa shallawa self-assigned this Feb 26, 2024
@shallawa shallawa added the SVG For bugs in the SVG implementation. label Feb 26, 2024
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Feb 26, 2024
@rwlbuis
Copy link
Contributor

rwlbuis commented Feb 26, 2024

I think this fixes the DRT output :
diff --git a/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp b/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp
index 995f6624fd2b..c3f04aeb266a 100644
--- a/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp
+++ b/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp
@@ -527,8 +527,8 @@ void writeSVGResourceContainer(TextStream& ts, const LegacyRenderSVGResourceCont

void writeSVGContainer(TextStream& ts, const LegacyRenderSVGContainer& container, OptionSet behavior)
{

  • // Currently RenderSVGResourceFilterPrimitive has no meaningful output.
  • if (container.isRenderSVGResourceFilterPrimitive())
  • // Currently LeagcyRenderSVGResourceFilterPrimitive has no meaningful output.
  • if (container.isLegacyRenderSVGResourceFilterPrimitive())
    return;

It may be a good idea to do the RenderObject.h renamings and related changes in a separate PR to make it easier to concentrate on the core bits of this PR.

@shallawa shallawa removed the merging-blocked Applied to prevent a change from being merged label Feb 26, 2024
@shallawa shallawa force-pushed the eng/LBSE-Implement-support-for-filters branch from 464cfe5 to 215792b Compare February 26, 2024 19:58
@rwlbuis
Copy link
Contributor

rwlbuis commented Feb 26, 2024

@shallawa just in case you missed it, there is a FIXME for pattern support in SVGBoundingBoxComputation::adjustBoxForClippingAndEffects. Implementing it may fix some of the remaining filter test failures.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Feb 26, 2024
@shallawa shallawa removed the merging-blocked Applied to prevent a change from being merged label Feb 27, 2024
@shallawa shallawa force-pushed the eng/LBSE-Implement-support-for-filters branch from 215792b to 9554d69 Compare February 27, 2024 00:19
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Feb 27, 2024
if (!parent)
return;

if (effect)
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it makes sense to check effect as first thing, otherwise we do the cast for nothing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes makes sense. Will do it.

Copy link
Contributor

@nikolaszimmermann nikolaszimmermann left a comment

Choose a reason for hiding this comment

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

Looks great! Sorry that it took so long to comment, I was on sick leave the last week.
Can you include a TestExpectations update @shallawa? I'd like to see how many tests are fixed :-) If that is also present, I'd r+ it, and I think we should continue in follow-up PRs.

Great job!

Source/WebCore/rendering/CSSFilter.cpp Outdated Show resolved Hide resolved
Source/WebCore/rendering/RenderLayerFilters.cpp Outdated Show resolved Hide resolved
Source/WebCore/rendering/RenderLayerFilters.cpp Outdated Show resolved Hide resolved
Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp Outdated Show resolved Hide resolved
@shallawa shallawa removed the merging-blocked Applied to prevent a change from being merged label Jun 12, 2024
@shallawa shallawa force-pushed the eng/LBSE-Implement-support-for-filters branch from 9554d69 to ecde857 Compare June 12, 2024 00:04
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 12, 2024
@shallawa shallawa removed the merging-blocked Applied to prevent a change from being merged label Jun 12, 2024
@shallawa shallawa force-pushed the eng/LBSE-Implement-support-for-filters branch from ecde857 to 07f6d40 Compare June 12, 2024 00:59
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 12, 2024
@nikolaszimmermann
Copy link
Contributor

Great that you're back on this topic @shallawa - can you update us what changed? I just had a quick glance, and think you only rebased it, right?

A few of the unresolved comments from March still apply.

@shallawa shallawa removed the merging-blocked Applied to prevent a change from being merged label Jun 17, 2024
@shallawa shallawa force-pushed the eng/LBSE-Implement-support-for-filters branch from 07f6d40 to 582de37 Compare June 17, 2024 21:26
@shallawa
Copy link
Contributor Author

Great that you're back on this topic @shallawa - can you update us what changed? I just had a quick glance, and think you only rebased it, right?

Yes. Initially I rebased the the PR

A few of the unresolved comments from March still apply.

Then I addressed all the review comments. Can you please have a second look?

Copy link
Contributor

@nikolaszimmermann nikolaszimmermann left a comment

Choose a reason for hiding this comment

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

r=me - very happy to see the initial fitter support landing!

@rwlbuis
Copy link
Contributor

rwlbuis commented Jun 19, 2024

r=me - very happy to see the initial fitter support landing!

Yes, thanks Said!
Note, I can try to rebaseline LBSE filter results after this PR lands (doing a general one here #29975), unless that was something you were planning to do yourself.

@shallawa shallawa added merge-queue Applied to send a pull request to merge-queue and removed merge-queue Applied to send a pull request to merge-queue labels Jun 19, 2024
@shallawa shallawa force-pushed the eng/LBSE-Implement-support-for-filters branch from 582de37 to 5195f54 Compare June 20, 2024 00:56
@shallawa shallawa added the merge-queue Applied to send a pull request to merge-queue label Jun 20, 2024
@webkit-commit-queue webkit-commit-queue force-pushed the eng/LBSE-Implement-support-for-filters branch from 5195f54 to 6fd0e5c Compare June 20, 2024 05:09
https://bugs.webkit.org/show_bug.cgi?id=265140
rdar://118834403

Reviewed by Nikolas Zimmermann.

Implement support for filters, based on the new paint server logic. The SVG
<filter> element will be handled as CSS filter with one ReferenceFilterOperation.

In future patches, the geometry of CSSFilter will be similar to the geometry of
the current SVGFilter.

* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/rendering/RenderLayerFilters.cpp:
(WebCore::RenderLayerFilters::beginFilterEffect):
* Source/WebCore/rendering/RenderLayerModelObject.cpp:
(WebCore::RenderLayerModelObject::svgFilterResourceFromStyle const):
* Source/WebCore/rendering/RenderLayerModelObject.h:
* Source/WebCore/rendering/RenderObject.h:
(WebCore::RenderObject::isRenderSVGHiddenContainer const):
(WebCore::RenderObject::isLegacyRenderSVGResourceFilter const):
(WebCore::RenderObject::isRenderSVGResourcePaintServer const):
(WebCore::RenderObject::isLegacyRenderSVGResourceFilterPrimitive const):
(WebCore::RenderObject::isRenderOrLegacyRenderSVGResourceFilterPrimitive const):
* Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp: Copied from Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceFilterPrimitive.h.
(WebCore::RenderSVGResourceFilter::RenderSVGResourceFilter):
(WebCore::RenderSVGResourceFilter::resourceBoundingBox):
(WebCore::RenderSVGResourceFilter::invalidateFilter):
* Source/WebCore/rendering/svg/RenderSVGResourceFilter.h: Copied from Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceFilterPrimitive.h.
* Source/WebCore/rendering/svg/RenderSVGResourceFilterInlines.h: Added.
(WebCore::RenderSVGResourceFilter::filterElement const):
(WebCore::RenderSVGResourceFilter::protectedFilterElement const):
(WebCore::RenderSVGResourceFilter::filterUnits const):
(WebCore::RenderSVGResourceFilter::primitiveUnits const):
* Source/WebCore/rendering/svg/RenderSVGResourceFilterPrimitive.cpp: Copied from Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceFilterPrimitive.h.
(WebCore::RenderSVGResourceFilterPrimitive::RenderSVGResourceFilterPrimitive):
(WebCore::RenderSVGResourceFilterPrimitive::markFilterEffectForRepaint):
(WebCore::RenderSVGResourceFilterPrimitive::markFilterEffectForRebuild):
* Source/WebCore/rendering/svg/RenderSVGResourceFilterPrimitive.h: Copied from Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceFilterPrimitive.h.
* Source/WebCore/rendering/svg/RenderSVGResourcePaintServer.h:
(WebCore::RenderSVGResourcePaintServer::prepareFillOperation):
(WebCore::RenderSVGResourcePaintServer::prepareStrokeOperation):
* Source/WebCore/rendering/svg/SVGBoundingBoxComputation.cpp:
(WebCore::SVGBoundingBoxComputation::adjustBoxForClippingAndEffects const):
* Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp:
(WebCore::writeSVGContainer):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceFilter.cpp:
(WebCore::LegacyRenderSVGResourceFilter::LegacyRenderSVGResourceFilter):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceFilter.h:
(isType):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceFilterPrimitive.cpp:
(WebCore::LegacyRenderSVGResourceFilterPrimitive::LegacyRenderSVGResourceFilterPrimitive):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceFilterPrimitive.h:
* Source/WebCore/rendering/svg/legacy/SVGResourcesCache.cpp:
(WebCore::SVGResourcesCache::clientStyleChanged):
* Source/WebCore/svg/SVGElement.cpp:
(WebCore::isSVGLayerAwareElement):
* Source/WebCore/svg/SVGFEConvolveMatrixElement.cpp:
* Source/WebCore/svg/SVGFEDiffuseLightingElement.cpp:
* Source/WebCore/svg/SVGFEDropShadowElement.cpp:
* Source/WebCore/svg/SVGFEGaussianBlurElement.cpp:
* Source/WebCore/svg/SVGFELightElement.cpp:
(WebCore::SVGFELightElement::svgAttributeChanged):
* Source/WebCore/svg/SVGFEMorphologyElement.cpp:
* Source/WebCore/svg/SVGFESpecularLightingElement.cpp:
* Source/WebCore/svg/SVGFilterElement.cpp:
(WebCore::SVGFilterElement::childrenChanged):
(WebCore::SVGFilterElement::createElementRenderer):
* Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp:
(WebCore::SVGFilterPrimitiveStandardAttributes::primitiveAttributeChanged):
(WebCore::SVGFilterPrimitiveStandardAttributes::primitiveAttributeOnChildChanged):
(WebCore::SVGFilterPrimitiveStandardAttributes::markFilterEffectForRepaint):
(WebCore::SVGFilterPrimitiveStandardAttributes::markFilterEffectForRebuild):
(WebCore::SVGFilterPrimitiveStandardAttributes::createElementRenderer):
(WebCore::SVGFilterPrimitiveStandardAttributes::invalidateFilterPrimitiveParent):
* Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h:

Canonical link: https://commits.webkit.org/280190@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/LBSE-Implement-support-for-filters branch from 6fd0e5c to 2e6697f Compare June 20, 2024 05:11
@webkit-commit-queue
Copy link
Collaborator

Committed 280190@main (2e6697f): https://commits.webkit.org/280190@main

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

@webkit-commit-queue webkit-commit-queue merged commit 2e6697f into WebKit:main Jun 20, 2024
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SVG For bugs in the SVG implementation.
Projects
None yet
6 participants