Title: [123151] trunk
Revision
123151
Author
[email protected]
Date
2012-07-19 15:02:47 -0700 (Thu, 19 Jul 2012)

Log Message

Keep overlap testing on for descendants of an animating element
https://bugs.webkit.org/show_bug.cgi?id=91787

Reviewed by Beth Dakin.

Source/WebCore:

RenderLayerCompositor::computeCompositingRequirements() would turn off
overlap testing for descendants of a layer that has a 3D transform,
or has an animating transform. This could cause compositing changes
inside an animating element when transitions start and stop, which
is undesirable.

Instead, we can keep overlap testing on for descendants of that
animating element, but we have to turn it off for layers later
in z-order.

Also enhance the "IndirectCompositingReason" flags so that in
the compositing log output, we can distinguish between layers that
were composited as a result of overlap testing from those compositing
for stacking reasons.

Test: compositing/layer-creation/animation-overlap-with-children.html

* rendering/RenderLayer.h: New IndirectCompositingReason value to
distinguish overlap from stacking.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::computeCompositingRequirements):
Use an IndirectCompositingReason enum rather than a bool to track whether
the layer starts as composited.
Remove the if (layer->has3DTransform() || isRunningAcceleratedTransformAnimation(layer->renderer()))
check that turned off overlap testing for descendants of this layer.
Use IndirectCompositingForStacking (somewhat arbitrarily) for reflection layers.
Turn overlap testing off for layers later in the z-order.
(WebCore::RenderLayerCompositor::requiresOwnBackingStore): Take IndirectCompositingForStacking into
account.
(WebCore::RenderLayerCompositor::reasonForCompositing): Improve the logging output.

LayoutTests:

Test with two layers inside an animating container; one should be composited
because of overlap, the other should not be.

* compositing/layer-creation/animation-overlap-with-children-expected.txt: Added.
* compositing/layer-creation/animation-overlap-with-children.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (123150 => 123151)


--- trunk/LayoutTests/ChangeLog	2012-07-19 21:54:19 UTC (rev 123150)
+++ trunk/LayoutTests/ChangeLog	2012-07-19 22:02:47 UTC (rev 123151)
@@ -1,3 +1,16 @@
+2012-07-19  Simon Fraser  <[email protected]>
+
+        Keep overlap testing on for descendants of an animating element
+        https://bugs.webkit.org/show_bug.cgi?id=91787
+
+        Reviewed by Beth Dakin.
+
+        Test with two layers inside an animating container; one should be composited
+        because of overlap, the other should not be.
+
+        * compositing/layer-creation/animation-overlap-with-children-expected.txt: Added.
+        * compositing/layer-creation/animation-overlap-with-children.html: Added.
+
 2012-07-19  Luciano Wolf  <[email protected]>
 
         [Qt] [Part 5] platform/qt/css1 tests needs update after rebaseline and new testfonts

Added: trunk/LayoutTests/compositing/layer-creation/animation-overlap-with-children-expected.txt (0 => 123151)


--- trunk/LayoutTests/compositing/layer-creation/animation-overlap-with-children-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/compositing/layer-creation/animation-overlap-with-children-expected.txt	2012-07-19 22:02:47 UTC (rev 123151)
@@ -0,0 +1,35 @@
+Should be compositedShould not be composited
+Should be composited
+(GraphicsLayer
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (children 2
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 262.00 212.00)
+          (drawsContent 1)
+          (children 2
+            (GraphicsLayer
+              (position 6.00 6.00)
+              (bounds 250.00 50.00)
+              (drawsContent 1)
+            )
+            (GraphicsLayer
+              (position 11.00 21.00)
+              (bounds 100.00 100.00)
+              (drawsContent 1)
+            )
+          )
+        )
+        (GraphicsLayer
+          (position 18.00 230.00)
+          (bounds 100.00 100.00)
+          (drawsContent 1)
+        )
+      )
+    )
+  )
+)
+
Property changes on: trunk/LayoutTests/compositing/layer-creation/animation-overlap-with-children-expected.txt
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/compositing/layer-creation/animation-overlap-with-children.html (0 => 123151)


