Title: [131626] trunk
Revision
131626
Author
simon.fra...@apple.com
Date
2012-10-17 11:20:31 -0700 (Wed, 17 Oct 2012)

Log Message

GraphicsLayer visible rect computation needs to use the current animating transform
https://bugs.webkit.org/show_bug.cgi?id=99529

Reviewed by Dean Jackson.

Source/WebCore:

If we're running an accelerated animation of transform
on a GraphicsLayerCA, the current value of the transform won't
be reflected in the GraphicsLayer's m_transform. However,
we need the current value of the transform in order to correctly
compute the visible rect of this layer and descendants.

Add a function to GraphicsLayerClient to retrieve the current
value of the transform from the client.

RenderLayer's currentTransform() used to return a transform
with transform-origin baked in; GraphicsLayerClient needs one
that excludes transform-origin, so enhance RenderLayer::currentTransform()
to be able to produce either.

Tests: compositing/visible-rect/animated-from-none.html
       compositing/visible-rect/animated.html

* platform/graphics/GraphicsLayerClient.h:
(WebCore):
(GraphicsLayerClient):
(WebCore::GraphicsLayerClient::getCurrentTransform):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::computeVisibleRect):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::currentTransform):
* rendering/RenderLayer.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::currentTransform):
* rendering/RenderLayerBacking.h:
(RenderLayerBacking):

LayoutTests:

Tests that exercise visible-rect computation on an animating layer.

* compositing/visible-rect/animated-expected.txt: Added.
* compositing/visible-rect/animated-from-none-expected.txt: Added.
* compositing/visible-rect/animated-from-none.html: Added.
* compositing/visible-rect/animated.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (131625 => 131626)


--- trunk/LayoutTests/ChangeLog	2012-10-17 18:18:12 UTC (rev 131625)
+++ trunk/LayoutTests/ChangeLog	2012-10-17 18:20:31 UTC (rev 131626)
@@ -1,3 +1,17 @@
+2012-10-17  Simon Fraser  <simon.fra...@apple.com>
+
+        GraphicsLayer visible rect computation needs to use the current animating transform
+        https://bugs.webkit.org/show_bug.cgi?id=99529
+
+        Reviewed by Dean Jackson.
+
+        Tests that exercise visible-rect computation on an animating layer.
+
+        * compositing/visible-rect/animated-expected.txt: Added.
+        * compositing/visible-rect/animated-from-none-expected.txt: Added.
+        * compositing/visible-rect/animated-from-none.html: Added.
+        * compositing/visible-rect/animated.html: Added.
+
 2012-10-17  Sadrul Habib Chowdhury  <sad...@chromium.org>
 
         plugins: Allow a plugin to dictate whether it can receive drag events or not.

Added: trunk/LayoutTests/compositing/visible-rect/animated-expected.txt (0 => 131626)


