Diff
Modified: trunk/Source/WebCore/ChangeLog (292511 => 292512)
--- trunk/Source/WebCore/ChangeLog 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/ChangeLog 2022-04-06 22:41:39 UTC (rev 292512)
@@ -1,3 +1,128 @@
+2022-04-06 Said Abou-Hallawa <[email protected]>
+
+ [GPU Process] Make SVGFEImageElement::filterEffect() create an ImageBuffer compatible with the destination GraphicsContext
+ https://bugs.webkit.org/show_bug.cgi?id=236573
+ rdar://89209695
+
+ Reviewed by Simon Fraser.
+
+ Pass a GraphicsContext to CSSFilter::create() and SVGFilter::create().
+ If there is no GraphicsContext available, like the call we make in
+ CSSFilterImageValue::image(), pass a NullGraphicsContext(). This will
+ create a local ImageBuffer. And this is exactly what we want.
+
+ The GraphicsContext will be passed from SVGFilter::buildFilterExpression()
+ to all the overridden filterEffect(). SVGFEImageElement::filterEffect()
+ is the only one that is going to use it. It calls GraphicsContext::
+ createImageBuffer() to create an ImageBuffer for drawing the SVGElement.
+
+ In preparation to remove SVGFilterBuilder:
+
+ -- Pass an SVGFilter instead of SVGFilterBuilder to all the overridden
+ filterEffect() and all the overridden lightSource().
+ -- Make SVGFilterBuilder::calculateFilterOutsets() a static method.
+ -- Remove the members: SVGFilterBuilder::m_tragetBoundingBox and
+ SVGFilterBuilder::m_primitiveUnits since they exist in SVGFilter.
+
+ * css/CSSFilterImageValue.cpp:
+ (WebCore::CSSFilterImageValue::image):
+ * page/FrameView.cpp:
+ (WebCore::FrameView::adjustPageHeightDeprecated):
+ * platform/graphics/NullGraphicsContext.h:
+ * rendering/CSSFilter.cpp:
+ (WebCore::CSSFilter::create):
+ (WebCore::calculateReferenceFilterOutsets):
+ (WebCore::createReferenceFilter):
+ (WebCore::CSSFilter::buildFilterFunctions):
+ * rendering/CSSFilter.h:
+ * rendering/RenderLayerBacking.cpp:
+ (WebCore::RenderLayerBacking::updateEventRegion):
+ * rendering/RenderLayerFilters.cpp:
+ (WebCore::RenderLayerFilters::beginFilterEffect):
+ * rendering/svg/RenderSVGResourceFilter.cpp:
+ (WebCore::RenderSVGResourceFilter::applyResource):
+ * rendering/svg/SVGRenderTreeAsText.cpp:
+ (WebCore::writeSVGResourceContainer):
+ * svg/SVGFEBlendElement.cpp:
+ (WebCore::SVGFEBlendElement::filterEffect const):
+ * svg/SVGFEBlendElement.h:
+ * svg/SVGFEColorMatrixElement.cpp:
+ (WebCore::SVGFEColorMatrixElement::filterEffect const):
+ * svg/SVGFEColorMatrixElement.h:
+ * svg/SVGFEComponentTransferElement.cpp:
+ (WebCore::SVGFEComponentTransferElement::filterEffect const):
+ * svg/SVGFEComponentTransferElement.h:
+ * svg/SVGFECompositeElement.cpp:
+ (WebCore::SVGFECompositeElement::filterEffect const):
+ * svg/SVGFECompositeElement.h:
+ * svg/SVGFEConvolveMatrixElement.cpp:
+ (WebCore::SVGFEConvolveMatrixElement::filterEffect const):
+ * svg/SVGFEConvolveMatrixElement.h:
+ * svg/SVGFEDiffuseLightingElement.cpp:
+ (WebCore::SVGFEDiffuseLightingElement::filterEffect const):
+ * svg/SVGFEDiffuseLightingElement.h:
+ * svg/SVGFEDisplacementMapElement.cpp:
+ (WebCore::SVGFEDisplacementMapElement::filterEffect const):
+ * svg/SVGFEDisplacementMapElement.h:
+ * svg/SVGFEDistantLightElement.cpp:
+ (WebCore::SVGFEDistantLightElement::lightSource const):
+ * svg/SVGFEDistantLightElement.h:
+ * svg/SVGFEDropShadowElement.cpp:
+ (WebCore::SVGFEDropShadowElement::filterEffect const):
+ * svg/SVGFEDropShadowElement.h:
+ * svg/SVGFEFloodElement.cpp:
+ (WebCore::SVGFEFloodElement::filterEffect const):
+ * svg/SVGFEFloodElement.h:
+ * svg/SVGFEGaussianBlurElement.cpp:
+ (WebCore::SVGFEGaussianBlurElement::filterEffect const):
+ * svg/SVGFEGaussianBlurElement.h:
+ * svg/SVGFEImageElement.cpp:
+ (WebCore::SVGFEImageElement::imageBufferForEffect const):
+ (WebCore::SVGFEImageElement::filterEffect const):
+ (WebCore::scaledImageBufferRect): Deleted.
+ (WebCore::clampingScaleForImageBufferSize): Deleted.
+ (WebCore::createImageBuffer): Deleted.
+ * svg/SVGFEImageElement.h:
+ * svg/SVGFELightElement.h:
+ * svg/SVGFEMergeElement.cpp:
+ (WebCore::SVGFEMergeElement::filterEffect const):
+ * svg/SVGFEMergeElement.h:
+ * svg/SVGFEMorphologyElement.cpp:
+ (WebCore::SVGFEMorphologyElement::filterEffect const):
+ * svg/SVGFEMorphologyElement.h:
+ * svg/SVGFEOffsetElement.cpp:
+ (WebCore::SVGFEOffsetElement::filterEffect const):
+ * svg/SVGFEOffsetElement.h:
+ * svg/SVGFEPointLightElement.cpp:
+ (WebCore::SVGFEPointLightElement::lightSource const):
+ * svg/SVGFEPointLightElement.h:
+ * svg/SVGFESpecularLightingElement.cpp:
+ (WebCore::SVGFESpecularLightingElement::filterEffect const):
+ * svg/SVGFESpecularLightingElement.h:
+ * svg/SVGFESpotLightElement.cpp:
+ (WebCore::SVGFESpotLightElement::lightSource const):
+ * svg/SVGFESpotLightElement.h:
+ * svg/SVGFETileElement.cpp:
+ (WebCore::SVGFETileElement::filterEffect const):
+ * svg/SVGFETileElement.h:
+ * svg/SVGFETurbulenceElement.cpp:
+ (WebCore::SVGFETurbulenceElement::filterEffect const):
+ * svg/SVGFETurbulenceElement.h:
+ * svg/SVGFilterElement.cpp:
+ * svg/SVGFilterPrimitiveStandardAttributes.cpp:
+ * svg/SVGFilterPrimitiveStandardAttributes.h:
+ * svg/graphics/filters/SVGFilter.cpp:
+ (WebCore::SVGFilter::create):
+ * svg/graphics/filters/SVGFilter.h:
+ * svg/graphics/filters/SVGFilterBuilder.cpp:
+ (WebCore::SVGFilterBuilder::buildFilterExpression):
+ (WebCore::SVGFilterBuilder::calculateFilterOutsets):
+ (WebCore::SVGFilterBuilder::SVGFilterBuilder): Deleted.
+ * svg/graphics/filters/SVGFilterBuilder.h:
+ (WebCore::SVGFilterBuilder::targetBoundingBox const): Deleted.
+ (WebCore::SVGFilterBuilder::primitiveUnits const): Deleted.
+ (): Deleted.
+
2022-04-06 Simon Fraser <[email protected]>
FilterImage::imageBufferFromPixelBuffer() can trigger accelerated buffers in the web process
Modified: trunk/Source/WebCore/css/CSSFilterImageValue.cpp (292511 => 292512)
--- trunk/Source/WebCore/css/CSSFilterImageValue.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/css/CSSFilterImageValue.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -31,8 +31,8 @@
#include "CSSFilter.h"
#include "CachedImage.h"
#include "CachedResourceLoader.h"
-#include "GraphicsContext.h"
#include "ImageBuffer.h"
+#include "NullGraphicsContext.h"
#include "RenderElement.h"
#include "StyleBuilderState.h"
#include "StyleCachedImage.h"
@@ -122,7 +122,7 @@
auto sourceImageRect = FloatRect { { }, size };
sourceImage->context().drawImage(*image, sourceImageRect);
- auto cssFilter = CSSFilter::create(renderer, m_filterOperations, renderingMode, FloatSize { 1, 1 }, Filter::ClipOperation::Intersect, sourceImageRect);
+ auto cssFilter = CSSFilter::create(renderer, m_filterOperations, renderingMode, FloatSize { 1, 1 }, Filter::ClipOperation::Intersect, sourceImageRect, NullGraphicsContext());
if (!cssFilter)
return &Image::nullImage();
Modified: trunk/Source/WebCore/page/FrameView.cpp (292511 => 292512)
--- trunk/Source/WebCore/page/FrameView.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/page/FrameView.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -4858,7 +4858,7 @@
}
// Use a context with painting disabled.
- NullGraphicsContext context(NullGraphicsContext::PaintInvalidationReasons::None);
+ NullGraphicsContext context;
renderView->setTruncatedAt(static_cast<int>(floorf(oldBottom)));
IntRect dirtyRect(0, static_cast<int>(floorf(oldTop)), renderView->layoutOverflowRect().maxX(), static_cast<int>(ceilf(oldBottom - oldTop)));
renderView->setPrintRect(dirtyRect);
Modified: trunk/Source/WebCore/platform/graphics/NullGraphicsContext.h (292511 => 292512)
--- trunk/Source/WebCore/platform/graphics/NullGraphicsContext.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/platform/graphics/NullGraphicsContext.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -38,6 +38,8 @@
DetectingContentfulPaint
};
+ NullGraphicsContext() = default;
+
NullGraphicsContext(PaintInvalidationReasons reasons)
: m_paintInvalidationReasons(reasons)
{
Modified: trunk/Source/WebCore/rendering/CSSFilter.cpp (292511 => 292512)
--- trunk/Source/WebCore/rendering/CSSFilter.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/rendering/CSSFilter.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -42,7 +42,7 @@
namespace WebCore {
-RefPtr<CSSFilter> CSSFilter::create(RenderElement& renderer, const FilterOperations& operations, RenderingMode renderingMode, const FloatSize& filterScale, ClipOperation clipOperation, const FloatRect& targetBoundingBox)
+RefPtr<CSSFilter> CSSFilter::create(RenderElement& renderer, const FilterOperations& operations, RenderingMode renderingMode, const FloatSize& filterScale, ClipOperation clipOperation, const FloatRect& targetBoundingBox, const GraphicsContext& destinationContext)
{
bool hasFilterThatMovesPixels = operations.hasFilterThatMovesPixels();
bool hasFilterThatShouldBeRestrictedBySecurityOrigin = operations.hasFilterThatShouldBeRestrictedBySecurityOrigin();
@@ -49,7 +49,7 @@
auto filter = adoptRef(*new CSSFilter(renderingMode, filterScale, clipOperation, hasFilterThatMovesPixels, hasFilterThatShouldBeRestrictedBySecurityOrigin));
- if (!filter->buildFilterFunctions(renderer, operations, targetBoundingBox))
+ if (!filter->buildFilterFunctions(renderer, operations, targetBoundingBox, destinationContext))
return nullptr;
if (renderingMode == RenderingMode::Accelerated && !filter->supportsAcceleratedRendering())
@@ -253,11 +253,10 @@
if (!filterElement)
return { };
- SVGFilterBuilder builder(targetBoundingBox, filterElement->primitiveUnits());
- return builder.calculateFilterOutsets(*filterElement);
+ return SVGFilterBuilder::calculateFilterOutsets(*filterElement, targetBoundingBox);
}
-static RefPtr<SVGFilter> createReferenceFilter(CSSFilter& filter, const ReferenceFilterOperation& filterOperation, RenderElement& renderer, const FloatRect& targetBoundingBox)
+static RefPtr<SVGFilter> createReferenceFilter(CSSFilter& filter, const ReferenceFilterOperation& filterOperation, RenderElement& renderer, const FloatRect& targetBoundingBox, const GraphicsContext& destinationContext)
{
auto filterElement = referenceFilterElement(filterOperation, renderer);
if (!filterElement)
@@ -265,11 +264,11 @@
auto filterRegion = SVGLengthContext::resolveRectangle<SVGFilterElement>(filterElement, filterElement->filterUnits(), targetBoundingBox);
- SVGFilterBuilder builder(targetBoundingBox, filterElement->primitiveUnits());
- return SVGFilter::create(*filterElement, builder, filter.renderingMode(), filter.filterScale(), filter.clipOperation(), filterRegion, targetBoundingBox);
+ SVGFilterBuilder builder;
+ return SVGFilter::create(*filterElement, builder, filter.renderingMode(), filter.filterScale(), filter.clipOperation(), filterRegion, targetBoundingBox, destinationContext);
}
-bool CSSFilter::buildFilterFunctions(RenderElement& renderer, const FilterOperations& operations, const FloatRect& targetBoundingBox)
+bool CSSFilter::buildFilterFunctions(RenderElement& renderer, const FilterOperations& operations, const FloatRect& targetBoundingBox, const GraphicsContext& destinationContext)
{
RefPtr<FilterFunction> function;
@@ -320,7 +319,7 @@
break;
case FilterOperation::REFERENCE:
- function = createReferenceFilter(*this, downcast<ReferenceFilterOperation>(*operation), renderer, targetBoundingBox);
+ function = createReferenceFilter(*this, downcast<ReferenceFilterOperation>(*operation), renderer, targetBoundingBox, destinationContext);
break;
default:
Modified: trunk/Source/WebCore/rendering/CSSFilter.h (292511 => 292512)
--- trunk/Source/WebCore/rendering/CSSFilter.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/rendering/CSSFilter.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -31,6 +31,7 @@
namespace WebCore {
class FilterOperations;
+class GraphicsContext;
class RenderElement;
class SourceGraphic;
@@ -37,7 +38,7 @@
class CSSFilter final : public Filter {
WTF_MAKE_FAST_ALLOCATED;
public:
- static RefPtr<CSSFilter> create(RenderElement&, const FilterOperations&, RenderingMode, const FloatSize& filterScale, ClipOperation, const FloatRect& targetBoundingBox);
+ static RefPtr<CSSFilter> create(RenderElement&, const FilterOperations&, RenderingMode, const FloatSize& filterScale, ClipOperation, const FloatRect& targetBoundingBox, const GraphicsContext& destinationContext);
WEBCORE_EXPORT static RefPtr<CSSFilter> create(Vector<Ref<FilterFunction>>&&);
const Vector<Ref<FilterFunction>>& functions() const { return m_functions; }
@@ -56,9 +57,9 @@
private:
CSSFilter(RenderingMode, const FloatSize& filterScale, ClipOperation, bool hasFilterThatMovesPixels, bool hasFilterThatShouldBeRestrictedBySecurityOrigin);
CSSFilter(Vector<Ref<FilterFunction>>&&);
-
- bool buildFilterFunctions(RenderElement&, const FilterOperations&, const FloatRect& targetBoundingBox);
+ bool buildFilterFunctions(RenderElement&, const FilterOperations&, const FloatRect& targetBoundingBox, const GraphicsContext& destinationContext);
+
bool supportsAcceleratedRendering() const final;
WTF::TextStream& externalRepresentation(WTF::TextStream&, FilterRepresentation) const final;
Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (292511 => 292512)
--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -1830,7 +1830,7 @@
};
auto updateEventRegionForLayer = [&](GraphicsLayer& graphicsLayer) {
- NullGraphicsContext nullContext(NullGraphicsContext::PaintInvalidationReasons::None);
+ NullGraphicsContext nullContext;
EventRegion eventRegion;
#if ENABLE(EDITABLE_REGION)
if (renderer().page().shouldBuildEditableRegion())
Modified: trunk/Source/WebCore/rendering/RenderLayerFilters.cpp (292511 => 292512)
--- trunk/Source/WebCore/rendering/RenderLayerFilters.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/rendering/RenderLayerFilters.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -154,7 +154,7 @@
if (!m_filter || m_targetBoundingBox != targetBoundingBox) {
m_targetBoundingBox = targetBoundingBox;
// FIXME: This rebuilds the entire effects chain even if the filter style didn't change.
- m_filter = CSSFilter::create(renderer, renderer.style().filter(), m_renderingMode, m_filterScale, Filter::ClipOperation::Unite, m_targetBoundingBox);
+ m_filter = CSSFilter::create(renderer, renderer.style().filter(), m_renderingMode, m_filterScale, Filter::ClipOperation::Unite, m_targetBoundingBox, context);
}
if (!m_filter)
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp (292511 => 292512)
--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -129,8 +129,8 @@
auto renderingMode = renderer.page().acceleratedFiltersEnabled() ? RenderingMode::Accelerated : RenderingMode::Unaccelerated;
// Create the SVGFilter object.
- filterData->builder = makeUnique<SVGFilterBuilder>(targetBoundingBox, filterElement().primitiveUnits());
- filterData->filter = SVGFilter::create(filterElement(), *filterData->builder, renderingMode, filterScale, Filter::ClipOperation::Intersect, filterData->boundaries, targetBoundingBox);
+ filterData->builder = makeUnique<SVGFilterBuilder>();
+ filterData->filter = SVGFilter::create(filterElement(), *filterData->builder, renderingMode, filterScale, Filter::ClipOperation::Intersect, filterData->boundaries, targetBoundingBox, *context);
if (!filterData->filter) {
m_rendererFilterDataMap.remove(&renderer);
return false;
Modified: trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp (292511 => 292512)
--- trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -477,8 +477,8 @@
// Creating a placeholder filter which is passed to the builder.
FloatRect dummyRect;
FloatSize dummyScale(1, 1);
- SVGFilterBuilder builder(dummyRect);
- auto dummyFilter = SVGFilter::create(filter.filterElement(), builder, RenderingMode::Unaccelerated, dummyScale, Filter::ClipOperation::Intersect, dummyRect, dummyRect);
+ SVGFilterBuilder builder;
+ auto dummyFilter = SVGFilter::create(filter.filterElement(), builder, RenderingMode::Unaccelerated, dummyScale, Filter::ClipOperation::Intersect, dummyRect, dummyRect, NullGraphicsContext());
if (dummyFilter) {
TextStream::IndentScope indentScope(ts);
dummyFilter->externalRepresentation(ts, FilterRepresentation::TestOutput);
Modified: trunk/Source/WebCore/svg/SVGFEBlendElement.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEBlendElement.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEBlendElement.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -97,7 +97,7 @@
SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName);
}
-RefPtr<FilterEffect> SVGFEBlendElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
+RefPtr<FilterEffect> SVGFEBlendElement::filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext&) const
{
return FEBlend::create(mode());
}
Modified: trunk/Source/WebCore/svg/SVGFEBlendElement.h (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEBlendElement.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEBlendElement.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -71,7 +71,7 @@
bool setFilterEffectAttribute(FilterEffect*, const QualifiedName& attrName) override;
Vector<AtomString> filterEffectInputsNames() const override { return { in1(), in2() }; }
- RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
+ RefPtr<FilterEffect> filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext& destinationContext) const override;
PropertyRegistry m_propertyRegistry { *this };
Ref<SVGAnimatedString> m_in1 { SVGAnimatedString::create(this) };
Modified: trunk/Source/WebCore/svg/SVGFEColorMatrixElement.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEColorMatrixElement.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEColorMatrixElement.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -98,7 +98,7 @@
SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName);
}
-RefPtr<FilterEffect> SVGFEColorMatrixElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
+RefPtr<FilterEffect> SVGFEColorMatrixElement::filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext&) const
{
Vector<float> filterValues;
ColorMatrixType filterType = type();
Modified: trunk/Source/WebCore/svg/SVGFEColorMatrixElement.h (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEColorMatrixElement.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEColorMatrixElement.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -87,7 +87,7 @@
bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&) override;
Vector<AtomString> filterEffectInputsNames() const override { return { in1() }; }
- RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
+ RefPtr<FilterEffect> filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext& destinationContext) const override;
PropertyRegistry m_propertyRegistry { *this };
Ref<SVGAnimatedString> m_in1 { SVGAnimatedString::create(this) };
Modified: trunk/Source/WebCore/svg/SVGFEComponentTransferElement.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEComponentTransferElement.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEComponentTransferElement.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -62,7 +62,7 @@
SVGFilterPrimitiveStandardAttributes::parseAttribute(name, value);
}
-RefPtr<FilterEffect> SVGFEComponentTransferElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
+RefPtr<FilterEffect> SVGFEComponentTransferElement::filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext&) const
{
ComponentTransferFunction red;
ComponentTransferFunction green;
Modified: trunk/Source/WebCore/svg/SVGFEComponentTransferElement.h (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEComponentTransferElement.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEComponentTransferElement.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -44,7 +44,7 @@
void parseAttribute(const QualifiedName&, const AtomString&) override;
Vector<AtomString> filterEffectInputsNames() const override { return { in1() }; }
- RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
+ RefPtr<FilterEffect> filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext& destinationContext) const override;
PropertyRegistry m_propertyRegistry { *this };
Ref<SVGAnimatedString> m_in1 { SVGAnimatedString::create(this) };
Modified: trunk/Source/WebCore/svg/SVGFECompositeElement.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFECompositeElement.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFECompositeElement.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -129,7 +129,7 @@
SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName);
}
-RefPtr<FilterEffect> SVGFECompositeElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
+RefPtr<FilterEffect> SVGFECompositeElement::filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext&) const
{
return FEComposite::create(svgOperator(), k1(), k2(), k3(), k4());
}
Modified: trunk/Source/WebCore/svg/SVGFECompositeElement.h (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFECompositeElement.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFECompositeElement.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -110,7 +110,7 @@
bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&) override;
Vector<AtomString> filterEffectInputsNames() const override { return { in1(), in2() }; }
- RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
+ RefPtr<FilterEffect> filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext& destinationContext) const override;
PropertyRegistry m_propertyRegistry { *this };
Ref<SVGAnimatedString> m_in1 { SVGAnimatedString::create(this) };
Modified: trunk/Source/WebCore/svg/SVGFEConvolveMatrixElement.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEConvolveMatrixElement.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEConvolveMatrixElement.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -187,7 +187,7 @@
SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName);
}
-RefPtr<FilterEffect> SVGFEConvolveMatrixElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
+RefPtr<FilterEffect> SVGFEConvolveMatrixElement::filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext&) const
{
int orderXValue = orderX();
int orderYValue = orderY();
Modified: trunk/Source/WebCore/svg/SVGFEConvolveMatrixElement.h (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEConvolveMatrixElement.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEConvolveMatrixElement.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -104,7 +104,7 @@
bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&) override;
Vector<AtomString> filterEffectInputsNames() const override { return { in1() }; }
- RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
+ RefPtr<FilterEffect> filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext& destinationContext) const override;
PropertyRegistry m_propertyRegistry { *this };
Ref<SVGAnimatedString> m_in1 { SVGAnimatedString::create(this) };
Modified: trunk/Source/WebCore/svg/SVGFEDiffuseLightingElement.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEDiffuseLightingElement.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEDiffuseLightingElement.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -148,13 +148,13 @@
primitiveAttributeChanged(attrName);
}
-RefPtr<FilterEffect> SVGFEDiffuseLightingElement::filterEffect(const SVGFilterBuilder& filterBuilder, const FilterEffectVector&) const
+RefPtr<FilterEffect> SVGFEDiffuseLightingElement::filterEffect(const SVGFilter& filter, const FilterEffectVector&, const GraphicsContext&) const
{
RefPtr lightElement = SVGFELightElement::findLightElement(this);
if (!lightElement)
return nullptr;
- auto lightSource = lightElement->lightSource(filterBuilder);
+ auto lightSource = lightElement->lightSource(filter);
RenderObject* renderer = this->renderer();
if (!renderer)
Modified: trunk/Source/WebCore/svg/SVGFEDiffuseLightingElement.h (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEDiffuseLightingElement.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEDiffuseLightingElement.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -59,7 +59,7 @@
bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&) override;
Vector<AtomString> filterEffectInputsNames() const override { return { in1() }; }
- RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
+ RefPtr<FilterEffect> filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext& destinationContext) const override;
PropertyRegistry m_propertyRegistry { *this };
Ref<SVGAnimatedString> m_in1 { SVGAnimatedString::create(this) };
Modified: trunk/Source/WebCore/svg/SVGFEDisplacementMapElement.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEDisplacementMapElement.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEDisplacementMapElement.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -113,7 +113,7 @@
SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName);
}
-RefPtr<FilterEffect> SVGFEDisplacementMapElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
+RefPtr<FilterEffect> SVGFEDisplacementMapElement::filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext&) const
{
return FEDisplacementMap::create(xChannelSelector(), yChannelSelector(), scale());
}
Modified: trunk/Source/WebCore/svg/SVGFEDisplacementMapElement.h (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEDisplacementMapElement.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEDisplacementMapElement.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -92,7 +92,7 @@
bool setFilterEffectAttribute(FilterEffect*, const QualifiedName& attrName) override;
Vector<AtomString> filterEffectInputsNames() const override { return { in1(), in2() }; }
- RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
+ RefPtr<FilterEffect> filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext& destinationContext) const override;
PropertyRegistry m_propertyRegistry { *this };
Ref<SVGAnimatedString> m_in1 { SVGAnimatedString::create(this) };
Modified: trunk/Source/WebCore/svg/SVGFEDistantLightElement.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEDistantLightElement.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEDistantLightElement.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -36,7 +36,7 @@
return adoptRef(*new SVGFEDistantLightElement(tagName, document));
}
-Ref<LightSource> SVGFEDistantLightElement::lightSource(const SVGFilterBuilder&) const
+Ref<LightSource> SVGFEDistantLightElement::lightSource(const SVGFilter&) const
{
return DistantLightSource::create(azimuth(), elevation());
}
Modified: trunk/Source/WebCore/svg/SVGFEDistantLightElement.h (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEDistantLightElement.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEDistantLightElement.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -30,7 +30,7 @@
private:
SVGFEDistantLightElement(const QualifiedName&, Document&);
- Ref<LightSource> lightSource(const SVGFilterBuilder&) const override;
+ Ref<LightSource> lightSource(const SVGFilter&) const override;
};
static_assert(sizeof(SVGFEDistantLightElement) == sizeof(SVGFELightElement));
Modified: trunk/Source/WebCore/svg/SVGFEDropShadowElement.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEDropShadowElement.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEDropShadowElement.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -103,7 +103,7 @@
return FEDropShadow::calculateOutsets(offset, stdDeviation);
}
-RefPtr<FilterEffect> SVGFEDropShadowElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
+RefPtr<FilterEffect> SVGFEDropShadowElement::filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext&) const
{
RenderObject* renderer = this->renderer();
if (!renderer)
Modified: trunk/Source/WebCore/svg/SVGFEDropShadowElement.h (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEDropShadowElement.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEDropShadowElement.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -55,7 +55,7 @@
Vector<AtomString> filterEffectInputsNames() const override { return { in1() }; }
IntOutsets outsets(const FloatRect& targetBoundingBox, SVGUnitTypes::SVGUnitType primitiveUnits) const override;
- RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
+ RefPtr<FilterEffect> filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext& destinationContext) const override;
PropertyRegistry m_propertyRegistry { *this };
Ref<SVGAnimatedString> m_in1 { SVGAnimatedString::create(this) };
Modified: trunk/Source/WebCore/svg/SVGFEFloodElement.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEFloodElement.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEFloodElement.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -59,7 +59,7 @@
return false;
}
-RefPtr<FilterEffect> SVGFEFloodElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
+RefPtr<FilterEffect> SVGFEFloodElement::filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext&) const
{
RenderObject* renderer = this->renderer();
if (!renderer)
Modified: trunk/Source/WebCore/svg/SVGFEFloodElement.h (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEFloodElement.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEFloodElement.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -37,7 +37,7 @@
const SVGPropertyRegistry& propertyRegistry() const final { return m_propertyRegistry; }
bool setFilterEffectAttribute(FilterEffect*, const QualifiedName& attrName) override;
- RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
+ RefPtr<FilterEffect> filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext& destinationContext) const override;
PropertyRegistry m_propertyRegistry { *this };
};
Modified: trunk/Source/WebCore/svg/SVGFEGaussianBlurElement.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEGaussianBlurElement.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEGaussianBlurElement.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -100,7 +100,7 @@
return FEGaussianBlur::calculateOutsets(stdDeviation);
}
-RefPtr<FilterEffect> SVGFEGaussianBlurElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
+RefPtr<FilterEffect> SVGFEGaussianBlurElement::filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext&) const
{
if (stdDeviationX() < 0 || stdDeviationY() < 0)
return nullptr;
Modified: trunk/Source/WebCore/svg/SVGFEGaussianBlurElement.h (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEGaussianBlurElement.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEGaussianBlurElement.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -55,7 +55,7 @@
Vector<AtomString> filterEffectInputsNames() const override { return { in1() }; }
IntOutsets outsets(const FloatRect& targetBoundingBox, SVGUnitTypes::SVGUnitType primitiveUnits) const override;
- RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
+ RefPtr<FilterEffect> filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext& destinationContext) const override;
PropertyRegistry m_propertyRegistry { *this };
Ref<SVGAnimatedString> m_in1 { SVGAnimatedString::create(this) };
Modified: trunk/Source/WebCore/svg/SVGFEImageElement.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEImageElement.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEImageElement.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -178,39 +178,8 @@
RenderSVGResource::markForLayoutAndParentResourceInvalidation(*parentRenderer);
}
-static inline IntRect scaledImageBufferRect(const FloatRect& rect, const FloatSize& scale)
+std::tuple<RefPtr<ImageBuffer>, FloatRect> SVGFEImageElement::imageBufferForEffect(const GraphicsContext& destinationContext) const
{
- auto scaledRect = rect;
- scaledRect.scale(scale);
- return enclosingIntRect(scaledRect);
-}
-
-static inline FloatSize clampingScaleForImageBufferSize(const FloatSize& size)
-{
- FloatSize clampingScale(1, 1);
- ImageBuffer::sizeNeedsClamping(size, clampingScale);
- return clampingScale;
-}
-
-static RefPtr<ImageBuffer> createImageBuffer(const FloatRect& rect, const FloatSize& scale, HostWindow* hostWindow)
-{
- auto scaledRect = scaledImageBufferRect(rect, scale);
- if (scaledRect.isEmpty())
- return nullptr;
-
- auto clampingScale = clampingScaleForImageBufferSize(scaledRect.size());
- auto imageBuffer = ImageBuffer::create(scaledRect.size() * clampingScale, RenderingPurpose::DOM, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8, { }, { hostWindow });
- if (!imageBuffer)
- return nullptr;
-
- imageBuffer->context().scale(clampingScale);
- imageBuffer->context().translate(-scaledRect.location());
- imageBuffer->context().scale(scale);
- return imageBuffer;
-}
-
-std::tuple<RefPtr<ImageBuffer>, FloatRect> SVGFEImageElement::imageBufferForEffect() const
-{
auto target = SVGURIReference::targetElementFromIRIString(href(), treeScope());
if (!is<SVGElement>(target.element))
return { };
@@ -231,8 +200,7 @@
FloatSize scale(absoluteTransform.xScale(), absoluteTransform.yScale());
auto imageRect = renderer->repaintRectInLocalCoordinates();
- // FIXME: Replace this call with GraphicsContext::createImageBuffer() once the destination GraphicsContext is passed to this function.
- auto imageBuffer = createImageBuffer(imageRect, scale, renderer->hostWindow());
+ auto imageBuffer = destinationContext.createScaledImageBuffer(imageRect, scale);
if (!imageBuffer)
return { };
@@ -242,7 +210,7 @@
return { imageBuffer, imageRect };
}
-RefPtr<FilterEffect> SVGFEImageElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
+RefPtr<FilterEffect> SVGFEImageElement::filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext& destinationContext) const
{
if (m_cachedImage) {
auto image = m_cachedImage->imageForRenderer(renderer());
@@ -257,7 +225,7 @@
return FEImage::create({ nativeImage.releaseNonNull() }, imageRect, preserveAspectRatio());
}
- auto [imageBuffer, imageRect] = imageBufferForEffect();
+ auto [imageBuffer, imageRect] = imageBufferForEffect(destinationContext);
if (!imageBuffer)
return nullptr;
Modified: trunk/Source/WebCore/svg/SVGFEImageElement.h (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEImageElement.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEImageElement.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -54,9 +54,9 @@
void didFinishInsertingNode() override;
- std::tuple<RefPtr<ImageBuffer>, FloatRect> imageBufferForEffect() const;
+ std::tuple<RefPtr<ImageBuffer>, FloatRect> imageBufferForEffect(const GraphicsContext& destinationContext) const;
- RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
+ RefPtr<FilterEffect> filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext& destinationContext) const override;
void clearResourceReferences();
void requestImageResource();
Modified: trunk/Source/WebCore/svg/SVGFELightElement.h (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFELightElement.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFELightElement.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -27,12 +27,12 @@
namespace WebCore {
-class SVGFilterBuilder;
+class SVGFilter;
class SVGFELightElement : public SVGElement {
WTF_MAKE_ISO_ALLOCATED(SVGFELightElement);
public:
- virtual Ref<LightSource> lightSource(const SVGFilterBuilder&) const = 0;
+ virtual Ref<LightSource> lightSource(const SVGFilter&) const = 0;
static SVGFELightElement* findLightElement(const SVGElement*);
float azimuth() const { return m_azimuth->currentValue(); }
Modified: trunk/Source/WebCore/svg/SVGFEMergeElement.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEMergeElement.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEMergeElement.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -52,7 +52,7 @@
return inputsNames;
}
-RefPtr<FilterEffect> SVGFEMergeElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector& inputs) const
+RefPtr<FilterEffect> SVGFEMergeElement::filterEffect(const SVGFilter&, const FilterEffectVector& inputs, const GraphicsContext&) const
{
return FEMerge::create(inputs.size());
}
Modified: trunk/Source/WebCore/svg/SVGFEMergeElement.h (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEMergeElement.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEMergeElement.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -37,7 +37,7 @@
const SVGPropertyRegistry& propertyRegistry() const final { return m_propertyRegistry; }
Vector<AtomString> filterEffectInputsNames() const override;
- RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
+ RefPtr<FilterEffect> filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext& destinationContext) const override;
PropertyRegistry m_propertyRegistry { *this };
};
Modified: trunk/Source/WebCore/svg/SVGFEMorphologyElement.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEMorphologyElement.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEMorphologyElement.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -112,7 +112,7 @@
SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName);
}
-RefPtr<FilterEffect> SVGFEMorphologyElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
+RefPtr<FilterEffect> SVGFEMorphologyElement::filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext&) const
{
if (radiusX() < 0 || radiusY() < 0)
return nullptr;
Modified: trunk/Source/WebCore/svg/SVGFEMorphologyElement.h (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEMorphologyElement.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEMorphologyElement.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -82,7 +82,7 @@
bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&) override;
Vector<AtomString> filterEffectInputsNames() const override { return { in1() }; }
- RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
+ RefPtr<FilterEffect> filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext& destinationContext) const override;
PropertyRegistry m_propertyRegistry { *this };
Ref<SVGAnimatedString> m_in1 { SVGAnimatedString::create(this) };
Modified: trunk/Source/WebCore/svg/SVGFEOffsetElement.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEOffsetElement.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEOffsetElement.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -85,7 +85,7 @@
return FEOffset::calculateOutsets(offset);
}
-RefPtr<FilterEffect> SVGFEOffsetElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
+RefPtr<FilterEffect> SVGFEOffsetElement::filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext&) const
{
return FEOffset::create(dx(), dy());
}
Modified: trunk/Source/WebCore/svg/SVGFEOffsetElement.h (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEOffsetElement.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEOffsetElement.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -49,7 +49,7 @@
Vector<AtomString> filterEffectInputsNames() const override { return { in1() }; }
IntOutsets outsets(const FloatRect& targetBoundingBox, SVGUnitTypes::SVGUnitType primitiveUnits) const override;
- RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
+ RefPtr<FilterEffect> filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext& destinationContext) const override;
PropertyRegistry m_propertyRegistry { *this };
Ref<SVGAnimatedString> m_in1 { SVGAnimatedString::create(this) };
Modified: trunk/Source/WebCore/svg/SVGFEPointLightElement.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEPointLightElement.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEPointLightElement.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -24,7 +24,7 @@
#include "GeometryUtilities.h"
#include "ImageBuffer.h"
#include "PointLightSource.h"
-#include "SVGFilterBuilder.h"
+#include "SVGFilter.h"
#include "SVGNames.h"
#include <wtf/MathExtras.h>
@@ -41,11 +41,11 @@
return adoptRef(*new SVGFEPointLightElement(tagName, document));
}
-Ref<LightSource> SVGFEPointLightElement::lightSource(const SVGFilterBuilder& builder) const
+Ref<LightSource> SVGFEPointLightElement::lightSource(const SVGFilter& filter) const
{
FloatPoint3D position;
- if (builder.primitiveUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
- FloatRect referenceBox = builder.targetBoundingBox();
+ if (filter.primitiveUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
+ FloatRect referenceBox = filter.targetBoundingBox();
position.setX(referenceBox.x() + x() * referenceBox.width());
position.setY(referenceBox.y() + y() * referenceBox.height());
Modified: trunk/Source/WebCore/svg/SVGFEPointLightElement.h (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFEPointLightElement.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFEPointLightElement.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -30,7 +30,7 @@
private:
SVGFEPointLightElement(const QualifiedName&, Document&);
- Ref<LightSource> lightSource(const SVGFilterBuilder&) const override;
+ Ref<LightSource> lightSource(const SVGFilter&) const override;
};
static_assert(sizeof(SVGFEPointLightElement) == sizeof(SVGFELightElement));
Modified: trunk/Source/WebCore/svg/SVGFESpecularLightingElement.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFESpecularLightingElement.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFESpecularLightingElement.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -158,13 +158,13 @@
primitiveAttributeChanged(attrName);
}
-RefPtr<FilterEffect> SVGFESpecularLightingElement::filterEffect(const SVGFilterBuilder& filterBuilder, const FilterEffectVector&) const
+RefPtr<FilterEffect> SVGFESpecularLightingElement::filterEffect(const SVGFilter& filter, const FilterEffectVector&, const GraphicsContext&) const
{
RefPtr lightElement = SVGFELightElement::findLightElement(this);
if (!lightElement)
return nullptr;
- auto lightSource = lightElement->lightSource(filterBuilder);
+ auto lightSource = lightElement->lightSource(filter);
RenderObject* renderer = this->renderer();
if (!renderer)
Modified: trunk/Source/WebCore/svg/SVGFESpecularLightingElement.h (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFESpecularLightingElement.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFESpecularLightingElement.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -59,7 +59,7 @@
bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&) override;
Vector<AtomString> filterEffectInputsNames() const override { return { in1() }; }
- RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
+ RefPtr<FilterEffect> filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext& destinationContext) const override;
PropertyRegistry m_propertyRegistry { *this };
Ref<SVGAnimatedString> m_in1 { SVGAnimatedString::create(this) };
Modified: trunk/Source/WebCore/svg/SVGFESpotLightElement.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFESpotLightElement.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFESpotLightElement.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -23,7 +23,7 @@
#include "FilterEffectVector.h"
#include "GeometryUtilities.h"
#include "ImageBuffer.h"
-#include "SVGFilterBuilder.h"
+#include "SVGFilter.h"
#include "SVGNames.h"
#include "SpotLightSource.h"
#include <wtf/MathExtras.h>
@@ -41,13 +41,13 @@
return adoptRef(*new SVGFESpotLightElement(tagName, document));
}
-Ref<LightSource> SVGFESpotLightElement::lightSource(const SVGFilterBuilder& builder) const
+Ref<LightSource> SVGFESpotLightElement::lightSource(const SVGFilter& filter) const
{
FloatPoint3D position;
FloatPoint3D pointsAt;
- if (builder.primitiveUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
- FloatRect referenceBox = builder.targetBoundingBox();
+ if (filter.primitiveUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
+ FloatRect referenceBox = filter.targetBoundingBox();
position.setX(referenceBox.x() + x() * referenceBox.width());
position.setY(referenceBox.y() + y() * referenceBox.height());
Modified: trunk/Source/WebCore/svg/SVGFESpotLightElement.h (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFESpotLightElement.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFESpotLightElement.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -30,7 +30,7 @@
private:
SVGFESpotLightElement(const QualifiedName&, Document&);
- Ref<LightSource> lightSource(const SVGFilterBuilder&) const override;
+ Ref<LightSource> lightSource(const SVGFilter&) const override;
};
static_assert(sizeof(SVGFESpotLightElement) == sizeof(SVGFELightElement));
Modified: trunk/Source/WebCore/svg/SVGFETileElement.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFETileElement.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFETileElement.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -68,7 +68,7 @@
SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName);
}
-RefPtr<FilterEffect> SVGFETileElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
+RefPtr<FilterEffect> SVGFETileElement::filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext&) const
{
return FETile::create();
}
Modified: trunk/Source/WebCore/svg/SVGFETileElement.h (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFETileElement.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFETileElement.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -43,7 +43,7 @@
void svgAttributeChanged(const QualifiedName&) override;
Vector<AtomString> filterEffectInputsNames() const override { return { in1() }; }
- RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
+ RefPtr<FilterEffect> filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext& destinationContext) const override;
PropertyRegistry m_propertyRegistry { *this };
Ref<SVGAnimatedString> m_in1 { SVGAnimatedString::create(this) };
Modified: trunk/Source/WebCore/svg/SVGFETurbulenceElement.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFETurbulenceElement.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFETurbulenceElement.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -117,7 +117,7 @@
SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName);
}
-RefPtr<FilterEffect> SVGFETurbulenceElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
+RefPtr<FilterEffect> SVGFETurbulenceElement::filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext&) const
{
if (baseFrequencyX() < 0 || baseFrequencyY() < 0)
return nullptr;
Modified: trunk/Source/WebCore/svg/SVGFETurbulenceElement.h (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFETurbulenceElement.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFETurbulenceElement.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -119,7 +119,7 @@
void svgAttributeChanged(const QualifiedName&) override;
bool setFilterEffectAttribute(FilterEffect*, const QualifiedName& attrName) override;
- RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
+ RefPtr<FilterEffect> filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext& destinationContext) const override;
PropertyRegistry m_propertyRegistry { *this };
Ref<SVGAnimatedNumber> m_baseFrequencyX { SVGAnimatedNumber::create(this) };
Modified: trunk/Source/WebCore/svg/SVGFilterElement.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFilterElement.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFilterElement.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -28,7 +28,6 @@
#include "RenderSVGResourceFilter.h"
#include "SVGElementInlines.h"
-#include "SVGFilterBuilder.h"
#include "SVGFilterPrimitiveStandardAttributes.h"
#include "SVGNames.h"
#include "SVGParserUtilities.h"
Modified: trunk/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -26,7 +26,6 @@
#include "FilterEffect.h"
#include "RenderSVGResourceFilterPrimitive.h"
#include "SVGElementInlines.h"
-#include "SVGFilterBuilder.h"
#include <wtf/IsoMallocInlines.h>
#include <wtf/NeverDestroyed.h>
Modified: trunk/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h (292511 => 292512)
--- trunk/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -31,7 +31,7 @@
class Filter;
class FilterEffect;
-class SVGFilterBuilder;
+class SVGFilter;
class SVGFilterPrimitiveStandardAttributes : public SVGElement {
WTF_MAKE_ISO_ALLOCATED(SVGFilterPrimitiveStandardAttributes);
@@ -54,7 +54,7 @@
virtual bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&);
virtual Vector<AtomString> filterEffectInputsNames() const { return { }; }
virtual IntOutsets outsets(const FloatRect&, SVGUnitTypes::SVGUnitType) const { return { }; }
- virtual RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const = 0;
+ virtual RefPtr<FilterEffect> filterEffect(const SVGFilter&, const FilterEffectVector&, const GraphicsContext& destinationContext) const = 0;
static void invalidateFilterPrimitiveParent(SVGElement*);
Modified: trunk/Source/WebCore/svg/graphics/filters/SVGFilter.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/graphics/filters/SVGFilter.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/graphics/filters/SVGFilter.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -30,11 +30,11 @@
namespace WebCore {
-RefPtr<SVGFilter> SVGFilter::create(SVGFilterElement& filterElement, SVGFilterBuilder& builder, RenderingMode renderingMode, const FloatSize& filterScale, ClipOperation clipOperation, const FloatRect& filterRegion, const FloatRect& targetBoundingBox)
+RefPtr<SVGFilter> SVGFilter::create(SVGFilterElement& filterElement, SVGFilterBuilder& builder, RenderingMode renderingMode, const FloatSize& filterScale, ClipOperation clipOperation, const FloatRect& filterRegion, const FloatRect& targetBoundingBox, const GraphicsContext& destinationContext)
{
auto filter = adoptRef(*new SVGFilter(renderingMode, filterScale, clipOperation, filterRegion, targetBoundingBox, filterElement.primitiveUnits()));
- auto _expression_ = builder.buildFilterExpression(filterElement);
+ auto _expression_ = builder.buildFilterExpression(filterElement, filter, destinationContext);
if (!_expression_)
return nullptr;
Modified: trunk/Source/WebCore/svg/graphics/filters/SVGFilter.h (292511 => 292512)
--- trunk/Source/WebCore/svg/graphics/filters/SVGFilter.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/graphics/filters/SVGFilter.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -31,12 +31,13 @@
namespace WebCore {
class FilterImage;
+class GraphicsContext;
class SVGFilterBuilder;
class SVGFilterElement;
class SVGFilter final : public Filter {
public:
- static RefPtr<SVGFilter> create(SVGFilterElement&, SVGFilterBuilder&, RenderingMode, const FloatSize& filterScale, ClipOperation, const FloatRect& filterRegion, const FloatRect& targetBoundingBox);
+ static RefPtr<SVGFilter> create(SVGFilterElement&, SVGFilterBuilder&, RenderingMode, const FloatSize& filterScale, ClipOperation, const FloatRect& filterRegion, const FloatRect& targetBoundingBox, const GraphicsContext& destinationContext);
WEBCORE_EXPORT static RefPtr<SVGFilter> create(const FloatRect& targetBoundingBox, SVGUnitTypes::SVGUnitType primitiveUnits, SVGFilterExpression&&);
FloatRect targetBoundingBox() const { return m_targetBoundingBox; }
Modified: trunk/Source/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp (292511 => 292512)
--- trunk/Source/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp 2022-04-06 22:41:39 UTC (rev 292512)
@@ -36,12 +36,6 @@
static constexpr unsigned maxTotalNumberFilterEffects = 100;
static constexpr unsigned maxCountChildNodes = 200;
-SVGFilterBuilder::SVGFilterBuilder(const FloatRect& targetBoundingBox, SVGUnitTypes::SVGUnitType primitiveUnits)
- : m_targetBoundingBox(targetBoundingBox)
- , m_primitiveUnits(primitiveUnits)
-{
-}
-
static OptionSet<FilterEffectGeometry::Flags> effectGeometryFlagsForElement(SVGElement& element)
{
OptionSet<FilterEffectGeometry::Flags> flags;
@@ -123,7 +117,7 @@
return true;
}
-std::optional<SVGFilterExpression> SVGFilterBuilder::buildFilterExpression(SVGFilterElement& filterElement)
+std::optional<SVGFilterExpression> SVGFilterBuilder::buildFilterExpression(SVGFilterElement& filterElement, const SVGFilter& filter, const GraphicsContext& destinationContext)
{
if (filterElement.countChildNodes() > maxCountChildNodes)
return std::nullopt;
@@ -136,12 +130,12 @@
if (!inputs)
return std::nullopt;
- auto effect = effectElement.filterEffect(*this, *inputs);
+ auto effect = effectElement.filterEffect(filter, *inputs, destinationContext);
if (!effect)
return std::nullopt;
if (auto flags = effectGeometryFlagsForElement(effectElement)) {
- auto effectBoundaries = SVGLengthContext::resolveRectangle<SVGFilterPrimitiveStandardAttributes>(&effectElement, m_primitiveUnits, m_targetBoundingBox);
+ auto effectBoundaries = SVGLengthContext::resolveRectangle<SVGFilterPrimitiveStandardAttributes>(&effectElement, filter.primitiveUnits(), filter.targetBoundingBox());
effectGeometryMap.add(*effect, FilterEffectGeometry(effectBoundaries, flags));
}
@@ -193,7 +187,7 @@
return calculateSubGraphOutsets(graph, *graph.lastNode(), stack, targetBoundingBox, primitiveUnits);
}
-IntOutsets SVGFilterBuilder::calculateFilterOutsets(SVGFilterElement& filterElement)
+IntOutsets SVGFilterBuilder::calculateFilterOutsets(SVGFilterElement& filterElement, const FloatRect& targetBoundingBox)
{
if (filterElement.countChildNodes() > maxCountChildNodes)
return { };
@@ -207,7 +201,7 @@
graph.setNodeInputs(effectElement, WTFMove(inputs));
}
- return calculateGraphOutsets(graph, m_targetBoundingBox, m_primitiveUnits);
+ return calculateGraphOutsets(graph, targetBoundingBox, filterElement.primitiveUnits());
}
} // namespace WebCore
Modified: trunk/Source/WebCore/svg/graphics/filters/SVGFilterBuilder.h (292511 => 292512)
--- trunk/Source/WebCore/svg/graphics/filters/SVGFilterBuilder.h 2022-04-06 22:21:41 UTC (rev 292511)
+++ trunk/Source/WebCore/svg/graphics/filters/SVGFilterBuilder.h 2022-04-06 22:41:39 UTC (rev 292512)
@@ -28,27 +28,24 @@
namespace WebCore {
class FilterEffect;
+class GraphicsContext;
class RenderObject;
+class SVGFilter;
class SVGFilterElement;
class SVGFilterBuilder {
WTF_MAKE_FAST_ALLOCATED;
public:
- SVGFilterBuilder(const FloatRect& targetBoundingBox, SVGUnitTypes::SVGUnitType primitiveUnits = SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE);
+ SVGFilterBuilder() = default;
- FloatRect targetBoundingBox() const { return m_targetBoundingBox; }
- SVGUnitTypes::SVGUnitType primitiveUnits() const { return m_primitiveUnits; }
+ std::optional<SVGFilterExpression> buildFilterExpression(SVGFilterElement&, const SVGFilter&, const GraphicsContext& destinationContext);
+ static IntOutsets calculateFilterOutsets(SVGFilterElement&, const FloatRect& targetBoundingBox);
- std::optional<SVGFilterExpression> buildFilterExpression(SVGFilterElement&);
- IntOutsets calculateFilterOutsets(SVGFilterElement&);
-
// Required to change the attributes of a filter during an svgAttributeChanged.
FilterEffect* effectByRenderer(RenderObject* object) { return m_effectRenderer.get(object); }
private:
HashMap<RenderObject*, FilterEffect*> m_effectRenderer;
- FloatRect m_targetBoundingBox;
- SVGUnitTypes::SVGUnitType m_primitiveUnits { SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE };
};
} // namespace WebCore