Title: [269204] trunk
Revision
269204
Author
[email protected]
Date
2020-10-30 13:27:23 -0700 (Fri, 30 Oct 2020)

Log Message

[TextureMapper] Replica layers don't blend correctly because computeOverlapRegions doesn't take TextureMapperPaintOptions::transform into account
https://bugs.webkit.org/show_bug.cgi?id=218307

Reviewed by Don Olmstead.

Source/WebCore:

Blending in replica layers didn't work as expected because
computeOverlapRegions didn't take the transform of
TextureMapperPaintOptions into account. Rendering replica layers
are achieved by using the transform.

TextureMapperLayer::paintWithIntermediateSurface also should take
the transform. commitSurface no longer needs to transform by it.

Test: compositing/reflections/opacity-in-reflection.html

* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::computeOverlapRegions):
(WebCore::TextureMapperLayer::paintUsingOverlapRegions):
(WebCore::commitSurface):
(WebCore::TextureMapperLayer::paintWithIntermediateSurface):
* platform/graphics/texmap/TextureMapperLayer.h:

LayoutTests:

* compositing/reflections/opacity-in-reflection-expected.html: Added.
* compositing/reflections/opacity-in-reflection.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (269203 => 269204)


--- trunk/LayoutTests/ChangeLog	2020-10-30 20:09:56 UTC (rev 269203)
+++ trunk/LayoutTests/ChangeLog	2020-10-30 20:27:23 UTC (rev 269204)
@@ -1,3 +1,13 @@
+2020-10-30  Fujii Hironori  <[email protected]>
+
+        [TextureMapper] Replica layers don't blend correctly because computeOverlapRegions doesn't take TextureMapperPaintOptions::transform into account
+        https://bugs.webkit.org/show_bug.cgi?id=218307
+
+        Reviewed by Don Olmstead.
+
+        * compositing/reflections/opacity-in-reflection-expected.html: Added.
+        * compositing/reflections/opacity-in-reflection.html: Added.
+
 2020-10-30  Chris Dumez  <[email protected]>
 
         Resync web-platform-tests/resources tests from upstream

Added: trunk/LayoutTests/compositing/reflections/opacity-in-reflection-expected.html (0 => 269204)


--- trunk/LayoutTests/compositing/reflections/opacity-in-reflection-expected.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/reflections/opacity-in-reflection-expected.html	2020-10-30 20:27:23 UTC (rev 269204)
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            .right {
+                position: relative;
+                width: 150px;
+                height: 150px;
+                -webkit-box-reflect: right 10px;
+            }
+            .below {
+                width: 150px;
+                height: 150px;
+                -webkit-box-reflect: below 10px;
+            }
+            .container {
+                height: 100px;
+                width: 100px;
+                background-color: green;
+                opacity: 0.5;
+            }
+            .container div {
+                position: relative;
+                top: 10px;
+                left: 10px;
+                height: 100px;
+                width: 100px;
+            }
+            .child1 {
+                background-color: blue;
+            }
+            .child2 {
+                opacity: 0.5;
+                background-color: yellow;
+            }
+            .child3 {
+                background-color: red;
+            }
+            .child4 {
+                background-color: green;
+            }
+        </style>
+    </head>
+    <body>
+        <div class="right">
+            <div class="below">
+                <div class="container">
+                    <div class="child1">
+                        <div class="child2">
+                            <div class="child3">
+                                <div class="child4">
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </body>
+</html>
+

Added: trunk/LayoutTests/compositing/reflections/opacity-in-reflection.html (0 => 269204)


--- trunk/LayoutTests/compositing/reflections/opacity-in-reflection.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/reflections/opacity-in-reflection.html	2020-10-30 20:27:23 UTC (rev 269204)
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            .right {
+                position: relative;
+                width: 150px;
+                height: 150px;
+                -webkit-box-reflect: right 10px;
+            }
+            .below {
+                width: 150px;
+                height: 150px;
+                -webkit-box-reflect: below 10px;
+            }
+            .container {
+                height: 100px;
+                width: 100px;
+                background-color: green;
+                opacity: 0.5;
+                will-change: transform;
+            }
+            .container div {
+                position: relative;
+                top: 10px;
+                left: 10px;
+                height: 100px;
+                width: 100px;
+                will-change: transform;
+            }
+            .child1 {
+                background-color: blue;
+            }
+            .child2 {
+                opacity: 0.5;
+                background-color: yellow;
+            }
+            .child3 {
+                background-color: red;
+            }
+            .child4 {
+                background-color: green;
+            }
+        </style>
+    </head>
+    <body>
+        <div class="right">
+            <div class="below">
+                <div class="container">
+                    <div class="child1">
+                        <div class="child2">
+                            <div class="child3">
+                                <div class="child4">
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </body>
+</html>
+

Modified: trunk/Source/WebCore/ChangeLog (269203 => 269204)