--- trunk/LayoutTests/compositing/visible-rect/animated-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/compositing/visible-rect/animated-expected.txt	2012-10-17 18:20:31 UTC (rev 131626)
@@ -0,0 +1,33 @@
+(GraphicsLayer
+  (bounds 800.00 600.00)
+  (visible rect 0.00, 0.00 800.00 x 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (visible rect 0.00, 0.00 800.00 x 600.00)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 502.00 202.00)
+          (visible rect 0.00, 0.00 502.00 x 202.00)
+          (children 1
+            (GraphicsLayer
+              (position 1.00 1.00)
+              (bounds 500.00 200.00)
+              (visible rect 0.00, 0.00 500.00 x 200.00)
+              (children 1
+                (GraphicsLayer
+                  (bounds 200.00 200.00)
+                  (drawsContent 1)
+                  (transform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [-100.00 0.00 0.00 1.00])
+                  (visible rect 100.00, 0.00 100.00 x 200.00)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
Property changes on: trunk/LayoutTests/compositing/visible-rect/animated-expected.txt
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/compositing/visible-rect/animated-from-none-expected.txt (0 => 131626)


--- trunk/LayoutTests/compositing/visible-rect/animated-from-none-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/compositing/visible-rect/animated-from-none-expected.txt	2012-10-17 18:20:31 UTC (rev 131626)
@@ -0,0 +1,33 @@
+(GraphicsLayer
+  (bounds 800.00 600.00)
+  (visible rect 0.00, 0.00 800.00 x 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (visible rect 0.00, 0.00 800.00 x 600.00)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 502.00 202.00)
+          (visible rect 0.00, 0.00 502.00 x 202.00)
+          (children 1
+            (GraphicsLayer
+              (position 1.00 1.00)
+              (bounds 500.00 200.00)
+              (visible rect 0.00, 0.00 500.00 x 200.00)
+              (children 1
+                (GraphicsLayer
+                  (position -100.00 0.00)
+                  (bounds 200.00 200.00)
+                  (drawsContent 1)
+                  (visible rect 100.00, 0.00 100.00 x 200.00)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
Property changes on: trunk/LayoutTests/compositing/visible-rect/animated-from-none-expected.txt
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/compositing/visible-rect/animated-from-none.html (0 => 131626)


--- trunk/LayoutTests/compositing/visible-rect/animated-from-none.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/visible-rect/animated-from-none.html	2012-10-17 18:20:31 UTC (rev 131626)
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        .container {
+            position: relative;
+            height: 200px;
+            width: 500px;
+            border: 1px solid black;
+            overflow: hidden;
+            z-index: 0;
+        }
+        
+        .box {
+            position: absolute;
+            left: -100px;
+            width: 200px;
+            height: 200px;
+            background-color: blue;
+            -webkit-animation: move 20000000s linear;
+        }
+        
+        @-webkit-keyframes move {
+            from { -webkit-transform: none; }
+            to   { -webkit-transform: translateX(400px); }
+        }
+    </style>
+    <script>
+        if (window.testRunner) {
+            testRunner.dumpAsText();
+            testRunner.waitUntilDone();
+        }
+
+        function doTest()
+        {
+            document.getElementById('animated').addEventListener('webkitAnimationStart', function() {
+                if (window.internals)
+                    document.getElementById('layers').innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS)
+
+                if (window.testRunner)
+                    testRunner.notifyDone();
+            }, false);
+        }
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+
+    <div class="container">
+        <div id="animated" class="box"></div>
+    </div>
+
+<pre id="layers">Layer tree goes here when testing</pre>
+</body>
+</html>
Property changes on: trunk/LayoutTests/compositing/visible-rect/animated-from-none.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/compositing/visible-rect/animated.html (0 => 131626)


--- trunk/LayoutTests/compositing/visible-rect/animated.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/visible-rect/animated.html	2012-10-17 18:20:31 UTC (rev 131626)
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        .container {
+            position: relative;
+            height: 200px;
+            width: 500px;
+            border: 1px solid black;
+            overflow: hidden;
+            z-index: 0;
+        }
+        
+        .box {
+            position: absolute;
+            width: 200px;
+            height: 200px;
+            background-color: blue;
+            -webkit-animation: move 20000000s linear;
+        }
+        
+        @-webkit-keyframes move {
+            from { -webkit-transform: translateX(-100px); }
+            to   { -webkit-transform: translateX(300px); }
+        }
+    </style>
+    <script>
+        if (window.testRunner) {
+            testRunner.dumpAsText();
+            testRunner.waitUntilDone();
+        }
+
+        function doTest()
+        {
+            document.getElementById('animated').addEventListener('webkitAnimationStart', function() {
+                if (window.internals)
+                    document.getElementById('layers').innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS)
+
+                if (window.testRunner)
+                    testRunner.notifyDone();
+            }, false);
+        }
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+
+    <div class="container">
+        <div id="animated" class="box"></div>
+    </div>
+
+<pre id="layers">Layer tree goes here when testing</pre>
+</body>
+</html>
Property changes on: trunk/LayoutTests/compositing/visible-rect/animated.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (131625 => 131626)


--- trunk/Source/WebCore/ChangeLog	2012-10-17 18:18:12 UTC (rev 131625)
+++ trunk/Source/WebCore/ChangeLog	2012-10-17 18:20:31 UTC (rev 131626)
@@ -1,3 +1,41 @@
+2012-10-17  Simon Fraser  <simon.fra...@apple.com>
+
+        GraphicsLayer visible rect computation needs to use the current animating transform
+        https://bugs.webkit.org/show_bug.cgi?id=99529
+
+        Reviewed by Dean Jackson.
+
+        If we're running an accelerated animation of transform
+        on a GraphicsLayerCA, the current value of the transform won't
+        be reflected in the GraphicsLayer's m_transform. However,
+        we need the current value of the transform in order to correctly
+        compute the visible rect of this layer and descendants.
+        
+        Add a function to GraphicsLayerClient to retrieve the current
+        value of the transform from the client.
+        
+        RenderLayer's currentTransform() used to return a transform
+        with transform-origin baked in; GraphicsLayerClient needs one
+        that excludes transform-origin, so enhance RenderLayer::currentTransform()
+        to be able to produce either.
+
+        Tests: compositing/visible-rect/animated-from-none.html
+               compositing/visible-rect/animated.html
+
+        * platform/graphics/GraphicsLayerClient.h:
+        (WebCore):
+        (GraphicsLayerClient):
+        (WebCore::GraphicsLayerClient::getCurrentTransform):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::computeVisibleRect):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::currentTransform):
+        * rendering/RenderLayer.h:
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::currentTransform):
+        * rendering/RenderLayerBacking.h:
+        (RenderLayerBacking):
+
 2012-10-17  Sadrul Habib Chowdhury  <sad...@chromium.org>
 
         plugins: Allow a plugin to dictate whether it can receive drag events or not.

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h (131625 => 131626)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h	2012-10-17 18:18:12 UTC (rev 131625)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h	2012-10-17 18:20:31 UTC (rev 131626)
@@ -30,11 +30,12 @@
 
 namespace WebCore {
 
+class FloatPoint;
 class GraphicsContext;
 class GraphicsLayer;
 class IntPoint;
 class IntRect;
-class FloatPoint;
+class TransformationMatrix;
 
 enum GraphicsLayerPaintingPhaseFlags {
     GraphicsLayerPaintBackground = (1 << 0),
@@ -69,6 +70,10 @@
     virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& inClip) = 0;
     virtual void didCommitChangesForLayer(const GraphicsLayer*) const { }
 
+    // Provides current transform (taking transform-origin and animations into account). Input matrix has been
+    // initialized to identity already. Returns false if the layer has no transform.
+    virtual bool getCurrentTransform(const GraphicsLayer*, TransformationMatrix&) const { return false; }
+
     // Multiplier for backing store size, related to high DPI.
     virtual float deviceScaleFactor() const { return 1; }
     // Page scale factor.

Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (131625 => 131626)


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2012-10-17 18:18:12 UTC (rev 131625)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2012-10-17 18:20:31 UTC (rev 131626)
@@ -921,12 +921,13 @@
 
     TransformationMatrix layerTransform;
     layerTransform.translate(m_position.x(), m_position.y());
-    
-    if (!transform().isIdentity()) {
+
+    TransformationMatrix currentTransform;
+    if (client() && client()->getCurrentTransform(this, currentTransform) && !currentTransform.isIdentity()) {
         FloatPoint3D absoluteAnchorPoint(anchorPoint());
         absoluteAnchorPoint.scale(size().width(), size().height(), 1);
         layerTransform.translate3d(absoluteAnchorPoint.x(), absoluteAnchorPoint.y(), absoluteAnchorPoint.z());
-        layerTransform.multiply(transform());
+        layerTransform.multiply(currentTransform);
         layerTransform.translate3d(-absoluteAnchorPoint.x(), -absoluteAnchorPoint.y(), -absoluteAnchorPoint.z());
     }
 

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (131625 => 131626)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2012-10-17 18:18:12 UTC (rev 131625)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2012-10-17 18:20:31 UTC (rev 131626)
@@ -597,7 +597,7 @@
         dirty3DTransformedDescendantStatus();
 }
 
-TransformationMatrix RenderLayer::currentTransform() const
+TransformationMatrix RenderLayer::currentTransform(RenderStyle::ApplyTransformOrigin applyOrigin) const
 {
     if (!m_transform)
         return TransformationMatrix();
@@ -606,10 +606,19 @@
     if (renderer()->style()->isRunningAcceleratedAnimation()) {
         TransformationMatrix currTransform;
         RefPtr<RenderStyle> style = renderer()->animation()->getAnimatedStyleForRenderer(renderer());
-        style->applyTransform(currTransform, renderBox()->pixelSnappedBorderBoxRect().size(), RenderStyle::IncludeTransformOrigin);
+        style->applyTransform(currTransform, renderBox()->pixelSnappedBorderBoxRect().size(), applyOrigin);
         makeMatrixRenderable(currTransform, canRender3DTransforms());
         return currTransform;
     }
+
+    // m_transform includes transform-origin, so we need to recompute the transform here.
+    if (applyOrigin == RenderStyle::ExcludeTransformOrigin) {
+        RenderBox* box = renderBox();
+        TransformationMatrix currTransform;
+        box->style()->applyTransform(currTransform, box->pixelSnappedBorderBoxRect().size(), RenderStyle::ExcludeTransformOrigin);
+        makeMatrixRenderable(currTransform, canRender3DTransforms());
+        return currTransform;
+    }
 #endif
 
     return *m_transform;

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (131625 => 131626)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2012-10-17 18:18:12 UTC (rev 131625)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2012-10-17 18:20:31 UTC (rev 131626)
@@ -595,7 +595,7 @@
     // currentTransform computes a transform which takes accelerated animations into account. The
     // resulting transform has transform-origin baked in. If the layer does not have a transform,
     // returns the identity matrix.
-    TransformationMatrix currentTransform() const;
+    TransformationMatrix currentTransform(RenderStyle::ApplyTransformOrigin = RenderStyle::IncludeTransformOrigin) const;
     TransformationMatrix renderableTransform(PaintBehavior) const;
     
     // Get the perspective transform, which is applied to transformed sublayers.

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (131625 => 131626)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2012-10-17 18:18:12 UTC (rev 131625)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2012-10-17 18:20:31 UTC (rev 131626)
@@ -1539,6 +1539,18 @@
     compositor()->didFlushChangesForLayer(m_owningLayer);
 }
 
+bool RenderLayerBacking::getCurrentTransform(const GraphicsLayer* graphicsLayer, TransformationMatrix& transform) const
+{
+    if (graphicsLayer != m_graphicsLayer)
+        return false;
+
+    if (m_owningLayer->hasTransform()) {
+        transform = m_owningLayer->currentTransform(RenderStyle::ExcludeTransformOrigin);
+        return true;
+    }
+    return false;
+}
+
 bool RenderLayerBacking::showDebugBorders(const GraphicsLayer*) const
 {
     return compositor() ? compositor()->compositorShowDebugBorders() : false;

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.h (131625 => 131626)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.h	2012-10-17 18:18:12 UTC (rev 131625)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.h	2012-10-17 18:20:31 UTC (rev 131626)
@@ -148,6 +148,7 @@
     virtual float deviceScaleFactor() const;
     virtual float pageScaleFactor() const;
     virtual void didCommitChangesForLayer(const GraphicsLayer*) const;
+    virtual bool getCurrentTransform(const GraphicsLayer*, TransformationMatrix&) const;
 
     virtual bool showDebugBorders(const GraphicsLayer*) const;
     virtual bool showRepaintCounter(const GraphicsLayer*) const;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to