Skip to content
Permalink
Browse files
[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:



Canonical link: https://commits.webkit.org/245930@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287892 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
shallawa committed Jan 11, 2022
1 parent 4fc14b6 commit 4cde7245c351767b707ee4fcbe62cc26d7311cc9
Showing with 377 additions and 340 deletions.
  1. +143 −0 Source/WebCore/ChangeLog
  2. +0 −6 Source/WebCore/platform/graphics/filters/FilterEffect.cpp
  3. +4 −12 Source/WebCore/platform/graphics/filters/FilterEffect.h
  4. +5 −17 Source/WebCore/platform/graphics/filters/SourceAlpha.cpp
  5. +2 −4 Source/WebCore/platform/graphics/filters/SourceAlpha.h
  6. +6 −12 Source/WebCore/rendering/CSSFilter.cpp
  7. +1 −1 Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp
  8. +1 −1 Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp
  9. +4 −14 Source/WebCore/svg/SVGFEBlendElement.cpp
  10. +3 −2 Source/WebCore/svg/SVGFEBlendElement.h
  11. +5 −13 Source/WebCore/svg/SVGFEColorMatrixElement.cpp
  12. +3 −2 Source/WebCore/svg/SVGFEColorMatrixElement.h
  13. +5 −13 Source/WebCore/svg/SVGFEComponentTransferElement.cpp
  14. +3 −2 Source/WebCore/svg/SVGFEComponentTransferElement.h
  15. +5 −14 Source/WebCore/svg/SVGFECompositeElement.cpp
  16. +3 −2 Source/WebCore/svg/SVGFECompositeElement.h
  17. +8 −15 Source/WebCore/svg/SVGFEConvolveMatrixElement.cpp
  18. +3 −2 Source/WebCore/svg/SVGFEConvolveMatrixElement.h
  19. +4 −13 Source/WebCore/svg/SVGFEDiffuseLightingElement.cpp
  20. +3 −2 Source/WebCore/svg/SVGFEDiffuseLightingElement.h
  21. +5 −14 Source/WebCore/svg/SVGFEDisplacementMapElement.cpp
  22. +3 −2 Source/WebCore/svg/SVGFEDisplacementMapElement.h
  23. +1 −1 Source/WebCore/svg/SVGFEDistantLightElement.cpp
  24. +1 −1 Source/WebCore/svg/SVGFEDistantLightElement.h
  25. +4 −11 Source/WebCore/svg/SVGFEDropShadowElement.cpp
  26. +3 −2 Source/WebCore/svg/SVGFEDropShadowElement.h
  27. +4 −3 Source/WebCore/svg/SVGFEFloodElement.cpp
  28. +2 −1 Source/WebCore/svg/SVGFEFloodElement.h
  29. +5 −12 Source/WebCore/svg/SVGFEGaussianBlurElement.cpp
  30. +3 −2 Source/WebCore/svg/SVGFEGaussianBlurElement.h
  31. +3 −3 Source/WebCore/svg/SVGFEImageElement.cpp
  32. +2 −2 Source/WebCore/svg/SVGFEImageElement.h
  33. +1 −1 Source/WebCore/svg/SVGFELightElement.h
  34. +11 −20 Source/WebCore/svg/SVGFEMergeElement.cpp
  35. +3 −1 Source/WebCore/svg/SVGFEMergeElement.h
  36. +5 −14 Source/WebCore/svg/SVGFEMorphologyElement.cpp
  37. +3 −2 Source/WebCore/svg/SVGFEMorphologyElement.h
  38. +4 −12 Source/WebCore/svg/SVGFEOffsetElement.cpp
  39. +3 −2 Source/WebCore/svg/SVGFEOffsetElement.h
  40. +1 −1 Source/WebCore/svg/SVGFEPointLightElement.cpp
  41. +1 −1 Source/WebCore/svg/SVGFEPointLightElement.h
  42. +7 −14 Source/WebCore/svg/SVGFESpecularLightingElement.cpp
  43. +3 −2 Source/WebCore/svg/SVGFESpecularLightingElement.h
  44. +1 −3 Source/WebCore/svg/SVGFESpotLightElement.cpp
  45. +1 −1 Source/WebCore/svg/SVGFESpotLightElement.h
  46. +4 −13 Source/WebCore/svg/SVGFETileElement.cpp
  47. +3 −2 Source/WebCore/svg/SVGFETileElement.h
  48. +4 −3 Source/WebCore/svg/SVGFETurbulenceElement.cpp
  49. +2 −2 Source/WebCore/svg/SVGFETurbulenceElement.h
  50. +6 −5 Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h
  51. +2 −16 Source/WebCore/svg/graphics/filters/SVGFilter.cpp
  52. +1 −3 Source/WebCore/svg/graphics/filters/SVGFilter.h
  53. +52 −15 Source/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp
  54. +12 −6 Source/WebCore/svg/graphics/filters/SVGFilterBuilder.h
@@ -1,3 +1,146 @@
2022-01-11 Said Abou-Hallawa <said@apple.com>

[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:

2022-01-11 Sam Weinig <weinig@apple.com>

Use the new template ColorSpaceCG helpers to cleanup some code
@@ -149,12 +149,6 @@ RefPtr<FilterImage> FilterEffect::apply(const Filter& filter, const FilterImageV
return result;
}

FilterEffect& FilterEffect::inputEffect(unsigned number) const
{
ASSERT_WITH_SECURITY_IMPLICATION(number < m_inputEffects.size());
return m_inputEffects.at(number);
}

TextStream& FilterEffect::externalRepresentation(TextStream& ts, FilterRepresentation representation) const
{
// FIXME: We should dump the subRegions of the filter primitives here later. This isn't
@@ -23,11 +23,8 @@
#pragma once

#include "DestinationColorSpace.h"
#include "FilterEffectVector.h"
#include "FilterFunction.h"
#include "FilterImage.h"
#include "FilterImageVector.h"
#include <wtf/Vector.h>

namespace WTF {
class TextStream;
@@ -38,21 +35,18 @@ namespace WebCore {
class Filter;
class FilterEffectApplier;
class FilterEffectGeometry;
class FilterResults;

class FilterEffect : public FilterFunction {
using FilterFunction::apply;

public:
FilterImageVector takeImageInputs(FilterImageVector& stack) const;

FilterEffectVector& inputEffects() { return m_inputEffects; }
FilterEffect& inputEffect(unsigned) const;

RefPtr<FilterImage> apply(const Filter&, const FilterImageVector& inputs, FilterResults&, const std::optional<FilterEffectGeometry>& = std::nullopt);

const DestinationColorSpace& operatingColorSpace() const { return m_operatingColorSpace; }
virtual void setOperatingColorSpace(const DestinationColorSpace& colorSpace) { m_operatingColorSpace = colorSpace; }

FilterImageVector takeImageInputs(FilterImageVector& stack) const;
RefPtr<FilterImage> apply(const Filter&, const FilterImageVector& inputs, FilterResults&, const std::optional<FilterEffectGeometry>& = std::nullopt);

WTF::TextStream& externalRepresentation(WTF::TextStream&, FilterRepresentation) const override;

protected:
@@ -80,8 +74,6 @@ class FilterEffect : public FilterFunction {

RefPtr<FilterImage> apply(const Filter&, FilterImage& input, FilterResults&) override;

FilterEffectVector m_inputEffects;

DestinationColorSpace m_operatingColorSpace { DestinationColorSpace::SRGB() };
};

@@ -1,6 +1,6 @@
/*
* Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
* Copyright (C) 2021 Apple Inc. All rights reserved.
* Copyright (C) 2021-2022 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -21,32 +21,20 @@
#include "config.h"
#include "SourceAlpha.h"

#include "ImageBuffer.h"
#include "SourceAlphaSoftwareApplier.h"
#include <wtf/text/TextStream.h>

namespace WebCore {

Ref<SourceAlpha> SourceAlpha::create()
Ref<SourceAlpha> SourceAlpha::create(const DestinationColorSpace& colorSpace)
{
return adoptRef(*new SourceAlpha());
return adoptRef(*new SourceAlpha(colorSpace));
}

Ref<SourceAlpha> SourceAlpha::create(FilterEffect& sourceEffect)
{
return adoptRef(*new SourceAlpha(sourceEffect));
}

SourceAlpha::SourceAlpha()
: FilterEffect(FilterEffect::Type::SourceAlpha)
{
}

SourceAlpha::SourceAlpha(FilterEffect& sourceEffect)
SourceAlpha::SourceAlpha(const DestinationColorSpace& colorSpace)
: FilterEffect(FilterEffect::Type::SourceAlpha)
{
setOperatingColorSpace(sourceEffect.operatingColorSpace());
inputEffects().append(sourceEffect);
setOperatingColorSpace(colorSpace);
}

std::unique_ptr<FilterEffectApplier> SourceAlpha::createApplier(const Filter&) const
@@ -26,14 +26,12 @@ namespace WebCore {

class SourceAlpha : public FilterEffect {
public:
WEBCORE_EXPORT static Ref<SourceAlpha> create();
static Ref<SourceAlpha> create(FilterEffect&);
WEBCORE_EXPORT static Ref<SourceAlpha> create(const DestinationColorSpace& = DestinationColorSpace::SRGB());

static AtomString effectName() { return FilterEffect::sourceAlphaName(); }

private:
SourceAlpha();
explicit SourceAlpha(FilterEffect&);
explicit SourceAlpha(const DestinationColorSpace&);

std::unique_ptr<FilterEffectApplier> createApplier(const Filter&) const override;

@@ -218,7 +218,7 @@ static RefPtr<FilterEffect> createSepiaEffect(const BasicColorMatrixFilterOperat
return FEColorMatrix::create(FECOLORMATRIX_TYPE_MATRIX, WTFMove(inputParameters));
}

static RefPtr<SVGFilter> createSVGFilter(CSSFilter& filter, const ReferenceFilterOperation& filterOperation, RenderElement& renderer, const FloatRect& targetBoundingBox, FilterEffect& previousEffect)
static RefPtr<SVGFilter> createSVGFilter(CSSFilter& filter, const ReferenceFilterOperation& filterOperation, RenderElement& renderer, const FloatRect& targetBoundingBox)
{
auto& referencedSVGResources = renderer.ensureReferencedSVGResources();
auto* filterElement = referencedSVGResources.referencedFilterElement(renderer.document(), filterOperation);
@@ -232,15 +232,14 @@ static RefPtr<SVGFilter> createSVGFilter(CSSFilter& filter, const ReferenceFilte
}

SVGFilterBuilder builder;
return SVGFilter::create(*filterElement, builder, filter.renderingMode(), filter.filterScale(), filter.clipOperation(), targetBoundingBox, previousEffect);
return SVGFilter::create(*filterElement, builder, filter.renderingMode(), filter.filterScale(), filter.clipOperation(), targetBoundingBox, targetBoundingBox);
}

bool CSSFilter::buildFilterFunctions(RenderElement& renderer, const FilterOperations& operations, const FloatRect& targetBoundingBox)
{
m_functions.clear();
m_outsets = { };

RefPtr<FilterEffect> previousEffect = SourceGraphic::create();
RefPtr<SVGFilter> filter;

for (auto& operation : operations.operations()) {
@@ -292,32 +291,27 @@ bool CSSFilter::buildFilterFunctions(RenderElement& renderer, const FilterOperat
break;

case FilterOperation::REFERENCE:
filter = createSVGFilter(*this, downcast<ReferenceFilterOperation>(*operation), renderer, targetBoundingBox, *previousEffect);
filter = createSVGFilter(*this, downcast<ReferenceFilterOperation>(*operation), renderer, targetBoundingBox);
effect = nullptr;
break;

default:
break;
}

if ((filter || effect) && m_functions.isEmpty()) {
ASSERT(previousEffect->filterType() == FilterEffect::Type::SourceGraphic);
m_functions.append({ *previousEffect });
}
if ((filter || effect) && m_functions.isEmpty())
m_functions.append(SourceGraphic::create());

if (filter) {
effect = filter->lastEffect();
effect->setOperatingColorSpace(DestinationColorSpace::SRGB());
m_functions.append(filter.releaseNonNull());
previousEffect = WTFMove(effect);
continue;
}

if (effect) {
effect->setOperatingColorSpace(DestinationColorSpace::SRGB());
effect->inputEffects() = { previousEffect.releaseNonNull() };
m_functions.append({ *effect });
previousEffect = WTFMove(effect);
m_functions.append(effect.releaseNonNull());
}
}

@@ -129,7 +129,7 @@ bool RenderSVGResourceFilter::applyResource(RenderElement& renderer, const Rende

// Create the SVGFilter object.
filterData->builder = makeUnique<SVGFilterBuilder>();
filterData->filter = SVGFilter::create(filterElement(), *filterData->builder, renderingMode, filterScale, filterData->boundaries, targetBoundingBox);
filterData->filter = SVGFilter::create(filterElement(), *filterData->builder, renderingMode, filterScale, Filter::ClipOperation::Intersect, filterData->boundaries, targetBoundingBox);
if (!filterData->filter) {
m_rendererFilterDataMap.remove(&renderer);
return false;
@@ -474,7 +474,7 @@ void writeSVGResourceContainer(TextStream& ts, const RenderSVGResourceContainer&
FloatRect dummyRect;
FloatSize dummyScale(1, 1);
SVGFilterBuilder builder;
auto dummyFilter = SVGFilter::create(filter.filterElement(), builder, RenderingMode::Unaccelerated, dummyScale, dummyRect, dummyRect);
auto dummyFilter = SVGFilter::create(filter.filterElement(), builder, RenderingMode::Unaccelerated, dummyScale, Filter::ClipOperation::Intersect, dummyRect, dummyRect);
if (dummyFilter) {
TextStream::IndentScope indentScope(ts);
dummyFilter->externalRepresentation(ts, FilterRepresentation::TestOutput);
@@ -2,7 +2,7 @@
* Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
* Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
* Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved.
* Copyright (C) 2018-2019 Apple Inc. All rights reserved.
* Copyright (C) 2018-2022 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -24,8 +24,6 @@
#include "SVGFEBlendElement.h"

#include "FEBlend.h"
#include "FilterEffect.h"
#include "SVGFilterBuilder.h"
#include "SVGNames.h"
#include <wtf/IsoMallocInlines.h>

@@ -100,17 +98,9 @@ void SVGFEBlendElement::svgAttributeChanged(const QualifiedName& attrName)
SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName);
}

RefPtr<FilterEffect> SVGFEBlendElement::build(SVGFilterBuilder& filterBuilder) const
RefPtr<FilterEffect> SVGFEBlendElement::filterEffect(const SVGFilterBuilder&, const FilterEffectVector&) const
{
auto input1 = filterBuilder.getEffectById(in1());
auto input2 = filterBuilder.getEffectById(in2());

if (!input1 || !input2)
return nullptr;

auto effect = FEBlend::create(mode());
effect->inputEffects() = { input1.releaseNonNull(), input2.releaseNonNull() };
return effect;
return FEBlend::create(mode());
}

}
} // namespace WebCore

0 comments on commit 4cde724

Please sign in to comment.