⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 287892 in webkit


Ignore:
Timestamp:
Jan 11, 2022, 12:30:16 PM (5 years ago)
Author:
Said Abou-Hallawa
Message:

[GPU Process] Remove the dependency from FilterEffect to its inputs
https://bugs.webkit.org/show_bug.cgi?id=232841
rdar://85425930

Reviewed by Darin Adler.

This is the last clean-up in the FilterEffect code. It will make the
FilterEffect objects in the GPUProcess resemble exactly their counterpart
ones in the WebProcess from now on.

For CSSFilter, we do not need to set the input effects because every
FilterFunction is the input of its successor. Passing the previous result
FilterImage to the apply() method of the current FilterFunction is enough
to get the filter applied correctly.

For SVGFilter, we need the filter effect inputs only when building the
SVGFilterExpression. So we can build a HashMap in SVGFilterBuilder which
maps a FilterEffect to its input FilterEffectVector. To make the change
clearer, the SVGFExxxElement classes will implement two methods:

  1. filterEffectInputsNames() which returns the names of the input FilterEffects.
  2. filterEffect() which returns the FilterEffect representing this element.

SVGFilterBuilder::buildFilterEffects() converts the names to FilterEffects.

No need to initialize the SourceGraphic of the referenced SVGFilter with
the FilterEffect of its previous FilterFunction. The referenced SVGFilter
will create its own native SourceGraphic. This SourceGraphic will copy
the input FilterImage to the result FilterImage.

  • platform/graphics/filters/FilterEffect.cpp:

(WebCore::FilterEffect::inputEffect const): Deleted.

  • platform/graphics/filters/FilterEffect.h:

(WebCore::FilterEffect::inputEffects): Deleted.

  • platform/graphics/filters/SourceAlpha.cpp:

(WebCore::SourceAlpha::create):
(WebCore::SourceAlpha::SourceAlpha):

  • platform/graphics/filters/SourceAlpha.h:
  • rendering/CSSFilter.cpp:

(WebCore::createSVGFilter):
(WebCore::CSSFilter::buildFilterFunctions):

  • rendering/svg/RenderSVGResourceFilter.cpp:

(WebCore::RenderSVGResourceFilter::applyResource):

  • rendering/svg/SVGRenderTreeAsText.cpp:

(WebCore::writeSVGResourceContainer):

  • svg/SVGFEBlendElement.cpp:

(WebCore::SVGFEBlendElement::filterEffect const):
(WebCore::SVGFEBlendElement::build const): Deleted.

  • svg/SVGFEBlendElement.h:
  • svg/SVGFEColorMatrixElement.cpp:

(WebCore::SVGFEColorMatrixElement::filterEffect const):
(WebCore::SVGFEColorMatrixElement::build const): Deleted.

  • svg/SVGFEColorMatrixElement.h:
  • svg/SVGFEComponentTransferElement.cpp:

(WebCore::SVGFEComponentTransferElement::filterEffect const):
(WebCore::SVGFEComponentTransferElement::build const): Deleted.

  • svg/SVGFEComponentTransferElement.h:
  • svg/SVGFECompositeElement.cpp:

(WebCore::SVGFECompositeElement::filterEffect const):
(WebCore::SVGFECompositeElement::build const): Deleted.

  • svg/SVGFECompositeElement.h:
  • svg/SVGFEConvolveMatrixElement.cpp:

(WebCore::SVGFEConvolveMatrixElement::filterEffect const):
(WebCore::SVGFEConvolveMatrixElement::build const): Deleted.

  • svg/SVGFEConvolveMatrixElement.h:
  • svg/SVGFEDiffuseLightingElement.cpp:

(WebCore::SVGFEDiffuseLightingElement::filterEffect const):
(WebCore::SVGFEDiffuseLightingElement::build const): Deleted.

  • svg/SVGFEDiffuseLightingElement.h:
  • svg/SVGFEDisplacementMapElement.cpp:

(WebCore::SVGFEDisplacementMapElement::filterEffect const):
(WebCore::SVGFEDisplacementMapElement::build const): Deleted.

  • svg/SVGFEDisplacementMapElement.h:
  • svg/SVGFEDistantLightElement.cpp:

(WebCore::SVGFEDistantLightElement::lightSource const):

  • svg/SVGFEDistantLightElement.h:
  • svg/SVGFEDropShadowElement.cpp:

(WebCore::SVGFEDropShadowElement::filterEffect const):
(WebCore::SVGFEDropShadowElement::build const): Deleted.

  • svg/SVGFEDropShadowElement.h:
  • svg/SVGFEFloodElement.cpp:

(WebCore::SVGFEFloodElement::filterEffect const):
(WebCore::SVGFEFloodElement::build const): Deleted.

  • svg/SVGFEFloodElement.h:
  • svg/SVGFEGaussianBlurElement.cpp:

(WebCore::SVGFEGaussianBlurElement::filterEffect const):
(WebCore::SVGFEGaussianBlurElement::build const): Deleted.

  • svg/SVGFEGaussianBlurElement.h:
  • svg/SVGFEImageElement.cpp:

(WebCore::SVGFEImageElement::filterEffect const):
(WebCore::SVGFEImageElement::build const): Deleted.

  • svg/SVGFEImageElement.h:
  • svg/SVGFELightElement.h:
  • svg/SVGFEMergeElement.cpp:

(WebCore::SVGFEMergeElement::filterEffectInputsNames const):
(WebCore::SVGFEMergeElement::filterEffect const):
(WebCore::SVGFEMergeElement::build const): Deleted.

  • svg/SVGFEMergeElement.h:
  • svg/SVGFEMorphologyElement.cpp:

(WebCore::SVGFEMorphologyElement::filterEffect const):
(WebCore::SVGFEMorphologyElement::build const): Deleted.

  • svg/SVGFEMorphologyElement.h:
  • svg/SVGFEOffsetElement.cpp:

(WebCore::SVGFEOffsetElement::filterEffect const):
(WebCore::SVGFEOffsetElement::build const): Deleted.

  • svg/SVGFEOffsetElement.h:
  • svg/SVGFEPointLightElement.cpp:

(WebCore::SVGFEPointLightElement::lightSource const):

  • svg/SVGFEPointLightElement.h:
  • svg/SVGFESpecularLightingElement.cpp:

(WebCore::SVGFESpecularLightingElement::filterEffect const):
(WebCore::SVGFESpecularLightingElement::build const): Deleted.

  • svg/SVGFESpecularLightingElement.h:
  • svg/SVGFESpotLightElement.cpp:

(WebCore::SVGFESpotLightElement::lightSource const):

  • svg/SVGFESpotLightElement.h:
  • svg/SVGFETileElement.cpp:

(WebCore::SVGFETileElement::filterEffect const):
(WebCore::SVGFETileElement::build const): Deleted.

  • svg/SVGFETileElement.h:
  • svg/SVGFETurbulenceElement.cpp:

(WebCore::SVGFETurbulenceElement::filterEffect const):
(WebCore::SVGFETurbulenceElement::build const): Deleted.

  • svg/SVGFETurbulenceElement.h:
  • svg/SVGFilterPrimitiveStandardAttributes.h:

(WebCore::SVGFilterPrimitiveStandardAttributes::filterEffectInputsNames const):

  • svg/graphics/filters/SVGFilter.cpp:

(WebCore::SVGFilter::create):

  • svg/graphics/filters/SVGFilter.h:
  • svg/graphics/filters/SVGFilterBuilder.cpp:

(WebCore::SVGFilterBuilder::setupBuiltinEffects):
(WebCore::SVGFilterBuilder::buildFilterEffects):
(WebCore::SVGFilterBuilder::sourceGraphic const):
(WebCore::SVGFilterBuilder::sourceAlpha const):
(WebCore::SVGFilterBuilder::addNamedEffect):
(WebCore::SVGFilterBuilder::namedEffect const):
(WebCore::SVGFilterBuilder::namedEffects const):
(WebCore::SVGFilterBuilder::setEffectInputs):
(WebCore::SVGFilterBuilder::buildEffectExpression const):
(WebCore::SVGFilterBuilder::add): Deleted.
(WebCore::SVGFilterBuilder::getEffectById const): Deleted.

  • svg/graphics/filters/SVGFilterBuilder.h:
Location:
trunk/Source/WebCore
Files:
54 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r287889 r287892  
     12022-01-11  Said Abou-Hallawa  <said@apple.com>
     2
     3        [GPU Process] Remove the dependency from FilterEffect to its inputs
     4        https://bugs.webkit.org/show_bug.cgi?id=232841
     5        rdar://85425930
     6
     7        Reviewed by Darin Adler.
     8
     9        This is the last clean-up in the FilterEffect code. It will make the
     10        FilterEffect objects in the GPUProcess resemble exactly their counterpart
     11        ones in the WebProcess from now on.
     12
     13        For CSSFilter, we do not need to set the input effects because every
     14        FilterFunction is the input of its successor. Passing the previous result
     15        FilterImage to the apply() method of the current FilterFunction is enough
     16        to get the filter applied correctly.
     17
     18        For SVGFilter, we need the filter effect inputs only when building the
     19        SVGFilterExpression. So we can build a HashMap in SVGFilterBuilder which
     20        maps a FilterEffect to its input FilterEffectVector. To make the change
     21        clearer, the SVGFExxxElement classes will implement two methods:
     22        1. filterEffectInputsNames() which returns the names of the input FilterEffects.
     23        2. filterEffect() which returns the FilterEffect representing this element.
     24        SVGFilterBuilder::buildFilterEffects() converts the names to FilterEffects.
     25
     26        No need to initialize the SourceGraphic of the referenced SVGFilter with
     27        the FilterEffect of its previous FilterFunction. The referenced SVGFilter
     28        will create its own native SourceGraphic. This SourceGraphic will copy
     29        the input FilterImage to the result FilterImage.
     30
     31        * platform/graphics/filters/FilterEffect.cpp:
     32        (WebCore::FilterEffect::inputEffect const): Deleted.
     33        * platform/graphics/filters/FilterEffect.h:
     34        (WebCore::FilterEffect::inputEffects): Deleted.
     35        * platform/graphics/filters/SourceAlpha.cpp:
     36        (WebCore::SourceAlpha::create):
     37        (WebCore::SourceAlpha::SourceAlpha):
     38        * platform/graphics/filters/SourceAlpha.h:
     39        * rendering/CSSFilter.cpp:
     40        (WebCore::createSVGFilter):
     41        (WebCore::CSSFilter::buildFilterFunctions):
     42        * rendering/svg/RenderSVGResourceFilter.cpp:
     43        (WebCore::RenderSVGResourceFilter::applyResource):
     44        * rendering/svg/SVGRenderTreeAsText.cpp:
     45        (WebCore::writeSVGResourceContainer):
     46        * svg/SVGFEBlendElement.cpp:
     47        (WebCore::SVGFEBlendElement::filterEffect const):
     48        (WebCore::SVGFEBlendElement::build const): Deleted.
     49        * svg/SVGFEBlendElement.h:
     50        * svg/SVGFEColorMatrixElement.cpp:
     51        (WebCore::SVGFEColorMatrixElement::filterEffect const):
     52        (WebCore::SVGFEColorMatrixElement::build const): Deleted.
     53        * svg/SVGFEColorMatrixElement.h:
     54        * svg/SVGFEComponentTransferElement.cpp:
     55        (WebCore::SVGFEComponentTransferElement::filterEffect const):
     56        (WebCore::SVGFEComponentTransferElement::build const): Deleted.
     57        * svg/SVGFEComponentTransferElement.h:
     58        * svg/SVGFECompositeElement.cpp:
     59        (WebCore::SVGFECompositeElement::filterEffect const):
     60        (WebCore::SVGFECompositeElement::build const): Deleted.
     61        * svg/SVGFECompositeElement.h:
     62        * svg/SVGFEConvolveMatrixElement.cpp:
     63        (WebCore::SVGFEConvolveMatrixElement::filterEffect const):
     64        (WebCore::SVGFEConvolveMatrixElement::build const): Deleted.
     65        * svg/SVGFEConvolveMatrixElement.h:
     66        * svg/SVGFEDiffuseLightingElement.cpp:
     67        (WebCore::SVGFEDiffuseLightingElement::filterEffect const):
     68        (WebCore::SVGFEDiffuseLightingElement::build const): Deleted.
     69        * svg/SVGFEDiffuseLightingElement.h:
     70        * svg/SVGFEDisplacementMapElement.cpp:
     71        (WebCore::SVGFEDisplacementMapElement::filterEffect const):
     72        (WebCore::SVGFEDisplacementMapElement::build const): Deleted.
     73        * svg/SVGFEDisplacementMapElement.h:
     74        * svg/SVGFEDistantLightElement.cpp:
     75        (WebCore::SVGFEDistantLightElement::lightSource const):
     76        * svg/SVGFEDistantLightElement.h:
     77        * svg/SVGFEDropShadowElement.cpp:
     78        (WebCore::SVGFEDropShadowElement::filterEffect const):
     79        (WebCore::SVGFEDropShadowElement::build const): Deleted.
     80        * svg/SVGFEDropShadowElement.h:
     81        * svg/SVGFEFloodElement.cpp:
     82        (WebCore::SVGFEFloodElement::filterEffect const):
     83        (WebCore::SVGFEFloodElement::build const): Deleted.
     84        * svg/SVGFEFloodElement.h:
     85        * svg/SVGFEGaussianBlurElement.cpp:
     86        (WebCore::SVGFEGaussianBlurElement::filterEffect const):
     87        (WebCore::SVGFEGaussianBlurElement::build const): Deleted.
     88        * svg/SVGFEGaussianBlurElement.h:
     89        * svg/SVGFEImageElement.cpp:
     90        (WebCore::SVGFEImageElement::filterEffect const):
     91        (WebCore::SVGFEImageElement::build const): Deleted.
     92        * svg/SVGFEImageElement.h:
     93        * svg/SVGFELightElement.h:
     94        * svg/SVGFEMergeElement.cpp:
     95        (WebCore::SVGFEMergeElement::filterEffectInputsNames const):
     96        (WebCore::SVGFEMergeElement::filterEffect const):
     97        (WebCore::SVGFEMergeElement::build const): Deleted.
     98        * svg/SVGFEMergeElement.h:
     99        * svg/SVGFEMorphologyElement.cpp:
     100        (WebCore::SVGFEMorphologyElement::filterEffect const):
     101        (WebCore::SVGFEMorphologyElement::build const): Deleted.
     102        * svg/SVGFEMorphologyElement.h:
     103        * svg/SVGFEOffsetElement.cpp:
     104        (WebCore::SVGFEOffsetElement::filterEffect const):
     105        (WebCore::SVGFEOffsetElement::build const): Deleted.
     106        * svg/SVGFEOffsetElement.h:
     107        * svg/SVGFEPointLightElement.cpp:
     108        (WebCore::SVGFEPointLightElement::lightSource const):
     109        * svg/SVGFEPointLightElement.h:
     110        * svg/SVGFESpecularLightingElement.cpp:
     111        (WebCore::SVGFESpecularLightingElement::filterEffect const):
     112        (WebCore::SVGFESpecularLightingElement::build const): Deleted.
     113        * svg/SVGFESpecularLightingElement.h:
     114        * svg/SVGFESpotLightElement.cpp:
     115        (WebCore::SVGFESpotLightElement::lightSource const):
     116        * svg/SVGFESpotLightElement.h:
     117        * svg/SVGFETileElement.cpp:
     118        (WebCore::SVGFETileElement::filterEffect const):
     119        (WebCore::SVGFETileElement::build const): Deleted.
     120        * svg/SVGFETileElement.h:
     121        * svg/SVGFETurbulenceElement.cpp:
     122        (WebCore::SVGFETurbulenceElement::filterEffect const):
     123        (WebCore::SVGFETurbulenceElement::build const): Deleted.
     124        * svg/SVGFETurbulenceElement.h:
     125        * svg/SVGFilterPrimitiveStandardAttributes.h:
     126        (WebCore::SVGFilterPrimitiveStandardAttributes::filterEffectInputsNames const):
     127        * svg/graphics/filters/SVGFilter.cpp:
     128        (WebCore::SVGFilter::create):
     129        * svg/graphics/filters/SVGFilter.h:
     130        * svg/graphics/filters/SVGFilterBuilder.cpp:
     131        (WebCore::SVGFilterBuilder::setupBuiltinEffects):
     132        (WebCore::SVGFilterBuilder::buildFilterEffects):
     133        (WebCore::SVGFilterBuilder::sourceGraphic const):
     134        (WebCore::SVGFilterBuilder::sourceAlpha const):
     135        (WebCore::SVGFilterBuilder::addNamedEffect):
     136        (WebCore::SVGFilterBuilder::namedEffect const):
     137        (WebCore::SVGFilterBuilder::namedEffects const):
     138        (WebCore::SVGFilterBuilder::setEffectInputs):
     139        (WebCore::SVGFilterBuilder::buildEffectExpression const):
     140        (WebCore::SVGFilterBuilder::add): Deleted.
     141        (WebCore::SVGFilterBuilder::getEffectById const): Deleted.
     142        * svg/graphics/filters/SVGFilterBuilder.h:
     143
    11442022-01-11  Sam Weinig  <weinig@apple.com>
    2145
  • trunk/Source/WebCore/platform/graphics/filters/FilterEffect.cpp

    r287782 r287892  
    150150}
    151151
    152 FilterEffect& FilterEffect::inputEffect(unsigned number) const
    153 {
    154     ASSERT_WITH_SECURITY_IMPLICATION(number < m_inputEffects.size());
    155     return m_inputEffects.at(number);
    156 }
    157 
    158152TextStream& FilterEffect::externalRepresentation(TextStream& ts, FilterRepresentation representation) const
    159153{
  • trunk/Source/WebCore/platform/graphics/filters/FilterEffect.h

    r287782 r287892  
    2424
    2525#include "DestinationColorSpace.h"
    26 #include "FilterEffectVector.h"
    2726#include "FilterFunction.h"
    28 #include "FilterImage.h"
    2927#include "FilterImageVector.h"
    30 #include <wtf/Vector.h>
    3128
    3229namespace WTF {
     
    3936class FilterEffectApplier;
    4037class FilterEffectGeometry;
     38class FilterResults;
    4139
    4240class FilterEffect : public FilterFunction {
     
    4442
    4543public:
    46     FilterImageVector takeImageInputs(FilterImageVector& stack) const;
    47 
    48     FilterEffectVector& inputEffects() { return m_inputEffects; }
    49     FilterEffect& inputEffect(unsigned) const;
    50 
    51     RefPtr<FilterImage> apply(const Filter&, const FilterImageVector& inputs, FilterResults&, const std::optional<FilterEffectGeometry>& = std::nullopt);
    52 
    5344    const DestinationColorSpace& operatingColorSpace() const { return m_operatingColorSpace; }
    5445    virtual void setOperatingColorSpace(const DestinationColorSpace& colorSpace) { m_operatingColorSpace = colorSpace; }
     46
     47    FilterImageVector takeImageInputs(FilterImageVector& stack) const;
     48    RefPtr<FilterImage> apply(const Filter&, const FilterImageVector& inputs, FilterResults&, const std::optional<FilterEffectGeometry>& = std::nullopt);
    5549
    5650    WTF::TextStream& externalRepresentation(WTF::TextStream&, FilterRepresentation) const override;
     
    8175    RefPtr<FilterImage> apply(const Filter&, FilterImage& input, FilterResults&) override;
    8276
    83     FilterEffectVector m_inputEffects;
    84 
    8577    DestinationColorSpace m_operatingColorSpace { DestinationColorSpace::SRGB() };
    8678};
  • trunk/Source/WebCore/platform/graphics/filters/SourceAlpha.cpp

    r286864 r287892  
    11/*
    22 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
    3  * Copyright (C) 2021 Apple Inc.  All rights reserved.
     3 * Copyright (C) 2021-2022 Apple Inc.  All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    2222#include "SourceAlpha.h"
    2323
    24 #include "ImageBuffer.h"
    2524#include "SourceAlphaSoftwareApplier.h"
    2625#include <wtf/text/TextStream.h>
     
    2827namespace WebCore {
    2928
    30 Ref<SourceAlpha> SourceAlpha::create()
     29Ref<SourceAlpha> SourceAlpha::create(const DestinationColorSpace& colorSpace)
    3130{
    32     return adoptRef(*new SourceAlpha());
     31    return adoptRef(*new SourceAlpha(colorSpace));
    3332}
    3433
    35 Ref<SourceAlpha> SourceAlpha::create(FilterEffect& sourceEffect)
    36 {
    37     return adoptRef(*new SourceAlpha(sourceEffect));
    38 }
    39 
    40 SourceAlpha::SourceAlpha()
     34SourceAlpha::SourceAlpha(const DestinationColorSpace& colorSpace)
    4135    : FilterEffect(FilterEffect::Type::SourceAlpha)
    4236{
    43 }
    44 
    45 SourceAlpha::SourceAlpha(FilterEffect& sourceEffect)
    46     : FilterEffect(FilterEffect::Type::SourceAlpha)
    47 {
    48     setOperatingColorSpace(sourceEffect.operatingColorSpace());
    49     inputEffects().append(sourceEffect);
     37    setOperatingColorSpace(colorSpace);
    5038}
    5139
  • trunk/Source/WebCore/platform/graphics/filters/SourceAlpha.h

    r286765 r287892  
    2727class SourceAlpha : public FilterEffect {
    2828public:
    29     WEBCORE_EXPORT static Ref<SourceAlpha> create();
    30     static Ref<SourceAlpha> create(FilterEffect&);
     29    WEBCORE_EXPORT static Ref<SourceAlpha> create(const DestinationColorSpace& = DestinationColorSpace::SRGB());
    3130
    3231    static AtomString effectName() { return FilterEffect::sourceAlphaName(); }
    3332
    3433private:
    35     SourceAlpha();
    36     explicit SourceAlpha(FilterEffect&);
     34    explicit SourceAlpha(const DestinationColorSpace&);
    3735
    3836    std::unique_ptr<FilterEffectApplier> createApplier(const Filter&) const override;
  • trunk/Source/WebCore/rendering/CSSFilter.cpp

    r287782 r287892  
    219219}
    220220
    221 static RefPtr<SVGFilter> createSVGFilter(CSSFilter& filter, const ReferenceFilterOperation& filterOperation, RenderElement& renderer, const FloatRect& targetBoundingBox, FilterEffect& previousEffect)
     221static RefPtr<SVGFilter> createSVGFilter(CSSFilter& filter, const ReferenceFilterOperation& filterOperation, RenderElement& renderer, const FloatRect& targetBoundingBox)
    222222{
    223223    auto& referencedSVGResources = renderer.ensureReferencedSVGResources();
     
    233233
    234234    SVGFilterBuilder builder;
    235     return SVGFilter::create(*filterElement, builder, filter.renderingMode(), filter.filterScale(), filter.clipOperation(), targetBoundingBox, previousEffect);
     235    return SVGFilter::create(*filterElement, builder, filter.renderingMode(), filter.filterScale(), filter.clipOperation(), targetBoundingBox, targetBoundingBox);
    236236}
    237237
     
    241241    m_outsets = { };
    242242
    243     RefPtr<FilterEffect> previousEffect = SourceGraphic::create();
    244243    RefPtr<SVGFilter> filter;
    245244   
     
    293292
    294293        case FilterOperation::REFERENCE:
    295             filter = createSVGFilter(*this, downcast<ReferenceFilterOperation>(*operation), renderer, targetBoundingBox, *previousEffect);
     294            filter = createSVGFilter(*this, downcast<ReferenceFilterOperation>(*operation), renderer, targetBoundingBox);
    296295            effect = nullptr;
    297296            break;
     
    301300        }
    302301
    303         if ((filter || effect) && m_functions.isEmpty()) {
    304             ASSERT(previousEffect->filterType() == FilterEffect::Type::SourceGraphic);
    305             m_functions.append({ *previousEffect });
    306         }
     302        if ((filter || effect) && m_functions.isEmpty())
     303            m_functions.append(SourceGraphic::create());
    307304       
    308305        if (filter) {
     
    310307            effect->setOperatingColorSpace(DestinationColorSpace::SRGB());
    311308            m_functions.append(filter.releaseNonNull());
    312             previousEffect = WTFMove(effect);
    313309            continue;
    314310        }
     
    316312        if (effect) {
    317313            effect->setOperatingColorSpace(DestinationColorSpace::SRGB());
    318             effect->inputEffects() = { previousEffect.releaseNonNull() };
    319             m_functions.append({ *effect });
    320             previousEffect = WTFMove(effect);
     314            m_functions.append(effect.releaseNonNull());
    321315        }
    322316    }
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp

    r287832 r287892  
    130130    // Create the SVGFilter object.
    131131    filterData->builder = makeUnique<SVGFilterBuilder>();
    132     filterData->filter = SVGFilter::create(filterElement(), *filterData->builder, renderingMode, filterScale, filterData->boundaries, targetBoundingBox);
     132    filterData->filter = SVGFilter::create(filterElement(), *filterData->builder, renderingMode, filterScale, Filter::ClipOperation::Intersect, filterData->boundaries, targetBoundingBox);
    133133    if (!filterData->filter) {
    134134        m_rendererFilterDataMap.remove(&renderer);
  • trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp

    r287832 r287892  
    475475        FloatSize dummyScale(1, 1);
    476476        SVGFilterBuilder builder;
    477         auto dummyFilter = SVGFilter::create(filter.filterElement(), builder, RenderingMode::Unaccelerated, dummyScale, dummyRect, dummyRect);
     477        auto dummyFilter = SVGFilter::create(filter.filterElement(), builder, RenderingMode::Unaccelerated, dummyScale, Filter::ClipOperation::Intersect, dummyRect, dummyRect);
    478478        if (dummyFilter) {
    479479            TextStream::IndentScope indentScope(ts);
  • trunk/Source/WebCore/svg/SVGFEBlendElement.cpp

    r286864 r287892  
    33 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
    44 * Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved.
    5  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     5 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    66 *
    77 * This library is free software; you can redistribute it and/or
     
    2525
    2626#include "FEBlend.h"
    27 #include "FilterEffect.h"
    28 #include "SVGFilterBuilder.h"
    2927#include "SVGNames.h"
    3028#include <wtf/IsoMallocInlines.h>
     
    10199}
    102100
    103 RefPtr<FilterEffect> SVGFEBlendElement::build(SVGFilterBuilder& filterBuilder) const
     101RefPtr<FilterEffect> SVGFEBlendElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
    104102{
    105     auto input1 = filterBuilder.getEffectById(in1());
    106     auto input2 = filterBuilder.getEffectById(in2());
    107 
    108     if (!input1 || !input2)
    109         return nullptr;
    110 
    111     auto effect = FEBlend::create(mode());
    112     effect->inputEffects() = { input1.releaseNonNull(), input2.releaseNonNull() };
    113     return effect;
     103    return FEBlend::create(mode());
    114104}
    115105
    116 }
     106} // namespace WebCore
  • trunk/Source/WebCore/svg/SVGFEBlendElement.h

    r285796 r287892  
    33 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
    44 * Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved.
    5  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     5 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    66 *
    77 * This library is free software; you can redistribute it and/or
     
    7070    void svgAttributeChanged(const QualifiedName&) override;
    7171
    72     RefPtr<FilterEffect> build(SVGFilterBuilder&) const override;
    7372    bool setFilterEffectAttribute(FilterEffect*, const QualifiedName& attrName) override;
     73    Vector<AtomString> filterEffectInputsNames() const override { return { in1(), in2() }; }
     74    RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
    7475
    7576    PropertyRegistry m_propertyRegistry { *this };
  • trunk/Source/WebCore/svg/SVGFEColorMatrixElement.cpp

    r286864 r287892  
    22 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
    4  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     4 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    2323#include "SVGFEColorMatrixElement.h"
    2424
    25 #include "FilterEffect.h"
    26 #include "SVGFilterBuilder.h"
     25#include "FEColorMatrix.h"
    2726#include "SVGNames.h"
    2827#include <wtf/IsoMallocInlines.h>
     
    101100}
    102101
    103 RefPtr<FilterEffect> SVGFEColorMatrixElement::build(SVGFilterBuilder& filterBuilder) const
     102RefPtr<FilterEffect> SVGFEColorMatrixElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
    104103{
    105     auto input1 = filterBuilder.getEffectById(in1());
    106 
    107     if (!input1)
    108         return nullptr;
    109 
    110104    Vector<float> filterValues;
    111105    ColorMatrixType filterType = type();
     
    137131            || (filterType == FECOLORMATRIX_TYPE_SATURATE && size != 1))
    138132            return nullptr;
    139        
     133
    140134        filterValues = values();
    141135        filterValues.shrinkToFit();
    142136    }
    143137
    144     auto effect = FEColorMatrix::create(filterType, WTFMove(filterValues));
    145     effect->inputEffects() = { input1.releaseNonNull() };
    146     return effect;
     138    return FEColorMatrix::create(filterType, WTFMove(filterValues));
    147139}
    148140
  • trunk/Source/WebCore/svg/SVGFEColorMatrixElement.h

    r285796 r287892  
    22 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
    4  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     4 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    8787
    8888    bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&) override;
    89     RefPtr<FilterEffect> build(SVGFilterBuilder&) const override;
     89    Vector<AtomString> filterEffectInputsNames() const override { return { in1() }; }
     90    RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
    9091
    9192    PropertyRegistry m_propertyRegistry { *this };
  • trunk/Source/WebCore/svg/SVGFEComponentTransferElement.cpp

    r286864 r287892  
    22 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
    4  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     4 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    2424
    2525#include "ElementIterator.h"
    26 #include "FilterEffect.h"
     26#include "FEComponentTransfer.h"
    2727#include "SVGElementTypeHelpers.h"
    2828#include "SVGFEFuncAElement.h"
     
    3030#include "SVGFEFuncGElement.h"
    3131#include "SVGFEFuncRElement.h"
    32 #include "SVGFilterBuilder.h"
    3332#include "SVGNames.h"
    3433#include <wtf/IsoMallocInlines.h>
     
    6463}
    6564
    66 RefPtr<FilterEffect> SVGFEComponentTransferElement::build(SVGFilterBuilder& filterBuilder) const
     65RefPtr<FilterEffect> SVGFEComponentTransferElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
    6766{
    68     auto input1 = filterBuilder.getEffectById(in1());
    69    
    70     if (!input1)
    71         return nullptr;
    72 
    7367    ComponentTransferFunction red;
    7468    ComponentTransferFunction green;
     
    8781    }
    8882
    89     auto effect = FEComponentTransfer::create(red, green, blue, alpha);
    90     effect->inputEffects() = { input1.releaseNonNull() };
    91     return effect;
     83    return FEComponentTransfer::create(red, green, blue, alpha);
    9284}
    9385
    94 }
     86} // namespace WebCore
  • trunk/Source/WebCore/svg/SVGFEComponentTransferElement.h

    r285796 r287892  
    33 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
    44 * Copyright (C) 2018 Apple Inc. All rights reserved.
    5  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     5 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    66 *
    77 * This library is free software; you can redistribute it and/or
     
    4444    void parseAttribute(const QualifiedName&, const AtomString&) override;
    4545
    46     RefPtr<FilterEffect> build(SVGFilterBuilder&) const override;
     46    Vector<AtomString> filterEffectInputsNames() const override { return { in1() }; }
     47    RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
    4748
    4849    PropertyRegistry m_propertyRegistry { *this };
  • trunk/Source/WebCore/svg/SVGFECompositeElement.cpp

    r286864 r287892  
    22 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
    4  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     4 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    2323#include "SVGFECompositeElement.h"
    2424
    25 #include "FilterEffect.h"
    26 #include "SVGFilterBuilder.h"
     25#include "FEComposite.h"
    2726#include "SVGNames.h"
    2827#include <wtf/IsoMallocInlines.h>
     
    132131}
    133132
    134 RefPtr<FilterEffect> SVGFECompositeElement::build(SVGFilterBuilder& filterBuilder) const
     133RefPtr<FilterEffect> SVGFECompositeElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
    135134{
    136     auto input1 = filterBuilder.getEffectById(in1());
    137     auto input2 = filterBuilder.getEffectById(in2());
    138    
    139     if (!input1 || !input2)
    140         return nullptr;
    141 
    142     auto effect = FEComposite::create(svgOperator(), k1(), k2(), k3(), k4());
    143     effect->inputEffects() = { input1.releaseNonNull(), input2.releaseNonNull() };
    144     return effect;
     135    return FEComposite::create(svgOperator(), k1(), k2(), k3(), k4());
    145136}
    146137
    147 }
     138} // namespace WebCore
  • trunk/Source/WebCore/svg/SVGFECompositeElement.h

    r285796 r287892  
    22 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
    4  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     4 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    110110
    111111    bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&) override;
    112     RefPtr<FilterEffect> build(SVGFilterBuilder&) const override;
     112    Vector<AtomString> filterEffectInputsNames() const override { return { in1(), in2() }; }
     113    RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
    113114
    114115    PropertyRegistry m_propertyRegistry { *this };
  • trunk/Source/WebCore/svg/SVGFEConvolveMatrixElement.cpp

    r286864 r287892  
    11/*
    22 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
    3  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     3 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    2222#include "SVGFEConvolveMatrixElement.h"
    2323
    24 #include "FilterEffect.h"
    25 #include "FloatPoint.h"
    26 #include "IntPoint.h"
    27 #include "IntSize.h"
    28 #include "SVGFilterBuilder.h"
     24#include "FEConvolveMatrix.h"
    2925#include "SVGNames.h"
    3026#include "SVGParserUtilities.h"
     
    192188}
    193189
    194 RefPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilterBuilder& filterBuilder) const
    195 {
    196     auto input1 = filterBuilder.getEffectById(in1());
    197 
    198     if (!input1)
    199         return nullptr;
    200 
     190RefPtr<FilterEffect> SVGFEConvolveMatrixElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
     191{
    201192    int orderXValue = orderX();
    202193    int orderYValue = orderY();
     
    208199    if (orderXValue < 1 || orderYValue < 1)
    209200        return nullptr;
     201
    210202    auto& kernelMatrix = this->kernelMatrix();
    211203    int kernelMatrixSize = kernelMatrix.items().size();
     
    218210    if (hasAttribute(SVGNames::targetXAttr) && (targetXValue < 0 || targetXValue >= orderXValue))
    219211        return nullptr;
     212
    220213    // The spec says the default value is: targetX = floor ( orderX / 2 ))
    221214    if (!hasAttribute(SVGNames::targetXAttr))
     
    223216    if (hasAttribute(SVGNames::targetYAttr) && (targetYValue < 0 || targetYValue >= orderYValue))
    224217        return nullptr;
     218
    225219    // The spec says the default value is: targetY = floor ( orderY / 2 ))
    226220    if (!hasAttribute(SVGNames::targetYAttr))
     
    240234    if (hasAttribute(SVGNames::divisorAttr) && !divisorValue)
    241235        return nullptr;
     236
    242237    if (!hasAttribute(SVGNames::divisorAttr)) {
    243238        for (int i = 0; i < kernelMatrixSize; ++i)
     
    247242    }
    248243
    249     auto effect = FEConvolveMatrix::create(IntSize(orderXValue, orderYValue), divisorValue, bias(), IntPoint(targetXValue, targetYValue), edgeMode(), FloatPoint(kernelUnitLengthXValue, kernelUnitLengthYValue), preserveAlpha(), kernelMatrix);
    250     effect->inputEffects() = { input1.releaseNonNull() };
    251     return effect;
     244    return FEConvolveMatrix::create(IntSize(orderXValue, orderYValue), divisorValue, bias(), IntPoint(targetXValue, targetYValue), edgeMode(), FloatPoint(kernelUnitLengthXValue, kernelUnitLengthYValue), preserveAlpha(), kernelMatrix);
    252245}
    253246
  • trunk/Source/WebCore/svg/SVGFEConvolveMatrixElement.h

    r286152 r287892  
    11/*
    22 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
    3  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     3 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    104104
    105105    bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&) override;
    106     RefPtr<FilterEffect> build(SVGFilterBuilder&) const override;
     106    Vector<AtomString> filterEffectInputsNames() const override { return { in1() }; }
     107    RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
    107108
    108109    PropertyRegistry m_propertyRegistry { *this };
  • trunk/Source/WebCore/svg/SVGFEDiffuseLightingElement.cpp

    r286864 r287892  
    11/*
    22 * Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>
    3  * Copyright (C) 2018 Apple Inc. All rights reserved.
     3 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    2323
    2424#include "FEDiffuseLighting.h"
    25 #include "FilterEffect.h"
    2625#include "RenderStyle.h"
    2726#include "SVGFELightElement.h"
    28 #include "SVGFilterBuilder.h"
    2927#include "SVGNames.h"
    3028#include "SVGParserUtilities.h"
     
    152150}
    153151
    154 RefPtr<FilterEffect> SVGFEDiffuseLightingElement::build(SVGFilterBuilder& filterBuilder) const
     152RefPtr<FilterEffect> SVGFEDiffuseLightingElement::filterEffect(const SVGFilterBuilder& filterBuilder, const FilterEffectVector&) const
    155153{
    156     auto input1 = filterBuilder.getEffectById(in1());
    157 
    158     if (!input1)
    159         return nullptr;
    160 
    161154    RefPtr lightElement = SVGFELightElement::findLightElement(this);
    162155    if (!lightElement)
     
    171164    Color color = renderer->style().colorByApplyingColorFilter(renderer->style().svgStyle().lightingColor());
    172165
    173     auto effect = FEDiffuseLighting::create(color, surfaceScale(), diffuseConstant(), kernelUnitLengthX(), kernelUnitLengthY(), WTFMove(lightSource));
    174     effect->inputEffects() = { input1.releaseNonNull() };
    175     return effect;
     166    return FEDiffuseLighting::create(color, surfaceScale(), diffuseConstant(), kernelUnitLengthX(), kernelUnitLengthY(), WTFMove(lightSource));
    176167}
    177168
    178 }
     169} // namespace WebCore
  • trunk/Source/WebCore/svg/SVGFEDiffuseLightingElement.h

    r285796 r287892  
    33 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
    44 * Copyright (C) 2005 Oliver Hunt <oliver@nerget.com>
    5  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     5 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    66 *
    77 * This library is free software; you can redistribute it and/or
     
    5959
    6060    bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&) override;
    61     RefPtr<FilterEffect> build(SVGFilterBuilder&) const override;
     61    Vector<AtomString> filterEffectInputsNames() const override { return { in1() }; }
     62    RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
    6263
    6364    PropertyRegistry m_propertyRegistry { *this };
  • trunk/Source/WebCore/svg/SVGFEDisplacementMapElement.cpp

    r286864 r287892  
    11/*
    22 * Copyright (C) 2006 Oliver Hunt <oliver@nerget.com>
    3  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     3 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    2222#include "SVGFEDisplacementMapElement.h"
    2323
    24 #include "FilterEffect.h"
    25 #include "SVGFilterBuilder.h"
     24#include "FEDisplacementMap.h"
    2625#include "SVGNames.h"
    2726#include <wtf/IsoMallocInlines.h>
     
    116115}
    117116
    118 RefPtr<FilterEffect> SVGFEDisplacementMapElement::build(SVGFilterBuilder& filterBuilder) const
     117RefPtr<FilterEffect> SVGFEDisplacementMapElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
    119118{
    120     auto input1 = filterBuilder.getEffectById(in1());
    121     auto input2 = filterBuilder.getEffectById(in2());
    122    
    123     if (!input1 || !input2)
    124         return nullptr;
    125 
    126     auto effect = FEDisplacementMap::create(xChannelSelector(), yChannelSelector(), scale());
    127     effect->inputEffects() = { input1.releaseNonNull(), input2.releaseNonNull() };
    128     return effect;
     119    return FEDisplacementMap::create(xChannelSelector(), yChannelSelector(), scale());
    129120}
    130121
    131 }
     122} // namespace WebCore
  • trunk/Source/WebCore/svg/SVGFEDisplacementMapElement.h

    r285796 r287892  
    11/*
    22 * Copyright (C) 2006 Oliver Hunt <oliver@nerget.com>
    3  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     3 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    9292
    9393    bool setFilterEffectAttribute(FilterEffect*, const QualifiedName& attrName) override;
    94     RefPtr<FilterEffect> build(SVGFilterBuilder&) const override;
     94    Vector<AtomString> filterEffectInputsNames() const override { return { in1(), in2() }; }
     95    RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
    9596
    9697    PropertyRegistry m_propertyRegistry { *this };
  • trunk/Source/WebCore/svg/SVGFEDistantLightElement.cpp

    r226373 r287892  
    3737}
    3838
    39 Ref<LightSource> SVGFEDistantLightElement::lightSource(SVGFilterBuilder&) const
     39Ref<LightSource> SVGFEDistantLightElement::lightSource(const SVGFilterBuilder&) const
    4040{
    4141    return DistantLightSource::create(azimuth(), elevation());
  • trunk/Source/WebCore/svg/SVGFEDistantLightElement.h

    r250060 r287892  
    3131    SVGFEDistantLightElement(const QualifiedName&, Document&);
    3232
    33     Ref<LightSource> lightSource(SVGFilterBuilder&) const override;
     33    Ref<LightSource> lightSource(const SVGFilterBuilder&) const override;
    3434};
    3535static_assert(sizeof(SVGFEDistantLightElement) == sizeof(SVGFELightElement));
  • trunk/Source/WebCore/svg/SVGFEDropShadowElement.cpp

    r286864 r287892  
    11/*
    22 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
    3  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     3 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    2323
    2424#include "RenderStyle.h"
    25 #include "SVGFilterBuilder.h"
    2625#include "SVGNames.h"
    2726#include "SVGParserUtilities.h"
     
    9897}
    9998
    100 RefPtr<FilterEffect> SVGFEDropShadowElement::build(SVGFilterBuilder& filterBuilder) const
     99RefPtr<FilterEffect> SVGFEDropShadowElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
    101100{
    102     auto input1 = filterBuilder.getEffectById(in1());
    103     if (!input1)
    104         return nullptr;
    105 
    106101    RenderObject* renderer = this->renderer();
    107102    if (!renderer)
     
    116111    float opacity = svgStyle.floodOpacity();
    117112
    118     auto effect = FEDropShadow::create(stdDeviationX(), stdDeviationY(), dx(), dy(), color, opacity);
    119     effect->inputEffects() = { input1.releaseNonNull() };
    120     return effect;
     113    return FEDropShadow::create(stdDeviationX(), stdDeviationY(), dx(), dy(), color, opacity);
    121114}
    122115
    123 }
     116} // namespace WebCore
  • trunk/Source/WebCore/svg/SVGFEDropShadowElement.h

    r285796 r287892  
    11/*
    22 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
    3  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     3 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    5454    void svgAttributeChanged(const QualifiedName&) override;
    5555
    56     RefPtr<FilterEffect> build(SVGFilterBuilder&) const override;
     56    Vector<AtomString> filterEffectInputsNames() const override { return { in1() }; }
     57    RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
    5758
    5859    PropertyRegistry m_propertyRegistry { *this };
  • trunk/Source/WebCore/svg/SVGFEFloodElement.cpp

    r285796 r287892  
    22 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005, 2007, 2008 Rob Buis <buis@kde.org>
     4 * Copyright (C) 2022 Apple Inc. All rights reserved.
    45 *
    56 * This library is free software; you can redistribute it and/or
     
    5960}
    6061
    61 RefPtr<FilterEffect> SVGFEFloodElement::build(SVGFilterBuilder&) const
     62RefPtr<FilterEffect> SVGFEFloodElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
    6263{
    6364    RenderObject* renderer = this->renderer();
    6465    if (!renderer)
    6566        return nullptr;
    66    
     67
    6768    const SVGRenderStyle& svgStyle = renderer->style().svgStyle();
    6869
     
    7374}
    7475
    75 }
     76} // namespace WebCore
  • trunk/Source/WebCore/svg/SVGFEFloodElement.h

    r285796 r287892  
    22 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005, 2008 Rob Buis <buis@kde.org>
     4 * Copyright (C) 2022 Apple Inc. All rights reserved.
    45 *
    56 * This library is free software; you can redistribute it and/or
     
    3738
    3839    bool setFilterEffectAttribute(FilterEffect*, const QualifiedName& attrName) override;
    39     RefPtr<FilterEffect> build(SVGFilterBuilder&) const override;
     40    RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
    4041
    4142    PropertyRegistry m_propertyRegistry { *this };
  • trunk/Source/WebCore/svg/SVGFEGaussianBlurElement.cpp

    r286864 r287892  
    22 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
    4  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     4 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    2323#include "SVGFEGaussianBlurElement.h"
    2424
    25 #include "FilterEffect.h"
    26 #include "SVGFilterBuilder.h"
     25#include "FEGaussianBlur.h"
    2726#include "SVGNames.h"
    2827#include "SVGParserUtilities.h"
     
    9695}
    9796
    98 RefPtr<FilterEffect> SVGFEGaussianBlurElement::build(SVGFilterBuilder& filterBuilder) const
     97RefPtr<FilterEffect> SVGFEGaussianBlurElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
    9998{
    100     auto input1 = filterBuilder.getEffectById(in1());
    101     if (!input1)
    102         return nullptr;
    103 
    10499    if (stdDeviationX() < 0 || stdDeviationY() < 0)
    105100        return nullptr;
    106101
    107     auto effect = FEGaussianBlur::create(stdDeviationX(), stdDeviationY(), edgeMode());
    108     effect->inputEffects() = { input1.releaseNonNull() };
    109     return effect;
     102    return FEGaussianBlur::create(stdDeviationX(), stdDeviationY(), edgeMode());
    110103}
    111104
    112 }
     105} // namespace WebCore
  • trunk/Source/WebCore/svg/SVGFEGaussianBlurElement.h

    r286152 r287892  
    22 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
    4  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     4 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    5454    void svgAttributeChanged(const QualifiedName&) override;
    5555
    56     RefPtr<FilterEffect> build(SVGFilterBuilder&) const override;
     56    Vector<AtomString> filterEffectInputsNames() const override { return { in1() }; }
     57    RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
    5758
    5859    PropertyRegistry m_propertyRegistry { *this };
  • trunk/Source/WebCore/svg/SVGFEImageElement.cpp

    r285796 r287892  
    33 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
    44 * Copyright (C) 2010 Dirk Schulze <krit@webkit.org>
    5  * Copyright (C) 2018-2021 Apple Inc. All rights reserved.
     5 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    66 *
    77 * This library is free software; you can redistribute it and/or
     
    209209}
    210210
    211 RefPtr<FilterEffect> SVGFEImageElement::build(SVGFilterBuilder&) const
     211RefPtr<FilterEffect> SVGFEImageElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
    212212{
    213213    if (m_cachedImage)
     
    228228}
    229229
    230 }
     230} // namespace WebCore
  • trunk/Source/WebCore/svg/SVGFEImageElement.h

    r285796 r287892  
    22 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
    4  * Copyright (C) 2018-2021 Apple Inc. All rights reserved.
     4 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    5858    std::tuple<RefPtr<ImageBuffer>, FloatRect> imageBufferForEffect() const;
    5959
    60     RefPtr<FilterEffect> build(SVGFilterBuilder&) const override;
     60    RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
    6161
    6262    void clearResourceReferences();
  • trunk/Source/WebCore/svg/SVGFELightElement.h

    r246490 r287892  
    3333    WTF_MAKE_ISO_ALLOCATED(SVGFELightElement);
    3434public:
    35     virtual Ref<LightSource> lightSource(SVGFilterBuilder&) const = 0;
     35    virtual Ref<LightSource> lightSource(const SVGFilterBuilder&) const = 0;
    3636    static SVGFELightElement* findLightElement(const SVGElement*);
    3737
  • trunk/Source/WebCore/svg/SVGFEMergeElement.cpp

    r286864 r287892  
    22 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
     4 * Copyright (C) 2022 Apple Inc. All rights reserved.
    45 *
    56 * This library is free software; you can redistribute it and/or
     
    2425#include "ElementIterator.h"
    2526#include "FEMerge.h"
    26 #include "FilterEffect.h"
    2727#include "SVGElementTypeHelpers.h"
    2828#include "SVGFEMergeNodeElement.h"
    29 #include "SVGFilterBuilder.h"
    3029#include "SVGNames.h"
    3130#include <wtf/IsoMallocInlines.h>
     
    4645}
    4746
    48 RefPtr<FilterEffect> SVGFEMergeElement::build(SVGFilterBuilder& filterBuilder) const
     47Vector<AtomString> SVGFEMergeElement::filterEffectInputsNames() const
    4948{
    50     FilterEffectVector mergeInputs;
    51 
    52     for (auto& mergeNode : childrenOfType<SVGFEMergeNodeElement>(*this)) {
    53         auto mergeEffect = filterBuilder.getEffectById(mergeNode.in1());
    54         if (!mergeEffect)
    55             return nullptr;
    56         mergeInputs.append(mergeEffect.releaseNonNull());
    57     }
    58 
    59     mergeInputs.shrinkToFit();
    60 
    61     if (mergeInputs.isEmpty())
    62         return nullptr;
    63 
    64     auto effect = FEMerge::create(mergeInputs.size());
    65     effect->inputEffects() = WTFMove(mergeInputs);
    66     return effect;
     49    Vector<AtomString> inputsNames;
     50    for (auto& mergeNode : childrenOfType<SVGFEMergeNodeElement>(*this))
     51        inputsNames.append(mergeNode.in1());
     52    return inputsNames;
    6753}
    6854
     55RefPtr<FilterEffect> SVGFEMergeElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector& inputs) const
     56{
     57    return FEMerge::create(inputs.size());
    6958}
     59
     60} // namespace WebCore
  • trunk/Source/WebCore/svg/SVGFEMergeElement.h

    r285796 r287892  
    22 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
     4 * Copyright (C) 2022 Apple Inc. All rights reserved.
    45 *
    56 * This library is free software; you can redistribute it and/or
     
    3637    const SVGPropertyRegistry& propertyRegistry() const final { return m_propertyRegistry; }
    3738
    38     RefPtr<FilterEffect> build(SVGFilterBuilder&) const override;
     39    Vector<AtomString> filterEffectInputsNames() const override;
     40    RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
    3941
    4042    PropertyRegistry m_propertyRegistry { *this };
  • trunk/Source/WebCore/svg/SVGFEMorphologyElement.cpp

    r286864 r287892  
    11/*
    22 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
    3  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     3 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    2222#include "SVGFEMorphologyElement.h"
    2323
    24 #include "FilterEffect.h"
    25 #include "SVGFilterBuilder.h"
     24#include "FEMorphology.h"
    2625#include "SVGNames.h"
    2726#include "SVGParserUtilities.h"
     
    115114}
    116115
    117 RefPtr<FilterEffect> SVGFEMorphologyElement::build(SVGFilterBuilder& filterBuilder) const
     116RefPtr<FilterEffect> SVGFEMorphologyElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
    118117{
    119     auto input1 = filterBuilder.getEffectById(in1());
    120     if (!input1)
     118    if (radiusX() < 0 || radiusY() < 0)
    121119        return nullptr;
    122120
    123     float xRadius = radiusX();
    124     float yRadius = radiusY();
    125     if (xRadius < 0 || yRadius < 0)
    126         return nullptr;
    127 
    128     auto effect = FEMorphology::create(svgOperator(), xRadius, yRadius);
    129     effect->inputEffects() = { input1.releaseNonNull() };
    130     return effect;
     121    return FEMorphology::create(svgOperator(), radiusX(), radiusY());
    131122}
    132123
  • trunk/Source/WebCore/svg/SVGFEMorphologyElement.h

    r286152 r287892  
    11/*
    22 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
    3  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     3 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    8282
    8383    bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&) override;
    84     RefPtr<FilterEffect> build(SVGFilterBuilder&) const override;
     84    Vector<AtomString> filterEffectInputsNames() const override { return { in1() }; }
     85    RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
    8586
    8687    PropertyRegistry m_propertyRegistry { *this };
  • trunk/Source/WebCore/svg/SVGFEOffsetElement.cpp

    r286864 r287892  
    22 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
    4  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     4 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    2424
    2525#include "FEOffset.h"
    26 #include "FilterEffect.h"
    27 #include "SVGFilterBuilder.h"
    2826#include "SVGNames.h"
    2927#include <wtf/IsoMallocInlines.h>
     
    8280}
    8381
    84 RefPtr<FilterEffect> SVGFEOffsetElement::build(SVGFilterBuilder& filterBuilder) const
     82RefPtr<FilterEffect> SVGFEOffsetElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
    8583{
    86     auto input1 = filterBuilder.getEffectById(in1());
    87     if (!input1)
    88         return nullptr;
    89 
    90     auto effect = FEOffset::create(dx(), dy());
    91     effect->inputEffects() = { input1.releaseNonNull() };
    92     return effect;
     84    return FEOffset::create(dx(), dy());
    9385}
    9486
    95 }
     87} // namespace WebCore
  • trunk/Source/WebCore/svg/SVGFEOffsetElement.h

    r285796 r287892  
    22 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
    4  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     4 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    4848    void svgAttributeChanged(const QualifiedName&) override;
    4949
    50     RefPtr<FilterEffect> build(SVGFilterBuilder&) const override;
     50    Vector<AtomString> filterEffectInputsNames() const override { return { in1() }; }
     51    RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
    5152
    5253    PropertyRegistry m_propertyRegistry { *this };
  • trunk/Source/WebCore/svg/SVGFEPointLightElement.cpp

    r286837 r287892  
    4141}
    4242
    43 Ref<LightSource> SVGFEPointLightElement::lightSource(SVGFilterBuilder& builder) const
     43Ref<LightSource> SVGFEPointLightElement::lightSource(const SVGFilterBuilder& builder) const
    4444{
    4545    FloatPoint3D position;
  • trunk/Source/WebCore/svg/SVGFEPointLightElement.h

    r250060 r287892  
    3131    SVGFEPointLightElement(const QualifiedName&, Document&);
    3232
    33     Ref<LightSource> lightSource(SVGFilterBuilder&) const override;
     33    Ref<LightSource> lightSource(const SVGFilterBuilder&) const override;
    3434};
    3535static_assert(sizeof(SVGFEPointLightElement) == sizeof(SVGFELightElement));
  • trunk/Source/WebCore/svg/SVGFESpecularLightingElement.cpp

    r286864 r287892  
    33 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
    44 * Copyright (C) 2005 Oliver Hunt <oliver@nerget.com>
    5  * Copyright (C) 2018 Apple Inc. All rights reserved.
     5 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    66 *
    77 * This library is free software; you can redistribute it and/or
     
    2424#include "SVGFESpecularLightingElement.h"
    2525
    26 #include "FilterEffect.h"
     26#include "FESpecularLighting.h"
    2727#include "RenderStyle.h"
    2828#include "SVGFELightElement.h"
    29 #include "SVGFilterBuilder.h"
    3029#include "SVGNames.h"
    3130#include "SVGParserUtilities.h"
     
    161160}
    162161
    163 RefPtr<FilterEffect> SVGFESpecularLightingElement::build(SVGFilterBuilder& filterBuilder) const
     162RefPtr<FilterEffect> SVGFESpecularLightingElement::filterEffect(const SVGFilterBuilder& filterBuilder, const FilterEffectVector&) const
    164163{
    165     auto input1 = filterBuilder.getEffectById(in1());
    166     if (!input1)
    167         return nullptr;
    168 
    169164    RefPtr lightElement = SVGFELightElement::findLightElement(this);
    170165    if (!lightElement)
    171166        return nullptr;
    172    
     167
    173168    auto lightSource = lightElement->lightSource(filterBuilder);
    174169
     
    176171    if (!renderer)
    177172        return nullptr;
    178    
     173
    179174    Color color = renderer->style().colorByApplyingColorFilter(renderer->style().svgStyle().lightingColor());
    180175
    181     auto effect = FESpecularLighting::create(color, surfaceScale(), specularConstant(), specularExponent(), kernelUnitLengthX(), kernelUnitLengthY(), WTFMove(lightSource));
    182     effect->inputEffects() = { input1.releaseNonNull() };
    183     return effect;
     176    return FESpecularLighting::create(color, surfaceScale(), specularConstant(), specularExponent(), kernelUnitLengthX(), kernelUnitLengthY(), WTFMove(lightSource));
    184177}
    185178
    186 }
     179} // namespace WebCore
  • trunk/Source/WebCore/svg/SVGFESpecularLightingElement.h

    r285796 r287892  
    33 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
    44 * Copyright (C) 2005 Oliver Hunt <oliver@nerget.com>
    5  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     5 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    66 *
    77 * This library is free software; you can redistribute it and/or
     
    5959
    6060    bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&) override;
    61     RefPtr<FilterEffect> build(SVGFilterBuilder&) const override;
     61    Vector<AtomString> filterEffectInputsNames() const override { return { in1() }; }
     62    RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
    6263
    6364    PropertyRegistry m_propertyRegistry { *this };
  • trunk/Source/WebCore/svg/SVGFESpotLightElement.cpp

    r286837 r287892  
    2121#include "SVGFESpotLightElement.h"
    2222
    23 #include "GeometryUtilities.h"
    24 #include "ImageBuffer.h"
    2523#include "SVGFilterBuilder.h"
    2624#include "SVGNames.h"
     
    4139}
    4240
    43 Ref<LightSource> SVGFESpotLightElement::lightSource(SVGFilterBuilder& builder) const
     41Ref<LightSource> SVGFESpotLightElement::lightSource(const SVGFilterBuilder& builder) const
    4442{
    4543    FloatPoint3D position;
  • trunk/Source/WebCore/svg/SVGFESpotLightElement.h

    r250060 r287892  
    3131    SVGFESpotLightElement(const QualifiedName&, Document&);
    3232
    33     Ref<LightSource> lightSource(SVGFilterBuilder&) const override;
     33    Ref<LightSource> lightSource(const SVGFilterBuilder&) const override;
    3434};
    3535static_assert(sizeof(SVGFESpotLightElement) == sizeof(SVGFELightElement));
  • trunk/Source/WebCore/svg/SVGFETileElement.cpp

    r286864 r287892  
    22 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
    4  * Copyright (C) 2018 Apple Inc. All rights reserved.
     4 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    2424
    2525#include "FETile.h"
    26 #include "FilterEffect.h"
    27 #include "SVGFilterBuilder.h"
    2826#include "SVGNames.h"
    29 #include "SVGRenderStyle.h"
    3027#include <wtf/IsoMallocInlines.h>
    3128
     
    7168}
    7269
    73 RefPtr<FilterEffect> SVGFETileElement::build(SVGFilterBuilder& filterBuilder) const
     70RefPtr<FilterEffect> SVGFETileElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
    7471{
    75     auto input1 = filterBuilder.getEffectById(in1());
    76     if (!input1)
    77         return nullptr;
    78 
    79     auto effect = FETile::create();
    80     effect->inputEffects() = { input1.releaseNonNull() };
    81     return effect;
     72    return FETile::create();
    8273}
    8374
    84 }
     75} // namespace WebCore
  • trunk/Source/WebCore/svg/SVGFETileElement.h

    r285796 r287892  
    22 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
    4  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     4 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    4343    void svgAttributeChanged(const QualifiedName&) override;
    4444
    45     RefPtr<FilterEffect> build(SVGFilterBuilder&) const override;
     45    Vector<AtomString> filterEffectInputsNames() const override { return { in1() }; }
     46    RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
    4647
    4748    PropertyRegistry m_propertyRegistry { *this };
  • trunk/Source/WebCore/svg/SVGFETurbulenceElement.cpp

    r285796 r287892  
    22 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
    4  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     4 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    118118}
    119119
    120 RefPtr<FilterEffect> SVGFETurbulenceElement::build(SVGFilterBuilder&) const
     120RefPtr<FilterEffect> SVGFETurbulenceElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
    121121{
    122122    if (baseFrequencyX() < 0 || baseFrequencyY() < 0)
    123123        return nullptr;
     124
    124125    return FETurbulence::create(type(), baseFrequencyX(), baseFrequencyY(), numOctaves(), seed(), stitchTiles() == SVG_STITCHTYPE_STITCH);
    125126}
    126127
    127 }
     128} // namespace WebCore
  • trunk/Source/WebCore/svg/SVGFETurbulenceElement.h

    r285796 r287892  
    22 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
    4  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     4 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    120120
    121121    bool setFilterEffectAttribute(FilterEffect*, const QualifiedName& attrName) override;
    122     RefPtr<FilterEffect> build(SVGFilterBuilder&) const override;
     122    RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const override;
    123123
    124124    PropertyRegistry m_propertyRegistry { *this };
  • trunk/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h

    r286466 r287892  
    22 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
    4  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     4 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    3737    WTF_MAKE_ISO_ALLOCATED(SVGFilterPrimitiveStandardAttributes);
    3838public:
    39     virtual RefPtr<FilterEffect> build(SVGFilterBuilder&) const = 0;
    40     // Returns true, if the new value is different from the old one.
    41     virtual bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&);
    42 
    4339    using PropertyRegistry = SVGPropertyOwnerRegistry<SVGFilterPrimitiveStandardAttributes, SVGElement>;
    4440
     
    5450    SVGAnimatedLength& heightAnimated() { return m_height; }
    5551    SVGAnimatedString& resultAnimated() { return m_result; }
     52
     53    // Returns true, if the new value is different from the old one.
     54    virtual bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&);
     55    virtual Vector<AtomString> filterEffectInputsNames() const { return { }; }
     56    virtual RefPtr<FilterEffect> filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const = 0;
    5657
    5758protected:
  • trunk/Source/WebCore/svg/graphics/filters/SVGFilter.cpp

    r287782 r287892  
    3131namespace WebCore {
    3232
    33 RefPtr<SVGFilter> SVGFilter::create(SVGFilterElement& filterElement, SVGFilterBuilder& builder, RenderingMode renderingMode, const FloatSize& filterScale, ClipOperation clipOperation, const FloatRect& targetBoundingBox, FilterEffect& previousEffect)
    34 {
    35     return create(filterElement, builder, renderingMode, filterScale, clipOperation, targetBoundingBox, targetBoundingBox, &previousEffect);
    36 }
    37 
    38 RefPtr<SVGFilter> SVGFilter::create(SVGFilterElement& filterElement, SVGFilterBuilder& builder, RenderingMode renderingMode, const FloatSize& filterScale, const FloatRect& filterRegion, const FloatRect& targetBoundingBox)
    39 {
    40     return create(filterElement, builder, renderingMode, filterScale, ClipOperation::Intersect, filterRegion, targetBoundingBox, nullptr);
    41 }
    42 
    43 RefPtr<SVGFilter> SVGFilter::create(SVGFilterElement& filterElement, SVGFilterBuilder& builder, RenderingMode renderingMode, const FloatSize& filterScale, ClipOperation clipOperation, const FloatRect& filterRegion, const FloatRect& targetBoundingBox, FilterEffect* previousEffect)
     33RefPtr<SVGFilter> SVGFilter::create(SVGFilterElement& filterElement, SVGFilterBuilder& builder, RenderingMode renderingMode, const FloatSize& filterScale, ClipOperation clipOperation, const FloatRect& filterRegion, const FloatRect& targetBoundingBox)
    4434{
    4535    auto filter = adoptRef(*new SVGFilter(renderingMode, filterScale, clipOperation, filterRegion, targetBoundingBox, filterElement.primitiveUnits()));
    4636
    47     if (!previousEffect)
    48         builder.setupBuiltinEffects(SourceGraphic::create());
    49     else
    50         builder.setupBuiltinEffects({ *previousEffect });
    51 
     37    builder.setupBuiltinEffects(SourceGraphic::create());
    5238    builder.setTargetBoundingBox(targetBoundingBox);
    5339    builder.setPrimitiveUnits(filterElement.primitiveUnits());
  • trunk/Source/WebCore/svg/graphics/filters/SVGFilter.h

    r287782 r287892  
    3737class SVGFilter final : public Filter {
    3838public:
    39     static RefPtr<SVGFilter> create(SVGFilterElement&, SVGFilterBuilder&, RenderingMode, const FloatSize& filterScale, ClipOperation, const FloatRect& targetBoundingBox, FilterEffect& previousEffect);
    40     static RefPtr<SVGFilter> create(SVGFilterElement&, SVGFilterBuilder&, RenderingMode, const FloatSize& filterScale, const FloatRect& filterRegion, const FloatRect& targetBoundingBox);
    41     static RefPtr<SVGFilter> create(SVGFilterElement&, SVGFilterBuilder&, RenderingMode, const FloatSize& filterScale, ClipOperation, const FloatRect& filterRegion, const FloatRect& targetBoundingBox, FilterEffect* previousEffect);
     39    static RefPtr<SVGFilter> create(SVGFilterElement&, SVGFilterBuilder&, RenderingMode, const FloatSize& filterScale, ClipOperation, const FloatRect& filterRegion, const FloatRect& targetBoundingBox);
    4240    WEBCORE_EXPORT static RefPtr<SVGFilter> create(const FloatRect& targetBoundingBox, SVGUnitTypes::SVGUnitType primitiveUnits, SVGFilterExpression&&);
    4341
  • trunk/Source/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp

    r287782 r287892  
    4040void SVGFilterBuilder::setupBuiltinEffects(Ref<FilterEffect> sourceGraphic)
    4141{
    42     m_builtinEffects.add(SourceGraphic::effectName(), sourceGraphic.ptr());
    43     m_builtinEffects.add(SourceAlpha::effectName(), SourceAlpha::create(sourceGraphic));
     42    m_builtinEffects.add(SourceGraphic::effectName(), sourceGraphic);
     43    m_builtinEffects.add(SourceAlpha::effectName(), SourceAlpha::create(sourceGraphic->operatingColorSpace()));
    4444}
    4545
     
    8484        return nullptr;
    8585
    86     RefPtr<FilterEffect> effect;
     86    setEffectInputs(sourceAlpha(), FilterEffectVector { sourceGraphic() });
    8787
    8888    for (auto& effectElement : childrenOfType<SVGFilterPrimitiveStandardAttributes>(filterElement)) {
    89         effect = effectElement.build(*this);
     89        auto inputs = namedEffects(effectElement.filterEffectInputsNames());
     90        if (!inputs)
     91            return nullptr;
     92
     93        auto effect = effectElement.filterEffect(*this, *inputs);
    9094        if (!effect)
    91             break;
     95            return nullptr;
    9296
    9397        if (auto flags = effectGeometryFlagsForElement(effectElement)) {
     
    104108            appendEffectToEffectRenderer(*effect, *renderer);
    105109
    106         add(effectElement.result(), effect);
    107     }
    108 
    109     return effect;
    110 }
    111 
    112 void SVGFilterBuilder::add(const AtomString& id, RefPtr<FilterEffect> effect)
     110        addNamedEffect(effectElement.result(), { *effect });
     111        setEffectInputs(*effect, WTFMove(*inputs));
     112    }
     113
     114    return m_lastEffect;
     115}
     116
     117FilterEffect& SVGFilterBuilder::sourceGraphic() const
     118{
     119    return *m_builtinEffects.get(FilterEffect::sourceGraphicName());
     120}
     121
     122FilterEffect& SVGFilterBuilder::sourceAlpha() const
     123{
     124    return *m_builtinEffects.get(FilterEffect::sourceAlphaName());
     125}
     126
     127void SVGFilterBuilder::addNamedEffect(const AtomString& id, Ref<FilterEffect>&& effect)
    113128{
    114129    if (id.isEmpty()) {
    115         m_lastEffect = effect;
     130        m_lastEffect = WTFMove(effect);
    116131        return;
    117132    }
     
    120135        return;
    121136
    122     m_lastEffect = effect;
    123     m_namedEffects.set(id, m_lastEffect);
    124 }
    125 
    126 RefPtr<FilterEffect> SVGFilterBuilder::getEffectById(const AtomString& id) const
     137    m_lastEffect = WTFMove(effect);
     138    m_namedEffects.set(id, Ref { *m_lastEffect });
     139}
     140
     141RefPtr<FilterEffect> SVGFilterBuilder::namedEffect(const AtomString& id) const
    127142{
    128143    if (id.isEmpty()) {
     
    130145            return m_lastEffect;
    131146
    132         return m_builtinEffects.get(SourceGraphic::effectName());
     147        return &sourceGraphic();
    133148    }
    134149
     
    137152
    138153    return m_namedEffects.get(id);
     154}
     155
     156std::optional<FilterEffectVector> SVGFilterBuilder::namedEffects(Span<const AtomString> names) const
     157{
     158    FilterEffectVector effects;
     159
     160    effects.reserveInitialCapacity(names.size());
     161
     162    for (auto& name : names) {
     163        auto effect = namedEffect(name);
     164        if (!effect)
     165            return std::nullopt;
     166
     167        effects.uncheckedAppend(effect.releaseNonNull());
     168    }
     169
     170    return effects;
     171}
     172
     173void SVGFilterBuilder::setEffectInputs(FilterEffect& effect, FilterEffectVector&& inputs)
     174{
     175    m_inputsMap.set({ effect }, WTFMove(inputs));
    139176}
    140177
     
    162199    expression.append({ effect, effectGeometry(effect), level });
    163200
    164     for (auto& inputEffect : effect.inputEffects()) {
    165         if (!buildEffectExpression(inputEffect, stack, level + 1, expression))
     201    for (auto& input : m_inputsMap.get(effect)) {
     202        if (!buildEffectExpression(input, stack, level + 1, expression))
    166203            return false;
    167204    }
  • trunk/Source/WebCore/svg/graphics/filters/SVGFilterBuilder.h

    r287782 r287892  
    2626#include "SVGUnitTypes.h"
    2727#include <wtf/HashMap.h>
    28 #include <wtf/HashSet.h>
    2928#include <wtf/text/AtomStringHash.h>
    3029#include <wtf/text/WTFString.h>
     
    4746    void setPrimitiveUnits(SVGUnitTypes::SVGUnitType units) { m_primitiveUnits = units; }
    4847
    49     void add(const AtomString& id, RefPtr<FilterEffect>);
    50     RefPtr<FilterEffect> getEffectById(const AtomString&) const;
    51 
    5248    // Required to change the attributes of a filter during an svgAttributeChanged.
    5349    void appendEffectToEffectRenderer(FilterEffect&, RenderObject&);
     
    5955
    6056private:
     57    FilterEffect& sourceGraphic() const;
     58    FilterEffect& sourceAlpha() const;
     59
     60    RefPtr<FilterEffect> namedEffect(const AtomString&) const;
     61    std::optional<FilterEffectVector> namedEffects(Span<const AtomString>) const;
     62
     63    void addNamedEffect(const AtomString& id, Ref<FilterEffect>&&);
     64    void setEffectInputs(FilterEffect&, FilterEffectVector&& inputs);
     65
    6166    std::optional<FilterEffectGeometry> effectGeometry(FilterEffect&) const;
    6267    bool buildEffectExpression(FilterEffect&, FilterEffectVector& stack, unsigned level, SVGFilterExpression&) const;
    6368
    64     HashMap<AtomString, RefPtr<FilterEffect>> m_builtinEffects;
    65     HashMap<AtomString, RefPtr<FilterEffect>> m_namedEffects;
     69    HashMap<AtomString, Ref<FilterEffect>> m_builtinEffects;
     70    HashMap<AtomString, Ref<FilterEffect>> m_namedEffects;
    6671    HashMap<RenderObject*, FilterEffect*> m_effectRenderer;
     72    HashMap<Ref<FilterEffect>, FilterEffectVector> m_inputsMap;
    6773
    6874    RefPtr<FilterEffect> m_lastEffect;
Note: See TracChangeset for help on using the changeset viewer.