Title: [245977] trunk
Revision
245977
Author
[email protected]
Date
2019-05-31 12:07:30 -0700 (Fri, 31 May 2019)

Log Message

Move code that sets compositing paint phases into a single function
https://bugs.webkit.org/show_bug.cgi?id=198420

Reviewed by Zalan Bujtas.

Source/WebCore:

To compute the correct paint phases for the various GraphicsLayers in a RenderLayerBacking,
we have to know which set of layers we've created (m_scrollContainerLayer, m_foregroundLayer etc).
So move the code that sets phases into a single function which is called when that
set of layers changes.

The test dumps paint phases for a stacking-context-composited scroller with a negative z-index child.

Also have GraphicsLayer::setPaintingPhase() trigger the necessary repaint when the paint phase changes.

Test: compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases.html

* platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::setPaintingPhase):
* platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::setPaintingPhase): Deleted.
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateConfiguration):
(WebCore::RenderLayerBacking::updateForegroundLayer):
(WebCore::RenderLayerBacking::updateBackgroundLayer):
(WebCore::RenderLayerBacking::updateMaskingLayer):
(WebCore::RenderLayerBacking::updateScrollingLayers):
(WebCore::RenderLayerBacking::updatePaintingPhases):
(WebCore::RenderLayerBacking::paintingPhaseForPrimaryLayer const): Deleted.
* rendering/RenderLayerBacking.h:

LayoutTests:

* compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt: Added.
* compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases.html: Added.
* platform/ios-wk2/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt: Added.
* platform/mac-wk1/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (245976 => 245977)


--- trunk/LayoutTests/ChangeLog	2019-05-31 19:05:51 UTC (rev 245976)
+++ trunk/LayoutTests/ChangeLog	2019-05-31 19:07:30 UTC (rev 245977)
@@ -1,3 +1,15 @@
+2019-05-31  Simon Fraser  <[email protected]>
+
+        Move code that sets compositing paint phases into a single function
+        https://bugs.webkit.org/show_bug.cgi?id=198420
+
+        Reviewed by Zalan Bujtas.
+
+        * compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt: Added.
+        * compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases.html: Added.
+        * platform/ios-wk2/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt: Added.
+        * platform/mac-wk1/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt: Added.
+
 2019-05-31  Saam Barati  <[email protected]>
 
         [WHLSL] Make sure we properly emit code for "&*x"

Added: trunk/LayoutTests/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt (0 => 245977)


