Diff
Modified: trunk/Source/WebCore/ChangeLog (285915 => 285916)
--- trunk/Source/WebCore/ChangeLog 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/ChangeLog 2021-11-17 06:24:11 UTC (rev 285916)
@@ -1,3 +1,97 @@
+2021-11-16 Said Abou-Hallawa <[email protected]>
+
+ [GPU Process] Build a postfix _expression_ for applying the FilterEffects of the SVGFilter
+ https://bugs.webkit.org/show_bug.cgi?id=233214
+
+ Reviewed by Cameron McCormack.
+
+ The goal of building this _expression_ is to have all inputs of each
+ FilterEffect be applied before applying it. This will eliminate the need
+ to do recursive applying in FilterEffect::apply(). And it will also
+ eliminate the need to store the rectangle of the result of FilterEffect.
+ Once the absolutePaintRect is calculated, the result image can be created.
+
+ Filter::apply() and FilterEffect::apply() should return a boolean so the
+ caller knows that applying the filter function was not successful.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * 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.cpp:
+ (WebCore::FEFlood::platformApplySoftware):
+ * 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::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::FETurbulence::platformApplySoftware):
+ * platform/graphics/filters/FETurbulence.h:
+ * platform/graphics/filters/Filter.h:
+ * platform/graphics/filters/FilterEffect.cpp:
+ (WebCore::FilterEffect::apply):
+ * platform/graphics/filters/FilterEffect.h:
+ * platform/graphics/filters/FilterEffectVector.h: Added.
+ * platform/graphics/filters/FilterFunction.h:
+ (WebCore::FilterFunction::apply):
+ * platform/graphics/filters/SourceAlpha.cpp:
+ (WebCore::SourceAlpha::platformApplySoftware):
+ * platform/graphics/filters/SourceAlpha.h:
+ * platform/graphics/filters/SourceGraphic.cpp:
+ (WebCore::SourceGraphic::platformApplySoftware):
+ * platform/graphics/filters/SourceGraphic.h:
+ * rendering/CSSFilter.cpp:
+ (WebCore::CSSFilter::apply):
+ * rendering/CSSFilter.h:
+ * svg/graphics/filters/SVGFEImage.cpp:
+ (WebCore::FEImage::platformApplySoftware):
+ * svg/graphics/filters/SVGFEImage.h:
+ * svg/graphics/filters/SVGFilter.cpp:
+ (WebCore::SVGFilter::create):
+ (WebCore::SVGFilter::apply):
+ (WebCore::SVGFilter::outsets const):
+ (WebCore::SVGFilter::clearResult):
+ * svg/graphics/filters/SVGFilter.h:
+ * svg/graphics/filters/SVGFilterBuilder.cpp:
+ (WebCore::buildEffectExpression):
+ (WebCore::SVGFilterBuilder::buildExpression const):
+ * svg/graphics/filters/SVGFilterBuilder.h:
+
2021-11-16 Joonghun Park <[email protected]>
border-radius inline style should serialize with valid syntax
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (285915 => 285916)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-11-17 06:24:11 UTC (rev 285916)
@@ -10852,6 +10852,7 @@
71FF851822A3F81F005D5959 /* NavigatorMaxTouchPoints.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NavigatorMaxTouchPoints.idl; sourceTree = "<group>"; };
721443452240C8BA00F12FF7 /* SVGAnimatedValueProperty.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedValueProperty.h; sourceTree = "<group>"; };
721443462240CAD200F12FF7 /* SVGValueProperty.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGValueProperty.h; sourceTree = "<group>"; };
+ 7214B9B7274458FA003BE6DF /* FilterEffectVector.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FilterEffectVector.h; sourceTree = "<group>"; };
721B496F2512AC0400FE9D3B /* ImageBitmapBacking.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ImageBitmapBacking.cpp; sourceTree = "<group>"; };
721B49702512AC0400FE9D3B /* ImageBitmapBacking.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageBitmapBacking.h; sourceTree = "<group>"; };
722A815C238FD50500C00583 /* AnimationFrameRate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AnimationFrameRate.h; sourceTree = "<group>"; };
@@ -25925,6 +25926,7 @@
08C925180FCC7C4A00480DEC /* FilterEffect.h */,
2C85653824C10B0B00A37673 /* FilterEffectRenderer.cpp */,
2C85653324C0F73C00A37673 /* FilterEffectRenderer.h */,
+ 7214B9B7274458FA003BE6DF /* FilterEffectVector.h */,
7262D757272A174100C56A09 /* FilterFunction.cpp */,
7262D756272A174100C56A09 /* FilterFunction.h */,
49ECEB631499790D00CDD3A4 /* FilterOperation.cpp */,
Modified: trunk/Source/WebCore/platform/graphics/cpu/arm/filters/FEBlendNEON.h (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/cpu/arm/filters/FEBlendNEON.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/cpu/arm/filters/FEBlendNEON.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -106,7 +106,7 @@
}
};
-void FEBlend::platformApplySoftware(const Filter&)
+bool FEBlend::platformApplySoftware(const Filter&)
{
FilterEffect* in = inputEffect(0);
FilterEffect* in2 = inputEffect(1);
@@ -113,7 +113,7 @@
auto& destinationPixelBuffer = createPremultipliedImageResult();
if (!destinationPixelBuffer)
- return;
+ return false;
auto& destinationPixelArray = destinationPixelBuffer->data();
@@ -128,7 +128,7 @@
if (sourcePixelArrayLength >= 8) {
platformApplyNEON(sourcePixelArrayA->data(), sourcePixelArrayB->data(), destinationPixelArray.data(), sourcePixelArrayLength);
- return;
+ return true;
}
// If there is just one pixel we expand it to two.
ASSERT(sourcePixelArrayLength > 0);
@@ -139,6 +139,7 @@
sourceBAndDest[0] = reinterpret_cast<uint32_t*>(sourcePixelArrayB->data())[0];
platformApplyNEON(reinterpret_cast<uint8_t*>(sourceA), reinterpret_cast<uint8_t*>(sourceBAndDest), reinterpret_cast<uint8_t*>(sourceBAndDest), 8);
reinterpret_cast<uint32_t*>(destinationPixelArray.data())[0] = sourceBAndDest[0];
+ return true;
}
void FEBlend::platformApplyNEON(unsigned char* srcPixelArrayA, unsigned char* srcPixelArrayB, unsigned char* dstPixelArray,
Modified: trunk/Source/WebCore/platform/graphics/filters/FEBlend.cpp (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEBlend.cpp 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEBlend.cpp 2021-11-17 06:24:11 UTC (rev 285916)
@@ -54,7 +54,7 @@
}
#if !HAVE(ARM_NEON_INTRINSICS)
-void FEBlend::platformApplySoftware(const Filter&)
+bool FEBlend::platformApplySoftware(const Filter&)
{
FilterEffect* in = inputEffect(0);
FilterEffect* in2 = inputEffect(1);
@@ -61,16 +61,17 @@
ImageBuffer* resultImage = createImageBufferResult();
if (!resultImage)
- return;
+ return false;
GraphicsContext& filterContext = resultImage->context();
ImageBuffer* imageBuffer = in->imageBufferResult();
ImageBuffer* imageBuffer2 = in2->imageBufferResult();
if (!imageBuffer || !imageBuffer2)
- return;
+ return false;
filterContext.drawImageBuffer(*imageBuffer2, drawingRegionOfInputImage(in2->absolutePaintRect()));
filterContext.drawImageBuffer(*imageBuffer, drawingRegionOfInputImage(in->absolutePaintRect()), { { }, imageBuffer->logicalSize() }, { CompositeOperator::SourceOver, m_mode });
+ return true;
}
#endif
Modified: trunk/Source/WebCore/platform/graphics/filters/FEBlend.h (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEBlend.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEBlend.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -37,7 +37,7 @@
private:
FEBlend(BlendMode);
- void platformApplySoftware(const Filter&) override;
+ bool platformApplySoftware(const Filter&) override;
void platformApplyGeneric(unsigned char* srcPixelArrayA, unsigned char* srcPixelArrayB, unsigned char* dstPixelArray,
unsigned colorArrayLength);
void platformApplyNEON(unsigned char* srcPixelArrayA, unsigned char* srcPixelArrayB, unsigned char* dstPixelArray,
Modified: trunk/Source/WebCore/platform/graphics/filters/FEColorMatrix.cpp (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEColorMatrix.cpp 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEColorMatrix.cpp 2021-11-17 06:24:11 UTC (rev 285916)
@@ -273,13 +273,13 @@
}
}
-void FEColorMatrix::platformApplySoftware(const Filter&)
+bool FEColorMatrix::platformApplySoftware(const Filter&)
{
FilterEffect* in = inputEffect(0);
ImageBuffer* resultImage = createImageBufferResult();
if (!resultImage)
- return;
+ return false;
ImageBuffer* inBuffer = in->imageBufferResult();
if (inBuffer)
@@ -289,7 +289,7 @@
IntRect imageRect(IntPoint(), resultImage->truncatedLogicalSize());
auto pixelBuffer = resultImage->getPixelBuffer(format, imageRect);
if (!pixelBuffer)
- return;
+ return false;
auto& pixelArray = pixelBuffer->data();
auto pixelArrayDimensions = pixelBuffer->size();
@@ -315,6 +315,7 @@
}
resultImage->putPixelBuffer(*pixelBuffer, imageRect);
+ return true;
}
static TextStream& operator<<(TextStream& ts, const ColorMatrixType& type)
Modified: trunk/Source/WebCore/platform/graphics/filters/FEColorMatrix.h (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEColorMatrix.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEColorMatrix.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -50,7 +50,7 @@
private:
FEColorMatrix(ColorMatrixType, Vector<float>&&);
- void platformApplySoftware(const Filter&) override;
+ bool platformApplySoftware(const Filter&) override;
WTF::TextStream& externalRepresentation(WTF::TextStream&, RepresentationType) const override;
Modified: trunk/Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp 2021-11-17 06:24:11 UTC (rev 285916)
@@ -101,13 +101,13 @@
}
}
-void FEComponentTransfer::platformApplySoftware(const Filter&)
+bool FEComponentTransfer::platformApplySoftware(const Filter&)
{
FilterEffect* in = inputEffect(0);
auto& destinationPixelBuffer = createUnmultipliedImageResult();
if (!destinationPixelBuffer)
- return;
+ return false;
auto& destinationPixelArray = destinationPixelBuffer->data();
@@ -127,6 +127,8 @@
data[pixelOffset + 2] = blueTable[data[pixelOffset + 2]];
data[pixelOffset + 3] = alphaTable[data[pixelOffset + 3]];
}
+
+ return true;
}
void FEComponentTransfer::computeLookupTables(LookupTable& redTable, LookupTable& greenTable, LookupTable& blueTable, LookupTable& alphaTable)
Modified: trunk/Source/WebCore/platform/graphics/filters/FEComponentTransfer.h (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEComponentTransfer.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEComponentTransfer.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -71,7 +71,7 @@
void computeLookupTables(LookupTable& redTable, LookupTable& greenTable, LookupTable& blueTable, LookupTable& alphaTable);
- void platformApplySoftware(const Filter&) override;
+ bool platformApplySoftware(const Filter&) override;
WTF::TextStream& externalRepresentation(WTF::TextStream&, RepresentationType) const override;
Modified: trunk/Source/WebCore/platform/graphics/filters/FEComposite.cpp (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEComposite.cpp 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEComposite.cpp 2021-11-17 06:24:11 UTC (rev 285916)
@@ -223,7 +223,7 @@
}
}
-void FEComposite::platformApplySoftware(const Filter&)
+bool FEComposite::platformApplySoftware(const Filter&)
{
FilterEffect* in = inputEffect(0);
FilterEffect* in2 = inputEffect(1);
@@ -231,7 +231,7 @@
if (m_type == FECOMPOSITE_OPERATOR_ARITHMETIC) {
auto& destinationPixelBuffer = createPremultipliedImageResult();
if (!destinationPixelBuffer)
- return;
+ return false;
auto& destinationPixelArray = destinationPixelBuffer->data();
@@ -238,24 +238,24 @@
IntRect effectADrawingRect = requestedRegionOfInputPixelBuffer(in->absolutePaintRect());
auto sourcePixelArray = in->premultipliedResult(effectADrawingRect, operatingColorSpace());
if (!sourcePixelArray)
- return;
+ return false;
IntRect effectBDrawingRect = requestedRegionOfInputPixelBuffer(in2->absolutePaintRect());
in2->copyPremultipliedResult(destinationPixelArray, effectBDrawingRect, operatingColorSpace());
platformArithmeticSoftware(*sourcePixelArray, destinationPixelArray, m_k1, m_k2, m_k3, m_k4);
- return;
+ return true;
}
ImageBuffer* resultImage = createImageBufferResult();
if (!resultImage)
- return;
+ return false;
GraphicsContext& filterContext = resultImage->context();
ImageBuffer* imageBuffer = in->imageBufferResult();
ImageBuffer* imageBuffer2 = in2->imageBufferResult();
if (!imageBuffer || !imageBuffer2)
- return;
+ return false;
switch (m_type) {
case FECOMPOSITE_OPERATOR_OVER:
@@ -295,6 +295,8 @@
default:
break;
}
+
+ return true;
}
static TextStream& operator<<(TextStream& ts, const CompositeOperationType& type)
Modified: trunk/Source/WebCore/platform/graphics/filters/FEComposite.h (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEComposite.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEComposite.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -65,7 +65,7 @@
void determineAbsolutePaintRect(const Filter&) override;
- void platformApplySoftware(const Filter&) override;
+ bool platformApplySoftware(const Filter&) override;
WTF::TextStream& externalRepresentation(WTF::TextStream&, RepresentationType) const override;
Modified: trunk/Source/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp 2021-11-17 06:24:11 UTC (rev 285916)
@@ -361,13 +361,13 @@
fastSetOuterPixels<false>(paintingData, x1, y1, x2, y2);
}
-void FEConvolveMatrix::platformApplySoftware(const Filter&)
+bool FEConvolveMatrix::platformApplySoftware(const Filter&)
{
FilterEffect* in = inputEffect(0);
auto& destinationPixelBuffer = m_preserveAlpha ? createUnmultipliedImageResult() : createPremultipliedImageResult();
if (!destinationPixelBuffer)
- return;
+ return false;
auto& destinationPixelArray = destinationPixelBuffer->data();
@@ -379,7 +379,7 @@
else
sourcePixelArray = in->premultipliedResult(effectDrawingRect, operatingColorSpace());
if (!sourcePixelArray)
- return;
+ return false;
IntSize paintSize = absolutePaintRect().size();
@@ -397,9 +397,9 @@
int clipBottom = paintSize.height() - m_kernelSize.height();
if (clipRight < 0 || clipBottom < 0) {
- // Rare situation, not optimizied for speed
+ // Rare situation, not optimized for speed
setOuterPixels(paintingData, 0, 0, paintSize.width(), paintSize.height());
- return;
+ return true;
}
if (int iterations = (absolutePaintRect().width() * absolutePaintRect().height()) / s_minimalRectDimension) {
@@ -425,6 +425,8 @@
setOuterPixels(paintingData, 0, m_targetOffset.y(), m_targetOffset.x(), clipBottom);
if (clipRight < paintSize.width())
setOuterPixels(paintingData, clipRight, m_targetOffset.y(), paintSize.width(), clipBottom);
+
+ return true;
}
static TextStream& operator<<(TextStream& ts, const EdgeModeType& type)
Modified: trunk/Source/WebCore/platform/graphics/filters/FEConvolveMatrix.h (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEConvolveMatrix.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEConvolveMatrix.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -78,7 +78,7 @@
void determineAbsolutePaintRect(const Filter&) override { setAbsolutePaintRect(enclosingIntRect(maxEffectRect())); }
- void platformApplySoftware(const Filter&) override;
+ bool platformApplySoftware(const Filter&) override;
WTF::TextStream& externalRepresentation(WTF::TextStream&, RepresentationType) const override;
Modified: trunk/Source/WebCore/platform/graphics/filters/FEDisplacementMap.cpp (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEDisplacementMap.cpp 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEDisplacementMap.cpp 2021-11-17 06:24:11 UTC (rev 285916)
@@ -90,7 +90,7 @@
return x * bytesPerPixel + y * rowBytes;
}
-void FEDisplacementMap::platformApplySoftware(const Filter& filter)
+bool FEDisplacementMap::platformApplySoftware(const Filter& filter)
{
FilterEffect* in = inputEffect(0);
FilterEffect* in2 = inputEffect(1);
@@ -100,7 +100,7 @@
auto& destinationPixelBuffer = createPremultipliedImageResult();
if (!destinationPixelBuffer)
- return;
+ return false;
auto& destinationPixelArray = destinationPixelBuffer->data();
@@ -112,7 +112,7 @@
auto displacementImage = in2->unmultipliedResult(effectBDrawingRect);
if (!inputImage || !displacementImage)
- return;
+ return false;
ASSERT(inputImage->length() == displacementImage->length());
@@ -147,6 +147,8 @@
*destinationPixelPtr = *reinterpret_cast<unsigned*>(inputImage->data() + byteOffsetOfPixel(srcX, srcY, rowBytes));
}
}
+
+ return true;
}
static TextStream& operator<<(TextStream& ts, const ChannelSelectorType& type)
Modified: trunk/Source/WebCore/platform/graphics/filters/FEDisplacementMap.h (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEDisplacementMap.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEDisplacementMap.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -53,7 +53,7 @@
private:
FEDisplacementMap(ChannelSelectorType xChannelSelector, ChannelSelectorType yChannelSelector, float);
- void platformApplySoftware(const Filter&) override;
+ bool platformApplySoftware(const Filter&) override;
void determineAbsolutePaintRect(const Filter&) override { setAbsolutePaintRect(enclosingIntRect(maxEffectRect())); }
Modified: trunk/Source/WebCore/platform/graphics/filters/FEDropShadow.cpp (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEDropShadow.cpp 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEDropShadow.cpp 2021-11-17 06:24:11 UTC (rev 285916)
@@ -69,13 +69,13 @@
setAbsolutePaintRect(enclosingIntRect(absolutePaintRect));
}
-void FEDropShadow::platformApplySoftware(const Filter& filter)
+bool FEDropShadow::platformApplySoftware(const Filter& filter)
{
FilterEffect* in = inputEffect(0);
ImageBuffer* resultImage = createImageBufferResult();
if (!resultImage)
- return;
+ return false;
FloatSize blurRadius = 2 * filter.scaledByFilterScale({ m_stdX, m_stdY });
FloatSize offset = filter.scaledByFilterScale({ m_dx, m_dy });
@@ -86,7 +86,7 @@
ImageBuffer* sourceImage = in->imageBufferResult();
if (!sourceImage)
- return;
+ return false;
GraphicsContext& resultContext = resultImage->context();
resultContext.setAlpha(m_shadowOpacity);
@@ -99,7 +99,7 @@
IntRect shadowArea(IntPoint(), resultImage->truncatedLogicalSize());
auto pixelBuffer = resultImage->getPixelBuffer(format, shadowArea);
if (!pixelBuffer)
- return;
+ return false;
auto& sourcePixelArray = pixelBuffer->data();
contextShadow.blurLayerImage(sourcePixelArray.data(), pixelBuffer->size(), 4 * pixelBuffer->size().width());
@@ -111,6 +111,8 @@
resultContext.setCompositeOperation(CompositeOperator::DestinationOver);
resultImage->context().drawImageBuffer(*sourceImage, drawingRegion);
+
+ return true;
}
IntOutsets FEDropShadow::outsets() const
Modified: trunk/Source/WebCore/platform/graphics/filters/FEDropShadow.h (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEDropShadow.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEDropShadow.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -53,7 +53,7 @@
IntOutsets outsets() const override;
- void platformApplySoftware(const Filter&) override;
+ bool platformApplySoftware(const Filter&) override;
WTF::TextStream& externalRepresentation(WTF::TextStream&, RepresentationType) const override;
Modified: trunk/Source/WebCore/platform/graphics/filters/FEFlood.cpp (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEFlood.cpp 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEFlood.cpp 2021-11-17 06:24:11 UTC (rev 285916)
@@ -58,14 +58,16 @@
return true;
}
-void FEFlood::platformApplySoftware(const Filter&)
+bool FEFlood::platformApplySoftware(const Filter&)
{
ImageBuffer* resultImage = createImageBufferResult();
if (!resultImage)
- return;
+ return false;
auto color = floodColor().colorWithAlphaMultipliedBy(floodOpacity());
resultImage->context().fillRect(FloatRect(FloatPoint(), absolutePaintRect().size()), color);
+
+ return true;
}
TextStream& FEFlood::externalRepresentation(TextStream& ts, RepresentationType representation) const
Modified: trunk/Source/WebCore/platform/graphics/filters/FEFlood.h (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEFlood.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEFlood.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -48,7 +48,7 @@
void determineAbsolutePaintRect(const Filter&) override { setAbsolutePaintRect(enclosingIntRect(maxEffectRect())); }
- void platformApplySoftware(const Filter&) override;
+ bool platformApplySoftware(const Filter&) override;
WTF::TextStream& externalRepresentation(WTF::TextStream&, RepresentationType) const override;
Modified: trunk/Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp 2021-11-17 06:24:11 UTC (rev 285916)
@@ -519,13 +519,13 @@
setAbsolutePaintRect(enclosingIntRect(absolutePaintRect));
}
-void FEGaussianBlur::platformApplySoftware(const Filter& filter)
+bool FEGaussianBlur::platformApplySoftware(const Filter& filter)
{
FilterEffect* in = inputEffect(0);
auto& destinationPixelBuffer = createPremultipliedImageResult();
if (!destinationPixelBuffer)
- return;
+ return false;
auto& destinationPixelArray = destinationPixelBuffer->data();
@@ -534,7 +534,7 @@
IntRect effectDrawingRect = requestedRegionOfInputPixelBuffer(in->absolutePaintRect());
in->copyPremultipliedResult(destinationPixelArray, effectDrawingRect, operatingColorSpace());
if (!m_stdX && !m_stdY)
- return;
+ return true;
IntSize kernelSize = calculateKernelSize(filter, { m_stdX, m_stdY });
@@ -541,9 +541,10 @@
IntSize paintSize = absolutePaintRect().size();
auto tmpImageData = Uint8ClampedArray::tryCreateUninitialized(paintSize.area() * 4);
if (!tmpImageData)
- return;
+ return false;
platformApply(destinationPixelArray, *tmpImageData, kernelSize.width(), kernelSize.height(), paintSize);
+ return true;
}
IntOutsets FEGaussianBlur::outsets() const
Modified: trunk/Source/WebCore/platform/graphics/filters/FEGaussianBlur.h (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEGaussianBlur.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEGaussianBlur.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -60,7 +60,7 @@
void determineAbsolutePaintRect(const Filter&) override;
- void platformApplySoftware(const Filter&) override;
+ bool platformApplySoftware(const Filter&) override;
IntOutsets outsets() const override;
Modified: trunk/Source/WebCore/platform/graphics/filters/FELighting.cpp (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FELighting.cpp 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FELighting.cpp 2021-11-17 06:24:11 UTC (rev 285916)
@@ -471,13 +471,13 @@
return true;
}
-void FELighting::platformApplySoftware(const Filter&)
+bool FELighting::platformApplySoftware(const Filter&)
{
FilterEffect* in = inputEffect(0);
auto& destinationPixelBuffer = createPremultipliedImageResult();
if (!destinationPixelBuffer)
- return;
+ return false;
auto& destinationPixelArray = destinationPixelBuffer->data();
@@ -492,6 +492,7 @@
IntSize absolutePaintSize = absolutePaintRect().size();
drawLighting(destinationPixelArray, absolutePaintSize.width(), absolutePaintSize.height());
+ return true;
}
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/filters/FELighting.h (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FELighting.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FELighting.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -134,7 +134,7 @@
void determineAbsolutePaintRect(const Filter&) override { setAbsolutePaintRect(enclosingIntRect(maxEffectRect())); }
- void platformApplySoftware(const Filter&) override;
+ bool platformApplySoftware(const Filter&) override;
void platformApply(const LightingData&, const LightSource::PaintingData&);
Modified: trunk/Source/WebCore/platform/graphics/filters/FEMerge.cpp (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEMerge.cpp 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEMerge.cpp 2021-11-17 06:24:11 UTC (rev 285916)
@@ -38,7 +38,7 @@
{
}
-void FEMerge::platformApplySoftware(const Filter&)
+bool FEMerge::platformApplySoftware(const Filter&)
{
unsigned size = numberOfEffectInputs();
ASSERT(size > 0);
@@ -45,7 +45,7 @@
ImageBuffer* resultImage = createImageBufferResult();
if (!resultImage)
- return;
+ return false;
GraphicsContext& filterContext = resultImage->context();
for (unsigned i = 0; i < size; ++i) {
@@ -53,6 +53,8 @@
if (ImageBuffer* inBuffer = in->imageBufferResult())
filterContext.drawImageBuffer(*inBuffer, drawingRegionOfInputImage(in->absolutePaintRect()));
}
+
+ return true;
}
TextStream& FEMerge::externalRepresentation(TextStream& ts, RepresentationType representation) const
Modified: trunk/Source/WebCore/platform/graphics/filters/FEMerge.h (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEMerge.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEMerge.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -32,7 +32,7 @@
private:
FEMerge();
- void platformApplySoftware(const Filter&) override;
+ bool platformApplySoftware(const Filter&) override;
WTF::TextStream& externalRepresentation(WTF::TextStream&, RepresentationType) const override;
};
Modified: trunk/Source/WebCore/platform/graphics/filters/FEMorphology.cpp (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEMorphology.cpp 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEMorphology.cpp 2021-11-17 06:24:11 UTC (rev 285916)
@@ -239,13 +239,13 @@
return false;
}
-void FEMorphology::platformApplySoftware(const Filter& filter)
+bool FEMorphology::platformApplySoftware(const Filter& filter)
{
FilterEffect* in = inputEffect(0);
auto& destinationPixelBuffer = createPremultipliedImageResult();
if (!destinationPixelBuffer)
- return;
+ return false;
auto& destinationPixelArray = destinationPixelBuffer->data();
@@ -255,11 +255,11 @@
IntSize radius = flooredIntSize(FloatSize(m_radiusX, m_radiusY));
if (platformApplyDegenerate(destinationPixelArray, effectDrawingRect, radius.width(), radius.height()))
- return;
+ return true;
auto sourcePixelArray = in->premultipliedResult(effectDrawingRect, operatingColorSpace());
if (!sourcePixelArray)
- return;
+ return false;
radius = flooredIntSize(filter.scaledByFilterScale({ m_radiusX, m_radiusY }));
int radiusX = std::min(effectDrawingRect.width() - 1, radius.width());
@@ -266,7 +266,7 @@
int radiusY = std::min(effectDrawingRect.height() - 1, radius.height());
if (platformApplyDegenerate(destinationPixelArray, effectDrawingRect, radiusX, radiusY))
- return;
+ return true;
PaintingData paintingData;
paintingData.srcPixelArray = sourcePixelArray.get();
@@ -277,6 +277,7 @@
paintingData.radiusY = ceilf(radiusY);
platformApply(paintingData);
+ return true;
}
static TextStream& operator<<(TextStream& ts, const MorphologyOperatorType& type)
Modified: trunk/Source/WebCore/platform/graphics/filters/FEMorphology.h (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEMorphology.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEMorphology.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -49,7 +49,7 @@
void determineAbsolutePaintRect(const Filter&) override;
- void platformApplySoftware(const Filter&) override;
+ bool platformApplySoftware(const Filter&) override;
WTF::TextStream& externalRepresentation(WTF::TextStream&, RepresentationType) const override;
Modified: trunk/Source/WebCore/platform/graphics/filters/FEOffset.cpp (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEOffset.cpp 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEOffset.cpp 2021-11-17 06:24:11 UTC (rev 285916)
@@ -64,7 +64,7 @@
setAbsolutePaintRect(enclosingIntRect(paintRect));
}
-void FEOffset::platformApplySoftware(const Filter& filter)
+bool FEOffset::platformApplySoftware(const Filter& filter)
{
FilterEffect* in = inputEffect(0);
@@ -71,7 +71,7 @@
ImageBuffer* resultImage = createImageBufferResult();
ImageBuffer* inBuffer = in->imageBufferResult();
if (!resultImage || !inBuffer)
- return;
+ return false;
setIsAlphaImage(in->isAlphaImage());
@@ -78,6 +78,8 @@
FloatRect drawingRegion = drawingRegionOfInputImage(in->absolutePaintRect());
drawingRegion.move(filter.scaledByFilterScale({ m_dx, m_dy }));
resultImage->context().drawImageBuffer(*inBuffer, drawingRegion);
+
+ return true;
}
TextStream& FEOffset::externalRepresentation(TextStream& ts, RepresentationType representation) const
Modified: trunk/Source/WebCore/platform/graphics/filters/FEOffset.h (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FEOffset.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FEOffset.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -40,7 +40,7 @@
void determineAbsolutePaintRect(const Filter&) override;
- void platformApplySoftware(const Filter&) override;
+ bool platformApplySoftware(const Filter&) override;
WTF::TextStream& externalRepresentation(WTF::TextStream&, RepresentationType) const override;
Modified: trunk/Source/WebCore/platform/graphics/filters/FETile.cpp (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FETile.cpp 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FETile.cpp 2021-11-17 06:24:11 UTC (rev 285916)
@@ -42,7 +42,7 @@
{
}
-void FETile::platformApplySoftware(const Filter& filter)
+bool FETile::platformApplySoftware(const Filter& filter)
{
// FIXME: See bug 47315. This is a hack to work around a compile failure, but is incorrect behavior otherwise.
FilterEffect* in = inputEffect(0);
@@ -50,7 +50,7 @@
ImageBuffer* resultImage = createImageBufferResult();
ImageBuffer* inBuffer = in->imageBufferResult();
if (!resultImage || !inBuffer)
- return;
+ return false;
setIsAlphaImage(in->isAlphaImage());
@@ -66,7 +66,7 @@
auto tileImage = SVGRenderingContext::createImageBuffer(tileRect, tileRect, DestinationColorSpace::SRGB(), filter.renderingMode());
if (!tileImage)
- return;
+ return false;
GraphicsContext& tileImageContext = tileImage->context();
tileImageContext.translate(-inMaxEffectLocation.x(), -inMaxEffectLocation.y());
@@ -74,7 +74,7 @@
auto tileImageCopy = ImageBuffer::sinkIntoNativeImage(WTFMove(tileImage));
if (!tileImageCopy)
- return;
+ return false;
AffineTransform patternTransform;
patternTransform.translate(inMaxEffectLocation - maxEffectLocation);
@@ -84,6 +84,8 @@
GraphicsContext& filterContext = resultImage->context();
filterContext.setFillPattern(WTFMove(pattern));
filterContext.fillRect(FloatRect(FloatPoint(), absolutePaintRect().size()));
+
+ return true;
}
TextStream& FETile::externalRepresentation(TextStream& ts, RepresentationType representation) const
Modified: trunk/Source/WebCore/platform/graphics/filters/FETile.h (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FETile.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FETile.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -34,7 +34,7 @@
void determineAbsolutePaintRect(const Filter&) override { setAbsolutePaintRect(enclosingIntRect(maxEffectRect())); }
- void platformApplySoftware(const Filter&) override;
+ bool platformApplySoftware(const Filter&) override;
WTF::TextStream& externalRepresentation(WTF::TextStream&, RepresentationType) const override;
};
Modified: trunk/Source/WebCore/platform/graphics/filters/FETurbulence.cpp (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FETurbulence.cpp 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FETurbulence.cpp 2021-11-17 06:24:11 UTC (rev 285916)
@@ -393,11 +393,11 @@
parameters->effect->fillRegion(*parameters->filter, *parameters->pixelArray, *parameters->paintingData, parameters->stitchData, parameters->startY, parameters->endY);
}
-void FETurbulence::platformApplySoftware(const Filter& filter)
+bool FETurbulence::platformApplySoftware(const Filter& filter)
{
auto& destinationPixelBuffer = createUnmultipliedImageResult();
if (!destinationPixelBuffer)
- return;
+ return false;
auto& destinationPixelArray = destinationPixelBuffer->data();
@@ -405,7 +405,7 @@
if (resultSize.isEmpty()) {
destinationPixelArray.zeroFill();
- return;
+ return true;
}
IntSize tileSize = roundedIntSize(filterPrimitiveSubregion().size());
@@ -419,7 +419,7 @@
auto area = resultSize.area();
if (area.hasOverflowed())
- return;
+ return false;
int height = resultSize.height();
@@ -451,12 +451,13 @@
}
parallelJobs.execute();
- return;
+ return true;
}
}
// Fallback to single threaded mode if there is no room for a new thread or the paint area is too small.
fillRegion(filter, destinationPixelArray, paintingData, stitchData, 0, height);
+ return true;
}
static TextStream& operator<<(TextStream& ts, TurbulenceType type)
Modified: trunk/Source/WebCore/platform/graphics/filters/FETurbulence.h (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FETurbulence.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FETurbulence.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -106,7 +106,7 @@
FETurbulence(TurbulenceType, float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, bool stitchTiles);
void determineAbsolutePaintRect(const Filter&) override { setAbsolutePaintRect(enclosingIntRect(maxEffectRect())); }
- void platformApplySoftware(const Filter&) override;
+ bool platformApplySoftware(const Filter&) override;
WTF::TextStream& externalRepresentation(WTF::TextStream&, RepresentationType) const override;
void initPaint(PaintingData&);
Modified: trunk/Source/WebCore/platform/graphics/filters/Filter.h (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/Filter.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/Filter.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -32,6 +32,8 @@
class FilterEffect;
class Filter : public FilterFunction {
+ using FilterFunction::apply;
+
public:
FloatSize filterScale() const { return m_filterScale; }
void setFilterScale(const FloatSize& filterScale) { m_filterScale = filterScale; }
@@ -43,7 +45,7 @@
void setFilterRegion(const FloatRect& filterRegion) { m_filterRegion = filterRegion; }
virtual FloatSize scaledByFilterScale(FloatSize size) const { return size * m_filterScale; }
- virtual void apply() = 0;
+ virtual bool apply() = 0;
ImageBuffer* sourceImage() const { return m_sourceImage.get(); }
void setSourceImage(RefPtr<ImageBuffer>&& sourceImage) { m_sourceImage = WTFMove(sourceImage); }
Modified: trunk/Source/WebCore/platform/graphics/filters/FilterEffect.cpp (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FilterEffect.cpp 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FilterEffect.cpp 2021-11-17 06:24:11 UTC (rev 285916)
@@ -142,18 +142,17 @@
return m_inputEffects.at(number).get();
}
-void FilterEffect::apply(const Filter& filter)
+bool FilterEffect::apply(const Filter& filter)
{
if (hasResult())
- return;
+ return true;
+
unsigned size = m_inputEffects.size();
for (unsigned i = 0; i < size; ++i) {
FilterEffect* in = m_inputEffects.at(i).get();
- in->apply(filter);
- if (!in->hasResult())
- return;
// Convert input results to the current effect's color space.
+ ASSERT(in->hasResult());
transformResultColorSpace(in, i);
}
@@ -160,18 +159,25 @@
determineAbsolutePaintRect(filter);
setResultColorSpace(m_operatingColorSpace);
- LOG_WITH_STREAM(Filters, stream << "FilterEffect " << filterName() << " " << this << " apply():\n filterPrimitiveSubregion " << m_filterPrimitiveSubregion << "\n effectBoundaries " << m_effectBoundaries << "\n absoluteUnclippedSubregion " << m_absoluteUnclippedSubregion << "\n absolutePaintRect " << m_absolutePaintRect << "\n maxEffectRect " << m_maxEffectRect << "\n filter scale " << filter.filterScale());
+ LOG_WITH_STREAM(Filters, stream
+ << "FilterEffect " << filterName() << " " << this << " apply():"
+ << "\n filterPrimitiveSubregion " << m_filterPrimitiveSubregion
+ << "\n effectBoundaries " << m_effectBoundaries
+ << "\n absoluteUnclippedSubregion " << m_absoluteUnclippedSubregion
+ << "\n absolutePaintRect " << m_absolutePaintRect
+ << "\n maxEffectRect " << m_maxEffectRect
+ << "\n filter scale " << filter.filterScale());
if (m_absolutePaintRect.isEmpty() || ImageBuffer::sizeNeedsClamping(m_absolutePaintRect.size()))
- return;
+ return false;
if (requiresValidPreMultipliedPixels()) {
for (unsigned i = 0; i < size; ++i)
inputEffect(i)->correctFilterResultIfNeeded();
}
-
+
// Add platform specific apply functions here and return earlier.
- platformApplySoftware(filter);
+ return platformApplySoftware(filter);
}
void FilterEffect::forceValidPreMultipliedPixels()
Modified: trunk/Source/WebCore/platform/graphics/filters/FilterEffect.h (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FilterEffect.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FilterEffect.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -24,6 +24,7 @@
#include "AlphaPremultiplication.h"
#include "DestinationColorSpace.h"
+#include "FilterEffectVector.h"
#include "FilterFunction.h"
#include "FloatRect.h"
#include "IntRect.h"
@@ -41,11 +42,8 @@
namespace WebCore {
class Filter;
-class FilterEffect;
class ImageBuffer;
-typedef Vector<RefPtr<FilterEffect>> FilterEffectVector;
-
class FilterEffect : public FilterFunction {
public:
void clearResult() override;
@@ -84,7 +82,7 @@
FloatRect maxEffectRect() const { return m_maxEffectRect; }
void setMaxEffectRect(const FloatRect& maxEffectRect) { m_maxEffectRect = maxEffectRect; }
- void apply(const Filter&);
+ bool apply(const Filter&) override;
// Correct any invalid pixels, if necessary, in the result of a filter operation.
// This method is used to ensure valid pixel values on filter inputs and the final result.
@@ -156,7 +154,7 @@
void clipAbsolutePaintRect();
private:
- virtual void platformApplySoftware(const Filter&) = 0;
+ virtual bool platformApplySoftware(const Filter&) = 0;
void copyImageBytes(const Uint8ClampedArray& source, Uint8ClampedArray& destination, const IntRect&) const;
void copyConvertedImageBufferToDestination(Uint8ClampedArray&, const DestinationColorSpace&, AlphaPremultiplication, const IntRect&);
Added: trunk/Source/WebCore/platform/graphics/filters/FilterEffectVector.h (0 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FilterEffectVector.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/filters/FilterEffectVector.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class FilterEffect;
+
+using FilterEffectVector = Vector<RefPtr<FilterEffect>>;
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/filters/FilterFunction.h (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/FilterFunction.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/FilterFunction.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -36,6 +36,8 @@
namespace WebCore {
+class Filter;
+
class FilterFunction : public RefCounted<FilterFunction> {
public:
enum class Type : uint8_t {
@@ -82,6 +84,7 @@
static AtomString sourceGraphicName() { return filterName(Type::SourceGraphic); }
AtomString filterName() const { return filterName(m_filterType); }
+ virtual bool apply(const Filter&) { return false; }
virtual IntOutsets outsets() const { return { }; }
virtual void clearResult() { }
Modified: trunk/Source/WebCore/platform/graphics/filters/SourceAlpha.cpp (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/SourceAlpha.cpp 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/SourceAlpha.cpp 2021-11-17 06:24:11 UTC (rev 285916)
@@ -45,20 +45,23 @@
setAbsolutePaintRect(inputEffect(0)->absolutePaintRect());
}
-void SourceAlpha::platformApplySoftware(const Filter&)
+bool SourceAlpha::platformApplySoftware(const Filter&)
{
ImageBuffer* resultImage = createImageBufferResult();
if (!resultImage)
- return;
- GraphicsContext& filterContext = resultImage->context();
-
+ return false;
+
ImageBuffer* imageBuffer = inputEffect(0)->imageBufferResult();
if (!imageBuffer)
- return;
+ return false;
FloatRect imageRect(FloatPoint(), absolutePaintRect().size());
+ GraphicsContext& filterContext = resultImage->context();
+
filterContext.fillRect(imageRect, Color::black);
filterContext.drawImageBuffer(*imageBuffer, IntPoint(), CompositeOperator::DestinationIn);
+
+ return true;
}
TextStream& SourceAlpha::externalRepresentation(TextStream& ts, RepresentationType) const
Modified: trunk/Source/WebCore/platform/graphics/filters/SourceAlpha.h (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/SourceAlpha.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/SourceAlpha.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -34,7 +34,7 @@
void determineAbsolutePaintRect(const Filter&) override;
- void platformApplySoftware(const Filter&) override;
+ bool platformApplySoftware(const Filter&) override;
WTF::TextStream& externalRepresentation(WTF::TextStream&, RepresentationType) const override;
};
Modified: trunk/Source/WebCore/platform/graphics/filters/SourceGraphic.cpp (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/SourceGraphic.cpp 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/SourceGraphic.cpp 2021-11-17 06:24:11 UTC (rev 285916)
@@ -43,14 +43,15 @@
setAbsolutePaintRect(enclosingIntRect(paintRect));
}
-void SourceGraphic::platformApplySoftware(const Filter& filter)
+bool SourceGraphic::platformApplySoftware(const Filter& filter)
{
ImageBuffer* resultImage = createImageBufferResult();
ImageBuffer* sourceImage = filter.sourceImage();
if (!resultImage || !sourceImage)
- return;
+ return false;
resultImage->context().drawImageBuffer(*sourceImage, IntPoint());
+ return true;
}
TextStream& SourceGraphic::externalRepresentation(TextStream& ts, RepresentationType) const
Modified: trunk/Source/WebCore/platform/graphics/filters/SourceGraphic.h (285915 => 285916)
--- trunk/Source/WebCore/platform/graphics/filters/SourceGraphic.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/platform/graphics/filters/SourceGraphic.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -35,7 +35,7 @@
void determineAbsolutePaintRect(const Filter&) override;
- void platformApplySoftware(const Filter&) override;
+ bool platformApplySoftware(const Filter&) override;
WTF::TextStream& externalRepresentation(WTF::TextStream&, RepresentationType) const override;
};
Modified: trunk/Source/WebCore/rendering/CSSFilter.cpp (285915 => 285916)
--- trunk/Source/WebCore/rendering/CSSFilter.cpp 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/rendering/CSSFilter.cpp 2021-11-17 06:24:11 UTC (rev 285916)
@@ -408,7 +408,7 @@
function->clearResult();
}
-void CSSFilter::apply()
+bool CSSFilter::apply()
{
auto effect = lastEffect();
if (m_filterRenderer) {
@@ -415,19 +415,17 @@
m_filterRenderer->applyEffects(*this, *effect);
if (m_filterRenderer->hasResult()) {
effect->transformResultColorSpace(DestinationColorSpace::SRGB());
- return;
+ return true;
}
}
for (auto& function : m_functions) {
- if (function->isSVGFilter()) {
- downcast<SVGFilter>(function.get()).setSourceImage({ sourceImage() });
- downcast<SVGFilter>(function.get()).apply();
- } else if (function->isFilterEffect())
- downcast<FilterEffect>(function.get()).apply(*this);
+ if (!function->apply(*this))
+ return false;
}
effect->transformResultColorSpace(DestinationColorSpace::SRGB());
+ return true;
}
LayoutRect CSSFilter::computeSourceImageRectForDirtyRect(const LayoutRect& filterBoxRect, const LayoutRect& dirtyRect)
Modified: trunk/Source/WebCore/rendering/CSSFilter.h (285915 => 285916)
--- trunk/Source/WebCore/rendering/CSSFilter.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/rendering/CSSFilter.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -59,7 +59,7 @@
IntOutsets outsets() const override;
void clearIntermediateResults();
- void apply() override;
+ bool apply() override;
ImageBuffer* output();
Modified: trunk/Source/WebCore/svg/graphics/filters/SVGFEImage.cpp (285915 => 285916)
--- trunk/Source/WebCore/svg/graphics/filters/SVGFEImage.cpp 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/svg/graphics/filters/SVGFEImage.cpp 2021-11-17 06:24:11 UTC (rev 285916)
@@ -74,7 +74,7 @@
setAbsolutePaintRect(enclosingIntRect(imageRect));
}
-void FEImage::platformApplySoftware(const Filter& filter)
+bool FEImage::platformApplySoftware(const Filter& filter)
{
// FEImage results are always in DestinationColorSpace::SRGB()
setResultColorSpace(DestinationColorSpace::SRGB());
@@ -81,7 +81,7 @@
ImageBuffer* resultImage = createImageBufferResult();
if (!resultImage)
- return;
+ return false;
auto primitiveSubregion = filterPrimitiveSubregion();
auto& context = resultImage->context();
@@ -103,6 +103,8 @@
context.drawImageBuffer(imageBuffer, imageRect.location());
}
);
+
+ return true;
}
TextStream& FEImage::externalRepresentation(TextStream& ts, RepresentationType representation) const
Modified: trunk/Source/WebCore/svg/graphics/filters/SVGFEImage.h (285915 => 285916)
--- trunk/Source/WebCore/svg/graphics/filters/SVGFEImage.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/svg/graphics/filters/SVGFEImage.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -46,7 +46,7 @@
void determineAbsolutePaintRect(const Filter&) final;
- void platformApplySoftware(const Filter&) final;
+ bool platformApplySoftware(const Filter&) final;
WTF::TextStream& externalRepresentation(WTF::TextStream&, RepresentationType) const final;
Modified: trunk/Source/WebCore/svg/graphics/filters/SVGFilter.cpp (285915 => 285916)
--- trunk/Source/WebCore/svg/graphics/filters/SVGFilter.cpp 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/svg/graphics/filters/SVGFilter.cpp 2021-11-17 06:24:11 UTC (rev 285916)
@@ -56,7 +56,12 @@
if (!lastEffect)
return nullptr;
- filter->setLastEffect(WTFMove(lastEffect));
+ FilterEffectVector _expression_;
+ if (!builder.buildExpression(_expression_))
+ return nullptr;
+
+ ASSERT(!_expression_.isEmpty());
+ filter->setExpression(WTFMove(_expression_));
return filter;
}
@@ -75,19 +80,33 @@
return Filter::scaledByFilterScale(size);
}
-void SVGFilter::apply()
+bool SVGFilter::apply(const Filter& filter)
{
- m_lastEffect->apply(*this);
+ setSourceImage({ filter.sourceImage() });
+ return apply();
}
+bool SVGFilter::apply()
+{
+ ASSERT(!m_expression.isEmpty());
+ for (auto& effect : m_expression) {
+ if (!effect->apply(*this))
+ return false;
+ }
+ return true;
+}
+
IntOutsets SVGFilter::outsets() const
{
- return m_lastEffect->outsets();
+ ASSERT(lastEffect());
+ return lastEffect()->outsets();
}
void SVGFilter::clearResult()
{
- m_lastEffect->clearResultsRecursive();
+ ASSERT(!m_expression.isEmpty());
+ for (auto& effect : m_expression)
+ effect->clearResult();
}
} // namespace WebCore
Modified: trunk/Source/WebCore/svg/graphics/filters/SVGFilter.h (285915 => 285916)
--- trunk/Source/WebCore/svg/graphics/filters/SVGFilter.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/svg/graphics/filters/SVGFilter.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -21,6 +21,7 @@
#pragma once
#include "Filter.h"
+#include "FilterEffectVector.h"
#include "FloatRect.h"
#include <wtf/Ref.h>
#include <wtf/TypeCasts.h>
@@ -39,14 +40,15 @@
FloatSize scaledByFilterScale(FloatSize) const final;
FloatRect targetBoundingBox() const { return m_targetBoundingBox; }
- void apply() override;
+ bool apply() override;
- RefPtr<FilterEffect> lastEffect() { return m_lastEffect; }
- void setLastEffect(RefPtr<FilterEffect>&& lastEffect) { m_lastEffect = WTFMove(lastEffect); }
+ void setExpression(FilterEffectVector&& _expression_) { m_expression = WTFMove(_expression_); }
+ RefPtr<FilterEffect> lastEffect() const { return !m_expression.isEmpty() ? m_expression.last() : nullptr; }
private:
SVGFilter(const FloatSize& filterScale, const FloatRect& sourceImageRect, const FloatRect& targetBoundingBox, const FloatRect& filterRegion, bool effectBBoxMode);
+ bool apply(const Filter&) override;
IntOutsets outsets() const override;
void clearResult() override;
@@ -53,7 +55,7 @@
FloatRect m_targetBoundingBox;
bool m_effectBBoxMode;
- RefPtr<FilterEffect> m_lastEffect;
+ FilterEffectVector m_expression;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp (285915 => 285916)
--- trunk/Source/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp 2021-11-17 06:24:11 UTC (rev 285916)
@@ -21,12 +21,10 @@
#include "SVGFilterBuilder.h"
#include "ElementIterator.h"
-#include "ImageBuffer.h"
#include "SVGFilterElement.h"
#include "SVGFilterPrimitiveStandardAttributes.h"
#include "SourceAlpha.h"
#include "SourceGraphic.h"
-#include <wtf/text/StringConcatenateNumbers.h>
#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB)
#include "CSSComputedStyleDeclaration.h"
@@ -180,4 +178,40 @@
clearResultsRecursive(reference);
}
+static bool buildEffectExpression(const RefPtr<FilterEffect>& effect, FilterEffectVector& stack, FilterEffectVector& _expression_)
+{
+ // A cycle is detected.
+ if (stack.contains(effect))
+ return false;
+
+ stack.append(effect);
+
+ _expression_.append(effect);
+
+ for (auto& inputEffect : effect->inputEffects()) {
+ if (!buildEffectExpression(inputEffect, stack, _expression_))
+ return false;
+ }
+
+ ASSERT(!stack.isEmpty());
+ ASSERT(stack.last() == effect);
+
+ stack.removeLast();
+ return true;
+}
+
+bool SVGFilterBuilder::buildExpression(FilterEffectVector& _expression_) const
+{
+ if (!m_lastEffect)
+ return false;
+
+ FilterEffectVector stack;
+ if (!buildEffectExpression(m_lastEffect, stack, _expression_))
+ return false;
+
+ _expression_.reverse();
+ _expression_.shrinkToFit();
+ return true;
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/svg/graphics/filters/SVGFilterBuilder.h (285915 => 285916)
--- trunk/Source/WebCore/svg/graphics/filters/SVGFilterBuilder.h 2021-11-17 05:53:07 UTC (rev 285915)
+++ trunk/Source/WebCore/svg/graphics/filters/SVGFilterBuilder.h 2021-11-17 06:24:11 UTC (rev 285916)
@@ -67,6 +67,7 @@
void setupBuiltinEffects(Ref<FilterEffect> sourceGraphic);
RefPtr<FilterEffect> buildFilterEffects(SVGFilterElement&);
+ bool buildExpression(FilterEffectVector& _expression_) const;
private:
inline void addBuiltinEffects()