Title: [195724] trunk
Revision
195724
Author
[email protected]
Date
2016-01-27 18:21:25 -0800 (Wed, 27 Jan 2016)

Log Message

Garbage is displayed when root svg element has mix-blend-mode set
https://bugs.webkit.org/show_bug.cgi?id=150556

Patch by Said Abou-Hallawa <[email protected]> on 2016-01-27
Reviewed by Darin Adler.

Source/WebCore:

This bug happens when compositing on a CALayer and drawing on a transparent
layer, so it happens with WK2 with <svg style="mix-blend-mode...">. And it
can happen with WK1 also with <svg style="opacity=...;mix-blend-mode...">.
But in both cases, the SVG root renderer should be the root of the render
tree. So it happens only with the stand alone SVG documents.

SVGRenderContext::prepareToRenderSVGContent() ignores the opacity of
the SVG root but it creates a transparent layer for the blend-mode.

But RenderLayer::beginTransparencyLayers() creates a transparent layer
for opacity and it sets the blend-mode also.

The fix is to begin two transparent layers for the SVG root renderer: one
for the opacity and the second for the blend-mode. The opacity transparent
layer will be still managed by RenderLayer::beginTransparencyLayers(). While
the blend-mode transparent layer will be managed by SVGRenderContext
::prepareToRenderSVGContent().

Tests: svg/css/mix-blend-mode-background-root.svg
       svg/css/mix-blend-mode-opacity-root.svg

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::beginTransparencyLayers):

LayoutTests:

Ensure blending the SVG root renderer will be displayed correctly with
compositing when the SVG root renderer is the root of the render tree.

* svg/css/mix-blend-mode-background-root-expected.svg: Added.
* svg/css/mix-blend-mode-background-root.svg: Added.
* svg/css/mix-blend-mode-opacity-root-expected.svg: Added.
* svg/css/mix-blend-mode-opacity-root.svg: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (195723 => 195724)


--- trunk/LayoutTests/ChangeLog	2016-01-28 02:14:34 UTC (rev 195723)
+++ trunk/LayoutTests/ChangeLog	2016-01-28 02:21:25 UTC (rev 195724)
@@ -1,3 +1,18 @@
+2016-01-27  Said Abou-Hallawa  <[email protected]>
+
+        Garbage is displayed when root svg element has mix-blend-mode set
+        https://bugs.webkit.org/show_bug.cgi?id=150556
+
+        Reviewed by Darin Adler.
+
+        Ensure blending the SVG root renderer will be displayed correctly with
+        compositing when the SVG root renderer is the root of the render tree.
+
+        * svg/css/mix-blend-mode-background-root-expected.svg: Added.
+        * svg/css/mix-blend-mode-background-root.svg: Added.
+        * svg/css/mix-blend-mode-opacity-root-expected.svg: Added.
+        * svg/css/mix-blend-mode-opacity-root.svg: Added.
+
 2016-01-27  Brady Eidson  <[email protected]>
 
         Modern IDB: Incorrect handling of iterating cursors to their end.

Added: trunk/LayoutTests/svg/css/mix-blend-mode-background-root-expected.svg (0 => 195724)


--- trunk/LayoutTests/svg/css/mix-blend-mode-background-root-expected.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/css/mix-blend-mode-background-root-expected.svg	2016-01-28 02:21:25 UTC (rev 195724)
@@ -0,0 +1,6 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+    <rect x="20" y="20" width="100" height="100" fill="rgb(0,255,255)"/>
+    <rect x="140" y="20" width="100" height="100" fill="rgb(255,0,255)"/>
+    <rect x="20" y="140" width="100" height="100" fill="rgb(255,255,0)"/>
+    <rect x="140" y="140" width="100" height="100" fill="rgb(0,0,0)"/>
+</svg>

Added: trunk/LayoutTests/svg/css/mix-blend-mode-background-root.svg (0 => 195724)


--- trunk/LayoutTests/svg/css/mix-blend-mode-background-root.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/css/mix-blend-mode-background-root.svg	2016-01-28 02:21:25 UTC (rev 195724)
@@ -0,0 +1,7 @@
+<svg xmlns="http://www.w3.org/2000/svg" style="background-color:white; mix-blend-mode: difference;">
+    <rect x="20" y="20" width="100" height="100" fill="rgb(255,0,0)"/>
+    <rect x="140" y="20" width="100" height="100" fill="rgb(0,255,0)"/>
+    <rect x="20" y="140" width="100" height="100" fill="rgb(0,0,255)"/>
+    <rect x="140" y="140" width="100" height="100" fill="rgb(255,255,255)"/>
+</svg>
+