--- trunk/LayoutTests/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt	2019-05-31 19:07:30 UTC (rev 245977)
@@ -0,0 +1,60 @@
+Scrolled contents
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (paintingPhases
+    GraphicsLayerPaintBackground
+    GraphicsLayerPaintForeground
+    )
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (paintingPhases
+        GraphicsLayerPaintBackground
+        GraphicsLayerPaintForeground
+        )
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 322.00 322.00)
+          (drawsContent 1)
+          (paintingPhases
+            GraphicsLayerPaintBackground
+            GraphicsLayerPaintCompositedScroll
+            )
+          (children 1
+            (GraphicsLayer
+              (offsetFromRenderer width=1 height=1)
+              (position 1.00 1.00)
+              (bounds 305.00 305.00)
+              (children 1
+                (GraphicsLayer
+                  (offsetFromRenderer width=1 height=1)
+                  (anchor 0.00 0.00)
+                  (bounds 305.00 1020.00)
+                  (drawsContent 1)
+                  (paintingPhases
+                    GraphicsLayerPaintOverflowContents
+                    GraphicsLayerPaintCompositedScroll
+                    )
+                  (children 1
+                    (GraphicsLayer
+                      (offsetFromRenderer width=1 height=1)
+                      (bounds 305.00 1020.00)
+                      (drawsContent 1)
+                      (paintingPhases
+                        GraphicsLayerPaintForeground
+                        )
+                    )
+                  )
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+

Added: trunk/LayoutTests/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases.html (0 => 245977)


--- trunk/LayoutTests/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases.html	2019-05-31 19:07:30 UTC (rev 245977)
@@ -0,0 +1,44 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] --><html>
+<head>
+    <style>
+        .scroller {
+            position: relative;
+            z-index: 0;
+            width: 300px;
+            height: 300px;
+            border: 1px solid black;
+            overflow: scroll;
+            padding: 10px;
+        }
+
+        .contents {
+            height: 1000px;
+        }
+        
+        .negative {
+            position: absolute;
+            z-index: -1;
+            top: 50px;
+            left: 30px;
+            width: 100px;
+            height: 100px;
+            background-color: blue;
+        }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        window.addEventListener('load', () => {
+            document.getElementById('layers').textContent = internals.layerTreeAsText(document, window.internals.LAYER_TREE_INCLUDES_PAINTING_PHASES);
+        }, false);
+    </script>
+</head>
+<body>
+    <div class="scroller">
+        <div class="negative"></div>
+        <div class="contents">Scrolled contents</div>
+    </div>
+<pre id="layers"></pre>
+</body>
+</html>

Added: trunk/LayoutTests/platform/ios-wk2/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt (0 => 245977)


--- trunk/LayoutTests/platform/ios-wk2/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios-wk2/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt	2019-05-31 19:07:30 UTC (rev 245977)
@@ -0,0 +1,60 @@
+Scrolled contents
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (paintingPhases
+    GraphicsLayerPaintBackground
+    GraphicsLayerPaintForeground
+    )
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (paintingPhases
+        GraphicsLayerPaintBackground
+        GraphicsLayerPaintForeground
+        )
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 322.00 322.00)
+          (drawsContent 1)
+          (paintingPhases
+            GraphicsLayerPaintBackground
+            GraphicsLayerPaintCompositedScroll
+            )
+          (children 1
+            (GraphicsLayer
+              (offsetFromRenderer width=1 height=1)
+              (position 1.00 1.00)
+              (bounds 320.00 320.00)
+              (children 1
+                (GraphicsLayer
+                  (offsetFromRenderer width=1 height=1)
+                  (anchor 0.00 0.00)
+                  (bounds 320.00 1020.00)
+                  (drawsContent 1)
+                  (paintingPhases
+                    GraphicsLayerPaintOverflowContents
+                    GraphicsLayerPaintCompositedScroll
+                    )
+                  (children 1
+                    (GraphicsLayer
+                      (offsetFromRenderer width=1 height=1)
+                      (bounds 320.00 1020.00)
+                      (drawsContent 1)
+                      (paintingPhases
+                        GraphicsLayerPaintForeground
+                        )
+                    )
+                  )
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+

Added: trunk/LayoutTests/platform/mac-wk1/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt (0 => 245977)


--- trunk/LayoutTests/platform/mac-wk1/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk1/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt	2019-05-31 19:07:30 UTC (rev 245977)
@@ -0,0 +1,2 @@
+Scrolled contents
+

Modified: trunk/Source/WebCore/ChangeLog (245976 => 245977)


--- trunk/Source/WebCore/ChangeLog	2019-05-31 19:05:51 UTC (rev 245976)
+++ trunk/Source/WebCore/ChangeLog	2019-05-31 19:07:30 UTC (rev 245977)
@@ -1,3 +1,35 @@
+2019-05-31  Simon Fraser  <[email protected]>
+
+        Move code that sets compositing paint phases into a single function
+        https://bugs.webkit.org/show_bug.cgi?id=198420
+
+        Reviewed by Zalan Bujtas.
+
+        To compute the correct paint phases for the various GraphicsLayers in a RenderLayerBacking,
+        we have to know which set of layers we've created (m_scrollContainerLayer, m_foregroundLayer etc).
+        So move the code that sets phases into a single function which is called when that
+        set of layers changes.
+
+        The test dumps paint phases for a stacking-context-composited scroller with a negative z-index child.
+
+        Also have GraphicsLayer::setPaintingPhase() trigger the necessary repaint when the paint phase changes.
+
+        Test: compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases.html
+
+        * platform/graphics/GraphicsLayer.cpp:
+        (WebCore::GraphicsLayer::setPaintingPhase):
+        * platform/graphics/GraphicsLayer.h:
+        (WebCore::GraphicsLayer::setPaintingPhase): Deleted.
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::updateConfiguration):
+        (WebCore::RenderLayerBacking::updateForegroundLayer):
+        (WebCore::RenderLayerBacking::updateBackgroundLayer):
+        (WebCore::RenderLayerBacking::updateMaskingLayer):
+        (WebCore::RenderLayerBacking::updateScrollingLayers):
+        (WebCore::RenderLayerBacking::updatePaintingPhases):
+        (WebCore::RenderLayerBacking::paintingPhaseForPrimaryLayer const): Deleted.
+        * rendering/RenderLayerBacking.h:
+
 2019-05-31  Saam Barati  <[email protected]>
 
         [WHLSL] Make sure we properly emit code for "&*x"

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp (245976 => 245977)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp	2019-05-31 19:05:51 UTC (rev 245976)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp	2019-05-31 19:07:30 UTC (rev 245977)
@@ -491,6 +491,15 @@
     m_backgroundColor = color;
 }
 
+void GraphicsLayer::setPaintingPhase(OptionSet<GraphicsLayerPaintingPhase> phase)
+{
+    if (phase == m_paintingPhase)
+        return;
+
+    setNeedsDisplay();
+    m_paintingPhase = phase;
+}
+
 void GraphicsLayer::paintGraphicsLayerContents(GraphicsContext& context, const FloatRect& clip, GraphicsLayerPaintBehavior layerPaintBehavior)
 {
     FloatSize offset = offsetFromRenderer() - toFloatSize(scrollOffset());

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.h (245976 => 245977)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.h	2019-05-31 19:05:51 UTC (rev 245976)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.h	2019-05-31 19:07:30 UTC (rev 245977)
@@ -415,7 +415,7 @@
 
     // Some GraphicsLayers paint only the foreground or the background content
     OptionSet<GraphicsLayerPaintingPhase> paintingPhase() const { return m_paintingPhase; }
-    void setPaintingPhase(OptionSet<GraphicsLayerPaintingPhase> phase) { m_paintingPhase = phase; }
+    void setPaintingPhase(OptionSet<GraphicsLayerPaintingPhase>);
 
     enum ShouldClipToLayer {
         DoNotClipToLayer,

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (245976 => 245977)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2019-05-31 19:05:51 UTC (rev 245976)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2019-05-31 19:07:30 UTC (rev 245977)
@@ -819,7 +819,8 @@
             m_graphicsLayer->addChild(*flatteningLayer);
     }
 
-    updateMaskingLayer(renderer().hasMask(), renderer().hasClipPath());
+    if (updateMaskingLayer(renderer().hasMask(), renderer().hasClipPath()))
+        layerConfigChanged = true;
 
     updateChildClippingStrategy(needsDescendantsClippingLayer);
 
@@ -888,6 +889,9 @@
         }
     }
 
+    if (layerConfigChanged)
+        updatePaintingPhases();
+
     return layerConfigChanged;
 }
 
@@ -1709,7 +1713,6 @@
             String layerName = m_owningLayer.name() + " (foreground)";
             m_foregroundLayer = createGraphicsLayer(layerName);
             m_foregroundLayer->setDrawsContent(true);
-            m_foregroundLayer->setPaintingPhase({ GraphicsLayerPaintingPhase::Foreground });
             layerChanged = true;
         }
     } else if (m_foregroundLayer) {
@@ -1718,11 +1721,6 @@
         layerChanged = true;
     }
 
