Diff
Modified: trunk/LayoutTests/ChangeLog (131247 => 131248)
--- trunk/LayoutTests/ChangeLog 2012-10-13 01:16:09 UTC (rev 131247)
+++ trunk/LayoutTests/ChangeLog 2012-10-13 01:16:14 UTC (rev 131248)
@@ -1,5 +1,22 @@
2012-10-12 Simon Fraser <simon.fra...@apple.com>
+ Fix GraphicsLayerCA visible rect computation in the face of perspective and preserve-3d
+ https://bugs.webkit.org/show_bug.cgi?id=99212
+
+ Reviewed by Tim Horton.
+
+ Layer tree tests that include visible rect information, to test visible rect
+ computation for more complex layer trees.
+
+ * compositing/visible-rect/3d-transform-style-expected.txt: Added.
+ * compositing/visible-rect/3d-transform-style.html: Added.
+ * compositing/visible-rect/3d-transformed-expected.txt: Added.
+ * compositing/visible-rect/3d-transformed.html: Added.
+ * compositing/visible-rect/nested-transform-expected.txt: Added.
+ * compositing/visible-rect/nested-transform.html: Added.
+
+2012-10-12 Simon Fraser <simon.fra...@apple.com>
+
Add some initial visible rect tests and tweak the visible wash layer
https://bugs.webkit.org/show_bug.cgi?id=99095
Added: trunk/LayoutTests/compositing/visible-rect/3d-transform-style-expected.txt (0 => 131248)
--- trunk/LayoutTests/compositing/visible-rect/3d-transform-style-expected.txt (rev 0)
+++ trunk/LayoutTests/compositing/visible-rect/3d-transform-style-expected.txt 2012-10-13 01:16:14 UTC (rev 131248)
@@ -0,0 +1,69 @@
+(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 2
+ (GraphicsLayer
+ (position 18.00 10.00)
+ (bounds 204.00 204.00)
+ (visible rect 0.00, 0.00 204.00 x 204.00)
+ (children 1
+ (GraphicsLayer
+ (position 2.00 2.00)
+ (bounds 200.00 200.00)
+ (childrenTransform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.07 0.07 1.00 -0.00] [0.00 0.00 0.00 1.00])
+ (visible rect 0.00, 0.00 200.00 x 200.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 200.00 0.00)
+ (preserves3D 1)
+ (visible rect 0.00, 0.00 0.00 x 0.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 300.00 300.00)
+ (drawsContent 1)
+ (transform [1.00 0.00 0.00 0.00] [0.00 0.91 0.42 0.00] [0.00 -0.42 0.91 0.00] [0.00 0.00 0.00 1.00])
+ (visible rect 0.00, 0.00 213.67 x 200.68)
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ (GraphicsLayer
+ (position 18.00 224.00)
+ (bounds 204.00 204.00)
+ (visible rect 0.00, 0.00 204.00 x 204.00)
+ (children 1
+ (GraphicsLayer
+ (position 2.00 2.00)
+ (bounds 200.00 200.00)
+ (childrenTransform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.07 0.07 1.00 -0.00] [0.00 0.00 0.00 1.00])
+ (visible rect 0.00, 0.00 200.00 x 200.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 200.00 0.00)
+ (preserves3D 1)
+ (visible rect 0.00, 0.00 0.00 x 0.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 300.00 300.00)
+ (drawsContent 1)
+ (transform [0.91 0.00 0.42 0.00] [0.00 1.00 0.00 0.00] [-0.42 0.00 0.91 0.00] [0.00 0.00 0.00 1.00])
+ (visible rect 0.00, 0.00 200.68 x 213.67)
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+)
+
Property changes on: trunk/LayoutTests/compositing/visible-rect/3d-transform-style-expected.txt
___________________________________________________________________
Added: svn:mime-type
Added: svn:keywords
Added: svn:eol-style
Added: trunk/LayoutTests/compositing/visible-rect/3d-transform-style.html (0 => 131248)
--- trunk/LayoutTests/compositing/visible-rect/3d-transform-style.html (rev 0)
+++ trunk/LayoutTests/compositing/visible-rect/3d-transform-style.html 2012-10-13 01:16:14 UTC (rev 131248)
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+ <style>
+ .container {
+ position: relative;
+ height: 200px;
+ width: 200px;
+ border: 2px solid rgba(0, 0, 0, 0.2);
+ overflow: hidden;
+ z-index: 0;
+ margin: 10px;
+ -webkit-perspective: 800px;
+ -webkit-perspective-origin: 50px 50px;
+ }
+
+ .intermediate {
+ -webkit-transform-style: preserve-3d;
+ }
+
+ .box {
+ position: absolute;
+ width: 300px;
+ height: 300px;
+ background-color: blue;
+ }
+ </style>
+ <script>
+ if (window.testRunner)
+ testRunner.dumpAsText();
+
+ function dumpLayers()
+ {
+ if (window.internals)
+ document.getElementById('layers').innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS)
+ }
+ window.addEventListener('load', dumpLayers, false);
+ </script>
+</head>
+<body>
+
+ <div class="container">
+ <div class="intermediate">
+ <div class="box" style="-webkit-transform: rotateX(25deg);"></div>
+ </div>
+ </div>
+
+ <div class="container">
+ <div class="intermediate">
+ <div class="box" style="-webkit-transform: rotateY(-25deg)"></div>
+ </div>
+ </div>
+
+<pre id="layers">Layer tree goes here when testing</pre>
+</body>
+</html>
Property changes on: trunk/LayoutTests/compositing/visible-rect/3d-transform-style.html
___________________________________________________________________
Added: svn:mime-type
Added: svn:keywords
Added: svn:eol-style
Added: trunk/LayoutTests/compositing/visible-rect/3d-transformed-expected.txt (0 => 131248)
--- trunk/LayoutTests/compositing/visible-rect/3d-transformed-expected.txt (rev 0)
+++ trunk/LayoutTests/compositing/visible-rect/3d-transformed-expected.txt 2012-10-13 01:16:14 UTC (rev 131248)
@@ -0,0 +1,57 @@
+(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 2
+ (GraphicsLayer
+ (position 18.00 10.00)
+ (bounds 204.00 204.00)
+ (visible rect 0.00, 0.00 204.00 x 204.00)
+ (children 1
+ (GraphicsLayer
+ (position 2.00 2.00)
+ (bounds 200.00 200.00)
+ (childrenTransform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.07 0.07 1.00 -0.00] [0.00 0.00 0.00 1.00])
+ (visible rect 0.00, 0.00 200.00 x 200.00)
+ (children 1
+ (GraphicsLayer
+ (anchor 0.20 0.20)
+ (bounds 500.00 500.00)
+ (drawsContent 1)
+ (transform [1.00 0.00 0.00 0.00] [0.00 0.71 0.71 0.00] [0.00 -0.71 0.71 0.00] [0.00 0.00 0.00 1.00])
+ (visible rect 0.00, 0.00 220.62 x 218.46)
+ )
+ )
+ )
+ )
+ )
+ (GraphicsLayer
+ (position 18.00 224.00)
+ (bounds 204.00 204.00)
+ (visible rect 0.00, 0.00 204.00 x 204.00)
+ (children 1
+ (GraphicsLayer
+ (position 2.00 2.00)
+ (bounds 200.00 200.00)
+ (childrenTransform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.07 0.07 1.00 -0.00] [0.00 0.00 0.00 1.00])
+ (visible rect 0.00, 0.00 200.00 x 200.00)
+ (children 1
+ (GraphicsLayer
+ (anchor 0.20 0.20)
+ (bounds 500.00 500.00)
+ (drawsContent 1)
+ (transform [0.71 0.00 0.71 0.00] [0.00 1.00 0.00 0.00] [-0.71 0.00 0.71 0.00] [0.00 0.00 0.00 1.00])
+ (visible rect 0.00, 0.00 218.46 x 220.62)
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+)
+
Property changes on: trunk/LayoutTests/compositing/visible-rect/3d-transformed-expected.txt
___________________________________________________________________
Added: svn:mime-type
Added: svn:keywords
Added: svn:eol-style
Added: trunk/LayoutTests/compositing/visible-rect/3d-transformed.html (0 => 131248)
--- trunk/LayoutTests/compositing/visible-rect/3d-transformed.html (rev 0)
+++ trunk/LayoutTests/compositing/visible-rect/3d-transformed.html 2012-10-13 01:16:14 UTC (rev 131248)
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+ <style>
+ .container {
+ position: relative;
+ height: 200px;
+ width: 200px;
+ border: 2px solid rgba(0, 0, 0, 0.2);
+ overflow: hidden;
+ margin: 10px;
+ -webkit-perspective: 800px;
+ -webkit-perspective-origin: 50px 50px;
+ }
+
+ .box {
+ position: absolute;
+ width: 500px;
+ height: 500px;
+ background-color: blue;
+ -webkit-transform-origin: 102px 102px;
+ }
+ </style>
+ <script>
+ if (window.testRunner)
+ testRunner.dumpAsText();
+
+ function dumpLayers()
+ {
+ if (window.internals)
+ document.getElementById('layers').innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS)
+ }
+ window.addEventListener('load', dumpLayers, false);
+ </script>
+</head>
+<body>
+
+ <div class="container">
+ <div class="box" style="-webkit-transform: rotateX(45deg);"></div>
+ </div>
+
+ <div class="container">
+ <div class="box" style="-webkit-transform: rotateY(-45deg)"></div>
+ </div>
+
+<pre id="layers">Layer tree goes here when testing</pre>
+</body>
+</html>
Property changes on: trunk/LayoutTests/compositing/visible-rect/3d-transformed.html
___________________________________________________________________
Added: svn:mime-type
Added: svn:keywords
Added: svn:eol-style
Added: trunk/LayoutTests/compositing/visible-rect/nested-transform-expected.txt (0 => 131248)
--- trunk/LayoutTests/compositing/visible-rect/nested-transform-expected.txt (rev 0)
+++ trunk/LayoutTests/compositing/visible-rect/nested-transform-expected.txt 2012-10-13 01:16:14 UTC (rev 131248)
@@ -0,0 +1,86 @@
+(GraphicsLayer
+ (bounds 785.00 669.00)
+ (visible rect 0.00, 0.00 785.00 x 600.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 785.00 669.00)
+ (visible rect 0.00, 0.00 785.00 x 600.00)
+ (children 2
+ (GraphicsLayer
+ (position 18.00 10.00)
+ (bounds 304.00 304.00)
+ (visible rect 0.00, 0.00 304.00 x 304.00)
+ (children 1
+ (GraphicsLayer
+ (position 2.00 2.00)
+ (bounds 300.00 300.00)
+ (childrenTransform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.26 0.26 1.00 -0.00] [0.00 0.00 0.00 1.00])
+ (visible rect 0.00, 0.00 300.00 x 300.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 300.00 0.00)
+ (preserves3D 1)
+ (transform [0.94 0.00 -0.34 0.00] [0.00 1.00 0.00 0.00] [0.34 0.00 0.94 0.00] [0.00 0.00 0.00 1.00])
+ (visible rect 0.00, 0.00 0.00 x 0.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 300.00 0.00)
+ (preserves3D 1)
+ (transform [0.94 0.00 -0.34 0.00] [0.00 1.00 0.00 0.00] [0.34 0.00 0.94 0.00] [0.00 0.00 0.00 1.00])
+ (visible rect 0.00, 0.00 0.00 x 0.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 500.00 500.00)
+ (drawsContent 1)
+ (transform [1.00 0.00 0.00 0.00] [0.00 0.82 0.57 0.00] [0.00 -0.57 0.82 0.00] [0.00 0.00 0.00 1.00])
+ (visible rect 0.00, 0.00 500.00 x 369.91)
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ (GraphicsLayer
+ (position 18.00 324.00)
+ (bounds 304.00 304.00)
+ (visible rect 0.00, 0.00 304.00 x 276.00)
+ (children 1
+ (GraphicsLayer
+ (position 2.00 2.00)
+ (bounds 300.00 300.00)
+ (childrenTransform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.26 0.26 1.00 -0.00] [0.00 0.00 0.00 1.00])
+ (visible rect 0.00, 0.00 300.00 x 274.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 300.00 0.00)
+ (preserves3D 1)
+ (visible rect 0.00, 0.00 0.00 x 0.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 300.00 0.00)
+ (preserves3D 1)
+ (transform [0.77 0.00 -0.64 0.00] [0.00 1.00 0.00 0.00] [0.64 0.00 0.77 0.00] [0.00 0.00 0.00 1.00])
+ (visible rect 0.00, 0.00 0.00 x 0.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 500.00 500.00)
+ (drawsContent 1)
+ (transform [1.00 0.00 0.00 0.00] [0.00 0.82 0.57 0.00] [0.00 -0.57 0.82 0.00] [0.00 0.00 0.00 1.00])
+ (visible rect 0.00, 0.00 500.00 x 351.87)
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+)
+
Property changes on: trunk/LayoutTests/compositing/visible-rect/nested-transform-expected.txt
___________________________________________________________________
Added: svn:mime-type
Added: svn:keywords
Added: svn:eol-style
Added: trunk/LayoutTests/compositing/visible-rect/nested-transform.html (0 => 131248)
--- trunk/LayoutTests/compositing/visible-rect/nested-transform.html (rev 0)
+++ trunk/LayoutTests/compositing/visible-rect/nested-transform.html 2012-10-13 01:16:14 UTC (rev 131248)
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+ <style>
+ .container {
+ position: relative;
+ height: 300px;
+ width: 300px;
+ border: 2px solid rgba(0, 0, 0, 0.2);
+ overflow: hidden;
+ margin: 10px;
+ -webkit-perspective: 400px;
+ -webkit-perspective-origin: 50px 50px;
+ }
+
+ .intermediate {
+ -webkit-transform-style: preserve-3d;
+ }
+
+ .box {
+ position: absolute;
+ width: 500px;
+ height: 500px;
+ background-color: blue;
+ }
+ </style>
+ <script>
+ if (window.testRunner)
+ testRunner.dumpAsText();
+
+ function dumpLayers()
+ {
+ if (window.internals)
+ document.getElementById('layers').innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS)
+ }
+ window.addEventListener('load', dumpLayers, false);
+ </script>
+</head>
+<body>
+
+ <div class="container">
+ <div class="intermediate" style="-webkit-transform: rotateY(20deg);">
+ <div class="intermediate" style="-webkit-transform: rotateY(20deg);">
+ <div class="box" style="-webkit-transform: rotateX(35deg);"></div>
+ </div>
+ </div>
+ </div>
+
+ <div class="container">
+ <div class="intermediate" style="-webkit-transform: rotateY(0);">
+ <div class="intermediate" style="-webkit-transform: rotateY(40deg);">
+ <div class="box" style="-webkit-transform: rotateX(35deg);"></div>
+ </div>
+ </div>
+ </div>
+
+
+<pre id="layers">Layer tree goes here when testing</pre>
+</body>
+</html>
Property changes on: trunk/LayoutTests/compositing/visible-rect/nested-transform.html
___________________________________________________________________
Added: svn:mime-type
Added: svn:keywords
Added: svn:eol-style
Modified: trunk/Source/WebCore/ChangeLog (131247 => 131248)
--- trunk/Source/WebCore/ChangeLog 2012-10-13 01:16:09 UTC (rev 131247)
+++ trunk/Source/WebCore/ChangeLog 2012-10-13 01:16:14 UTC (rev 131248)
@@ -1,3 +1,30 @@
+2012-10-12 Simon Fraser <simon.fra...@apple.com>
+
+ Fix GraphicsLayerCA visible rect computation in the face of perspective and preserve-3d
+ https://bugs.webkit.org/show_bug.cgi?id=99212
+
+ Reviewed by Tim Horton.
+
+ GraphicsLayerCA::computeVisibleRect() was incorrect for layer trees with perspective
+ and preserve-3d, so fix that, and add some tests.
+
+ Perspective is implemented via childrenTransform(); if our parent has one,
+ we have to left-multiply this into the transformation matrix.
+
+ We have to test both this layer and its parent when deciding whether to accumulate
+ or flatten.
+
+ Use state.mappedQuad() rather than state.lastPlanarQuad(), because the last planar
+ quad might be for some distant ancestor, and there may be intermediate preserve-3d
+ layers.
+
+ Tests: compositing/visible-rect/3d-transform-style.html
+ compositing/visible-rect/3d-transformed.html
+ compositing/visible-rect/nested-transform.html
+
+ * platform/graphics/ca/GraphicsLayerCA.cpp:
+ (WebCore::GraphicsLayerCA::computeVisibleRect):
+
2012-10-11 Simon Fraser <simon.fra...@apple.com>
Move TransformState code into its own member function, and remove a test that was prematurely added
Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (131247 => 131248)
--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2012-10-13 01:16:09 UTC (rev 131247)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2012-10-13 01:16:14 UTC (rev 131248)
@@ -916,20 +916,34 @@
void GraphicsLayerCA::computeVisibleRect(TransformState& state)
{
- TransformState::TransformAccumulation accumulation = preserves3D() ? TransformState::AccumulateTransform : TransformState::FlattenTransform;
- state.move(m_position.x(), m_position.y(), accumulation);
+ bool preserve3D = preserves3D() || (parent() ? parent()->preserves3D() : false);
+ TransformState::TransformAccumulation accumulation = preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransform;
+
+ TransformationMatrix layerTransform;
+ layerTransform.translate(m_position.x(), m_position.y());
if (!transform().isIdentity()) {
- TransformationMatrix transformWithAnchorPoint;
FloatPoint3D absoluteAnchorPoint(anchorPoint());
absoluteAnchorPoint.scale(size().width(), size().height(), 1);
- transformWithAnchorPoint.translate3d(absoluteAnchorPoint.x(), absoluteAnchorPoint.y(), absoluteAnchorPoint.z());
- transformWithAnchorPoint.multiply(transform());
- transformWithAnchorPoint.translate3d(-absoluteAnchorPoint.x(), -absoluteAnchorPoint.y(), -absoluteAnchorPoint.z());
- state.applyTransform(transformWithAnchorPoint, accumulation);
+ layerTransform.translate3d(absoluteAnchorPoint.x(), absoluteAnchorPoint.y(), absoluteAnchorPoint.z());
+ layerTransform.multiply(transform());
+ layerTransform.translate3d(-absoluteAnchorPoint.x(), -absoluteAnchorPoint.y(), -absoluteAnchorPoint.z());
}
+
+ if (GraphicsLayer* parentLayer = parent()) {
+ if (!parentLayer->childrenTransform().isIdentity()) {
+ FloatPoint3D parentAnchorPoint(parentLayer->anchorPoint());
+ parentAnchorPoint.scale(parentLayer->size().width(), parentLayer->size().height(), 1);
+
+ layerTransform.translateRight3d(-parentAnchorPoint.x(), -parentAnchorPoint.y(), -parentAnchorPoint.z());
+ layerTransform = parentLayer->childrenTransform() * layerTransform;
+ layerTransform.translateRight3d(parentAnchorPoint.x(), parentAnchorPoint.y(), parentAnchorPoint.z());
+ }
+ }
+
+ state.applyTransform(layerTransform, accumulation);
- FloatRect clipRectForChildren = state.lastPlanarQuad().boundingBox();
+ FloatRect clipRectForChildren = state.mappedQuad().boundingBox();
FloatRect clipRectForSelf(0, 0, m_size.width(), m_size.height());
clipRectForSelf.intersect(clipRectForChildren);
@@ -940,9 +954,6 @@
}
m_visibleRect = clipRectForSelf;
-
- if (!childrenTransform().isIdentity())
- state.applyTransform(childrenTransform(), accumulation);
}
void GraphicsLayerCA::recursiveCommitChanges(const TransformState& state, float pageScaleFactor, const FloatPoint& positionRelativeToBase, bool affectedByPageScale)