Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[GPU Process] [Filters] Simplify the dynamic update of the SVG filter…
… elements https://bugs.webkit.org/show_bug.cgi?id=232842 rdar://85426197 Reviewed by Simon Fraser. Consider this SVG as an example: <svg> <filter id="blur"> <feGaussianBlur stdDeviation="5"/> </filter> <circle ... filter="url(#blur)"/> <rect ... filter="url(#blur)"/> </svg> The renderers of the <circle> and the <rect> elements ask the renderer of the <filter> element, i.e. RenderSVGResourceFilter to applyResource(). In this function a new SVGFilter is created for each target renderer. A new entry { target_renderer, FilterData } is added to RenderSVGResourceFilter::m_rendererFilterDataMap. While building the SVGFilter, a new FilterEffect is created for every target renderer and an entry { primitive_renderer, effect } is added to SVGFilterBuilder::m_effectRenderer. Suppose 'stdDeviation' of <feGaussianBlur> has been changed, this is the current workflow: SVGFEGaussianBlurElement::svgAttributeChanged() will call SVGFilterPrimitiveStandardAttributes::primitiveAttributeChanged() which will call RenderSVGResourceFilterPrimitive::primitiveAttributeChanged(). The last one will call RenderSVGResourceFilter::primitiveAttributeChanged() and pass itself as an argument. RenderSVGResourceFilter::primitiveAttributeChanged() will loop through all the entries in m_rendererFilterDataMap and get the FilterData. And then it gets the effect given the key primitive renderer from FilterData::SVGFilterBuilder::m_effectRenderer. Having this effect, its setFilterEffectAttribute() will be called. This workflow is cumbersome since it was mainly done this way because the result FilterImage was stored with the FilterEffect. But since the result FilterImage was moved out of the FilterEffect, we do not need to create a new FilterEffect for every target renderer. The same FilterEffect can be shared among all the target renderers. This is the new workflow for dynamically updating the FilterEffect attributes: No need to create a separate FilterEffect for every SVGFilter (or target renderer). A shared FilterEffect can be used instead. This will be SVGFilterPrimitiveStandardAttributes::m_effect. SVGFEGaussianBlurElement::svgAttributeChanged() will call SVGFilterPrimitiveStandardAttributes::primitiveAttributeChanged() which will call SVGFEGaussianBlurElement::setFilterEffectAttribute() if m_effect is not null. setFilterEffectAttribute() will return true if it needs to be repainted. RenderSVGResourceFilterPrimitive::markFilterEffectForRepaint() will be called then. RenderSVGResourceFilterPrimitive::markFilterForInvalidation() will call RenderSVGResourceFilter::markFilterForRepaint() if effect is not null which will clear the result FilterImage of this effect and all other FilterImages which takes the result FilterImage of this effect as an input. If svgAttributeChanged() finds out it needs to rebuild the entire SVGFilter, it will call SVGFilterPrimitiveStandardAttributes::markFilterEffectForRebuild() which will call RenderSVGResourceFilterPrimitive::markFilterEffectForRebuild() and sets SVGFilterPrimitiveStandardAttributes::m_effect to nullptr. RenderSVGResourceFilterPrimitive::markFilterEffectForRebuild() will call RenderSVGResourceFilter::markFilterForRebuild() which will clear RenderSVGResourceFilter::m_rendererFilterDataMap. This will force rebuilding the SVGFilter for all renderers. * Source/WebCore/platform/graphics/filters/FEDropShadow.cpp: (WebCore::FEDropShadow::setStdDeviationX): (WebCore::FEDropShadow::setStdDeviationY): (WebCore::FEDropShadow::setDx): (WebCore::FEDropShadow::setDy): (WebCore::FEDropShadow::setShadowColor): (WebCore::FEDropShadow::setShadowOpacity): * Source/WebCore/platform/graphics/filters/FEDropShadow.h: (WebCore::FEDropShadow::setStdDeviationX): Deleted. (WebCore::FEDropShadow::setStdDeviationY): Deleted. (WebCore::FEDropShadow::setDx): Deleted. (WebCore::FEDropShadow::setDy): Deleted. (WebCore::FEDropShadow::setShadowColor): Deleted. (WebCore::FEDropShadow::setShadowOpacity): Deleted. * Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp: (WebCore::FEGaussianBlur::setStdDeviationX): (WebCore::FEGaussianBlur::setStdDeviationY): (WebCore::FEGaussianBlur::setEdgeMode): * Source/WebCore/platform/graphics/filters/FEGaussianBlur.h: * Source/WebCore/platform/graphics/filters/FEOffset.cpp: (WebCore::FEOffset::setDx): (WebCore::FEOffset::setDy): * Source/WebCore/platform/graphics/filters/FEOffset.h: * Source/WebCore/rendering/CSSFilter.cpp: (WebCore::createReferenceFilter): * Source/WebCore/rendering/svg/RenderSVGResourceContainer.h: * Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp: (WebCore::RenderSVGResourceFilter::applyResource): (WebCore::RenderSVGResourceFilter::markFilterForRepaint): (WebCore::RenderSVGResourceFilter::markFilterForRebuild): (WebCore::RenderSVGResourceFilter::primitiveAttributeChanged): Deleted. * Source/WebCore/rendering/svg/RenderSVGResourceFilter.h: * Source/WebCore/rendering/svg/RenderSVGResourceFilterPrimitive.cpp: (WebCore::RenderSVGResourceFilterPrimitive::styleDidChange): (WebCore::RenderSVGResourceFilterPrimitive::markFilterEffectForRepaint): (WebCore::RenderSVGResourceFilterPrimitive::markFilterEffectForRebuild): * Source/WebCore/rendering/svg/RenderSVGResourceFilterPrimitive.h: * Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp: (WebCore::writeSVGResourceContainer): * Source/WebCore/svg/SVGFEBlendElement.cpp: (WebCore::SVGFEBlendElement::setFilterEffectAttribute): (WebCore::SVGFEBlendElement::createFilterEffect const): (WebCore::SVGFEBlendElement::filterEffect const): Deleted. * Source/WebCore/svg/SVGFEBlendElement.h: * Source/WebCore/svg/SVGFEColorMatrixElement.cpp: (WebCore::SVGFEColorMatrixElement::isInvalidValuesLength const): (WebCore::SVGFEColorMatrixElement::setFilterEffectAttribute): (WebCore::SVGFEColorMatrixElement::svgAttributeChanged): (WebCore::SVGFEColorMatrixElement::createFilterEffect const): (WebCore::SVGFEColorMatrixElement::filterEffect const): Deleted. * Source/WebCore/svg/SVGFEColorMatrixElement.h: * Source/WebCore/svg/SVGFEComponentTransferElement.cpp: (WebCore::SVGFEComponentTransferElement::svgAttributeChanged): (WebCore::SVGFEComponentTransferElement::createFilterEffect const): (WebCore::SVGFEComponentTransferElement::filterEffect const): Deleted. * Source/WebCore/svg/SVGFEComponentTransferElement.h: * Source/WebCore/svg/SVGFECompositeElement.cpp: (WebCore::SVGFECompositeElement::setFilterEffectAttribute): (WebCore::SVGFECompositeElement::svgAttributeChanged): (WebCore::SVGFECompositeElement::createFilterEffect const): (WebCore::SVGFECompositeElement::filterEffect const): Deleted. * Source/WebCore/svg/SVGFECompositeElement.h: * Source/WebCore/svg/SVGFEConvolveMatrixElement.cpp: (WebCore::SVGFEConvolveMatrixElement::setFilterEffectAttribute): (WebCore::SVGFEConvolveMatrixElement::svgAttributeChanged): (WebCore::SVGFEConvolveMatrixElement::createFilterEffect const): (WebCore::SVGFEConvolveMatrixElement::filterEffect const): Deleted. * Source/WebCore/svg/SVGFEConvolveMatrixElement.h: * Source/WebCore/svg/SVGFEDiffuseLightingElement.cpp: (WebCore::SVGFEDiffuseLightingElement::setFilterEffectAttribute): (WebCore::SVGFEDiffuseLightingElement::svgAttributeChanged): (WebCore::SVGFEDiffuseLightingElement::createFilterEffect const): (WebCore::SVGFEDiffuseLightingElement::filterEffect const): Deleted. * Source/WebCore/svg/SVGFEDiffuseLightingElement.h: * Source/WebCore/svg/SVGFEDisplacementMapElement.cpp: (WebCore::SVGFEDisplacementMapElement::setFilterEffectAttribute): (WebCore::SVGFEDisplacementMapElement::svgAttributeChanged): (WebCore::SVGFEDisplacementMapElement::createFilterEffect const): (WebCore::SVGFEDisplacementMapElement::filterEffect const): Deleted. * Source/WebCore/svg/SVGFEDisplacementMapElement.h: * Source/WebCore/svg/SVGFEDropShadowElement.cpp: (WebCore::SVGFEDropShadowElement::svgAttributeChanged): (WebCore::SVGFEDropShadowElement::setFilterEffectAttribute): (WebCore::SVGFEDropShadowElement::createFilterEffect const): (WebCore::SVGFEDropShadowElement::filterEffect const): Deleted. * Source/WebCore/svg/SVGFEDropShadowElement.h: * Source/WebCore/svg/SVGFEFloodElement.cpp: (WebCore::SVGFEFloodElement::setFilterEffectAttribute): (WebCore::SVGFEFloodElement::createFilterEffect const): (WebCore::SVGFEFloodElement::filterEffect const): Deleted. * Source/WebCore/svg/SVGFEFloodElement.h: * Source/WebCore/svg/SVGFEGaussianBlurElement.cpp: (WebCore::SVGFEGaussianBlurElement::svgAttributeChanged): (WebCore::SVGFEGaussianBlurElement::setFilterEffectAttribute): (WebCore::SVGFEGaussianBlurElement::createFilterEffect const): (WebCore::SVGFEGaussianBlurElement::filterEffect const): Deleted. * Source/WebCore/svg/SVGFEGaussianBlurElement.h: * Source/WebCore/svg/SVGFEImageElement.cpp: (WebCore::SVGFEImageElement::svgAttributeChanged): (WebCore::SVGFEImageElement::createFilterEffect const): (WebCore::SVGFEImageElement::filterEffect const): Deleted. * Source/WebCore/svg/SVGFEImageElement.h: * Source/WebCore/svg/SVGFEMergeElement.cpp: (WebCore::SVGFEMergeElement::childrenChanged): (WebCore::SVGFEMergeElement::createFilterEffect const): (WebCore::SVGFEMergeElement::filterEffect const): Deleted. * Source/WebCore/svg/SVGFEMergeElement.h: * Source/WebCore/svg/SVGFEMorphologyElement.cpp: (WebCore::SVGFEMorphologyElement::setFilterEffectAttribute): (WebCore::SVGFEMorphologyElement::svgAttributeChanged): (WebCore::SVGFEMorphologyElement::createFilterEffect const): (WebCore::SVGFEMorphologyElement::filterEffect const): Deleted. * Source/WebCore/svg/SVGFEMorphologyElement.h: * Source/WebCore/svg/SVGFEOffsetElement.cpp: (WebCore::SVGFEOffsetElement::svgAttributeChanged): (WebCore::SVGFEOffsetElement::setFilterEffectAttribute): (WebCore::SVGFEOffsetElement::createFilterEffect const): (WebCore::SVGFEOffsetElement::filterEffect const): Deleted. * Source/WebCore/svg/SVGFEOffsetElement.h: * Source/WebCore/svg/SVGFESpecularLightingElement.cpp: (WebCore::SVGFESpecularLightingElement::setFilterEffectAttribute): (WebCore::SVGFESpecularLightingElement::createFilterEffect const): (WebCore::SVGFESpecularLightingElement::filterEffect const): Deleted. * Source/WebCore/svg/SVGFESpecularLightingElement.h: * Source/WebCore/svg/SVGFETileElement.cpp: (WebCore::SVGFETileElement::createFilterEffect const): (WebCore::SVGFETileElement::filterEffect const): Deleted. * Source/WebCore/svg/SVGFETileElement.h: * Source/WebCore/svg/SVGFETurbulenceElement.cpp: (WebCore::SVGFETurbulenceElement::setFilterEffectAttribute): (WebCore::SVGFETurbulenceElement::createFilterEffect const): (WebCore::SVGFETurbulenceElement::filterEffect const): Deleted. * Source/WebCore/svg/SVGFETurbulenceElement.h: * Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp: (WebCore::SVGFilterPrimitiveStandardAttributes::filterEffect): (WebCore::SVGFilterPrimitiveStandardAttributes::primitiveAttributeChanged): (WebCore::SVGFilterPrimitiveStandardAttributes::markFilterEffectForRebuild): (WebCore::SVGFilterPrimitiveStandardAttributes::setFilterEffectAttribute): Deleted. * Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h: (WebCore::SVGFilterPrimitiveStandardAttributes::setFilterEffectAttribute): (WebCore::SVGFilterPrimitiveStandardAttributes::primitiveAttributeChanged): Deleted. * Source/WebCore/svg/graphics/filters/SVGFilter.cpp: (WebCore::SVGFilter::create): * Source/WebCore/svg/graphics/filters/SVGFilter.h: * Source/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp: (WebCore::SVGFilterBuilder::buildFilterExpression): * Source/WebCore/svg/graphics/filters/SVGFilterBuilder.h: (WebCore::SVGFilterBuilder::effectByRenderer): Deleted. Canonical link: https://commits.webkit.org/251503@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295498 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information