-    if (layerChanged) {
-        m_graphicsLayer->setNeedsDisplay();
-        m_graphicsLayer->setPaintingPhase(paintingPhaseForPrimaryLayer());
-    }
-
     return layerChanged;
 }
 
@@ -1735,7 +1733,6 @@
             m_backgroundLayer = createGraphicsLayer(layerName);
             m_backgroundLayer->setDrawsContent(true);
             m_backgroundLayer->setAnchorPoint(FloatPoint3D());
-            m_backgroundLayer->setPaintingPhase({ GraphicsLayerPaintingPhase::Background });
             layerChanged = true;
         }
         
@@ -1759,15 +1756,12 @@
             m_graphicsLayer->setAppliesPageScale(true);
         }
     }
-    
-    if (layerChanged)
-        m_graphicsLayer->setNeedsDisplay();
-    
+
     return layerChanged;
 }
 
 // Masking layer is used for masks or clip-path.
-void RenderLayerBacking::updateMaskingLayer(bool hasMask, bool hasClipPath)
+bool RenderLayerBacking::updateMaskingLayer(bool hasMask, bool hasClipPath)
 {
     bool layerChanged = false;
     if (hasMask || hasClipPath) {
@@ -1805,8 +1799,7 @@
         layerChanged = true;
     }
 
-    if (layerChanged)
-        m_graphicsLayer->setPaintingPhase(paintingPhaseForPrimaryLayer());
+    return layerChanged;
 }
 
 void RenderLayerBacking::updateChildClippingStrategy(bool needsDescendantsClippingLayer)
