Title: [181164] trunk
Revision
181164
Author
simon.fra...@apple.com
Date
2015-03-06 10:14:10 -0800 (Fri, 06 Mar 2015)

Log Message

Allow composited clip-path to be updated without a layer repaint
https://bugs.webkit.org/show_bug.cgi?id=142384

Reviewed by Zalan Bujtas.

Source/WebCore:

When clip-path is mapped to a compositing shape layer mask, we can just
push a new shape to the GraphicsLayer to update the clip path, without
needing to repaint.

Achieve this by adding ContextSensitivePropertyClipPath. When set, and the
stars are aligned, issue a StyleDifferenceRecompositeLayer rather than
a StyleDifferenceRepaint.

We ask RenderLayerCompositor whether the clip path can be composited
to hide platform differences related to whether GraphicsLayer supports
shape masks.

Test: compositing/masks/compositing-clip-path-change-no-repaint.html

* rendering/RenderElement.cpp:
(WebCore::RenderElement::adjustStyleDifference): Remove obvious comment
about opacity. Handle ContextSensitivePropertyClipPath.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::canCompositeClipPath): If we have a mask
we have to paint the mask + clip path into the mask layer (mirrors code in
RenderLayerBacking::updateMaskingLayer but isn't quite similar enough to share).
* rendering/RenderLayerCompositor.h:
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::changeRequiresRepaint): Set ContextSensitivePropertyClipPath
and don't return, as is normal for context-sensitive property handling.
* rendering/style/RenderStyleConstants.h: Line things up to avoid future bit
fumbles, and remove unnecessary braces.

LayoutTests:

Test repaint with a clip-path change.

* compositing/masks/compositing-clip-path-change-no-repaint-expected.txt: Added.
* compositing/masks/compositing-clip-path-change-no-repaint.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (181163 => 181164)


--- trunk/LayoutTests/ChangeLog	2015-03-06 18:13:10 UTC (rev 181163)
+++ trunk/LayoutTests/ChangeLog	2015-03-06 18:14:10 UTC (rev 181164)
@@ -1,3 +1,15 @@
+2015-03-06  Simon Fraser  <simon.fra...@apple.com>
+
+        Allow composited clip-path to be updated without a layer repaint
+        https://bugs.webkit.org/show_bug.cgi?id=142384
+
+        Reviewed by Zalan Bujtas.
+        
+        Test repaint with a clip-path change.
+
+        * compositing/masks/compositing-clip-path-change-no-repaint-expected.txt: Added.
+        * compositing/masks/compositing-clip-path-change-no-repaint.html: Added.
+
 2015-03-06  Gyuyoung Kim  <gyuyoung....@samsung.com>
 
         Unreviewed EFL gardening on 6th Mar.

Added: trunk/LayoutTests/compositing/masks/compositing-clip-path-change-no-repaint-expected.txt (0 => 181164)


--- trunk/LayoutTests/compositing/masks/compositing-clip-path-change-no-repaint-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/compositing/masks/compositing-clip-path-change-no-repaint-expected.txt	2015-03-06 18:14:10 UTC (rev 181164)
@@ -0,0 +1,30 @@
+box1
+box2
+Only the second box should have a repaint.
+
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 785.00 658.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 785.00 658.00)
+      (contentsOpaque 1)
+      (children 2
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 300.00 300.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 8.00 308.00)
+          (bounds 300.00 300.00)
+          (drawsContent 1)
+          (repaint rects
+            (rect 0.00 0.00 300.00 300.00)
+          )
+        )
+      )
+    )
+  )
+)
+

Added: trunk/LayoutTests/compositing/masks/compositing-clip-path-change-no-repaint.html (0 => 181164)


