- Revision
- 238094
- Author
- [email protected]
- Date
- 2018-11-12 09:58:56 -0800 (Mon, 12 Nov 2018)
Log Message
feFlood with alpha color doesn't work correctly
https://bugs.webkit.org/show_bug.cgi?id=163666
Reviewed by Zalan Bujtas.
Source/WebCore:
FEFlood::platformApplySoftware() erroneously used colorWithOverrideAlpha()
rather than multiplying the flood color with the flood opacity as other browsers do.
Test: svg/filters/feFlood-with-alpha-color.html
* platform/graphics/Color.cpp:
(WebCore::Color::colorWithAlpha const): I tried using colorWithAlphaMultipliedBy() elsewhere,
and it triggered a behavior change, so add a comment.
* platform/graphics/filters/FEFlood.cpp:
(WebCore::FEFlood::platformApplySoftware):
* svg/SVGStopElement.cpp:
(WebCore::SVGStopElement::stopColorIncludingOpacity const):
LayoutTests:
* svg/filters/feFlood-with-alpha-color-expected.html: Added.
* svg/filters/feFlood-with-alpha-color.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (238093 => 238094)
--- trunk/LayoutTests/ChangeLog 2018-11-12 17:42:56 UTC (rev 238093)
+++ trunk/LayoutTests/ChangeLog 2018-11-12 17:58:56 UTC (rev 238094)
@@ -1,3 +1,13 @@
+2018-11-12 Simon Fraser <[email protected]>
+
+ feFlood with alpha color doesn't work correctly
+ https://bugs.webkit.org/show_bug.cgi?id=163666
+
+ Reviewed by Zalan Bujtas.
+
+ * svg/filters/feFlood-with-alpha-color-expected.html: Added.
+ * svg/filters/feFlood-with-alpha-color.html: Added.
+
2018-11-12 Eric Carlson <[email protected]>
Require <iframe allow="display"> for an iframe to use getDisplayMedia
Added: trunk/LayoutTests/svg/filters/feFlood-with-alpha-color-expected.html (0 => 238094)
--- trunk/LayoutTests/svg/filters/feFlood-with-alpha-color-expected.html (rev 0)
+++ trunk/LayoutTests/svg/filters/feFlood-with-alpha-color-expected.html 2018-11-12 17:58:56 UTC (rev 238094)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+ <body>
+ <p>You should see two identical gray squares below</p>
+ <svg width="600px" height="500px" xmlns="http://www.w3.org/2000/svg">
+ <rect x="0" y="0" width="200" height="200" fill="rgba(0, 0, 0, 0.4)"/>
+ <rect x="0" y="250" width="200" height="200" fill="rgba(0, 0, 0, 0.4)"/>
+ </svg>
+ </body>
+</html>
Added: trunk/LayoutTests/svg/filters/feFlood-with-alpha-color.html (0 => 238094)
--- trunk/LayoutTests/svg/filters/feFlood-with-alpha-color.html (rev 0)
+++ trunk/LayoutTests/svg/filters/feFlood-with-alpha-color.html 2018-11-12 17:58:56 UTC (rev 238094)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+ <body>
+ <p>You should see two identical gray squares below</p>
+ <svg width="600px" height="500px" xmlns="http://www.w3.org/2000/svg">
+ <defs>
+ <filter id="flood" filterUnits="objectBoundingBox" x="0" y="0" width="1" height="1">
+ <feFlood flood-color="rgba(0, 0, 0, 0.4)"/>
+ </filter>
+
+ <filter id="flood-with-alpha" filterUnits="objectBoundingBox" x="0" y="0" width="1" height="1">
+ <feFlood flood-color="rgba(0, 0, 0, 0.8)" flood-opacity="0.5"/>
+ </filter>
+ </defs>
+ <rect x="0" y="0" width="200" height="200" filter="url(#flood)"/>
+ <rect x="0" y="250" width="200" height="200" filter="url(#flood-with-alpha)"/>
+ </svg>
+ </body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (238093 => 238094)
--- trunk/Source/WebCore/ChangeLog 2018-11-12 17:42:56 UTC (rev 238093)
+++ trunk/Source/WebCore/ChangeLog 2018-11-12 17:58:56 UTC (rev 238094)
@@ -1,3 +1,23 @@
+2018-11-12 Simon Fraser <[email protected]>
+
+ feFlood with alpha color doesn't work correctly
+ https://bugs.webkit.org/show_bug.cgi?id=163666
+
+ Reviewed by Zalan Bujtas.
+
+ FEFlood::platformApplySoftware() erroneously used colorWithOverrideAlpha()
+ rather than multiplying the flood color with the flood opacity as other browsers do.
+
+ Test: svg/filters/feFlood-with-alpha-color.html
+
+ * platform/graphics/Color.cpp:
+ (WebCore::Color::colorWithAlpha const): I tried using colorWithAlphaMultipliedBy() elsewhere,
+ and it triggered a behavior change, so add a comment.
+ * platform/graphics/filters/FEFlood.cpp:
+ (WebCore::FEFlood::platformApplySoftware):
+ * svg/SVGStopElement.cpp:
+ (WebCore::SVGStopElement::stopColorIncludingOpacity const):
+
2018-11-12 Eric Carlson <[email protected]>
Require <iframe allow="display"> for an iframe to use getDisplayMedia
Modified: trunk/Source/WebCore/platform/graphics/Color.cpp (238093 => 238094)
--- trunk/Source/WebCore/platform/graphics/Color.cpp 2018-11-12 17:42:56 UTC (rev 238093)
+++ trunk/Source/WebCore/platform/graphics/Color.cpp 2018-11-12 17:58:56 UTC (rev 238094)
@@ -517,7 +517,7 @@
if (isExtended())
return Color { m_colorData.extendedColor->red(), m_colorData.extendedColor->green(), m_colorData.extendedColor->blue(), alpha, m_colorData.extendedColor->colorSpace() };
- int newAlpha = alpha * 255;
+ int newAlpha = alpha * 255; // Why doesn't this use colorFloatToRGBAByte() like colorWithOverrideAlpha()?
Color result = { red(), green(), blue(), newAlpha };
if (isSemantic())
Modified: trunk/Source/WebCore/platform/graphics/filters/FEFlood.cpp (238093 => 238094)
--- trunk/Source/WebCore/platform/graphics/filters/FEFlood.cpp 2018-11-12 17:42:56 UTC (rev 238093)
+++ trunk/Source/WebCore/platform/graphics/filters/FEFlood.cpp 2018-11-12 17:58:56 UTC (rev 238094)
@@ -63,7 +63,9 @@
if (!resultImage)
return;
- const Color& color = colorWithOverrideAlpha(floodColor().rgb(), floodOpacity());
+ // FIXME: This should use colorWithAlphaMultipliedBy() but that has different rounding of the alpha component that breaks some tests.
+ float colorAlpha = floodColor().alpha() / 255.0;
+ auto color = colorWithOverrideAlpha(floodColor().rgb(), colorAlpha * floodOpacity());
resultImage->context().fillRect(FloatRect(FloatPoint(), absolutePaintRect().size()), color);
}
Modified: trunk/Source/WebCore/svg/SVGStopElement.cpp (238093 => 238094)
--- trunk/Source/WebCore/svg/SVGStopElement.cpp 2018-11-12 17:42:56 UTC (rev 238093)
+++ trunk/Source/WebCore/svg/SVGStopElement.cpp 2018-11-12 17:58:56 UTC (rev 238094)
@@ -92,14 +92,13 @@
Color SVGStopElement::stopColorIncludingOpacity() const
{
auto* style = renderer() ? &renderer()->style() : nullptr;
- // FIXME: This check for null style exists to address Bug WK 90814, a rare crash condition in
- // which the renderer or style is null. This entire class is scheduled for removal (Bug WK 86941)
- // and we will tolerate this null check until then.
+ // FIXME: This check for null style exists to address Bug WK 90814, a rare crash condition in which the renderer or style is null.
if (!style)
- return Color(Color::transparent, true); // Transparent black.
+ return Color(Color::transparent, true);
const SVGRenderStyle& svgStyle = style->svgStyle();
float colorAlpha = svgStyle.stopColor().alpha() / 255.0;
+ // FIXME: This should use colorWithAlphaMultipliedBy() but that has different rounding of the alpha component.
return colorWithOverrideAlpha(svgStyle.stopColor().rgb(), colorAlpha * svgStyle.stopOpacity());
}