Added: trunk/LayoutTests/svg/css/mix-blend-mode-opacity-root-expected.svg (0 => 195724)


--- trunk/LayoutTests/svg/css/mix-blend-mode-opacity-root-expected.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/css/mix-blend-mode-opacity-root-expected.svg	2016-01-28 02:21:25 UTC (rev 195724)
@@ -0,0 +1,6 @@
+<svg xmlns="http://www.w3.org/2000/svg" style="opacity: 0.6;">
+    <rect x="20" y="20" width="100" height="100" fill="rgb(0,255,255)"/>
+    <rect x="140" y="20" width="100" height="100" fill="rgb(255,0,255)"/>
+    <rect x="20" y="140" width="100" height="100" fill="rgb(255,255,0)"/>
+    <rect x="140" y="140" width="100" height="100" fill="rgb(0,0,0)"/>
+</svg>

Added: trunk/LayoutTests/svg/css/mix-blend-mode-opacity-root.svg (0 => 195724)


--- trunk/LayoutTests/svg/css/mix-blend-mode-opacity-root.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/css/mix-blend-mode-opacity-root.svg	2016-01-28 02:21:25 UTC (rev 195724)
@@ -0,0 +1,7 @@
+<svg xmlns="http://www.w3.org/2000/svg" style="opacity: 0.6; mix-blend-mode: difference;">
+    <rect x="20" y="20" width="100" height="100" fill="rgb(255,0,0)"/>
+    <rect x="140" y="20" width="100" height="100" fill="rgb(0,255,0)"/>
+    <rect x="20" y="140" width="100" height="100" fill="rgb(0,0,255)"/>
+    <rect x="140" y="140" width="100" height="100" fill="rgb(255,255,255)"/>
+</svg>
+

Modified: trunk/Source/WebCore/ChangeLog (195723 => 195724)


--- trunk/Source/WebCore/ChangeLog	2016-01-28 02:14:34 UTC (rev 195723)
+++ trunk/Source/WebCore/ChangeLog	2016-01-28 02:21:25 UTC (rev 195724)
@@ -1,3 +1,34 @@
+2016-01-27  Said Abou-Hallawa  <[email protected]>
+
+        Garbage is displayed when root svg element has mix-blend-mode set
+        https://bugs.webkit.org/show_bug.cgi?id=150556
+
+        Reviewed by Darin Adler.
+
+        This bug happens when compositing on a CALayer and drawing on a transparent
+        layer, so it happens with WK2 with <svg style="mix-blend-mode...">. And it
+        can happen with WK1 also with <svg style="opacity=...;mix-blend-mode...">.
+        But in both cases, the SVG root renderer should be the root of the render
+        tree. So it happens only with the stand alone SVG documents.
+
+        SVGRenderContext::prepareToRenderSVGContent() ignores the opacity of
+        the SVG root but it creates a transparent layer for the blend-mode.
+
+        But RenderLayer::beginTransparencyLayers() creates a transparent layer
+        for opacity and it sets the blend-mode also.
+
+        The fix is to begin two transparent layers for the SVG root renderer: one
+        for the opacity and the second for the blend-mode. The opacity transparent
+        layer will be still managed by RenderLayer::beginTransparencyLayers(). While
+        the blend-mode transparent layer will be managed by SVGRenderContext
+        ::prepareToRenderSVGContent().
+
+        Tests: svg/css/mix-blend-mode-background-root.svg
+               svg/css/mix-blend-mode-opacity-root.svg
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::beginTransparencyLayers):
+
 2016-01-27  Enrica Casucci  <[email protected]>
 
         Cache results of data detection in the UI process when load completes.

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (195723 => 195724)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2016-01-28 02:14:34 UTC (rev 195723)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2016-01-28 02:21:25 UTC (rev 195724)
@@ -1804,14 +1804,15 @@
         context.clip(pixelSnappedClipRect);
 
 #if ENABLE(CSS_COMPOSITING)
-        if (hasBlendMode())
+        // RenderSVGRoot takes care of its blend mode.
+        if (!renderer().isSVGRoot() && hasBlendMode())
             context.setCompositeOperation(context.compositeOperation(), blendMode());
 #endif
 
         context.beginTransparencyLayer(renderer().opacity());
 
 #if ENABLE(CSS_COMPOSITING)
-        if (hasBlendMode())
+        if (!renderer().isSVGRoot() && hasBlendMode())
             context.setCompositeOperation(context.compositeOperation(), BlendModeNormal);
 #endif
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to