--- trunk/LayoutTests/compositing/masks/compositing-clip-path-change-no-repaint.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/masks/compositing-clip-path-change-no-repaint.html	2015-03-06 18:14:10 UTC (rev 181164)
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        .box {
+          width: 300px;
+          height: 300px;
+          background-color: blue;
+        }
+        
+        .composited {
+          -webkit-transform: translateZ(0);
+        }
+        
+        .clipped {
+            -webkit-clip-path: inset(0 50px);
+        }
+        
+        .masked {
+            -webkit-mask: linear-gradient(white, transparent);
+        }
+        
+        body.changed .clipped {
+            -webkit-clip-path: inset(0 70px);
+        }
+    </style>
+    <script>
+        if (window.testRunner) {
+            testRunner.dumpAsText();
+        }
+
+        function doTest()
+        {
+            document.body.offsetWidth;
+
+            if (window.internals)
+                window.internals.startTrackingRepaints();
+
+            document.body.classList.add('changed');
+
+            if (window.internals)
+                document.getElementById('repaintRects').textContent = window.internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_REPAINT_RECTS);
+
+        }
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+    <div class="clipped composited box">box1</div>
+    <div class="clipped masked composited box">box2</div>
+<p>Only the second box should have a repaint.</p>
+<pre id="repaintRects"></pre>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (181163 => 181164)


--- trunk/Source/WebCore/ChangeLog	2015-03-06 18:13:10 UTC (rev 181163)
+++ trunk/Source/WebCore/ChangeLog	2015-03-06 18:14:10 UTC (rev 181164)
@@ -1,3 +1,38 @@
+2015-03-06  Simon Fraser  <simon.fra...@apple.com>
+
+        Allow composited clip-path to be updated without a layer repaint
+        https://bugs.webkit.org/show_bug.cgi?id=142384
+
+        Reviewed by Zalan Bujtas.
+        
+        When clip-path is mapped to a compositing shape layer mask, we can just
+        push a new shape to the GraphicsLayer to update the clip path, without
+        needing to repaint.
+        
+        Achieve this by adding ContextSensitivePropertyClipPath. When set, and the
+        stars are aligned, issue a StyleDifferenceRecompositeLayer rather than
+        a StyleDifferenceRepaint.
+        
+        We ask RenderLayerCompositor whether the clip path can be composited
+        to hide platform differences related to whether GraphicsLayer supports
+        shape masks.
+
+        Test: compositing/masks/compositing-clip-path-change-no-repaint.html
+
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::adjustStyleDifference): Remove obvious comment
+        about opacity. Handle ContextSensitivePropertyClipPath.
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::canCompositeClipPath): If we have a mask
+        we have to paint the mask + clip path into the mask layer (mirrors code in
+        RenderLayerBacking::updateMaskingLayer but isn't quite similar enough to share).
+        * rendering/RenderLayerCompositor.h:
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::changeRequiresRepaint): Set ContextSensitivePropertyClipPath
+        and don't return, as is normal for context-sensitive property handling.
+        * rendering/style/RenderStyleConstants.h: Line things up to avoid future bit
+        fumbles, and remove unnecessary braces.
+
 2015-03-06  Alex Christensen  <achristen...@webkit.org>
 
         [Content Extensions] Process all actions when blocking a URL.

Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (181163 => 181164)


--- trunk/Source/WebCore/rendering/RenderElement.cpp	2015-03-06 18:13:10 UTC (rev 181163)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp	2015-03-06 18:14:10 UTC (rev 181164)
@@ -277,8 +277,6 @@
             diff = std::max(diff, StyleDifferenceRecompositeLayer);
     }
 
-    // If opacity changed, and we are not composited, need to repaint (also
-    // ignoring text nodes)
     if (contextSensitiveProperties & ContextSensitivePropertyOpacity) {
         if (!hasLayer() || !downcast<RenderLayerModelObject>(*this).layer()->isComposited())
             diff = std::max(diff, StyleDifferenceRepaintLayer);
@@ -286,6 +284,16 @@
             diff = std::max(diff, StyleDifferenceRecompositeLayer);
     }
 
+    if (contextSensitiveProperties & ContextSensitivePropertyClipPath) {
+        if (hasLayer()
+            && downcast<RenderLayerModelObject>(*this).layer()->isComposited()
+            && hasClipPath()
+            && RenderLayerCompositor::canCompositeClipPath(*downcast<RenderLayerModelObject>(*this).layer()))
+            diff = std::max(diff, StyleDifferenceRecompositeLayer);
+        else
+            diff = std::max(diff, StyleDifferenceRepaint);
+    }
+    
     if ((contextSensitiveProperties & ContextSensitivePropertyFilter) && hasLayer()) {
         RenderLayer* layer = downcast<RenderLayerModelObject>(*this).layer();
         if (!layer->isComposited() || layer->paintsWithFilters())

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (181163 => 181164)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2015-03-06 18:13:10 UTC (rev 181163)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2015-03-06 18:14:10 UTC (rev 181164)
@@ -926,6 +926,18 @@
     }
 }
 
