Some FilterEffect cleanup and logging
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Nov 2017 17:26:14 +0000 (17:26 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Nov 2017 17:26:14 +0000 (17:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179932

Reviewed by Darin Adler.

Rename the FilterEffect functions that get the result of the filter
to have "result" in the name.

Re-order FilterEffect member variables and use initializers. webkit.org/b/45614
is closed so remove the comment about things moving to RenderSVGResourceFilterPrimitive.

Add a virtual filterName() function for use by logging.

Add a Filters log channel. Log some stuff.

Rename RenderSVGResourceFilter::m_filter to m_rendererFilterDataMap.

* platform/Logging.h:
* platform/graphics/cpu/arm/filters/FEBlendNEON.h:
(WebCore::FEBlend::platformApplySoftware):
* platform/graphics/filters/FEBlend.cpp:
(WebCore::FEBlend::platformApplySoftware):
* platform/graphics/filters/FEBlend.h:
* platform/graphics/filters/FEColorMatrix.cpp:
(WebCore::FEColorMatrix::platformApplySoftware):
* platform/graphics/filters/FEColorMatrix.h:
* platform/graphics/filters/FEComponentTransfer.cpp:
(WebCore::FEComponentTransfer::platformApplySoftware):
* platform/graphics/filters/FEComponentTransfer.h:
* platform/graphics/filters/FEComposite.cpp:
(WebCore::FEComposite::platformApplySoftware):
* platform/graphics/filters/FEComposite.h:
* platform/graphics/filters/FEConvolveMatrix.cpp:
(WebCore::FEConvolveMatrix::platformApplySoftware):
* platform/graphics/filters/FEConvolveMatrix.h:
* platform/graphics/filters/FEDisplacementMap.cpp:
(WebCore::FEDisplacementMap::platformApplySoftware):
* platform/graphics/filters/FEDisplacementMap.h:
* platform/graphics/filters/FEDropShadow.cpp:
(WebCore::FEDropShadow::platformApplySoftware):
* platform/graphics/filters/FEDropShadow.h:
* platform/graphics/filters/FEFlood.h:
* platform/graphics/filters/FEGaussianBlur.cpp:
(WebCore::FEGaussianBlur::platformApplySoftware):
* platform/graphics/filters/FEGaussianBlur.h:
* platform/graphics/filters/FELighting.cpp:
(WebCore::FELighting::platformApplySoftware):
* platform/graphics/filters/FELighting.h:
* platform/graphics/filters/FEMerge.cpp:
(WebCore::FEMerge::platformApplySoftware):
* platform/graphics/filters/FEMerge.h:
* platform/graphics/filters/FEMorphology.cpp:
(WebCore::FEMorphology::platformApplyDegenerate):
(WebCore::FEMorphology::platformApplySoftware):
* platform/graphics/filters/FEMorphology.h:
* platform/graphics/filters/FEOffset.cpp:
(WebCore::FEOffset::platformApplySoftware):
* platform/graphics/filters/FEOffset.h:
* platform/graphics/filters/FETile.cpp:
(WebCore::FETile::platformApplySoftware):
* platform/graphics/filters/FETile.h:
* platform/graphics/filters/FETurbulence.cpp:
(WebCore::operator<<):
* platform/graphics/filters/FETurbulence.h:
* platform/graphics/filters/FilterEffect.cpp:
(WebCore::FilterEffect::FilterEffect):
(WebCore::FilterEffect::imageBufferResult):
(WebCore::FilterEffect::unmultipliedResult):
(WebCore::FilterEffect::premultipliedResult):
(WebCore::FilterEffect::copyImageBytes const): This can be const. It'a also crazy
to mark a large, slow function like this as 'inline'.
(WebCore::FilterEffect::copyUnmultipliedResult):
(WebCore::FilterEffect::copyPremultipliedResult):
(WebCore::FilterEffect::createImageBufferResult):
(WebCore::FilterEffect::createUnmultipliedImageResult):
(WebCore::FilterEffect::createPremultipliedImageResult):
(WebCore::FilterEffect::transformResultColorSpace):
(WebCore::FilterEffect::asImageBuffer): Deleted.
(WebCore::FilterEffect::asUnmultipliedImage): Deleted.
(WebCore::FilterEffect::asPremultipliedImage): Deleted.
(WebCore::FilterEffect::copyImageBytes): Deleted.
(WebCore::FilterEffect::copyUnmultipliedImage): Deleted.
(WebCore::FilterEffect::copyPremultipliedImage): Deleted.
* platform/graphics/filters/FilterEffect.h:
* platform/graphics/filters/SourceAlpha.cpp:
(WebCore::SourceAlpha::platformApplySoftware):
* platform/graphics/filters/SourceAlpha.h:
* platform/graphics/filters/SourceGraphic.h:
* rendering/FilterEffectRenderer.cpp:
(WebCore::FilterEffectRenderer::output const):
* rendering/svg/RenderSVGResourceFilter.cpp:
(WebCore::RenderSVGResourceFilter::removeAllClientsFromCache):
(WebCore::RenderSVGResourceFilter::removeClientFromCache):
(WebCore::RenderSVGResourceFilter::applyResource):
(WebCore::RenderSVGResourceFilter::postApplyResource):
(WebCore::RenderSVGResourceFilter::primitiveAttributeChanged):
(WebCore::RenderSVGResourceFilter::drawingRegion const):
(WebCore::operator<<):
* rendering/svg/RenderSVGResourceFilter.h:
(WebCore::FilterData::FilterData): Deleted.
* svg/graphics/filters/SVGFEImage.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225137 268f45cc-cd09-0410-ab3c-d52691b4dbfc

41 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/Logging.h
Source/WebCore/platform/graphics/cpu/arm/filters/FEBlendNEON.h
Source/WebCore/platform/graphics/filters/FEBlend.cpp
Source/WebCore/platform/graphics/filters/FEBlend.h
Source/WebCore/platform/graphics/filters/FEColorMatrix.cpp
Source/WebCore/platform/graphics/filters/FEColorMatrix.h
Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp
Source/WebCore/platform/graphics/filters/FEComponentTransfer.h
Source/WebCore/platform/graphics/filters/FEComposite.cpp
Source/WebCore/platform/graphics/filters/FEComposite.h
Source/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp
Source/WebCore/platform/graphics/filters/FEConvolveMatrix.h
Source/WebCore/platform/graphics/filters/FEDisplacementMap.cpp
Source/WebCore/platform/graphics/filters/FEDisplacementMap.h
Source/WebCore/platform/graphics/filters/FEDropShadow.cpp
Source/WebCore/platform/graphics/filters/FEDropShadow.h
Source/WebCore/platform/graphics/filters/FEFlood.h
Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp
Source/WebCore/platform/graphics/filters/FEGaussianBlur.h
Source/WebCore/platform/graphics/filters/FELighting.cpp
Source/WebCore/platform/graphics/filters/FELighting.h
Source/WebCore/platform/graphics/filters/FEMerge.cpp
Source/WebCore/platform/graphics/filters/FEMerge.h
Source/WebCore/platform/graphics/filters/FEMorphology.cpp
Source/WebCore/platform/graphics/filters/FEMorphology.h
Source/WebCore/platform/graphics/filters/FEOffset.cpp
Source/WebCore/platform/graphics/filters/FEOffset.h
Source/WebCore/platform/graphics/filters/FETile.cpp
Source/WebCore/platform/graphics/filters/FETile.h
Source/WebCore/platform/graphics/filters/FETurbulence.cpp
Source/WebCore/platform/graphics/filters/FETurbulence.h
Source/WebCore/platform/graphics/filters/FilterEffect.cpp
Source/WebCore/platform/graphics/filters/FilterEffect.h
Source/WebCore/platform/graphics/filters/SourceAlpha.cpp
Source/WebCore/platform/graphics/filters/SourceAlpha.h
Source/WebCore/platform/graphics/filters/SourceGraphic.h
Source/WebCore/rendering/FilterEffectRenderer.cpp
Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp
Source/WebCore/rendering/svg/RenderSVGResourceFilter.h
Source/WebCore/svg/graphics/filters/SVGFEImage.h

index 4756c9b..41c59b9 100644 (file)
@@ -1,3 +1,107 @@
+2017-11-23  Simon Fraser  <simon.fraser@apple.com>
+
+        Some FilterEffect cleanup and logging
+        https://bugs.webkit.org/show_bug.cgi?id=179932
+
+        Reviewed by Darin Adler.
+        
+        Rename the FilterEffect functions that get the result of the filter
+        to have "result" in the name.
+        
+        Re-order FilterEffect member variables and use initializers. webkit.org/b/45614
+        is closed so remove the comment about things moving to RenderSVGResourceFilterPrimitive.
+        
+        Add a virtual filterName() function for use by logging.
+        
+        Add a Filters log channel. Log some stuff.
+        
+        Rename RenderSVGResourceFilter::m_filter to m_rendererFilterDataMap.
+
+        * platform/Logging.h:
+        * platform/graphics/cpu/arm/filters/FEBlendNEON.h:
+        (WebCore::FEBlend::platformApplySoftware):
+        * platform/graphics/filters/FEBlend.cpp:
+        (WebCore::FEBlend::platformApplySoftware):
+        * platform/graphics/filters/FEBlend.h:
+        * platform/graphics/filters/FEColorMatrix.cpp:
+        (WebCore::FEColorMatrix::platformApplySoftware):
+        * platform/graphics/filters/FEColorMatrix.h:
+        * platform/graphics/filters/FEComponentTransfer.cpp:
+        (WebCore::FEComponentTransfer::platformApplySoftware):
+        * platform/graphics/filters/FEComponentTransfer.h:
+        * platform/graphics/filters/FEComposite.cpp:
+        (WebCore::FEComposite::platformApplySoftware):
+        * platform/graphics/filters/FEComposite.h:
+        * platform/graphics/filters/FEConvolveMatrix.cpp:
+        (WebCore::FEConvolveMatrix::platformApplySoftware):
+        * platform/graphics/filters/FEConvolveMatrix.h:
+        * platform/graphics/filters/FEDisplacementMap.cpp:
+        (WebCore::FEDisplacementMap::platformApplySoftware):
+        * platform/graphics/filters/FEDisplacementMap.h:
+        * platform/graphics/filters/FEDropShadow.cpp:
+        (WebCore::FEDropShadow::platformApplySoftware):
+        * platform/graphics/filters/FEDropShadow.h:
+        * platform/graphics/filters/FEFlood.h:
+        * platform/graphics/filters/FEGaussianBlur.cpp:
+        (WebCore::FEGaussianBlur::platformApplySoftware):
+        * platform/graphics/filters/FEGaussianBlur.h:
+        * platform/graphics/filters/FELighting.cpp:
+        (WebCore::FELighting::platformApplySoftware):
+        * platform/graphics/filters/FELighting.h:
+        * platform/graphics/filters/FEMerge.cpp:
+        (WebCore::FEMerge::platformApplySoftware):
+        * platform/graphics/filters/FEMerge.h:
+        * platform/graphics/filters/FEMorphology.cpp:
+        (WebCore::FEMorphology::platformApplyDegenerate):
+        (WebCore::FEMorphology::platformApplySoftware):
+        * platform/graphics/filters/FEMorphology.h:
+        * platform/graphics/filters/FEOffset.cpp:
+        (WebCore::FEOffset::platformApplySoftware):
+        * platform/graphics/filters/FEOffset.h:
+        * platform/graphics/filters/FETile.cpp:
+        (WebCore::FETile::platformApplySoftware):
+        * platform/graphics/filters/FETile.h:
+        * platform/graphics/filters/FETurbulence.cpp:
+        (WebCore::operator<<):
+        * platform/graphics/filters/FETurbulence.h:
+        * platform/graphics/filters/FilterEffect.cpp:
+        (WebCore::FilterEffect::FilterEffect):
+        (WebCore::FilterEffect::imageBufferResult):
+        (WebCore::FilterEffect::unmultipliedResult):
+        (WebCore::FilterEffect::premultipliedResult):
+        (WebCore::FilterEffect::copyImageBytes const): This can be const. It'a also crazy
+        to mark a large, slow function like this as 'inline'.
+        (WebCore::FilterEffect::copyUnmultipliedResult):
+        (WebCore::FilterEffect::copyPremultipliedResult):
+        (WebCore::FilterEffect::createImageBufferResult):
+        (WebCore::FilterEffect::createUnmultipliedImageResult):
+        (WebCore::FilterEffect::createPremultipliedImageResult):
+        (WebCore::FilterEffect::transformResultColorSpace):
+        (WebCore::FilterEffect::asImageBuffer): Deleted.
+        (WebCore::FilterEffect::asUnmultipliedImage): Deleted.
+        (WebCore::FilterEffect::asPremultipliedImage): Deleted.
+        (WebCore::FilterEffect::copyImageBytes): Deleted.
+        (WebCore::FilterEffect::copyUnmultipliedImage): Deleted.
+        (WebCore::FilterEffect::copyPremultipliedImage): Deleted.
+        * platform/graphics/filters/FilterEffect.h:
+        * platform/graphics/filters/SourceAlpha.cpp:
+        (WebCore::SourceAlpha::platformApplySoftware):
+        * platform/graphics/filters/SourceAlpha.h:
+        * platform/graphics/filters/SourceGraphic.h:
+        * rendering/FilterEffectRenderer.cpp:
+        (WebCore::FilterEffectRenderer::output const):
+        * rendering/svg/RenderSVGResourceFilter.cpp:
+        (WebCore::RenderSVGResourceFilter::removeAllClientsFromCache):
+        (WebCore::RenderSVGResourceFilter::removeClientFromCache):
+        (WebCore::RenderSVGResourceFilter::applyResource):
+        (WebCore::RenderSVGResourceFilter::postApplyResource):
+        (WebCore::RenderSVGResourceFilter::primitiveAttributeChanged):
+        (WebCore::RenderSVGResourceFilter::drawingRegion const):
+        (WebCore::operator<<):
+        * rendering/svg/RenderSVGResourceFilter.h:
+        (WebCore::FilterData::FilterData): Deleted.
+        * svg/graphics/filters/SVGFEImage.h:
+
 2017-11-24  Antoine Quint  <graouts@apple.com>
 
         [Web Animations] Allow getComputedStyle() to return animated values for accelerated animations
index 651508b..8296a1e 100644 (file)
@@ -48,6 +48,7 @@ namespace WebCore {
     M(Editing) \
     M(Events) \
     M(FileAPI) \
+    M(Filters) \
     M(Frames) \
     M(FTP) \
     M(Fullscreen) \
index 50ec879..627577d 100644 (file)
@@ -116,10 +116,10 @@ void FEBlend::platformApplySoftware()
         return;
 
     IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
-    RefPtr<Uint8ClampedArray> srcPixelArrayA = in->asPremultipliedImage(effectADrawingRect);
+    RefPtr<Uint8ClampedArray> srcPixelArrayA = in->premultipliedResult(effectADrawingRect);
 
     IntRect effectBDrawingRect = requestedRegionOfInputImageData(in2->absolutePaintRect());
-    RefPtr<Uint8ClampedArray> srcPixelArrayB = in2->asPremultipliedImage(effectBDrawingRect);
+    RefPtr<Uint8ClampedArray> srcPixelArrayB = in2->premultipliedResult(effectBDrawingRect);
 
     unsigned pixelArrayLength = srcPixelArrayA->length();
     ASSERT(pixelArrayLength == srcPixelArrayB->length());
index 5cff439..219adc9 100644 (file)
@@ -65,8 +65,8 @@ void FEBlend::platformApplySoftware()
         return;
     GraphicsContext& filterContext = resultImage->context();
 
-    ImageBuffer* imageBuffer = in->asImageBuffer();
-    ImageBuffer* imageBuffer2 = in2->asImageBuffer();
+    ImageBuffer* imageBuffer = in->imageBufferResult();
+    ImageBuffer* imageBuffer2 = in2->imageBufferResult();
     if (!imageBuffer || !imageBuffer2)
         return;
 
index 0d634ff..1751bb8 100644 (file)
@@ -36,6 +36,8 @@ public:
     bool setBlendMode(BlendMode);
 
 private:
+    const char* filterName() const final { return "FEBlend"; }
+
     void platformApplySoftware() override;
     void platformApplyGeneric(unsigned char* srcPixelArrayA, unsigned char* srcPixelArrayB, unsigned char* dstPixelArray,
                            unsigned colorArrayLength);
index c44f09d..a408b75 100644 (file)
@@ -287,7 +287,7 @@ void FEColorMatrix::platformApplySoftware()
     MonotonicTime startTime = MonotonicTime::now();
 #endif
 
-    ImageBuffer* inBuffer = in->asImageBuffer();
+    ImageBuffer* inBuffer = in->imageBufferResult();
     if (inBuffer)
         resultImage->context().drawImageBuffer(*inBuffer, drawingRegionOfInputImage(in->absolutePaintRect()));
 
index 81b991f..2f6b5d3 100644 (file)
@@ -52,6 +52,8 @@ public:
 private:
     FEColorMatrix(Filter&, ColorMatrixType, const Vector<float>&);
 
+    const char* filterName() const final { return "FEColorMatrix"; }
+
     void platformApplySoftware() override;
 
     WTF::TextStream& externalRepresentation(WTF::TextStream&, int indention) const override;
index 329b460..7fa0aac 100644 (file)
@@ -120,7 +120,7 @@ void FEComponentTransfer::platformApplySoftware()
     computeLookupTables(redTable, greenTable, blueTable, alphaTable);
 
     IntRect drawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
-    in->copyUnmultipliedImage(pixelArray, drawingRect);
+    in->copyUnmultipliedResult(pixelArray, drawingRect);
 
     unsigned pixelArrayLength = pixelArray->length();
     uint8_t* data = pixelArray->data();
index e93a3b6..fc4a012 100644 (file)
@@ -65,6 +65,8 @@ private:
     FEComponentTransfer(Filter&, const ComponentTransferFunction& redFunc, const ComponentTransferFunction& greenFunc,
                         const ComponentTransferFunction& blueFunc, const ComponentTransferFunction& alphaFunc);
 
+     const char* filterName() const final { return "FEComponentTransfer"; }
+
     using LookupTable = std::array<uint8_t, 256>;
 
     static void computeIdentityTable(LookupTable&, const ComponentTransferFunction&);
index ec9181a..2328a83 100644 (file)
@@ -237,10 +237,10 @@ void FEComposite::platformApplySoftware()
             return;
 
         IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
-        RefPtr<Uint8ClampedArray> srcPixelArray = in->asPremultipliedImage(effectADrawingRect);
+        RefPtr<Uint8ClampedArray> srcPixelArray = in->premultipliedResult(effectADrawingRect);
 
         IntRect effectBDrawingRect = requestedRegionOfInputImageData(in2->absolutePaintRect());
-        in2->copyPremultipliedImage(dstPixelArray, effectBDrawingRect);
+        in2->copyPremultipliedResult(dstPixelArray, effectBDrawingRect);
 
         platformArithmeticSoftware(srcPixelArray.get(), dstPixelArray, m_k1, m_k2, m_k3, m_k4);
         return;
@@ -251,8 +251,8 @@ void FEComposite::platformApplySoftware()
         return;
     GraphicsContext& filterContext = resultImage->context();
 
-    ImageBuffer* imageBuffer = in->asImageBuffer();
-    ImageBuffer* imageBuffer2 = in2->asImageBuffer();
+    ImageBuffer* imageBuffer = in->imageBufferResult();
+    ImageBuffer* imageBuffer2 = in2->imageBufferResult();
     if (!imageBuffer || !imageBuffer2)
         return;
 
index e84ae16..1d17bdf 100644 (file)
@@ -64,6 +64,8 @@ protected:
 private:
     FEComposite(Filter&, const CompositeOperationType&, float, float, float, float);
 
+    const char* filterName() const final { return "FEComposite"; }
+
     void correctFilterResultIfNeeded() override;
     void determineAbsolutePaintRect() override;
 
index f6e57ea..be5c5ce 100644 (file)
@@ -384,9 +384,9 @@ void FEConvolveMatrix::platformApplySoftware()
 
     RefPtr<Uint8ClampedArray> srcPixelArray;
     if (m_preserveAlpha)
-        srcPixelArray = in->asUnmultipliedImage(effectDrawingRect);
+        srcPixelArray = in->unmultipliedResult(effectDrawingRect);
     else
-        srcPixelArray = in->asPremultipliedImage(effectDrawingRect);
+        srcPixelArray = in->premultipliedResult(effectDrawingRect);
 
     IntSize paintSize = absolutePaintRect().size();
     PaintingData paintingData;
index 86a8e18..96042e4 100644 (file)
@@ -80,6 +80,8 @@ private:
     FEConvolveMatrix(Filter&, const IntSize&, float, float,
             const IntPoint&, EdgeModeType, const FloatPoint&, bool, const Vector<float>&);
 
+    const char* filterName() const final { return "FEConvolveMatrix"; }
+
     void determineAbsolutePaintRect() override { setAbsolutePaintRect(enclosingIntRect(maxEffectRect())); }
 
     void platformApplySoftware() override;
index 6b408e9..f86f87a 100644 (file)
@@ -99,10 +99,10 @@ void FEDisplacementMap::platformApplySoftware()
         return;
 
     IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
-    RefPtr<Uint8ClampedArray> srcPixelArrayA = in->asPremultipliedImage(effectADrawingRect);
+    RefPtr<Uint8ClampedArray> srcPixelArrayA = in->premultipliedResult(effectADrawingRect);
 
     IntRect effectBDrawingRect = requestedRegionOfInputImageData(in2->absolutePaintRect());
-    RefPtr<Uint8ClampedArray> srcPixelArrayB = in2->asUnmultipliedImage(effectBDrawingRect);
+    RefPtr<Uint8ClampedArray> srcPixelArrayB = in2->unmultipliedResult(effectBDrawingRect);
 
     ASSERT(srcPixelArrayA->length() == srcPixelArrayB->length());
 
index dc15b1a..8086639 100644 (file)
@@ -54,6 +54,8 @@ public:
 private:
     FEDisplacementMap(Filter&, ChannelSelectorType xChannelSelector, ChannelSelectorType yChannelSelector, float);
 
+    const char* filterName() const final { return "FEDisplacementMap"; }
+
     void platformApplySoftware() override;
 
     void determineAbsolutePaintRect() override { setAbsolutePaintRect(enclosingIntRect(maxEffectRect())); }
index 8a16a09..32c426d 100644 (file)
@@ -86,7 +86,7 @@ void FEDropShadow::platformApplySoftware()
     FloatRect drawingRegionWithOffset(drawingRegion);
     drawingRegionWithOffset.move(offset);
 
-    ImageBuffer* sourceImage = in->asImageBuffer();
+    ImageBuffer* sourceImage = in->imageBufferResult();
     if (!sourceImage)
         return;
 
index 4bd5225..31ed26b 100644 (file)
@@ -50,6 +50,8 @@ public:
 private:
     FEDropShadow(Filter&, float, float, float, float, const Color&, float);
 
+    const char* filterName() const final { return "FEDropShadow"; }
+
     void platformApplySoftware() override;
 
     void determineAbsolutePaintRect() override;
index 935cc36..5b78f64 100644 (file)
@@ -47,6 +47,8 @@ public:
 private:
     FEFlood(Filter&, const Color&, float);
 
+    const char* filterName() const final { return "FEFlood"; }
+
     void platformApplySoftware() override;
 
     void determineAbsolutePaintRect() override { setAbsolutePaintRect(enclosingIntRect(maxEffectRect())); }
index 0fa19a5..1d8a208 100644 (file)
@@ -524,7 +524,7 @@ void FEGaussianBlur::platformApplySoftware()
     setIsAlphaImage(in->isAlphaImage());
 
     IntRect effectDrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
-    in->copyPremultipliedImage(srcPixelArray, effectDrawingRect);
+    in->copyPremultipliedResult(srcPixelArray, effectDrawingRect);
 
     if (!m_stdX && !m_stdY)
         return;
index d4bb726..08a0911 100644 (file)
@@ -46,6 +46,8 @@ public:
 private:
     FEGaussianBlur(Filter&, float, float, EdgeModeType);
 
+    const char* filterName() const final { return "FEGaussianBlur"; }
+
     static const int s_minimalRectDimension = 100 * 100; // Empirical data limit for parallel jobs
 
     template<typename Type>
index 6e14064..d9d3582 100644 (file)
@@ -473,7 +473,7 @@ void FELighting::platformApplySoftware()
     setIsAlphaImage(false);
 
     IntRect effectDrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
-    in->copyPremultipliedImage(srcPixelArray, effectDrawingRect);
+    in->copyPremultipliedResult(srcPixelArray, effectDrawingRect);
 
     // FIXME: support kernelUnitLengths other than (1,1). The issue here is that the W3
     // standard has no test case for them, and other browsers (like Firefox) has strange
index 3e1ef0a..1832b70 100644 (file)
@@ -133,6 +133,8 @@ protected:
 
     FELighting(Filter&, LightingType, const Color&, float, float, float, float, float, float, Ref<LightSource>&&);
 
+    const char* filterName() const final { return "FELighting"; }
+
     bool drawLighting(Uint8ClampedArray*, int, int);
 
     void setPixel(int offset, const LightingData&, const LightSource::PaintingData&, int x, int y, float factorX, float factorY, IntSize normalVector);
index 5c8c669..177417c 100644 (file)
@@ -51,7 +51,7 @@ void FEMerge::platformApplySoftware()
     GraphicsContext& filterContext = resultImage->context();
     for (unsigned i = 0; i < size; ++i) {
         FilterEffect* in = inputEffect(i);
-        if (ImageBuffer* inBuffer = in->asImageBuffer())
+        if (ImageBuffer* inBuffer = in->imageBufferResult())
             filterContext.drawImageBuffer(*inBuffer, drawingRegionOfInputImage(in->absolutePaintRect()));
     }
 }
index 2614f1d..7b0e082 100644 (file)
@@ -33,6 +33,8 @@ public:
 private:
     FEMerge(Filter&);
 
+    const char* filterName() const final { return "FEMerge"; }
+
     void platformApplySoftware() override;
 
     WTF::TextStream& externalRepresentation(WTF::TextStream&, int indention) const override;
index 4e23474..f957950 100644 (file)
@@ -204,7 +204,7 @@ bool FEMorphology::platformApplyDegenerate(Uint8ClampedArray* dstPixelArray, con
     // Input radius is equal to zero or the scaled radius is less than one.
     if (!m_radiusX || !m_radiusY) {
         FilterEffect* in = inputEffect(0);
-        in->copyPremultipliedImage(dstPixelArray, imageRect);
+        in->copyPremultipliedResult(dstPixelArray, imageRect);
         return true;
     }
 
@@ -226,7 +226,7 @@ void FEMorphology::platformApplySoftware()
         return;
 
     Filter& filter = this->filter();
-    RefPtr<Uint8ClampedArray> srcPixelArray = in->asPremultipliedImage(effectDrawingRect);
+    RefPtr<Uint8ClampedArray> srcPixelArray = in->premultipliedResult(effectDrawingRect);
     int radiusX = static_cast<int>(floorf(filter.applyHorizontalScale(m_radiusX)));
     int radiusY = static_cast<int>(floorf(filter.applyVerticalScale(m_radiusY)));
     radiusX = std::min(effectDrawingRect.width() - 1, radiusX);
index 25a7839..211127a 100644 (file)
@@ -49,6 +49,8 @@ public:
 private:
     FEMorphology(Filter&, MorphologyOperatorType, float radiusX, float radiusY);
 
+    const char* filterName() const final { return "FEMorphology"; }
+
     void platformApplySoftware() override;
 
     void determineAbsolutePaintRect() override;
index 623b8b3..fe3d683 100644 (file)
@@ -69,7 +69,7 @@ void FEOffset::platformApplySoftware()
     FilterEffect* in = inputEffect(0);
 
     ImageBuffer* resultImage = createImageBufferResult();
-    ImageBuffer* inBuffer = in->asImageBuffer();
+    ImageBuffer* inBuffer = in->imageBufferResult();
     if (!resultImage || !inBuffer)
         return;
 
index fc1531d..4f69483 100644 (file)
@@ -39,6 +39,8 @@ public:
 private:
     FEOffset(Filter&, float dx, float dy);
 
+    const char* filterName() const final { return "FEOffset"; }
+
     void platformApplySoftware() override;
     
     void determineAbsolutePaintRect() override;
index 1efa17f..7bb8eb1 100644 (file)
@@ -47,7 +47,7 @@ void FETile::platformApplySoftware()
     FilterEffect* in = inputEffect(0);
 
     ImageBuffer* resultImage = createImageBufferResult();
-    ImageBuffer* inBuffer = in->asImageBuffer();
+    ImageBuffer* inBuffer = in->imageBufferResult();
     if (!resultImage || !inBuffer)
         return;
 
index 256a615..5017c9c 100644 (file)
@@ -33,6 +33,8 @@ public:
 private:
     FETile(Filter&);
 
+    const char* filterName() const final { return "FETile"; }
+
     FilterEffectType filterEffectType() const override { return FilterEffectTypeTile; }
 
     void platformApplySoftware() override;
index 2d0b62c..282de29 100644 (file)
@@ -451,7 +451,7 @@ void FETurbulence::platformApplySoftware()
     fillRegion(pixelArray, paintingData, stitchData, 0, height);
 }
 
-static TextStream& operator<<(TextStream& ts, const TurbulenceType& type)
+static TextStream& operator<<(TextStream& ts, TurbulenceType type)
 {
     switch (type) {
     case TurbulenceType::Unknown:
index 93c52b8..aebddaa 100644 (file)
@@ -108,6 +108,8 @@ private:
 
     FETurbulence(Filter&, TurbulenceType, float, float, int, float, bool);
 
+    const char* filterName() const final { return "FETurbulence"; }
+
     void platformApplySoftware() override;
     void determineAbsolutePaintRect() override { setAbsolutePaintRect(enclosingIntRect(maxEffectRect())); }
     WTF::TextStream& externalRepresentation(WTF::TextStream&, int indention) const override;
index a70534d..80257dc 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "Filter.h"
 #include "ImageBuffer.h"
+#include "Logging.h"
 #include <runtime/JSCInlines.h>
 #include <runtime/TypedArrayInlines.h>
 #include <runtime/Uint8ClampedArray.h>
 namespace WebCore {
 
 FilterEffect::FilterEffect(Filter& filter)
-    : m_alphaImage(false)
-    , m_filter(filter)
-    , m_hasX(false)
-    , m_hasY(false)
-    , m_hasWidth(false)
-    , m_hasHeight(false)
-    , m_clipsToBounds(true)
-    , m_operatingColorSpace(ColorSpaceLinearRGB)
-    , m_resultColorSpace(ColorSpaceSRGB)
+    : m_filter(filter)
 {
 }
 
@@ -216,12 +209,16 @@ void FilterEffect::clearResultsRecursive()
         m_inputEffects.at(i).get()->clearResultsRecursive();
 }
 
-ImageBuffer* FilterEffect::asImageBuffer()
+ImageBuffer* FilterEffect::imageBufferResult()
 {
+    LOG_WITH_STREAM(Filters, stream << "FilterEffect " << filterName() << " " << this << " imageBufferResult(). Existing image buffer " << m_imageBufferResult.get() <<  " m_premultipliedImageResult " << m_premultipliedImageResult.get() << " m_unmultipliedImageResult " << m_unmultipliedImageResult.get());
+
     if (!hasResult())
         return nullptr;
+
     if (m_imageBufferResult)
         return m_imageBufferResult.get();
+
     m_imageBufferResult = ImageBuffer::create(m_absolutePaintRect.size(), m_filter.renderingMode(), m_filter.filterScale(), m_resultColorSpace);
     if (!m_imageBufferResult)
         return nullptr;
@@ -234,27 +231,27 @@ ImageBuffer* FilterEffect::asImageBuffer()
     return m_imageBufferResult.get();
 }
 
-RefPtr<Uint8ClampedArray> FilterEffect::asUnmultipliedImage(const IntRect& rect)
+RefPtr<Uint8ClampedArray> FilterEffect::unmultipliedResult(const IntRect& rect)
 {
     IntSize scaledSize(rect.size());
     ASSERT(!ImageBuffer::sizeNeedsClamping(scaledSize));
     scaledSize.scale(m_filter.filterScale());
     auto imageData = Uint8ClampedArray::createUninitialized((scaledSize.area() * 4).unsafeGet());
-    copyUnmultipliedImage(imageData.get(), rect);
+    copyUnmultipliedResult(imageData.get(), rect);
     return imageData;
 }
 
-RefPtr<Uint8ClampedArray> FilterEffect::asPremultipliedImage(const IntRect& rect)
+RefPtr<Uint8ClampedArray> FilterEffect::premultipliedResult(const IntRect& rect)
 {
     IntSize scaledSize(rect.size());
     ASSERT(!ImageBuffer::sizeNeedsClamping(scaledSize));
     scaledSize.scale(m_filter.filterScale());
     auto imageData = Uint8ClampedArray::createUninitialized((scaledSize.area() * 4).unsafeGet());
-    copyPremultipliedImage(imageData.get(), rect);
+    copyPremultipliedResult(imageData.get(), rect);
     return imageData;
 }
 
-inline void FilterEffect::copyImageBytes(Uint8ClampedArray* source, Uint8ClampedArray* destination, const IntRect& rect)
+void FilterEffect::copyImageBytes(Uint8ClampedArray* source, Uint8ClampedArray* destination, const IntRect& rect) const
 {
     IntRect scaledRect(rect);
     scaledRect.scale(m_filter.filterScale());
@@ -381,9 +378,11 @@ static void copyUnpremultiplyingAlpha(const Uint8ClampedArray* source, Uint8Clam
 #endif
 }
 
-void FilterEffect::copyUnmultipliedImage(Uint8ClampedArray* destination, const IntRect& rect)
+void FilterEffect::copyUnmultipliedResult(Uint8ClampedArray* destination, const IntRect& rect)
 {
     ASSERT(hasResult());
+    
+    LOG_WITH_STREAM(Filters, stream << "FilterEffect " << filterName() << " " << this << " copyUnmultipliedResult(). Existing image buffer " << m_imageBufferResult.get() <<  " m_premultipliedImageResult " << m_premultipliedImageResult.get() << " m_unmultipliedImageResult " << m_unmultipliedImageResult.get());
 
     if (!m_unmultipliedImageResult) {
         // We prefer a conversion from the image buffer.
@@ -395,7 +394,7 @@ void FilterEffect::copyUnmultipliedImage(Uint8ClampedArray* destination, const I
             inputSize.scale(m_filter.filterScale());
             m_unmultipliedImageResult = Uint8ClampedArray::createUninitialized((inputSize.area() * 4).unsafeGet());
             if (!m_unmultipliedImageResult) {
-                WTFLogAlways("FilterEffect::copyUnmultipliedImage Unable to create buffer. Requested size was %d x %d\n", inputSize.width(), inputSize.height());
+                WTFLogAlways("FilterEffect::copyUnmultipliedResult Unable to create buffer. Requested size was %d x %d\n", inputSize.width(), inputSize.height());
                 return;
             }
             
@@ -405,10 +404,12 @@ void FilterEffect::copyUnmultipliedImage(Uint8ClampedArray* destination, const I
     copyImageBytes(m_unmultipliedImageResult.get(), destination, rect);
 }
 
-void FilterEffect::copyPremultipliedImage(Uint8ClampedArray* destination, const IntRect& rect)
+void FilterEffect::copyPremultipliedResult(Uint8ClampedArray* destination, const IntRect& rect)
 {
     ASSERT(hasResult());
 
+    LOG_WITH_STREAM(Filters, stream << "FilterEffect " << filterName() << " " << this << " copyPremultipliedResult(). Existing image buffer " << m_imageBufferResult.get() <<  " m_premultipliedImageResult " << m_premultipliedImageResult.get() << " m_unmultipliedImageResult " << m_unmultipliedImageResult.get());
+
     if (!m_premultipliedImageResult) {
         // We prefer a conversion from the image buffer.
         if (m_imageBufferResult)
@@ -419,7 +420,7 @@ void FilterEffect::copyPremultipliedImage(Uint8ClampedArray* destination, const
             inputSize.scale(m_filter.filterScale());
             m_premultipliedImageResult = Uint8ClampedArray::createUninitialized((inputSize.area() * 4).unsafeGet());
             if (!m_premultipliedImageResult) {
-                WTFLogAlways("FilterEffect::copyPremultipliedImage Unable to create buffer. Requested size was %d x %d\n", inputSize.width(), inputSize.height());
+                WTFLogAlways("FilterEffect::copyPremultipliedResult Unable to create buffer. Requested size was %d x %d\n", inputSize.width(), inputSize.height());
                 return;
             }
             
@@ -431,6 +432,8 @@ void FilterEffect::copyPremultipliedImage(Uint8ClampedArray* destination, const
 
 ImageBuffer* FilterEffect::createImageBufferResult()
 {
+    LOG(Filters, "FilterEffect %s %p createImageBufferResult", filterName(), this);
+
     // Only one result type is allowed.
     ASSERT(!hasResult());
     if (m_absolutePaintRect.isEmpty())
@@ -446,6 +449,8 @@ ImageBuffer* FilterEffect::createImageBufferResult()
 
 Uint8ClampedArray* FilterEffect::createUnmultipliedImageResult()
 {
+    LOG(Filters, "FilterEffect %s %p createUnmultipliedImageResult", filterName(), this);
+
     // Only one result type is allowed.
     ASSERT(!hasResult());
     if (m_absolutePaintRect.isEmpty())
@@ -460,6 +465,8 @@ Uint8ClampedArray* FilterEffect::createUnmultipliedImageResult()
 
 Uint8ClampedArray* FilterEffect::createPremultipliedImageResult()
 {
+    LOG(Filters, "FilterEffect %s %p createPremultipliedImageResult", filterName(), this);
+
     // Only one result type is allowed.
     ASSERT(!hasResult());
     if (m_absolutePaintRect.isEmpty())
@@ -483,7 +490,7 @@ void FilterEffect::transformResultColorSpace(ColorSpace dstColorSpace)
 
     // FIXME: We can avoid this potentially unnecessary ImageBuffer conversion by adding
     // color space transform support for the {pre,un}multiplied arrays.
-    asImageBuffer()->transformColorSpace(m_resultColorSpace, dstColorSpace);
+    imageBufferResult()->transformColorSpace(m_resultColorSpace, dstColorSpace);
 
     m_resultColorSpace = dstColorSpace;
 
index b000625..8752e7d 100644 (file)
@@ -19,8 +19,7 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#ifndef FilterEffect_h
-#define FilterEffect_h
+#pragma once
 
 #include "ColorSpace.h"
 #include "FloatRect.h"
@@ -57,11 +56,11 @@ public:
     void clearResult();
     void clearResultsRecursive();
 
-    ImageBuffer* asImageBuffer();
-    RefPtr<Uint8ClampedArray> asUnmultipliedImage(const IntRect&);
-    RefPtr<Uint8ClampedArray> asPremultipliedImage(const IntRect&);
-    void copyUnmultipliedImage(Uint8ClampedArray* destination, const IntRect&);
-    void copyPremultipliedImage(Uint8ClampedArray* destination, const IntRect&);
+    ImageBuffer* imageBufferResult();
+    RefPtr<Uint8ClampedArray> unmultipliedResult(const IntRect&);
+    RefPtr<Uint8ClampedArray> premultipliedResult(const IntRect&);
+    void copyUnmultipliedResult(Uint8ClampedArray* destination, const IntRect&);
+    void copyPremultipliedResult(Uint8ClampedArray* destination, const IntRect&);
 
 #if ENABLE(OPENCL)
     OpenCLHandle openCLImage() { return m_openCLImageResult; }
@@ -116,7 +115,6 @@ public:
 
     virtual WTF::TextStream& externalRepresentation(WTF::TextStream&, int indention = 0) const;
 
-public:
     // The following functions are SVG specific and will move to RenderSVGResourceFilterPrimitive.
     // See bug https://bugs.webkit.org/show_bug.cgi?id=45614.
     bool hasX() const { return m_hasX; }
@@ -153,6 +151,8 @@ public:
 
 protected:
     FilterEffect(Filter&);
+    
+    virtual const char* filterName() const = 0;
 
     ImageBuffer* createImageBufferResult();
     Uint8ClampedArray* createUnmultipliedImageResult();
@@ -181,29 +181,24 @@ protected:
 private:
     virtual void platformApplySoftware() = 0;
 
+    void copyImageBytes(Uint8ClampedArray* source, Uint8ClampedArray* destination, const IntRect&) const;
+
+    Filter& m_filter;
+    FilterEffectVector m_inputEffects;
+
     std::unique_ptr<ImageBuffer> m_imageBufferResult;
     RefPtr<Uint8ClampedArray> m_unmultipliedImageResult;
     RefPtr<Uint8ClampedArray> m_premultipliedImageResult;
-    FilterEffectVector m_inputEffects;
 #if ENABLE(OPENCL)
     OpenCLHandle m_openCLImageResult;
 #endif
 
-    bool m_alphaImage;
-
     IntRect m_absolutePaintRect;
     
     // The maximum size of a filter primitive. In SVG this is the primitive subregion in absolute coordinate space.
     // The absolute paint rect should never be bigger than m_maxEffectRect.
     FloatRect m_maxEffectRect;
-    Filter& m_filter;
     
-private:
-    inline void copyImageBytes(Uint8ClampedArray* source, Uint8ClampedArray* destination, const IntRect&);
-
-    // The following member variables are SVG specific and will move to RenderSVGResourceFilterPrimitive.
-    // See bug https://bugs.webkit.org/show_bug.cgi?id=45614.
-
     // The subregion of a filter primitive according to the SVG Filter specification in local coordinates.
     // This is SVG specific and needs to move to RenderSVGResourceFilterPrimitive.
     FloatRect m_filterPrimitiveSubregion;
@@ -211,18 +206,19 @@ private:
     // x, y, width and height of the actual SVGFE*Element. Is needed to determine the subregion of the
     // filter primitive on a later step.
     FloatRect m_effectBoundaries;
-    bool m_hasX;
-    bool m_hasY;
-    bool m_hasWidth;
-    bool m_hasHeight;
+
+    bool m_alphaImage { false };
+    bool m_hasX { false };
+    bool m_hasY { false };
+    bool m_hasWidth { false };
+    bool m_hasHeight { false };
 
     // Should the effect clip to its primitive region, or expand to use the combined region of its inputs.
-    bool m_clipsToBounds;
+    bool m_clipsToBounds { true };
 
-    ColorSpace m_operatingColorSpace;
-    ColorSpace m_resultColorSpace;
+    ColorSpace m_operatingColorSpace { ColorSpaceLinearRGB };
+    ColorSpace m_resultColorSpace { ColorSpaceSRGB };
 };
 
 } // namespace WebCore
 
-#endif // FilterEffect_h
index 89d6765..66258a0 100644 (file)
@@ -54,7 +54,7 @@ void SourceAlpha::platformApplySoftware()
         return;
     GraphicsContext& filterContext = resultImage->context();
 
-    ImageBuffer* imageBuffer = inputEffect(0)->asImageBuffer();
+    ImageBuffer* imageBuffer = inputEffect(0)->imageBufferResult();
     if (!imageBuffer)
         return;
 
index cec7a05..1df0e91 100644 (file)
@@ -34,6 +34,8 @@ private:
     explicit SourceAlpha(FilterEffect&);
     FilterEffectType filterEffectType() const override { return FilterEffectTypeSourceInput; }
 
+    const char* filterName() const final { return "SourceAlpha"; }
+
     void platformApplySoftware() override;
     void determineAbsolutePaintRect() override;
     WTF::TextStream& externalRepresentation(WTF::TextStream&, int indention) const override;
index 62c5da7..38360cd 100644 (file)
@@ -39,6 +39,8 @@ private:
         setOperatingColorSpace(ColorSpaceSRGB);
     }
 
+    const char* filterName() const final { return "SourceGraphic"; }
+
     void determineAbsolutePaintRect() override;
     void platformApplySoftware() override;
     WTF::TextStream& externalRepresentation(WTF::TextStream&, int indention) const override;
index f8bb0c1..48dde9c 100644 (file)
@@ -363,7 +363,7 @@ LayoutRect FilterEffectRenderer::computeSourceImageRectForDirtyRect(const Layout
 
 ImageBuffer* FilterEffectRenderer::output() const
 {
-    return m_effects.last()->asImageBuffer();
+    return m_effects.last()->imageBufferResult();
 }
 
 void FilterEffectRenderer::setMaxEffectRects(const FloatRect& effectRect)
index 3711783..2594c1d 100644 (file)
@@ -32,6 +32,7 @@
 #include "Image.h"
 #include "ImageData.h"
 #include "IntRect.h"
+#include "Logging.h"
 #include "RenderSVGResourceFilterPrimitive.h"
 #include "RenderView.h"
 #include "SVGFilterPrimitiveStandardAttributes.h"
@@ -40,6 +41,7 @@
 #include "Settings.h"
 #include "SourceGraphic.h"
 #include <wtf/IsoMallocInlines.h>
+#include <wtf/text/TextStream.h>
 
 namespace WebCore {
 
@@ -54,18 +56,24 @@ RenderSVGResourceFilter::~RenderSVGResourceFilter() = default;
 
 void RenderSVGResourceFilter::removeAllClientsFromCache(bool markForInvalidation)
 {
-    m_filter.clear();
+    LOG(Filters, "RenderSVGResourceFilter %p removeAllClientsFromCache", this);
+
+    m_rendererFilterDataMap.clear();
 
     markAllClientsForInvalidation(markForInvalidation ? LayoutAndBoundariesInvalidation : ParentOnlyInvalidation);
 }
 
 void RenderSVGResourceFilter::removeClientFromCache(RenderElement& client, bool markForInvalidation)
 {
-    if (FilterData* filterData = m_filter.get(&client)) {
-        if (filterData->savedContext)
-            filterData->state = FilterData::MarkedForRemoval;
+    LOG(Filters, "RenderSVGResourceFilter %p removing client %p", this, &client);
+    
+    auto findResult = m_rendererFilterDataMap.find(&client);
+    if (findResult != m_rendererFilterDataMap.end()) {
+        FilterData& filterData = *findResult->value;
+        if (filterData.savedContext)
+            filterData.state = FilterData::MarkedForRemoval;
         else
-            m_filter.remove(&client);
+            m_rendererFilterDataMap.remove(findResult);
     }
 
     markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidation : ParentOnlyInvalidation);
@@ -102,8 +110,10 @@ bool RenderSVGResourceFilter::applyResource(RenderElement& renderer, const Rende
     ASSERT(context);
     ASSERT_UNUSED(resourceMode, resourceMode == RenderSVGResourceMode::ApplyToDefault);
 
-    if (m_filter.contains(&renderer)) {
-        FilterData* filterData = m_filter.get(&renderer);
+    LOG(Filters, "RenderSVGResourceFilter %p applyResource renderer %p", this, &renderer);
+
+    if (m_rendererFilterDataMap.contains(&renderer)) {
+        FilterData* filterData = m_rendererFilterDataMap.get(&renderer);
         if (filterData->state == FilterData::PaintingSource || filterData->state == FilterData::Applying)
             filterData->state = FilterData::CycleDetected;
         return false; // Already built, or we're in a cycle, or we're marked for removal. Regardless, just do nothing more now.
@@ -175,9 +185,9 @@ bool RenderSVGResourceFilter::applyResource(RenderElement& renderer, const Rende
     // If the drawingRegion is empty, we have something like <g filter=".."/>.
     // Even if the target objectBoundingBox() is empty, we still have to draw the last effect result image in postApplyResource.
     if (filterData->drawingRegion.isEmpty()) {
-        ASSERT(!m_filter.contains(&renderer));
+        ASSERT(!m_rendererFilterDataMap.contains(&renderer));
         filterData->savedContext = context;
-        m_filter.set(&renderer, WTFMove(filterData));
+        m_rendererFilterDataMap.set(&renderer, WTFMove(filterData));
         return false;
     }
 
@@ -189,9 +199,9 @@ bool RenderSVGResourceFilter::applyResource(RenderElement& renderer, const Rende
     RenderingMode renderingMode = renderer.settings().acceleratedFiltersEnabled() ? Accelerated : Unaccelerated;
     auto sourceGraphic = SVGRenderingContext::createImageBuffer(filterData->drawingRegion, effectiveTransform, ColorSpaceLinearRGB, renderingMode);
     if (!sourceGraphic) {
-        ASSERT(!m_filter.contains(&renderer));
+        ASSERT(!m_rendererFilterDataMap.contains(&renderer));
         filterData->savedContext = context;
-        m_filter.set(&renderer, WTFMove(filterData));
+        m_rendererFilterDataMap.set(&renderer, WTFMove(filterData));
         return false;
     }
     
@@ -205,8 +215,8 @@ bool RenderSVGResourceFilter::applyResource(RenderElement& renderer, const Rende
 
     context = &sourceGraphicContext;
 
-    ASSERT(!m_filter.contains(&renderer));
-    m_filter.set(&renderer, WTFMove(filterData));
+    ASSERT(!m_rendererFilterDataMap.contains(&renderer));
+    m_rendererFilterDataMap.set(&renderer, WTFMove(filterData));
 
     return true;
 }
@@ -216,13 +226,17 @@ void RenderSVGResourceFilter::postApplyResource(RenderElement& renderer, Graphic
     ASSERT(context);
     ASSERT_UNUSED(resourceMode, resourceMode == RenderSVGResourceMode::ApplyToDefault);
 
-    FilterData* filterData = m_filter.get(&renderer);
-    if (!filterData)
+    auto findResult = m_rendererFilterDataMap.find(&renderer);
+    if (findResult == m_rendererFilterDataMap.end())
         return;
 
-    switch (filterData->state) {
+    FilterData& filterData = *findResult->value;
+
+    LOG_WITH_STREAM(Filters, stream << "\nRenderSVGResourceFilter " << this << " postApplyResource - renderer " << &renderer << " filter state " << filterData.state);
+
+    switch (filterData.state) {
     case FilterData::MarkedForRemoval:
-        m_filter.remove(&renderer);
+        m_rendererFilterDataMap.remove(findResult);
         return;
 
     case FilterData::CycleDetected:
@@ -231,52 +245,53 @@ void RenderSVGResourceFilter::postApplyResource(RenderElement& renderer, Graphic
         // This can occur due to FeImage referencing a source that makes use of the FEImage itself.
         // This is the first place we've hit the cycle, so set the state back to PaintingSource so the return stack
         // will continue correctly.
-        filterData->state = FilterData::PaintingSource;
+        filterData.state = FilterData::PaintingSource;
         return;
 
     case FilterData::PaintingSource:
-        if (!filterData->savedContext) {
+        if (!filterData.savedContext) {
             removeClientFromCache(renderer);
             return;
         }
 
-        context = filterData->savedContext;
-        filterData->savedContext = 0;
+        context = filterData.savedContext;
+        filterData.savedContext = nullptr;
         break;
 
-    case FilterData::Built: { } // Empty
+    case FilterData::Built:
+        break;
     }
 
-    FilterEffect* lastEffect = filterData->builder->lastEffect();
+    FilterEffect* lastEffect = filterData.builder->lastEffect();
 
-    if (lastEffect && !filterData->boundaries.isEmpty() && !lastEffect->filterPrimitiveSubregion().isEmpty()) {
+    if (lastEffect && !filterData.boundaries.isEmpty() && !lastEffect->filterPrimitiveSubregion().isEmpty()) {
         // This is the real filtering of the object. It just needs to be called on the
         // initial filtering process. We just take the stored filter result on a
         // second drawing.
-        if (filterData->state != FilterData::Built)
-            filterData->filter->setSourceImage(WTFMove(filterData->sourceGraphicBuffer));
+        if (filterData.state != FilterData::Built)
+            filterData.filter->setSourceImage(WTFMove(filterData.sourceGraphicBuffer));
 
         // Always true if filterData is just built (filterData->state == FilterData::Built).
         if (!lastEffect->hasResult()) {
-            filterData->state = FilterData::Applying;
+            filterData.state = FilterData::Applying;
             lastEffect->applyAll();
             lastEffect->correctFilterResultIfNeeded();
             lastEffect->transformResultColorSpace(ColorSpaceDeviceRGB);
         }
-        filterData->state = FilterData::Built;
+        filterData.state = FilterData::Built;
 
-        ImageBuffer* resultImage = lastEffect->asImageBuffer();
+        ImageBuffer* resultImage = lastEffect->imageBufferResult();
         if (resultImage) {
-            context->concatCTM(filterData->shearFreeAbsoluteTransform.inverse().value_or(AffineTransform()));
+            context->concatCTM(filterData.shearFreeAbsoluteTransform.inverse().value_or(AffineTransform()));
 
-            context->scale(FloatSize(1 / filterData->filter->filterResolution().width(), 1 / filterData->filter->filterResolution().height()));
+            context->scale(FloatSize(1 / filterData.filter->filterResolution().width(), 1 / filterData.filter->filterResolution().height()));
             context->drawImageBuffer(*resultImage, lastEffect->absolutePaintRect());
-            context->scale(filterData->filter->filterResolution());
+            context->scale(filterData.filter->filterResolution());
 
-            context->concatCTM(filterData->shearFreeAbsoluteTransform);
+            context->concatCTM(filterData.shearFreeAbsoluteTransform);
         }
     }
-    filterData->sourceGraphicBuffer.reset();
+    filterData.sourceGraphicBuffer.reset();
 }
 
 FloatRect RenderSVGResourceFilter::resourceBoundingBox(const RenderObject& object)
@@ -288,7 +303,9 @@ void RenderSVGResourceFilter::primitiveAttributeChanged(RenderObject* object, co
 {
     SVGFilterPrimitiveStandardAttributes* primitve = static_cast<SVGFilterPrimitiveStandardAttributes*>(object->node());
 
-    for (const auto& objectFilterDataPair : m_filter) {
+    LOG(Filters, "RenderSVGResourceFilter %p primitiveAttributeChanged renderer %p", this, object);
+
+    for (const auto& objectFilterDataPair : m_rendererFilterDataMap) {
         const auto& filterData = objectFilterDataPair.value;
         if (filterData->state != FilterData::Built)
             continue;
@@ -311,8 +328,30 @@ void RenderSVGResourceFilter::primitiveAttributeChanged(RenderObject* object, co
 
 FloatRect RenderSVGResourceFilter::drawingRegion(RenderObject* object) const
 {
-    FilterData* filterData = m_filter.get(object);
+    FilterData* filterData = m_rendererFilterDataMap.get(object);
     return filterData ? filterData->drawingRegion : FloatRect();
 }
 
+TextStream& operator<<(TextStream& ts, FilterData::FilterDataState state)
+{
+    switch (state) {
+    case FilterData::PaintingSource:
+        ts << "painting source";
+        break;
+    case FilterData::Applying:
+        ts << "applying";
+        break;
+    case FilterData::Built:
+        ts << "built";
+        break;
+    case FilterData::CycleDetected:
+        ts << "cycle detected";
+        break;
+    case FilterData::MarkedForRemoval:
+        ts << "marked for removal";
+        break;
+    }
+    return ts;
 }
+
+} // namespace WebCore
index 8310ddf..319c5ee 100644 (file)
@@ -39,21 +39,17 @@ struct FilterData {
 public:
     enum FilterDataState { PaintingSource, Applying, Built, CycleDetected, MarkedForRemoval };
 
-    FilterData()
-        : savedContext(0)
-        , state(PaintingSource)
-    {
-    }
+    FilterData() = default;
 
     RefPtr<SVGFilter> filter;
     std::unique_ptr<SVGFilterBuilder> builder;
     std::unique_ptr<ImageBuffer> sourceGraphicBuffer;
-    GraphicsContext* savedContext;
+    GraphicsContext* savedContext { nullptr };
     AffineTransform shearFreeAbsoluteTransform;
     FloatRect boundaries;
     FloatRect drawingRegion;
     FloatSize scale;
-    FilterDataState state;
+    FilterDataState state { PaintingSource };
 };
 
 class GraphicsContext;
@@ -90,9 +86,11 @@ private:
     const char* renderName() const override { return "RenderSVGResourceFilter"; }
     bool isSVGResourceFilter() const override { return true; }
 
-    HashMap<RenderObject*, std::unique_ptr<FilterData>> m_filter;
+    HashMap<RenderObject*, std::unique_ptr<FilterData>> m_rendererFilterDataMap;
 };
 
+WTF::TextStream& operator<<(WTF::TextStream&, FilterData::FilterDataState);
+
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::RenderSVGResourceFilter)
index ba342f2..7bc272b 100644 (file)
@@ -40,6 +40,9 @@ private:
     virtual ~FEImage() = default;
     FEImage(Filter&, RefPtr<Image>, const SVGPreserveAspectRatioValue&);
     FEImage(Filter&, Document&, const String&, const SVGPreserveAspectRatioValue&);
+
+    const char* filterName() const final { return "FEImage"; }
+
     FilterEffectType filterEffectType() const final { return FilterEffectTypeImage; }
 
     RenderElement* referencedRenderer() const;