--- trunk/LayoutTests/compositing/layer-creation/animation-overlap-with-children.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/layer-creation/animation-overlap-with-children.html	2012-07-19 22:02:47 UTC (rev 123151)
@@ -0,0 +1,90 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+  <style>
+    
+    .animating {
+      -webkit-animation: slide 10s alternate linear infinite;
+    }
+    
+    .container {
+      height: 200px;
+      width: 250px;
+      padding: 5px;
+      border: 1px solid black;
+    }
+    
+    .banner {
+      width: 100%;
+      height: 50px;
+      background-color: silver;
+    }
+    
+    .box {
+      position: relative;
+      height: 100px;
+      width: 100px;
+      margin: 10px;
+      background-color: blue;
+    }
+    
+    .test1 {
+      position: absolute;
+      left: 0;
+      top: 10px;
+      background-color: orange;
+    }
+
+    .test2 {
+      position: absolute;
+      top: 60px;
+      left: 120px;
+      background-color: orange;
+    }
+    
+    .composited {
+      -webkit-transform: translateZ(0);
+    }
+    
+    @-webkit-keyframes slide {
+      from { -webkit-transform: none; }
+      to { -webkit-transform: translateX(100px); }
+    }
+  </style>
+  <script>
+    if (window.testRunner) {
+      testRunner.dumpAsText();
+      testRunner.waitUntilDone();
+    }
+      
+    function runTest()
+    {
+      var box = document.getElementById('to-animate');
+      box.addEventListener('webkitAnimationStart', animationStarted, false);
+      box.classList.add('animating');
+    }
+    
+    function animationStarted()
+    {
+      if (window.testRunner) {
+        document.getElementById('layers').innerText = testRunner.layerTreeAsText();
+        testRunner.notifyDone();
+      }
+    }
+    window.addEventListener('load', runTest, false);
+  </script>
+</head>
+<body>
+
+  <div id="to-animate" class="container">
+    <div class="composited banner"></div>
+    <div class="test1 box">Should be composited</div>
+    <div class="test2 box">Should not be composited</div>
+  </div>
+
+  <div class="box">Should be composited</div>
+  <pre id="layers">Layer tree goes here in DRT</pre>
+
+</body>
+</html>
Property changes on: trunk/LayoutTests/compositing/layer-creation/animation-overlap-with-children.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (123150 => 123151)


--- trunk/Source/WebCore/ChangeLog	2012-07-19 21:54:19 UTC (rev 123150)
+++ trunk/Source/WebCore/ChangeLog	2012-07-19 22:02:47 UTC (rev 123151)
@@ -1,3 +1,41 @@
+2012-07-19  Simon Fraser  <[email protected]>
+
+        Keep overlap testing on for descendants of an animating element
+        https://bugs.webkit.org/show_bug.cgi?id=91787
+
+        Reviewed by Beth Dakin.
+
+        RenderLayerCompositor::computeCompositingRequirements() would turn off
+        overlap testing for descendants of a layer that has a 3D transform,
+        or has an animating transform. This could cause compositing changes
+        inside an animating element when transitions start and stop, which
+        is undesirable.
+        
+        Instead, we can keep overlap testing on for descendants of that
+        animating element, but we have to turn it off for layers later
+        in z-order.
+        
+        Also enhance the "IndirectCompositingReason" flags so that in
+        the compositing log output, we can distinguish between layers that
+        were composited as a result of overlap testing from those compositing
+        for stacking reasons.
+
+        Test: compositing/layer-creation/animation-overlap-with-children.html
+
+        * rendering/RenderLayer.h: New IndirectCompositingReason value to
+        distinguish overlap from stacking.
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::computeCompositingRequirements):
+        Use an IndirectCompositingReason enum rather than a bool to track whether
+        the layer starts as composited.
+        Remove the if (layer->has3DTransform() || isRunningAcceleratedTransformAnimation(layer->renderer()))
+        check that turned off overlap testing for descendants of this layer.
+        Use IndirectCompositingForStacking (somewhat arbitrarily) for reflection layers.
+        Turn overlap testing off for layers later in the z-order.
+        (WebCore::RenderLayerCompositor::requiresOwnBackingStore): Take IndirectCompositingForStacking into
+        account.
+        (WebCore::RenderLayerCompositor::reasonForCompositing): Improve the logging output.
+
 2012-07-19  No'am Rosenthal  <[email protected]>
 
         [Qt] Enable CSS shaders in Qt (software mode)

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (123150 => 123151)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2012-07-19 21:54:19 UTC (rev 123150)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2012-07-19 22:02:47 UTC (rev 123151)
@@ -845,6 +845,7 @@
     
     enum IndirectCompositingReason {
         NoIndirectCompositingReason,
+        IndirectCompositingForStacking,
         IndirectCompositingForOverlap,
         IndirectCompositingForBackgroundLayer,
         IndirectCompositingForGraphicalEffect, // opacity, mask, filter, transform etc.

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (123150 => 123151)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2012-07-19 21:54:19 UTC (rev 123150)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2012-07-19 22:02:47 UTC (rev 123151)
@@ -730,7 +730,7 @@
     // Clear the flag
     layer->setHasCompositingDescendant(false);
     
-    bool mustOverlapCompositedLayers = compositingState.m_subtreeIsCompositing;
+    RenderLayer::IndirectCompositingReason compositingReason = compositingState.m_subtreeIsCompositing ? RenderLayer::IndirectCompositingForStacking : RenderLayer::NoIndirectCompositingReason;
 
     bool haveComputedBounds = false;
     IntRect absBounds;
@@ -742,10 +742,10 @@
         if (absBounds.isEmpty())
             absBounds.setSize(IntSize(1, 1));
         haveComputedBounds = true;
-        mustOverlapCompositedLayers = overlapMap->overlapsLayers(absBounds);
+        compositingReason = overlapMap->overlapsLayers(absBounds) ? RenderLayer::IndirectCompositingForOverlap : RenderLayer::NoIndirectCompositingReason;
     }
     