@@ -1846,8 +1839,9 @@
         return false;
 
     if (!m_scrollContainerLayer) {
-        // Outer layer which corresponds with the scroll view.
+        // Outer layer which corresponds with the scroll view. This never paints content.
         m_scrollContainerLayer = createGraphicsLayer("scroll container", GraphicsLayer::Type::ScrollContainer);
+        m_scrollContainerLayer->setPaintingPhase({ });
         m_scrollContainerLayer->setDrawsContent(false);
         m_scrollContainerLayer->setMasksToBounds(true);
 
@@ -1855,11 +1849,6 @@
         m_scrolledContentsLayer = createGraphicsLayer("scrolled contents", GraphicsLayer::Type::ScrolledContents);
         m_scrolledContentsLayer->setDrawsContent(true);
         m_scrolledContentsLayer->setAnchorPoint({ });
-
-        OptionSet<GraphicsLayerPaintingPhase> paintPhases = { GraphicsLayerPaintingPhase::OverflowContents, GraphicsLayerPaintingPhase::CompositedScroll };
-        if (!m_foregroundLayer)
-            paintPhases.add(GraphicsLayerPaintingPhase::Foreground);
-        m_scrolledContentsLayer->setPaintingPhase(paintPhases);
         m_scrollContainerLayer->addChild(*m_scrolledContentsLayer);
     } else {
         compositor().willRemoveScrollingLayerWithBacking(m_owningLayer, *this);
@@ -1871,9 +1860,6 @@
         GraphicsLayer::unparentAndClear(m_scrolledContentsLayer);
     }
 
-    m_graphicsLayer->setPaintingPhase(paintingPhaseForPrimaryLayer());
-    m_graphicsLayer->setNeedsDisplay(); // Because painting phases changed.
-
     if (m_scrollContainerLayer)
         compositor().didAddScrollingLayer(m_owningLayer);
     
@@ -1939,22 +1925,6 @@
     m_graphicsLayer->setIsViewportConstrained(viewportCoordinated);
 }
 
-OptionSet<GraphicsLayerPaintingPhase> RenderLayerBacking::paintingPhaseForPrimaryLayer() const
-{
-    OptionSet<GraphicsLayerPaintingPhase> phases;
-    if (!m_backgroundLayer)
-        phases.add(GraphicsLayerPaintingPhase::Background);
-    if (!m_foregroundLayer)
-        phases.add(GraphicsLayerPaintingPhase::Foreground);
-
-    if (m_scrolledContentsLayer) {
-        phases.remove(GraphicsLayerPaintingPhase::Foreground);
-        phases.add(GraphicsLayerPaintingPhase::CompositedScroll);
-    }
-
-    return phases;
-}
-
 float RenderLayerBacking::compositingOpacity(float rendererOpacity) const
 {
     float finalOpacity = rendererOpacity;
@@ -2123,6 +2093,35 @@
     }
 }
 