--- trunk/Source/WebCore/ChangeLog	2020-10-30 20:09:56 UTC (rev 269203)
+++ trunk/Source/WebCore/ChangeLog	2020-10-30 20:27:23 UTC (rev 269204)
@@ -1,3 +1,27 @@
+2020-10-30  Fujii Hironori  <[email protected]>
+
+        [TextureMapper] Replica layers don't blend correctly because computeOverlapRegions doesn't take TextureMapperPaintOptions::transform into account
+        https://bugs.webkit.org/show_bug.cgi?id=218307
+
+        Reviewed by Don Olmstead.
+
+        Blending in replica layers didn't work as expected because
+        computeOverlapRegions didn't take the transform of
+        TextureMapperPaintOptions into account. Rendering replica layers
+        are achieved by using the transform.
+
+        TextureMapperLayer::paintWithIntermediateSurface also should take
+        the transform. commitSurface no longer needs to transform by it.
+
+        Test: compositing/reflections/opacity-in-reflection.html
+
+        * platform/graphics/texmap/TextureMapperLayer.cpp:
+        (WebCore::TextureMapperLayer::computeOverlapRegions):
+        (WebCore::TextureMapperLayer::paintUsingOverlapRegions):
+        (WebCore::commitSurface):
+        (WebCore::TextureMapperLayer::paintWithIntermediateSurface):
+        * platform/graphics/texmap/TextureMapperLayer.h:
+
 2020-10-30  Chris Dumez  <[email protected]>
 
         BaseAudioContext.decodeAudioData() should throw an InvalidStateError when document is not fully active

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp (269203 => 269204)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2020-10-30 20:09:56 UTC (rev 269203)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2020-10-30 20:27:23 UTC (rev 269204)
@@ -325,7 +325,7 @@
     nonOverlapRegion.unite(newRegion);
 }
 
-void TextureMapperLayer::computeOverlapRegions(Region& overlapRegion, Region& nonOverlapRegion, ResolveSelfOverlapMode mode)
+void TextureMapperLayer::computeOverlapRegions(const TextureMapperPaintOptions& options, Region& overlapRegion, Region& nonOverlapRegion, ResolveSelfOverlapMode mode)
 {
     if (!m_state.visible || !m_state.contentsVisible)
         return;
@@ -344,6 +344,10 @@
         boundingRect.unite(unfilteredTargetRect);
     }
 
+    TransformationMatrix transform;
+    transform.multiply(options.transform);
+    transform.multiply(m_layerTransforms.combined);
+
     TransformationMatrix replicaMatrix;
     if (m_state.replicaLayer) {
         replicaMatrix = replicaTransform();
@@ -350,7 +354,7 @@
         boundingRect.unite(replicaMatrix.mapRect(boundingRect));
     }
 
-    boundingRect = m_layerTransforms.combined.mapRect(boundingRect);
+    boundingRect = transform.mapRect(boundingRect);
 
     // Count all masks and filters as overlap layers.
     if (hasFilters() || m_state.maskLayer || (m_state.replicaLayer && m_state.replicaLayer->m_state.maskLayer)) {
@@ -365,7 +369,7 @@
 
     if (!m_state.masksToBounds) {
         for (auto* child : m_children)
-            child->computeOverlapRegions(newOverlapRegion, newNonOverlapRegion, ResolveSelfOverlapIfNeeded);
+            child->computeOverlapRegions(options, newOverlapRegion, newNonOverlapRegion, ResolveSelfOverlapIfNeeded);
     }
 
     if (m_state.replicaLayer) {
@@ -387,7 +391,7 @@
 {
     Region overlapRegion;
     Region nonOverlapRegion;
-    computeOverlapRegions(overlapRegion, nonOverlapRegion, ResolveSelfOverlapAlways);
+    computeOverlapRegions(options, overlapRegion, nonOverlapRegion, ResolveSelfOverlapAlways);
     if (overlapRegion.isEmpty()) {
         paintSelfAndChildrenWithReplica(options);
         return;
@@ -460,11 +464,10 @@
 
 static void commitSurface(const TextureMapperPaintOptions& options, BitmapTexture& surface, const IntRect& rect, float opacity)
 {
+    IntRect targetRect(rect);
+    targetRect.move(options.offset);
     options.textureMapper.bindSurface(options.surface.get());
-    TransformationMatrix targetTransform;
-    targetTransform.translate(options.offset.width(), options.offset.height());
-    targetTransform.multiply(options.transform);
-    options.textureMapper.drawTexture(surface, rect, targetTransform, opacity);
+    options.textureMapper.drawTexture(surface, targetRect, { }, opacity);
 }
 
 void TextureMapperLayer::paintWithIntermediateSurface(const TextureMapperPaintOptions& options, const IntRect& rect)
@@ -471,15 +474,14 @@
 {
     TextureMapperPaintOptions paintOptions(options);
     paintOptions.surface = options.textureMapper.acquireTextureFromPool(rect.size(), BitmapTexture::SupportsAlpha);
-    paintOptions.offset = -IntSize(rect.x(), rect.y());
+    paintOptions.offset = -toIntSize(rect.location());
     paintOptions.opacity = 1;
-    paintOptions.transform = TransformationMatrix();
     if (m_state.replicaLayer) {
         paintOptions.isReplica = true;
-        paintOptions.transform = replicaTransform();
+        paintOptions.transform.multiply(replicaTransform());
         paintIntoSurface(paintOptions);
         paintOptions.isReplica = false;
-        paintOptions.transform = TransformationMatrix();
+        paintOptions.transform = options.transform;
         if (m_state.replicaLayer->m_state.maskLayer)
             m_state.replicaLayer->m_state.maskLayer->applyMask(paintOptions);
     }

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h (269203 => 269204)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h	2020-10-30 20:09:56 UTC (rev 269203)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h	2020-10-30 20:27:23 UTC (rev 269204)
@@ -127,7 +127,7 @@
         ResolveSelfOverlapAlways = 0,
         ResolveSelfOverlapIfNeeded
     };
-    void computeOverlapRegions(Region& overlapRegion, Region& nonOverlapRegion, ResolveSelfOverlapMode);
+    void computeOverlapRegions(const TextureMapperPaintOptions&, Region& overlapRegion, Region& nonOverlapRegion, ResolveSelfOverlapMode);
 
     void paintRecursive(const TextureMapperPaintOptions&);
     void paintUsingOverlapRegions(const TextureMapperPaintOptions&);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to