-    layer->setIndirectCompositingReason(mustOverlapCompositedLayers ? RenderLayer::IndirectCompositingForOverlap : RenderLayer::NoIndirectCompositingReason);
+    layer->setIndirectCompositingReason(compositingReason);
     
     // The children of this layer don't need to composite, unless there is
     // a compositing layer among them, so start by inheriting the compositing
@@ -762,11 +762,6 @@
 
         if (overlapMap)
             overlapMap->pushCompositingContainer();
-
-        if (layer->has3DTransform() || isRunningAcceleratedTransformAnimation(layer->renderer())) {
-            // If we have a 3D transform, or are animating transform, then turn overlap testing off.
-            childState.m_testingOverlap = false;
-        }
     }
 
 #if ENABLE(VIDEO)
@@ -852,15 +847,15 @@
     ASSERT(willBeComposited == needsToBeComposited(layer));
     if (layer->reflectionLayer()) {
         // FIXME: Shouldn't we call computeCompositingRequirements to handle a reflection overlapping with another renderer?
-        layer->reflectionLayer()->setIndirectCompositingReason(willBeComposited ? RenderLayer::IndirectCompositingForOverlap : RenderLayer::NoIndirectCompositingReason);
+        layer->reflectionLayer()->setIndirectCompositingReason(willBeComposited ? RenderLayer::IndirectCompositingForStacking : RenderLayer::NoIndirectCompositingReason);
     }
 
     // Subsequent layers in the parent stacking context also need to composite.
     if (childState.m_subtreeIsCompositing)
         compositingState.m_subtreeIsCompositing = true;
 
-    // We have to keep overlap testing disabled for later layers.
-    if (!childState.m_testingOverlap)
+    // Turn overlap testing off for later layers if it's already off, or if we have a 3D transform or an animating transform.
+    if (!childState.m_testingOverlap || layer->has3DTransform() || isRunningAcceleratedTransformAnimation(layer->renderer()))
         compositingState.m_testingOverlap = false;
 
     // Set the flag to say that this SC has compositing children.
@@ -1488,6 +1483,7 @@
     if (layer->mustCompositeForIndirectReasons()) {
         RenderLayer::IndirectCompositingReason reason = layer->indirectCompositingReason();
         return reason == RenderLayer::IndirectCompositingForOverlap
+            || reason == RenderLayer::IndirectCompositingForStacking
             || reason == RenderLayer::IndirectCompositingForBackgroundLayer
             || reason == RenderLayer::IndirectCompositingForGraphicalEffect
             || reason == RenderLayer::IndirectCompositingForPreserve3D; // preserve-3d has to create backing store to ensure that 3d-transformed elements intersect.
@@ -1534,9 +1530,11 @@
     if (requiresCompositingForPosition(renderer, layer))
         return "position: fixed";
 
-    // This includes layers made composited by requiresCompositingWhenDescendantsAreCompositing().
+    if (layer->indirectCompositingReason() == RenderLayer::IndirectCompositingForStacking)
+        return "stacking";
+
     if (layer->indirectCompositingReason() == RenderLayer::IndirectCompositingForOverlap)
-        return "overlap/stacking";
+        return "overlap";
 
     if (layer->indirectCompositingReason() == RenderLayer::IndirectCompositingForBackgroundLayer)
         return "negative z-index children";
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to