+void RenderLayerBacking::updatePaintingPhases()
+{
+    // Phases for m_childClippingMaskLayer and m_maskLayer are set elsewhere.
+    OptionSet<GraphicsLayerPaintingPhase> primaryLayerPhases = { GraphicsLayerPaintingPhase::Background, GraphicsLayerPaintingPhase::Foreground };
+    
+    if (m_foregroundLayer) {
+        OptionSet<GraphicsLayerPaintingPhase> foregroundLayerPhases { GraphicsLayerPaintingPhase::Foreground };
+        m_foregroundLayer->setPaintingPhase(foregroundLayerPhases);
+        primaryLayerPhases.remove(GraphicsLayerPaintingPhase::Foreground);
+    }
+
+    if (m_backgroundLayer) {
+        m_backgroundLayer->setPaintingPhase(GraphicsLayerPaintingPhase::Background);
+        primaryLayerPhases.remove(GraphicsLayerPaintingPhase::Background);
+    }
+
+    if (m_scrolledContentsLayer) {
+        OptionSet<GraphicsLayerPaintingPhase> scrolledContentLayerPhases = { GraphicsLayerPaintingPhase::OverflowContents, GraphicsLayerPaintingPhase::CompositedScroll };
+        if (!m_foregroundLayer)
+            scrolledContentLayerPhases.add(GraphicsLayerPaintingPhase::Foreground);
+        m_scrolledContentsLayer->setPaintingPhase(scrolledContentLayerPhases);
+
+        primaryLayerPhases.remove(GraphicsLayerPaintingPhase::Foreground);
+        primaryLayerPhases.add(GraphicsLayerPaintingPhase::CompositedScroll);
+    }
+
+    m_graphicsLayer->setPaintingPhase(primaryLayerPhases);
+}
+
 static bool supportsDirectlyCompositedBoxDecorations(const RenderLayerModelObject& renderer)
 {
     if (!GraphicsLayer::supportsBackgroundColorContent())

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.h (245976 => 245977)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.h	2019-05-31 19:05:51 UTC (rev 245976)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.h	2019-05-31 19:07:30 UTC (rev 245977)
@@ -316,7 +316,7 @@
     bool updateOverflowControlsLayers(bool needsHorizontalScrollbarLayer, bool needsVerticalScrollbarLayer, bool needsScrollCornerLayer);
     bool updateForegroundLayer(bool needsForegroundLayer);
     bool updateBackgroundLayer(bool needsBackgroundLayer);
-    void updateMaskingLayer(bool hasMask, bool hasClipPath);
+    bool updateMaskingLayer(bool hasMask, bool hasClipPath);
     bool requiresHorizontalScrollbarLayer() const;
     bool requiresVerticalScrollbarLayer() const;
     bool requiresScrollCornerLayer() const;
@@ -326,15 +326,12 @@
     void setLocationOfScrolledContents(ScrollOffset, ScrollingLayerPositionAction);
 
     void updateChildClippingStrategy(bool needsDescendantsClippingLayer);
-
     void updateMaskingLayerGeometry();
-    
     void updateRootLayerConfiguration();
+    void updatePaintingPhases();
 
     void setBackgroundLayerPaintsFixedRootBackground(bool);
 
-    OptionSet<GraphicsLayerPaintingPhase> paintingPhaseForPrimaryLayer() const;
-    
     LayoutSize contentOffsetInCompositingLayer() const;
     // Result is transform origin in device pixels.
     FloatPoint3D computeTransformOriginForPainting(const LayoutRect& borderBox) const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to