SVGFilterBuilder should drive the builtin sourceAlpha from the passed sourceGraphic
https://bugs.webkit.org/show_bug.cgi?id=144137

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2015-04-26
Reviewed by Darin Adler.

Source/WebCore:

The SourceAlpha should be driven from the last applied FilterEffect. This
will require the SourceAlpha FilterEffect to wrap a FilterEffect rather
than just getting the SourceGraphic reference from FilterEffectRenderer.

This is based on the Blink patch:
https://src.chromium.org/viewvc/blink?revision=194115&view=revision.

Test: svg/filters/sourceAlpha-input-filter-effect.html

* platform/graphics/filters/SourceAlpha.cpp:
(WebCore::SourceAlpha::create): Make SourceAlpha wraps a FilterEffect
rather than a Filter.

(WebCore::SourceAlpha::determineAbsolutePaintRect): Determine the paint
rect from the wrapped FilterEffect.

(WebCore::SourceAlpha::platformApplySoftware): Extract the alpha channel
from the wrapped FilterEffect.

(WebCore::SourceAlpha::SourceAlpha):
* platform/graphics/filters/SourceAlpha.h:
(WebCore::SourceAlpha::SourceAlpha): Deleted.
Reimplement the constructor of the SourceAlpha such that it wraps the
sourceEffect in its inputEffects.

* rendering/FilterEffectRenderer.cpp:
(WebCore::FilterEffectRenderer::buildReferenceFilter): Delete the FIXME
comment and do exactly what it said. This matches the implementation of
Gecko and Blink.

* rendering/svg/RenderSVGResourceFilter.cpp:
(WebCore::RenderSVGResourceFilter::buildPrimitives):
Delete the extra argument.

* svg/graphics/filters/SVGFilterBuilder.cpp:
(WebCore::SVGFilterBuilder::SVGFilterBuilder):
* svg/graphics/filters/SVGFilterBuilder.h: Drive the SourceAlpha from the
passed source FilterEffect.

* platform/graphics/filters/FEBlend.cpp:
* platform/graphics/filters/FEBlend.h:
* platform/graphics/filters/FEColorMatrix.cpp:
* platform/graphics/filters/FEColorMatrix.h:
* platform/graphics/filters/FEComponentTransfer.cpp:
* platform/graphics/filters/FEComponentTransfer.h:
* platform/graphics/filters/FEComposite.cpp:
* platform/graphics/filters/FEComposite.h:
* platform/graphics/filters/FEConvolveMatrix.cpp:
* platform/graphics/filters/FEConvolveMatrix.h:
* platform/graphics/filters/FEDiffuseLighting.cpp:
* platform/graphics/filters/FEDiffuseLighting.h:
* platform/graphics/filters/FEDisplacementMap.cpp:
* platform/graphics/filters/FEDisplacementMap.h:
* platform/graphics/filters/FEDropShadow.cpp:
* platform/graphics/filters/FEDropShadow.h:
* platform/graphics/filters/FEFlood.cpp:
* platform/graphics/filters/FEFlood.h:
* platform/graphics/filters/FEGaussianBlur.cpp:
* platform/graphics/filters/FEGaussianBlur.h:
* platform/graphics/filters/FELighting.cpp:
* platform/graphics/filters/FELighting.h:
* platform/graphics/filters/FEMerge.cpp:
* platform/graphics/filters/FEMerge.h:
* platform/graphics/filters/FEMorphology.cpp:
* platform/graphics/filters/FEMorphology.h:
* platform/graphics/filters/FEOffset.cpp:
* platform/graphics/filters/FEOffset.h:
* platform/graphics/filters/FESpecularLighting.cpp:
* platform/graphics/filters/FESpecularLighting.h:
* platform/graphics/filters/FETile.cpp:
* platform/graphics/filters/FETile.h:
* platform/graphics/filters/FETurbulence.cpp:
* platform/graphics/filters/FETurbulence.h:
* platform/graphics/filters/Filter.h:
* platform/graphics/filters/FilterEffect.cpp:
* platform/graphics/filters/FilterEffect.h:
* platform/graphics/filters/SourceGraphic.cpp:
* platform/graphics/filters/SourceGraphic.h:
* rendering/svg/RenderSVGResourceFilter.h:
* rendering/svg/SVGRenderTreeAsText.cpp:
Code clean up: Pointer to reference conversion. It starts by converting
FilterEffect::m_filter from pointer to reference and it kept expanding.
All the creations of FilterEffect were happening by passing "this" so
passing "*this" did not require to check whether the pointer is nil.

* svg/SVGFEBlendElement.cpp:
* svg/SVGFEBlendElement.h:
* svg/SVGFEColorMatrixElement.cpp:
* svg/SVGFEColorMatrixElement.h:
* svg/SVGFEComponentTransferElement.cpp:
* svg/SVGFEComponentTransferElement.h:
* svg/SVGFECompositeElement.cpp:
* svg/SVGFECompositeElement.h:
* svg/SVGFEConvolveMatrixElement.cpp:
* svg/SVGFEConvolveMatrixElement.h:
* svg/SVGFEDiffuseLightingElement.cpp:
* svg/SVGFEDiffuseLightingElement.h:
* svg/SVGFEDisplacementMapElement.cpp:
* svg/SVGFEDisplacementMapElement.h:
* svg/SVGFEDropShadowElement.cpp:
* svg/SVGFEDropShadowElement.h:
* svg/SVGFEFloodElement.cpp:
* svg/SVGFEFloodElement.h:
* svg/SVGFEGaussianBlurElement.cpp:
* svg/SVGFEGaussianBlurElement.h:
* svg/SVGFEImageElement.cpp:
* svg/SVGFEImageElement.h:
* svg/SVGFEMergeElement.cpp:
* svg/SVGFEMergeElement.h:
* svg/SVGFEMorphologyElement.cpp:
* svg/SVGFEMorphologyElement.h:
* svg/SVGFEOffsetElement.cpp:
* svg/SVGFEOffsetElement.h:
* svg/SVGFESpecularLightingElement.cpp:
* svg/SVGFESpecularLightingElement.h:
* svg/SVGFETileElement.cpp:
* svg/SVGFETileElement.h:
* svg/SVGFETurbulenceElement.cpp:
* svg/SVGFETurbulenceElement.h:
* svg/SVGFilterPrimitiveStandardAttributes.h:
* svg/graphics/filters/SVGFEImage.cpp:
* svg/graphics/filters/SVGFEImage.h:
Code clean up: Pointer to reference and PassRefPtr<> to RefPtr<> or Ref<>
conversion.

LayoutTests:

Ensure the SourceAlpha is driven from last applied FilterEffect.

* svg/filters/sourceAlpha-input-filter-effect-expected.html: Added.
* svg/filters/sourceAlpha-input-filter-effect.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@183381 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/svg/SVGFEDisplacementMapElement.h b/Source/WebCore/svg/SVGFEDisplacementMapElement.h
index 249e7da..a64f819 100644
--- a/Source/WebCore/svg/SVGFEDisplacementMapElement.h
+++ b/Source/WebCore/svg/SVGFEDisplacementMapElement.h
@@ -76,7 +76,7 @@
     virtual void parseAttribute(const QualifiedName&, const AtomicString&) override;
     virtual bool setFilterEffectAttribute(FilterEffect*, const QualifiedName& attrName) override;
     virtual void svgAttributeChanged(const QualifiedName&) override;
-    virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*) override;
+    virtual RefPtr<FilterEffect> build(SVGFilterBuilder*, Filter&) override;
 
     BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGFEDisplacementMapElement)
         DECLARE_ANIMATED_STRING(In1, in1)