+bool RenderLayerCompositor::canCompositeClipPath(const RenderLayer& layer)
+{
+    ASSERT(layer.isComposited());
+    ASSERT(layer.renderer().style().clipPath());
+
+    if (layer.renderer().hasMask())
+        return false;
+
+    ClipPathOperation& clipPath = *layer.renderer().style().clipPath();
+    return (clipPath.type() != ClipPathOperation::Shape || clipPath.type() == ClipPathOperation::Shape) && GraphicsLayer::supportsLayerType(GraphicsLayer::Type::Shape);
+}
+
 bool RenderLayerCompositor::updateBacking(RenderLayer& layer, CompositingChangeRepaint shouldRepaint)
 {
     bool layerChanged = false;

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.h (181163 => 181164)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.h	2015-03-06 18:13:10 UTC (rev 181163)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.h	2015-03-06 18:14:10 UTC (rev 181164)
@@ -173,6 +173,8 @@
 
     void layerStyleChanged(RenderLayer&, const RenderStyle* oldStyle);
 
+    static bool canCompositeClipPath(const RenderLayer&);
+
     // Get the nearest ancestor layer that has overflow or clip, but is not a stacking context
     RenderLayer* enclosingNonStackingClippingLayer(const RenderLayer&) const;
 

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (181163 => 181164)


--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2015-03-06 18:13:10 UTC (rev 181163)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2015-03-06 18:14:10 UTC (rev 181164)
@@ -716,7 +716,7 @@
     return false;
 }
 
-bool RenderStyle::changeRequiresRepaint(const RenderStyle& other, unsigned&) const
+bool RenderStyle::changeRequiresRepaint(const RenderStyle& other, unsigned& changedContextSensitiveProperties) const
 {
     if (inherited_flags._visibility != other.inherited_flags._visibility
         || inherited_flags.m_printColorAdjust != other.inherited_flags.m_printColorAdjust
@@ -737,8 +737,11 @@
         return true;
 #endif
 
-    if (rareNonInheritedData->m_clipPath != other.rareNonInheritedData->m_clipPath)
-        return true;
+    // FIXME: this should probably be moved to changeRequiresLayerRepaint().
+    if (rareNonInheritedData->m_clipPath != other.rareNonInheritedData->m_clipPath) {
+        changedContextSensitiveProperties |= ContextSensitivePropertyClipPath;
+        // Don't return; keep looking for another change.
+    }
 
     return false;
 }

Modified: trunk/Source/WebCore/rendering/style/RenderStyleConstants.h (181163 => 181164)


--- trunk/Source/WebCore/rendering/style/RenderStyleConstants.h	2015-03-06 18:13:10 UTC (rev 181163)
+++ trunk/Source/WebCore/rendering/style/RenderStyleConstants.h	2015-03-06 18:14:10 UTC (rev 181164)
@@ -63,11 +63,12 @@
 // A simple StyleDifference does not provide enough information so we return a bit mask of
 // StyleDifferenceContextSensitiveProperties from RenderStyle::diff() too.
 enum StyleDifferenceContextSensitiveProperty {
-    ContextSensitivePropertyNone = 0,
-    ContextSensitivePropertyTransform = (1 << 0),
-    ContextSensitivePropertyOpacity = (1 << 1),
-    ContextSensitivePropertyFilter = (1 << 2),
-    ContextSensitivePropertyClipRect = (1 << 3)
+    ContextSensitivePropertyNone        = 0,
+    ContextSensitivePropertyTransform   = 1 << 0,
+    ContextSensitivePropertyOpacity     = 1 << 1,
+    ContextSensitivePropertyFilter      = 1 << 2,
+    ContextSensitivePropertyClipRect    = 1 << 3,
+    ContextSensitivePropertyClipPath    = 1 << 4
 };
 
 // Static pseudo styles. Dynamic ones are produced on the fly.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to