OLD | NEW |
---|---|
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/layer_tree_host_common.h" | 5 #include "cc/layer_tree_host_common.h" |
6 | 6 |
7 #include "cc/content_layer.h" | 7 #include "cc/content_layer.h" |
8 #include "cc/content_layer_client.h" | 8 #include "cc/content_layer_client.h" |
9 #include "cc/layer.h" | 9 #include "cc/layer.h" |
10 #include "cc/layer_animation_controller.h" | 10 #include "cc/layer_animation_controller.h" |
11 #include "cc/layer_impl.h" | 11 #include "cc/layer_impl.h" |
12 #include "cc/layer_sorter.h" | 12 #include "cc/layer_sorter.h" |
13 #include "cc/math_util.h" | 13 #include "cc/math_util.h" |
14 #include "cc/proxy.h" | 14 #include "cc/proxy.h" |
15 #include "cc/single_thread_proxy.h" | 15 #include "cc/single_thread_proxy.h" |
16 #include "cc/test/animation_test_common.h" | 16 #include "cc/test/animation_test_common.h" |
17 #include "cc/test/geometry_test_utils.h" | 17 #include "cc/test/geometry_test_utils.h" |
18 #include "cc/thread.h" | 18 #include "cc/thread.h" |
19 #include "ui/gfx/size_conversions.h" | 19 #include "ui/gfx/size_conversions.h" |
20 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
22 #include <public/WebTransformationMatrix.h> | 22 #include "ui/gfx/transform.h" |
23 | 23 |
24 using namespace WebKitTests; | 24 using namespace WebKitTests; |
25 using WebKit::WebTransformationMatrix; | 25 using gfx::Transform; |
26 | 26 |
27 namespace cc { | 27 namespace cc { |
28 namespace { | 28 namespace { |
29 | 29 |
30 template<typename LayerType> | 30 template<typename LayerType> |
31 void setLayerPropertiesForTestingInternal(LayerType* layer, const WebTransformat ionMatrix& transform, const WebTransformationMatrix& sublayerTransform, const gf x::PointF& anchor, const gfx::PointF& position, const gfx::Size& bounds, bool pr eserves3D) | 31 void setLayerPropertiesForTestingInternal(LayerType* layer, const Transform& tra nsform, const Transform& sublayerTransform, const gfx::PointF& anchor, const gfx ::PointF& position, const gfx::Size& bounds, bool preserves3D) |
32 { | 32 { |
33 layer->setTransform(transform); | 33 layer->setTransform(transform); |
34 layer->setSublayerTransform(sublayerTransform); | 34 layer->setSublayerTransform(sublayerTransform); |
35 layer->setAnchorPoint(anchor); | 35 layer->setAnchorPoint(anchor); |
36 layer->setPosition(position); | 36 layer->setPosition(position); |
37 layer->setBounds(bounds); | 37 layer->setBounds(bounds); |
38 layer->setPreserves3D(preserves3D); | 38 layer->setPreserves3D(preserves3D); |
39 } | 39 } |
40 | 40 |
41 void setLayerPropertiesForTesting(Layer* layer, const WebTransformationMatrix& t ransform, const WebTransformationMatrix& sublayerTransform, const gfx::PointF& a nchor, const gfx::PointF& position, const gfx::Size& bounds, bool preserves3D) | 41 void setLayerPropertiesForTesting(Layer* layer, const Transform& transform, cons t Transform& sublayerTransform, const gfx::PointF& anchor, const gfx::PointF& po sition, const gfx::Size& bounds, bool preserves3D) |
42 { | 42 { |
43 setLayerPropertiesForTestingInternal<Layer>(layer, transform, sublayerTransf orm, anchor, position, bounds, preserves3D); | 43 setLayerPropertiesForTestingInternal<Layer>(layer, transform, sublayerTransf orm, anchor, position, bounds, preserves3D); |
44 layer->setAutomaticallyComputeRasterScale(true); | 44 layer->setAutomaticallyComputeRasterScale(true); |
45 } | 45 } |
46 | 46 |
47 void setLayerPropertiesForTesting(LayerImpl* layer, const WebTransformationMatri x& transform, const WebTransformationMatrix& sublayerTransform, const gfx::Point F& anchor, const gfx::PointF& position, const gfx::Size& bounds, bool preserves3 D) | 47 void setLayerPropertiesForTesting(LayerImpl* layer, const Transform& transform, const Transform& sublayerTransform, const gfx::PointF& anchor, const gfx::PointF & position, const gfx::Size& bounds, bool preserves3D) |
48 { | 48 { |
49 setLayerPropertiesForTestingInternal<LayerImpl>(layer, transform, sublayerTr ansform, anchor, position, bounds, preserves3D); | 49 setLayerPropertiesForTestingInternal<LayerImpl>(layer, transform, sublayerTr ansform, anchor, position, bounds, preserves3D); |
50 layer->setContentBounds(bounds); | 50 layer->setContentBounds(bounds); |
51 } | 51 } |
52 | 52 |
53 void executeCalculateDrawTransformsAndVisibility(Layer* rootLayer, float deviceS caleFactor = 1, float pageScaleFactor = 1) | 53 void executeCalculateDrawTransformsAndVisibility(Layer* rootLayer, float deviceS caleFactor = 1, float pageScaleFactor = 1) |
54 { | 54 { |
55 WebTransformationMatrix identityMatrix; | 55 Transform identityMatrix; |
56 std::vector<scoped_refptr<Layer> > dummyRenderSurfaceLayerList; | 56 std::vector<scoped_refptr<Layer> > dummyRenderSurfaceLayerList; |
57 int dummyMaxTextureSize = 512; | 57 int dummyMaxTextureSize = 512; |
58 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor); | 58 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor); |
59 | 59 |
60 // We are probably not testing what is intended if the rootLayer bounds are empty. | 60 // We are probably not testing what is intended if the rootLayer bounds are empty. |
61 DCHECK(!rootLayer->bounds().IsEmpty()); | 61 DCHECK(!rootLayer->bounds().IsEmpty()); |
62 LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, dummyRenderSurfaceLayer List); | 62 LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, dummyRenderSurfaceLayer List); |
63 } | 63 } |
64 | 64 |
65 void executeCalculateDrawTransformsAndVisibility(LayerImpl* rootLayer, float dev iceScaleFactor = 1, float pageScaleFactor = 1) | 65 void executeCalculateDrawTransformsAndVisibility(LayerImpl* rootLayer, float dev iceScaleFactor = 1, float pageScaleFactor = 1) |
66 { | 66 { |
67 // Note: this version skips layer sorting. | 67 // Note: this version skips layer sorting. |
68 | 68 |
69 WebTransformationMatrix identityMatrix; | 69 Transform identityMatrix; |
70 std::vector<LayerImpl*> dummyRenderSurfaceLayerList; | 70 std::vector<LayerImpl*> dummyRenderSurfaceLayerList; |
71 int dummyMaxTextureSize = 512; | 71 int dummyMaxTextureSize = 512; |
72 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor); | 72 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor); |
73 | 73 |
74 // We are probably not testing what is intended if the rootLayer bounds are empty. | 74 // We are probably not testing what is intended if the rootLayer bounds are empty. |
75 DCHECK(!rootLayer->bounds().IsEmpty()); | 75 DCHECK(!rootLayer->bounds().IsEmpty()); |
76 LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, 0, dummyMaxTextureSize, dummyRenderSurfaceLa yerList); | 76 LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, 0, dummyMaxTextureSize, dummyRenderSurfaceLa yerList); |
77 } | 77 } |
78 | 78 |
79 WebTransformationMatrix remove3DComponentOfMatrix(const WebTransformationMatrix& mat) | 79 Transform remove3DComponentOfMatrix(const Transform& mat) |
80 { | 80 { |
81 WebTransformationMatrix ret = mat; | 81 Transform ret = mat; |
82 ret.setM13(0); | 82 ret.matrix().setDouble(2, 0, 0); |
83 ret.setM23(0); | 83 ret.matrix().setDouble(2, 1, 0); |
84 ret.setM31(0); | 84 ret.matrix().setDouble(0, 2, 0); |
85 ret.setM32(0); | 85 ret.matrix().setDouble(1, 2, 0); |
86 ret.setM33(1); | 86 ret.matrix().setDouble(2, 2, 1); |
87 ret.setM34(0); | 87 ret.matrix().setDouble(3, 2, 0); |
88 ret.setM43(0); | 88 ret.matrix().setDouble(2, 3, 0); |
89 return ret; | 89 return ret; |
90 } | 90 } |
91 | 91 |
92 scoped_ptr<LayerImpl> createTreeForFixedPositionTests() | 92 scoped_ptr<LayerImpl> createTreeForFixedPositionTests() |
93 { | 93 { |
94 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 94 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
95 scoped_ptr<LayerImpl> child = LayerImpl::create(2); | 95 scoped_ptr<LayerImpl> child = LayerImpl::create(2); |
96 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(3); | 96 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(3); |
97 scoped_ptr<LayerImpl> greatGrandChild = LayerImpl::create(4); | 97 scoped_ptr<LayerImpl> greatGrandChild = LayerImpl::create(4); |
98 | 98 |
99 WebTransformationMatrix IdentityMatrix; | 99 Transform IdentityMatrix; |
100 gfx::PointF anchor(0, 0); | 100 gfx::PointF anchor(0, 0); |
101 gfx::PointF position(0, 0); | 101 gfx::PointF position(0, 0); |
102 gfx::Size bounds(100, 100); | 102 gfx::Size bounds(100, 100); |
103 setLayerPropertiesForTesting(root.get(), IdentityMatrix, IdentityMatrix, anc hor, position, bounds, false); | 103 setLayerPropertiesForTesting(root.get(), IdentityMatrix, IdentityMatrix, anc hor, position, bounds, false); |
104 setLayerPropertiesForTesting(child.get(), IdentityMatrix, IdentityMatrix, an chor, position, bounds, false); | 104 setLayerPropertiesForTesting(child.get(), IdentityMatrix, IdentityMatrix, an chor, position, bounds, false); |
105 setLayerPropertiesForTesting(grandChild.get(), IdentityMatrix, IdentityMatri x, anchor, position, bounds, false); | 105 setLayerPropertiesForTesting(grandChild.get(), IdentityMatrix, IdentityMatri x, anchor, position, bounds, false); |
106 setLayerPropertiesForTesting(greatGrandChild.get(), IdentityMatrix, Identity Matrix, anchor, position, bounds, false); | 106 setLayerPropertiesForTesting(greatGrandChild.get(), IdentityMatrix, Identity Matrix, anchor, position, bounds, false); |
107 | 107 |
108 grandChild->addChild(greatGrandChild.Pass()); | 108 grandChild->addChild(greatGrandChild.Pass()); |
109 child->addChild(grandChild.Pass()); | 109 child->addChild(grandChild.Pass()); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 // and with identity transforms, then the drawTransform, | 153 // and with identity transforms, then the drawTransform, |
154 // screenSpaceTransform, and the hierarchy passed on to children | 154 // screenSpaceTransform, and the hierarchy passed on to children |
155 // layers should also be identity transforms. | 155 // layers should also be identity transforms. |
156 | 156 |
157 scoped_refptr<Layer> parent = Layer::create(); | 157 scoped_refptr<Layer> parent = Layer::create(); |
158 scoped_refptr<Layer> child = Layer::create(); | 158 scoped_refptr<Layer> child = Layer::create(); |
159 scoped_refptr<Layer> grandChild = Layer::create(); | 159 scoped_refptr<Layer> grandChild = Layer::create(); |
160 parent->addChild(child); | 160 parent->addChild(child); |
161 child->addChild(grandChild); | 161 child->addChild(grandChild); |
162 | 162 |
163 WebTransformationMatrix identityMatrix; | 163 Transform identityMatrix; |
164 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 164 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
165 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(0, 0), false); | 165 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(0, 0), false); |
166 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(0, 0), false); | 166 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(0, 0), false); |
167 | 167 |
168 executeCalculateDrawTransformsAndVisibility(parent.get()); | 168 executeCalculateDrawTransformsAndVisibility(parent.get()); |
169 | 169 |
170 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 170 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); |
171 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->screenSpaceTransform( )); | 171 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->screenSpaceTransform( )); |
172 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform()) ; | 172 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform()) ; |
173 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->screenSpaceTrans form()); | 173 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->screenSpaceTrans form()); |
174 } | 174 } |
175 | 175 |
176 TEST(LayerTreeHostCommonTest, verifyTransformsForSingleLayer) | 176 TEST(LayerTreeHostCommonTest, verifyTransformsForSingleLayer) |
177 { | 177 { |
178 WebTransformationMatrix identityMatrix; | 178 Transform identityMatrix; |
179 scoped_refptr<Layer> layer = Layer::create(); | 179 scoped_refptr<Layer> layer = Layer::create(); |
180 | 180 |
181 scoped_refptr<Layer> root = Layer::create(); | 181 scoped_refptr<Layer> root = Layer::create(); |
182 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); | 182 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); |
183 root->addChild(layer); | 183 root->addChild(layer); |
184 | 184 |
185 // Case 1: setting the sublayer transform should not affect this layer's dra w transform or screen-space transform. | 185 // Case 1: setting the sublayer transform should not affect this layer's dra w transform or screen-space transform. |
186 WebTransformationMatrix arbitraryTranslation; | 186 Transform arbitraryTranslation; |
187 arbitraryTranslation.translate(10, 20); | 187 arbitraryTranslation.PreconcatTranslate(10, 20); |
188 setLayerPropertiesForTesting(layer.get(), identityMatrix, arbitraryTranslati on, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 188 setLayerPropertiesForTesting(layer.get(), identityMatrix, arbitraryTranslati on, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
189 executeCalculateDrawTransformsAndVisibility(root.get()); | 189 executeCalculateDrawTransformsAndVisibility(root.get()); |
190 WebTransformationMatrix expectedDrawTransform = identityMatrix; | 190 Transform expectedDrawTransform = identityMatrix; |
191 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedDrawTransform, layer->drawTransform( )); | 191 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedDrawTransform, layer->drawTransform( )); |
192 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform( )); | 192 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform( )); |
193 | 193 |
194 // Case 2: Setting the bounds of the layer should not affect either the draw transform or the screenspace transform. | 194 // Case 2: Setting the bounds of the layer should not affect either the draw transform or the screenspace transform. |
195 WebTransformationMatrix translationToCenter; | 195 Transform translationToCenter; |
196 translationToCenter.translate(5, 6); | 196 translationToCenter.PreconcatTranslate(5, 6); |
197 setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false); | 197 setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false); |
198 executeCalculateDrawTransformsAndVisibility(root.get()); | 198 executeCalculateDrawTransformsAndVisibility(root.get()); |
199 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->drawTransform()); | 199 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->drawTransform()); |
200 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform( )); | 200 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform( )); |
201 | 201 |
202 // Case 3: The anchor point by itself (without a layer transform) should hav e no effect on the transforms. | 202 // Case 3: The anchor point by itself (without a layer transform) should hav e no effect on the transforms. |
203 setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, gf x::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false); | 203 setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, gf x::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false); |
204 executeCalculateDrawTransformsAndVisibility(root.get()); | 204 executeCalculateDrawTransformsAndVisibility(root.get()); |
205 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->drawTransform()); | 205 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->drawTransform()); |
206 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform( )); | 206 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform( )); |
207 | 207 |
208 // Case 4: A change in actual position affects both the draw transform and s creen space transform. | 208 // Case 4: A change in actual position affects both the draw transform and s creen space transform. |
209 WebTransformationMatrix positionTransform; | 209 Transform positionTransform; |
210 positionTransform.translate(0, 1.2); | 210 positionTransform.PreconcatTranslate(0, 1.2); |
211 setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, gf x::PointF(0.25, 0.25), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false); | 211 setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, gf x::PointF(0.25, 0.25), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false); |
212 executeCalculateDrawTransformsAndVisibility(root.get()); | 212 executeCalculateDrawTransformsAndVisibility(root.get()); |
213 EXPECT_TRANSFORMATION_MATRIX_EQ(positionTransform, layer->drawTransform()); | 213 EXPECT_TRANSFORMATION_MATRIX_EQ(positionTransform, layer->drawTransform()); |
214 EXPECT_TRANSFORMATION_MATRIX_EQ(positionTransform, layer->screenSpaceTransfo rm()); | 214 EXPECT_TRANSFORMATION_MATRIX_EQ(positionTransform, layer->screenSpaceTransfo rm()); |
215 | 215 |
216 // Case 5: In the correct sequence of transforms, the layer transform should pre-multiply the translationToCenter. This is easily tested by | 216 // Case 5: In the correct sequence of transforms, the layer transform should pre-multiply the translationToCenter. This is easily tested by |
217 // using a scale transform, because scale and translation are not co mmutative. | 217 // using a scale transform, because scale and translation are not co mmutative. |
218 WebTransformationMatrix layerTransform; | 218 Transform layerTransform; |
219 layerTransform.scale3d(2, 2, 1); | 219 layerTransform.PreconcatScale3d(2, 2, 1); |
220 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false); | 220 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false); |
221 executeCalculateDrawTransformsAndVisibility(root.get()); | 221 executeCalculateDrawTransformsAndVisibility(root.get()); |
222 EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform, layer->drawTransform()); | 222 EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform, layer->drawTransform()); |
223 EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform, layer->screenSpaceTransform( )); | 223 EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform, layer->screenSpaceTransform( )); |
224 | 224 |
225 // Case 6: The layer transform should occur with respect to the anchor point . | 225 // Case 6: The layer transform should occur with respect to the anchor point . |
226 WebTransformationMatrix translationToAnchor; | 226 Transform translationToAnchor; |
227 translationToAnchor.translate(5, 0); | 227 translationToAnchor.PreconcatTranslate(5, 0); |
228 WebTransformationMatrix expectedResult = translationToAnchor * layerTransfor m * translationToAnchor.inverse(); | 228 Transform expectedResult = translationToAnchor * layerTransform * MathUtil:: inverse(translationToAnchor); |
229 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf x::PointF(0.5, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false); | 229 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf x::PointF(0.5, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false); |
230 executeCalculateDrawTransformsAndVisibility(root.get()); | 230 executeCalculateDrawTransformsAndVisibility(root.get()); |
231 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->drawTransform()); | 231 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->drawTransform()); |
232 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screenSpaceTransform( )); | 232 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screenSpaceTransform( )); |
233 | 233 |
234 // Case 7: Verify that position pre-multiplies the layer transform. | 234 // Case 7: Verify that position pre-multiplies the layer transform. |
235 // The current implementation of calculateDrawTransforms does this i mplicitly, but it is | 235 // The current implementation of calculateDrawTransforms does this i mplicitly, but it is |
236 // still worth testing to detect accidental regressions. | 236 // still worth testing to detect accidental regressions. |
237 expectedResult = positionTransform * translationToAnchor * layerTransform * translationToAnchor.inverse(); | 237 expectedResult = positionTransform * translationToAnchor * layerTransform * MathUtil::inverse(translationToAnchor); |
238 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf x::PointF(0.5, 0), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false); | 238 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf x::PointF(0.5, 0), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false); |
239 executeCalculateDrawTransformsAndVisibility(root.get()); | 239 executeCalculateDrawTransformsAndVisibility(root.get()); |
240 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->drawTransform()); | 240 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->drawTransform()); |
241 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screenSpaceTransform( )); | 241 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screenSpaceTransform( )); |
242 } | 242 } |
243 | 243 |
244 TEST(LayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy) | 244 TEST(LayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy) |
245 { | 245 { |
246 WebTransformationMatrix identityMatrix; | 246 Transform identityMatrix; |
247 scoped_refptr<Layer> root = Layer::create(); | 247 scoped_refptr<Layer> root = Layer::create(); |
248 scoped_refptr<Layer> parent = Layer::create(); | 248 scoped_refptr<Layer> parent = Layer::create(); |
249 scoped_refptr<Layer> child = Layer::create(); | 249 scoped_refptr<Layer> child = Layer::create(); |
250 scoped_refptr<Layer> grandChild = Layer::create(); | 250 scoped_refptr<Layer> grandChild = Layer::create(); |
251 root->addChild(parent); | 251 root->addChild(parent); |
252 parent->addChild(child); | 252 parent->addChild(child); |
253 child->addChild(grandChild); | 253 child->addChild(grandChild); |
254 | 254 |
255 // One-time setup of root layer | 255 // One-time setup of root layer |
256 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); | 256 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); |
257 | 257 |
258 // Case 1: parent's anchorPoint should not affect child or grandChild. | 258 // Case 1: parent's anchorPoint should not affect child or grandChild. |
259 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false); | 259 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false); |
260 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 260 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
261 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); | 261 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); |
262 executeCalculateDrawTransformsAndVisibility(root.get()); | 262 executeCalculateDrawTransformsAndVisibility(root.get()); |
263 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 263 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); |
264 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->screenSpaceTransform( )); | 264 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->screenSpaceTransform( )); |
265 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform()) ; | 265 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform()) ; |
266 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->screenSpaceTrans form()); | 266 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->screenSpaceTrans form()); |
267 | 267 |
268 // Case 2: parent's position affects child and grandChild. | 268 // Case 2: parent's position affects child and grandChild. |
269 WebTransformationMatrix parentPositionTransform; | 269 Transform parentPositionTransform; |
270 parentPositionTransform.translate(0, 1.2); | 270 parentPositionTransform.PreconcatTranslate(0, 1.2); |
271 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0.25, 0.25), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false); | 271 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0.25, 0.25), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false); |
272 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 272 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
273 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); | 273 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); |
274 executeCalculateDrawTransformsAndVisibility(root.get()); | 274 executeCalculateDrawTransformsAndVisibility(root.get()); |
275 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, child->drawTransfor m()); | 275 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, child->drawTransfor m()); |
276 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, child->screenSpaceT ransform()); | 276 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, child->screenSpaceT ransform()); |
277 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, grandChild->drawTra nsform()); | 277 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, grandChild->drawTra nsform()); |
278 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, grandChild->screenS paceTransform()); | 278 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, grandChild->screenS paceTransform()); |
279 | 279 |
280 // Case 3: parent's local transform affects child and grandchild | 280 // Case 3: parent's local transform affects child and grandchild |
281 WebTransformationMatrix parentLayerTransform; | 281 Transform parentLayerTransform; |
282 parentLayerTransform.scale3d(2, 2, 1); | 282 parentLayerTransform.PreconcatScale3d(2, 2, 1); |
283 WebTransformationMatrix parentTranslationToAnchor; | 283 Transform parentTranslationToAnchor; |
284 parentTranslationToAnchor.translate(2.5, 3); | 284 parentTranslationToAnchor.PreconcatTranslate(2.5, 3); |
285 WebTransformationMatrix parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * parentTranslationToAnchor.inverse(); | 285 Transform parentCompositeTransform = parentTranslationToAnchor * parentLayer Transform * MathUtil::inverse(parentTranslationToAnchor); |
286 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, identityMat rix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false); | 286 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, identityMat rix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false); |
287 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 287 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
288 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); | 288 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); |
289 executeCalculateDrawTransformsAndVisibility(root.get()); | 289 executeCalculateDrawTransformsAndVisibility(root.get()); |
290 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->drawTransfo rm()); | 290 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->drawTransfo rm()); |
291 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpace Transform()); | 291 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpace Transform()); |
292 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->drawTr ansform()); | 292 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->drawTr ansform()); |
293 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->screen SpaceTransform()); | 293 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->screen SpaceTransform()); |
294 | 294 |
295 // Case 4: parent's sublayerMatrix affects child and grandchild | 295 // Case 4: parent's sublayerMatrix affects child and grandchild |
296 // scaling is used here again so that the correct sequence of transf orms is properly tested. | 296 // scaling is used here again so that the correct sequence of transf orms is properly tested. |
297 // Note that preserves3D is false, but the sublayer matrix should re tain its 3D properties when given to child. | 297 // Note that preserves3D is false, but the sublayer matrix should re tain its 3D properties when given to child. |
298 // But then, the child also does not preserve3D. When it gives its h ierarchy to the grandChild, it should be flattened to 2D. | 298 // But then, the child also does not preserve3D. When it gives its h ierarchy to the grandChild, it should be flattened to 2D. |
299 WebTransformationMatrix parentSublayerMatrix; | 299 Transform parentSublayerMatrix; |
300 parentSublayerMatrix.scale3d(10, 10, 3.3); | 300 parentSublayerMatrix.PreconcatScale3d(10, 10, 3.3); |
301 WebTransformationMatrix parentTranslationToCenter; | 301 Transform parentTranslationToCenter; |
302 parentTranslationToCenter.translate(5, 6); | 302 parentTranslationToCenter.PreconcatTranslate(5, 6); |
303 // Sublayer matrix is applied to the center of the parent layer. | 303 // Sublayer matrix is applied to the center of the parent layer. |
304 parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * parentTranslationToAnchor.inverse() | 304 parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * MathUtil::inverse(parentTranslationToAnchor) |
305 * parentTranslationToCenter * parentSublayerMatrix * parentTranslati onToCenter.inverse(); | 305 * parentTranslationToCenter * parentSublayerMatrix * MathUtil::inver se(parentTranslationToCenter); |
306 WebTransformationMatrix flattenedCompositeTransform = remove3DComponentOfMat rix(parentCompositeTransform); | 306 Transform flattenedCompositeTransform = remove3DComponentOfMatrix(parentComp ositeTransform); |
307 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false) ; | 307 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false) ; |
308 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 308 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
309 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); | 309 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); |
310 executeCalculateDrawTransformsAndVisibility(root.get()); | 310 executeCalculateDrawTransformsAndVisibility(root.get()); |
311 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->drawTransfo rm()); | 311 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->drawTransfo rm()); |
312 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpace Transform()); | 312 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpace Transform()); |
313 EXPECT_TRANSFORMATION_MATRIX_EQ(flattenedCompositeTransform, grandChild->dra wTransform()); | 313 EXPECT_TRANSFORMATION_MATRIX_EQ(flattenedCompositeTransform, grandChild->dra wTransform()); |
314 EXPECT_TRANSFORMATION_MATRIX_EQ(flattenedCompositeTransform, grandChild->scr eenSpaceTransform()); | 314 EXPECT_TRANSFORMATION_MATRIX_EQ(flattenedCompositeTransform, grandChild->scr eenSpaceTransform()); |
315 | 315 |
316 // Case 5: same as Case 4, except that child does preserve 3D, so the grandC hild should receive the non-flattened composite transform. | 316 // Case 5: same as Case 4, except that child does preserve 3D, so the grandC hild should receive the non-flattened composite transform. |
(...skipping 12 matching lines...) Expand all Loading... | |
329 { | 329 { |
330 scoped_refptr<Layer> root = Layer::create(); | 330 scoped_refptr<Layer> root = Layer::create(); |
331 scoped_refptr<Layer> parent = Layer::create(); | 331 scoped_refptr<Layer> parent = Layer::create(); |
332 scoped_refptr<Layer> child = Layer::create(); | 332 scoped_refptr<Layer> child = Layer::create(); |
333 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n ew LayerWithForcedDrawsContent()); | 333 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n ew LayerWithForcedDrawsContent()); |
334 root->addChild(parent); | 334 root->addChild(parent); |
335 parent->addChild(child); | 335 parent->addChild(child); |
336 child->addChild(grandChild); | 336 child->addChild(grandChild); |
337 | 337 |
338 // One-time setup of root layer | 338 // One-time setup of root layer |
339 WebTransformationMatrix identityMatrix; | 339 Transform identityMatrix; |
340 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); | 340 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); |
341 | 341 |
342 // Child is set up so that a new render surface should be created. | 342 // Child is set up so that a new render surface should be created. |
343 child->setOpacity(0.5); | 343 child->setOpacity(0.5); |
344 | 344 |
345 WebTransformationMatrix parentLayerTransform; | 345 Transform parentLayerTransform; |
346 parentLayerTransform.scale3d(1, 0.9, 1); | 346 parentLayerTransform.PreconcatScale3d(1, 0.9, 1); |
347 WebTransformationMatrix parentTranslationToAnchor; | 347 Transform parentTranslationToAnchor; |
348 parentTranslationToAnchor.translate(25, 30); | 348 parentTranslationToAnchor.PreconcatTranslate(25, 30); |
349 WebTransformationMatrix parentSublayerMatrix; | 349 Transform parentSublayerMatrix; |
350 parentSublayerMatrix.scale3d(0.9, 1, 3.3); | 350 parentSublayerMatrix.PreconcatScale3d(0.9, 1, 3.3); |
351 WebTransformationMatrix parentTranslationToCenter; | 351 Transform parentTranslationToCenter; |
352 parentTranslationToCenter.translate(50, 60); | 352 parentTranslationToCenter.PreconcatTranslate(50, 60); |
353 WebTransformationMatrix parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * parentTranslationToAnchor.inverse() | 353 Transform parentCompositeTransform = parentTranslationToAnchor * parentLayer Transform * MathUtil::inverse(parentTranslationToAnchor) |
354 * parentTranslationToCenter * parentSublayerMatrix * parentTranslati onToCenter.inverse(); | 354 * parentTranslationToCenter * parentSublayerMatrix * MathUtil::inver se(parentTranslationToCenter); |
355 gfx::Vector2dF parentCompositeScale = MathUtil::computeTransform2dScaleCompo nents(parentCompositeTransform); | 355 gfx::Vector2dF parentCompositeScale = MathUtil::computeTransform2dScaleCompo nents(parentCompositeTransform); |
356 WebTransformationMatrix surfaceSublayerTransform; | 356 Transform surfaceSublayerTransform; |
357 surfaceSublayerTransform.scaleNonUniform(parentCompositeScale.x(), parentCom positeScale.y()); | 357 surfaceSublayerTransform.PreconcatScale(parentCompositeScale.x(), parentComp ositeScale.y()); |
358 WebTransformationMatrix surfaceSublayerCompositeTransform = parentCompositeT ransform * surfaceSublayerTransform.inverse(); | 358 Transform surfaceSublayerCompositeTransform = parentCompositeTransform * Mat hUtil::inverse(surfaceSublayerTransform); |
359 | 359 |
360 // Child's render surface should not exist yet. | 360 // Child's render surface should not exist yet. |
361 ASSERT_FALSE(child->renderSurface()); | 361 ASSERT_FALSE(child->renderSurface()); |
362 | 362 |
363 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(100, 120), fals e); | 363 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(100, 120), fals e); |
364 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 364 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
365 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(8, 10), false); | 365 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(8, 10), false); |
366 executeCalculateDrawTransformsAndVisibility(root.get()); | 366 executeCalculateDrawTransformsAndVisibility(root.get()); |
367 | 367 |
368 // Render surface should have been created now. | 368 // Render surface should have been created now. |
(...skipping 19 matching lines...) Expand all Loading... | |
388 scoped_refptr<Layer> parent = Layer::create(); | 388 scoped_refptr<Layer> parent = Layer::create(); |
389 scoped_refptr<Layer> child = Layer::create(); | 389 scoped_refptr<Layer> child = Layer::create(); |
390 scoped_refptr<Layer> childReplica = Layer::create(); | 390 scoped_refptr<Layer> childReplica = Layer::create(); |
391 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n ew LayerWithForcedDrawsContent()); | 391 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n ew LayerWithForcedDrawsContent()); |
392 root->addChild(parent); | 392 root->addChild(parent); |
393 parent->addChild(child); | 393 parent->addChild(child); |
394 child->addChild(grandChild); | 394 child->addChild(grandChild); |
395 child->setReplicaLayer(childReplica.get()); | 395 child->setReplicaLayer(childReplica.get()); |
396 | 396 |
397 // One-time setup of root layer | 397 // One-time setup of root layer |
398 WebTransformationMatrix identityMatrix; | 398 Transform identityMatrix; |
399 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); | 399 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); |
400 | 400 |
401 // Child is set up so that a new render surface should be created. | 401 // Child is set up so that a new render surface should be created. |
402 child->setOpacity(0.5); | 402 child->setOpacity(0.5); |
403 | 403 |
404 WebTransformationMatrix parentLayerTransform; | 404 Transform parentLayerTransform; |
405 parentLayerTransform.scale3d(2, 2, 1); | 405 parentLayerTransform.PreconcatScale3d(2, 2, 1); |
406 WebTransformationMatrix parentTranslationToAnchor; | 406 Transform parentTranslationToAnchor; |
407 parentTranslationToAnchor.translate(2.5, 3); | 407 parentTranslationToAnchor.PreconcatTranslate(2.5, 3); |
408 WebTransformationMatrix parentSublayerMatrix; | 408 Transform parentSublayerMatrix; |
409 parentSublayerMatrix.scale3d(10, 10, 3.3); | 409 parentSublayerMatrix.PreconcatScale3d(10, 10, 3.3); |
410 WebTransformationMatrix parentTranslationToCenter; | 410 Transform parentTranslationToCenter; |
411 parentTranslationToCenter.translate(5, 6); | 411 parentTranslationToCenter.PreconcatTranslate(5, 6); |
412 WebTransformationMatrix parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * parentTranslationToAnchor.inverse() | 412 Transform parentCompositeTransform = parentTranslationToAnchor * parentLayer Transform * MathUtil::inverse(parentTranslationToAnchor) |
413 * parentTranslationToCenter * parentSublayerMatrix * parentTranslati onToCenter.inverse(); | 413 * parentTranslationToCenter * parentSublayerMatrix * MathUtil::inver se(parentTranslationToCenter); |
414 WebTransformationMatrix childTranslationToCenter; | 414 Transform childTranslationToCenter; |
415 childTranslationToCenter.translate(8, 9); | 415 childTranslationToCenter.PreconcatTranslate(8, 9); |
416 WebTransformationMatrix replicaLayerTransform; | 416 Transform replicaLayerTransform; |
417 replicaLayerTransform.scale3d(3, 3, 1); | 417 replicaLayerTransform.PreconcatScale3d(3, 3, 1); |
418 gfx::Vector2dF parentCompositeScale = MathUtil::computeTransform2dScaleCompo nents(parentCompositeTransform); | 418 gfx::Vector2dF parentCompositeScale = MathUtil::computeTransform2dScaleCompo nents(parentCompositeTransform); |
419 WebTransformationMatrix surfaceSublayerTransform; | 419 Transform surfaceSublayerTransform; |
420 surfaceSublayerTransform.scaleNonUniform(parentCompositeScale.x(), parentCom positeScale.y()); | 420 surfaceSublayerTransform.PreconcatScale(parentCompositeScale.x(), parentComp ositeScale.y()); |
421 WebTransformationMatrix replicaCompositeTransform = parentCompositeTransform * replicaLayerTransform * surfaceSublayerTransform.inverse(); | 421 Transform replicaCompositeTransform = parentCompositeTransform * replicaLaye rTransform * MathUtil::inverse(surfaceSublayerTransform); |
422 | 422 |
423 // Child's render surface should not exist yet. | 423 // Child's render surface should not exist yet. |
424 ASSERT_FALSE(child->renderSurface()); | 424 ASSERT_FALSE(child->renderSurface()); |
425 | 425 |
426 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false) ; | 426 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false) ; |
427 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 427 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
428 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(-0.5, -0.5), gfx::Size(1, 1), false); | 428 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(-0.5, -0.5), gfx::Size(1, 1), false); |
429 setLayerPropertiesForTesting(childReplica.get(), replicaLayerTransform, iden tityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(0, 0), false); | 429 setLayerPropertiesForTesting(childReplica.get(), replicaLayerTransform, iden tityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(0, 0), false); |
430 executeCalculateDrawTransformsAndVisibility(root.get()); | 430 executeCalculateDrawTransformsAndVisibility(root.get()); |
431 | 431 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
468 childOfRS1->addChild(grandChildOfRS1); | 468 childOfRS1->addChild(grandChildOfRS1); |
469 childOfRS2->addChild(grandChildOfRS2); | 469 childOfRS2->addChild(grandChildOfRS2); |
470 renderSurface1->setReplicaLayer(replicaOfRS1.get()); | 470 renderSurface1->setReplicaLayer(replicaOfRS1.get()); |
471 renderSurface2->setReplicaLayer(replicaOfRS2.get()); | 471 renderSurface2->setReplicaLayer(replicaOfRS2.get()); |
472 | 472 |
473 // In combination with descendantDrawsContent, opacity != 1 forces the layer to have a new renderSurface. | 473 // In combination with descendantDrawsContent, opacity != 1 forces the layer to have a new renderSurface. |
474 renderSurface1->setOpacity(0.5); | 474 renderSurface1->setOpacity(0.5); |
475 renderSurface2->setOpacity(0.33f); | 475 renderSurface2->setOpacity(0.33f); |
476 | 476 |
477 // One-time setup of root layer | 477 // One-time setup of root layer |
478 WebTransformationMatrix identityMatrix; | 478 Transform identityMatrix; |
479 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); | 479 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); |
480 | 480 |
481 // All layers in the tree are initialized with an anchor at .25 and a size o f (10,10). | 481 // All layers in the tree are initialized with an anchor at .25 and a size o f (10,10). |
482 // matrix "A" is the composite layer transform used in all layers, centered about the anchor point | 482 // matrix "A" is the composite layer transform used in all layers, centered about the anchor point |
483 // matrix "B" is the sublayer transform used in all layers, centered about t he center position of the layer. | 483 // matrix "B" is the sublayer transform used in all layers, centered about t he center position of the layer. |
484 // matrix "R" is the composite replica transform used in all replica layers. | 484 // matrix "R" is the composite replica transform used in all replica layers. |
485 // | 485 // |
486 // x component tests that layerTransform and sublayerTransform are done in t he right order (translation and scale are noncommutative). | 486 // x component tests that layerTransform and sublayerTransform are done in t he right order (translation and scale are noncommutative). |
487 // y component has a translation by 1 for every ancestor, which indicates th e "depth" of the layer in the hierarchy. | 487 // y component has a translation by 1 for every ancestor, which indicates th e "depth" of the layer in the hierarchy. |
488 WebTransformationMatrix translationToAnchor; | 488 Transform translationToAnchor; |
489 translationToAnchor.translate(2.5, 0); | 489 translationToAnchor.PreconcatTranslate(2.5, 0); |
490 WebTransformationMatrix translationToCenter; | 490 Transform translationToCenter; |
491 translationToCenter.translate(5, 5); | 491 translationToCenter.PreconcatTranslate(5, 5); |
492 WebTransformationMatrix layerTransform; | 492 Transform layerTransform; |
493 layerTransform.translate(1, 1); | 493 layerTransform.PreconcatTranslate(1, 1); |
494 WebTransformationMatrix sublayerTransform; | 494 Transform sublayerTransform; |
495 sublayerTransform.scale3d(10, 1, 1); | 495 sublayerTransform.PreconcatScale3d(10, 1, 1); |
496 WebTransformationMatrix replicaLayerTransform; | 496 Transform replicaLayerTransform; |
497 replicaLayerTransform.scale3d(-2, 5, 1); | 497 replicaLayerTransform.PreconcatScale3d(-2, 5, 1); |
498 | 498 |
499 WebTransformationMatrix A = translationToAnchor * layerTransform * translati onToAnchor.inverse(); | 499 Transform A = translationToAnchor * layerTransform * MathUtil::inverse(trans lationToAnchor); |
500 WebTransformationMatrix B = translationToCenter * sublayerTransform * transl ationToCenter.inverse(); | 500 Transform B = translationToCenter * sublayerTransform * MathUtil::inverse(tr anslationToCenter); |
501 WebTransformationMatrix R = A * translationToAnchor * replicaLayerTransform * translationToAnchor.inverse(); | 501 Transform R = A * translationToAnchor * replicaLayerTransform * MathUtil::in verse(translationToAnchor); |
502 | 502 |
503 gfx::Vector2dF surface1ParentTransformScale = MathUtil::computeTransform2dSc aleComponents(A * B); | 503 gfx::Vector2dF surface1ParentTransformScale = MathUtil::computeTransform2dSc aleComponents(A * B); |
504 WebTransformationMatrix surface1SublayerTransform; | 504 Transform surface1SublayerTransform; |
505 surface1SublayerTransform.scaleNonUniform(surface1ParentTransformScale.x(), surface1ParentTransformScale.y()); | 505 surface1SublayerTransform.PreconcatScale(surface1ParentTransformScale.x(), s urface1ParentTransformScale.y()); |
506 | 506 |
507 // SS1 = transform given to the subtree of renderSurface1 | 507 // SS1 = transform given to the subtree of renderSurface1 |
508 WebTransformationMatrix SS1 = surface1SublayerTransform; | 508 Transform SS1 = surface1SublayerTransform; |
509 // S1 = transform to move from renderSurface1 pixels to the layer space of t he owning layer | 509 // S1 = transform to move from renderSurface1 pixels to the layer space of t he owning layer |
510 WebTransformationMatrix S1 = surface1SublayerTransform.inverse(); | 510 Transform S1 = MathUtil::inverse(surface1SublayerTransform); |
511 | 511 |
512 gfx::Vector2dF surface2ParentTransformScale = MathUtil::computeTransform2dSc aleComponents(SS1 * A * B); | 512 gfx::Vector2dF surface2ParentTransformScale = MathUtil::computeTransform2dSc aleComponents(SS1 * A * B); |
513 WebTransformationMatrix surface2SublayerTransform; | 513 Transform surface2SublayerTransform; |
514 surface2SublayerTransform.scaleNonUniform(surface2ParentTransformScale.x(), surface2ParentTransformScale.y()); | 514 surface2SublayerTransform.PreconcatScale(surface2ParentTransformScale.x(), s urface2ParentTransformScale.y()); |
515 | 515 |
516 // SS2 = transform given to the subtree of renderSurface2 | 516 // SS2 = transform given to the subtree of renderSurface2 |
517 WebTransformationMatrix SS2 = surface2SublayerTransform; | 517 Transform SS2 = surface2SublayerTransform; |
518 // S2 = transform to move from renderSurface2 pixels to the layer space of t he owning layer | 518 // S2 = transform to move from renderSurface2 pixels to the layer space of t he owning layer |
519 WebTransformationMatrix S2 = surface2SublayerTransform.inverse(); | 519 Transform S2 = MathUtil::inverse(surface2SublayerTransform); |
520 | 520 |
521 setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform , gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 521 setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform , gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
522 setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerT ransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 522 setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerT ransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
523 setLayerPropertiesForTesting(renderSurface2.get(), layerTransform, sublayerT ransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 523 setLayerPropertiesForTesting(renderSurface2.get(), layerTransform, sublayerT ransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
524 setLayerPropertiesForTesting(childOfRoot.get(), layerTransform, sublayerTran sform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 524 setLayerPropertiesForTesting(childOfRoot.get(), layerTransform, sublayerTran sform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
525 setLayerPropertiesForTesting(childOfRS1.get(), layerTransform, sublayerTrans form, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 525 setLayerPropertiesForTesting(childOfRS1.get(), layerTransform, sublayerTrans form, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
526 setLayerPropertiesForTesting(childOfRS2.get(), layerTransform, sublayerTrans form, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 526 setLayerPropertiesForTesting(childOfRS2.get(), layerTransform, sublayerTrans form, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
527 setLayerPropertiesForTesting(grandChildOfRoot.get(), layerTransform, sublaye rTransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 527 setLayerPropertiesForTesting(grandChildOfRoot.get(), layerTransform, sublaye rTransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
528 setLayerPropertiesForTesting(grandChildOfRS1.get(), layerTransform, sublayer Transform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 528 setLayerPropertiesForTesting(grandChildOfRS1.get(), layerTransform, sublayer Transform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
529 setLayerPropertiesForTesting(grandChildOfRS2.get(), layerTransform, sublayer Transform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 529 setLayerPropertiesForTesting(grandChildOfRS2.get(), layerTransform, sublayer Transform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
599 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * R * S1, renderSurface1->renderSurfac e()->replicaScreenSpaceTransform()); | 599 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * R * S1, renderSurface1->renderSurfac e()->replicaScreenSpaceTransform()); |
600 // Draw transform of render surface 2 is described with respect to render su rface 1. | 600 // Draw transform of render surface 2 is described with respect to render su rface 1. |
601 EXPECT_TRANSFORMATION_MATRIX_EQ(SS1 * B * A * S2, renderSurface2->renderSurf ace()->drawTransform()); | 601 EXPECT_TRANSFORMATION_MATRIX_EQ(SS1 * B * A * S2, renderSurface2->renderSurf ace()->drawTransform()); |
602 EXPECT_TRANSFORMATION_MATRIX_EQ(SS1 * B * R * S2, renderSurface2->renderSurf ace()->replicaDrawTransform()); | 602 EXPECT_TRANSFORMATION_MATRIX_EQ(SS1 * B * R * S2, renderSurface2->renderSurf ace()->replicaDrawTransform()); |
603 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A * S2, renderSurface2->rend erSurface()->screenSpaceTransform()); | 603 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A * S2, renderSurface2->rend erSurface()->screenSpaceTransform()); |
604 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * R * S2, renderSurface2->rend erSurface()->replicaScreenSpaceTransform()); | 604 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * R * S2, renderSurface2->rend erSurface()->replicaScreenSpaceTransform()); |
605 | 605 |
606 // Sanity check. If these fail there is probably a bug in the test itself. | 606 // Sanity check. If these fail there is probably a bug in the test itself. |
607 // It is expected that we correctly set up transforms so that the y-componen t of the screen-space transform | 607 // It is expected that we correctly set up transforms so that the y-componen t of the screen-space transform |
608 // encodes the "depth" of the layer in the tree. | 608 // encodes the "depth" of the layer in the tree. |
609 EXPECT_FLOAT_EQ(1, parent->screenSpaceTransform().m42()); | 609 EXPECT_FLOAT_EQ(1, parent->screenSpaceTransform().matrix().getDouble(1, 3)); |
610 EXPECT_FLOAT_EQ(2, childOfRoot->screenSpaceTransform().m42()); | 610 EXPECT_FLOAT_EQ(2, childOfRoot->screenSpaceTransform().matrix().getDouble(1, 3)); |
611 EXPECT_FLOAT_EQ(3, grandChildOfRoot->screenSpaceTransform().m42()); | 611 EXPECT_FLOAT_EQ(3, grandChildOfRoot->screenSpaceTransform().matrix().getDoub le(1, 3)); |
612 | 612 |
613 EXPECT_FLOAT_EQ(2, renderSurface1->screenSpaceTransform().m42()); | 613 EXPECT_FLOAT_EQ(2, renderSurface1->screenSpaceTransform().matrix().getDouble (1, 3)); |
614 EXPECT_FLOAT_EQ(3, childOfRS1->screenSpaceTransform().m42()); | 614 EXPECT_FLOAT_EQ(3, childOfRS1->screenSpaceTransform().matrix().getDouble(1, 3)); |
615 EXPECT_FLOAT_EQ(4, grandChildOfRS1->screenSpaceTransform().m42()); | 615 EXPECT_FLOAT_EQ(4, grandChildOfRS1->screenSpaceTransform().matrix().getDoubl e(1, 3)); |
616 | 616 |
617 EXPECT_FLOAT_EQ(3, renderSurface2->screenSpaceTransform().m42()); | 617 EXPECT_FLOAT_EQ(3, renderSurface2->screenSpaceTransform().matrix().getDouble (1, 3)); |
618 EXPECT_FLOAT_EQ(4, childOfRS2->screenSpaceTransform().m42()); | 618 EXPECT_FLOAT_EQ(4, childOfRS2->screenSpaceTransform().matrix().getDouble(1, 3)); |
619 EXPECT_FLOAT_EQ(5, grandChildOfRS2->screenSpaceTransform().m42()); | 619 EXPECT_FLOAT_EQ(5, grandChildOfRS2->screenSpaceTransform().matrix().getDoubl e(1, 3)); |
620 } | 620 } |
621 | 621 |
622 TEST(LayerTreeHostCommonTest, verifyTransformsForFlatteningLayer) | 622 TEST(LayerTreeHostCommonTest, verifyTransformsForFlatteningLayer) |
623 { | 623 { |
624 // For layers that flatten their subtree, there should be an orthographic pr ojection | 624 // For layers that flatten their subtree, there should be an orthographic pr ojection |
625 // (for x and y values) in the middle of the transform sequence. Note that t he way the | 625 // (for x and y values) in the middle of the transform sequence. Note that t he way the |
626 // code is currently implemented, it is not expected to use a canonical orth ographic | 626 // code is currently implemented, it is not expected to use a canonical orth ographic |
627 // projection. | 627 // projection. |
628 | 628 |
629 scoped_refptr<Layer> root = Layer::create(); | 629 scoped_refptr<Layer> root = Layer::create(); |
630 scoped_refptr<Layer> child = Layer::create(); | 630 scoped_refptr<Layer> child = Layer::create(); |
631 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n ew LayerWithForcedDrawsContent()); | 631 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n ew LayerWithForcedDrawsContent()); |
632 | 632 |
633 WebTransformationMatrix rotationAboutYAxis; | 633 Transform rotationAboutYAxis; |
634 rotationAboutYAxis.rotate3d(0, 30, 0); | 634 MathUtil::rotateEulerAngles(&rotationAboutYAxis, 0, 30, 0); |
635 | 635 |
636 const WebTransformationMatrix identityMatrix; | 636 const Transform identityMatrix; |
637 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(), gfx::PointF(), gfx::Size(100, 100), false); | 637 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(), gfx::PointF(), gfx::Size(100, 100), false); |
638 setLayerPropertiesForTesting(child.get(), rotationAboutYAxis, identityMatrix , gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 638 setLayerPropertiesForTesting(child.get(), rotationAboutYAxis, identityMatrix , gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
639 setLayerPropertiesForTesting(grandChild.get(), rotationAboutYAxis, identityM atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 639 setLayerPropertiesForTesting(grandChild.get(), rotationAboutYAxis, identityM atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
640 | 640 |
641 root->addChild(child); | 641 root->addChild(child); |
642 child->addChild(grandChild); | 642 child->addChild(grandChild); |
643 child->setForceRenderSurface(true); | 643 child->setForceRenderSurface(true); |
644 | 644 |
645 // No layers in this test should preserve 3d. | 645 // No layers in this test should preserve 3d. |
646 ASSERT_FALSE(root->preserves3D()); | 646 ASSERT_FALSE(root->preserves3D()); |
647 ASSERT_FALSE(child->preserves3D()); | 647 ASSERT_FALSE(child->preserves3D()); |
648 ASSERT_FALSE(grandChild->preserves3D()); | 648 ASSERT_FALSE(grandChild->preserves3D()); |
649 | 649 |
650 WebTransformationMatrix expectedChildDrawTransform = rotationAboutYAxis; | 650 Transform expectedChildDrawTransform = rotationAboutYAxis; |
651 WebTransformationMatrix expectedChildScreenSpaceTransform = rotationAboutYAx is; | 651 Transform expectedChildScreenSpaceTransform = rotationAboutYAxis; |
652 WebTransformationMatrix expectedGrandChildDrawTransform = rotationAboutYAxis ; // draws onto child's renderSurface | 652 Transform expectedGrandChildDrawTransform = rotationAboutYAxis; // draws ont o child's renderSurface |
653 WebTransformationMatrix expectedGrandChildScreenSpaceTransform = rotationAbo utYAxis.to2dTransform() * rotationAboutYAxis; | 653 Transform expectedGrandChildScreenSpaceTransform = MathUtil::to2dTransform(r otationAboutYAxis) * rotationAboutYAxis; |
654 | 654 |
655 executeCalculateDrawTransformsAndVisibility(root.get()); | 655 executeCalculateDrawTransformsAndVisibility(root.get()); |
656 | 656 |
657 // The child's drawTransform should have been taken by its surface. | 657 // The child's drawTransform should have been taken by its surface. |
658 ASSERT_TRUE(child->renderSurface()); | 658 ASSERT_TRUE(child->renderSurface()); |
659 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildDrawTransform, child->renderSur face()->drawTransform()); | 659 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildDrawTransform, child->renderSur face()->drawTransform()); |
660 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->re nderSurface()->screenSpaceTransform()); | 660 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->re nderSurface()->screenSpaceTransform()); |
661 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 661 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); |
662 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->sc reenSpaceTransform()); | 662 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->sc reenSpaceTransform()); |
663 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildDrawTransform, grandChild- >drawTransform()); | 663 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildDrawTransform, grandChild- >drawTransform()); |
664 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildScreenSpaceTransform, gran dChild->screenSpaceTransform()); | 664 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildScreenSpaceTransform, gran dChild->screenSpaceTransform()); |
665 } | 665 } |
666 | 666 |
667 TEST(LayerTreeHostCommonTest, verifyTransformsForDegenerateIntermediateLayer) | 667 TEST(LayerTreeHostCommonTest, verifyTransformsForDegenerateIntermediateLayer) |
668 { | 668 { |
669 // A layer that is empty in one axis, but not the other, was accidentally sk ipping a necessary translation. | 669 // A layer that is empty in one axis, but not the other, was accidentally sk ipping a necessary translation. |
670 // Without that translation, the coordinate space of the layer's drawTransfo rm is incorrect. | 670 // Without that translation, the coordinate space of the layer's drawTransfo rm is incorrect. |
671 // | 671 // |
672 // Normally this isn't a problem, because the layer wouldn't be drawn anyway , but if that layer becomes a renderSurface, then | 672 // Normally this isn't a problem, because the layer wouldn't be drawn anyway , but if that layer becomes a renderSurface, then |
673 // its drawTransform is implicitly inherited by the rest of the subtree, whi ch then is positioned incorrectly as a result. | 673 // its drawTransform is implicitly inherited by the rest of the subtree, whi ch then is positioned incorrectly as a result. |
674 | 674 |
675 scoped_refptr<Layer> root = Layer::create(); | 675 scoped_refptr<Layer> root = Layer::create(); |
676 scoped_refptr<Layer> child = Layer::create(); | 676 scoped_refptr<Layer> child = Layer::create(); |
677 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n ew LayerWithForcedDrawsContent()); | 677 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n ew LayerWithForcedDrawsContent()); |
678 | 678 |
679 // The child height is zero, but has non-zero width that should be accounted for while computing drawTransforms. | 679 // The child height is zero, but has non-zero width that should be accounted for while computing drawTransforms. |
680 const WebTransformationMatrix identityMatrix; | 680 const Transform identityMatrix; |
681 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(), gfx::PointF(), gfx::Size(100, 100), false); | 681 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(), gfx::PointF(), gfx::Size(100, 100), false); |
682 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(), gfx::PointF(), gfx::Size(10, 0), false); | 682 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(), gfx::PointF(), gfx::Size(10, 0), false); |
683 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 683 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri x, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
684 | 684 |
685 root->addChild(child); | 685 root->addChild(child); |
686 child->addChild(grandChild); | 686 child->addChild(grandChild); |
687 child->setForceRenderSurface(true); | 687 child->setForceRenderSurface(true); |
688 | 688 |
689 executeCalculateDrawTransformsAndVisibility(root.get()); | 689 executeCalculateDrawTransformsAndVisibility(root.get()); |
690 | 690 |
691 ASSERT_TRUE(child->renderSurface()); | 691 ASSERT_TRUE(child->renderSurface()); |
692 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->renderSurface()->draw Transform()); // This is the real test, the rest are sanity checks. | 692 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->renderSurface()->draw Transform()); // This is the real test, the rest are sanity checks. |
693 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 693 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); |
694 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform()) ; | 694 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform()) ; |
695 } | 695 } |
696 | 696 |
697 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForRenderSurfaceWithClipped Layer) | 697 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForRenderSurfaceWithClipped Layer) |
698 { | 698 { |
699 scoped_refptr<Layer> parent = Layer::create(); | 699 scoped_refptr<Layer> parent = Layer::create(); |
700 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 700 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
701 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La yerWithForcedDrawsContent()); | 701 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La yerWithForcedDrawsContent()); |
702 | 702 |
703 const WebTransformationMatrix identityMatrix; | 703 const Transform identityMatrix; |
704 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 704 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
705 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 705 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
706 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(), gfx::PointF(30, 30), gfx::Size(10, 10), false); | 706 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(), gfx::PointF(30, 30), gfx::Size(10, 10), false); |
707 | 707 |
708 parent->addChild(renderSurface1); | 708 parent->addChild(renderSurface1); |
709 parent->setMasksToBounds(true); | 709 parent->setMasksToBounds(true); |
710 renderSurface1->addChild(child); | 710 renderSurface1->addChild(child); |
711 renderSurface1->setForceRenderSurface(true); | 711 renderSurface1->setForceRenderSurface(true); |
712 | 712 |
713 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 713 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
714 int dummyMaxTextureSize = 512; | 714 int dummyMaxTextureSize = 512; |
715 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 715 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
716 | 716 |
717 // The child layer's content is entirely outside the parent's clip rect, so the intermediate | 717 // The child layer's content is entirely outside the parent's clip rect, so the intermediate |
718 // render surface should not be listed here, even if it was forced to be cre ated. Render surfaces without children or visible | 718 // render surface should not be listed here, even if it was forced to be cre ated. Render surfaces without children or visible |
719 // content are unexpected at draw time (e.g. we might try to create a conten t texture of size 0). | 719 // content are unexpected at draw time (e.g. we might try to create a conten t texture of size 0). |
720 ASSERT_TRUE(parent->renderSurface()); | 720 ASSERT_TRUE(parent->renderSurface()); |
721 ASSERT_FALSE(renderSurface1->renderSurface()); | 721 ASSERT_FALSE(renderSurface1->renderSurface()); |
722 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 722 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
723 } | 723 } |
724 | 724 |
725 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForTransparentChild) | 725 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForTransparentChild) |
726 { | 726 { |
727 scoped_refptr<Layer> parent = Layer::create(); | 727 scoped_refptr<Layer> parent = Layer::create(); |
728 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 728 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
729 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La yerWithForcedDrawsContent()); | 729 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La yerWithForcedDrawsContent()); |
730 | 730 |
731 const WebTransformationMatrix identityMatrix; | 731 const Transform identityMatrix; |
732 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 732 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
733 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 733 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
734 | 734 |
735 parent->addChild(renderSurface1); | 735 parent->addChild(renderSurface1); |
736 renderSurface1->addChild(child); | 736 renderSurface1->addChild(child); |
737 renderSurface1->setForceRenderSurface(true); | 737 renderSurface1->setForceRenderSurface(true); |
738 renderSurface1->setOpacity(0); | 738 renderSurface1->setOpacity(0); |
739 | 739 |
740 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 740 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
741 int dummyMaxTextureSize = 512; | 741 int dummyMaxTextureSize = 512; |
742 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 742 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
743 | 743 |
744 // Since the layer is transparent, renderSurface1->renderSurface() should no t have gotten added anywhere. | 744 // Since the layer is transparent, renderSurface1->renderSurface() should no t have gotten added anywhere. |
745 // Also, the drawable content rect should not have been extended by the chil dren. | 745 // Also, the drawable content rect should not have been extended by the chil dren. |
746 ASSERT_TRUE(parent->renderSurface()); | 746 ASSERT_TRUE(parent->renderSurface()); |
747 EXPECT_EQ(0U, parent->renderSurface()->layerList().size()); | 747 EXPECT_EQ(0U, parent->renderSurface()->layerList().size()); |
748 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 748 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
749 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 749 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
750 EXPECT_EQ(gfx::Rect(), parent->drawableContentRect()); | 750 EXPECT_EQ(gfx::Rect(), parent->drawableContentRect()); |
751 } | 751 } |
752 | 752 |
753 TEST(LayerTreeHostCommonTest, verifyForceRenderSurface) | 753 TEST(LayerTreeHostCommonTest, verifyForceRenderSurface) |
754 { | 754 { |
755 scoped_refptr<Layer> parent = Layer::create(); | 755 scoped_refptr<Layer> parent = Layer::create(); |
756 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 756 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
757 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La yerWithForcedDrawsContent()); | 757 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La yerWithForcedDrawsContent()); |
758 renderSurface1->setForceRenderSurface(true); | 758 renderSurface1->setForceRenderSurface(true); |
759 | 759 |
760 const WebTransformationMatrix identityMatrix; | 760 const Transform identityMatrix; |
761 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 761 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
762 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 762 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
763 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 763 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
764 | 764 |
765 parent->addChild(renderSurface1); | 765 parent->addChild(renderSurface1); |
766 renderSurface1->addChild(child); | 766 renderSurface1->addChild(child); |
767 | 767 |
768 // Sanity check before the actual test | 768 // Sanity check before the actual test |
769 EXPECT_FALSE(parent->renderSurface()); | 769 EXPECT_FALSE(parent->renderSurface()); |
770 EXPECT_FALSE(renderSurface1->renderSurface()); | 770 EXPECT_FALSE(renderSurface1->renderSurface()); |
(...skipping 23 matching lines...) Expand all Loading... | |
794 LayerImpl* child = root->children()[0]; | 794 LayerImpl* child = root->children()[0]; |
795 LayerImpl* grandChild = child->children()[0]; | 795 LayerImpl* grandChild = child->children()[0]; |
796 | 796 |
797 child->setIsContainerForFixedPositionLayers(true); | 797 child->setIsContainerForFixedPositionLayers(true); |
798 grandChild->setFixedToContainerLayer(true); | 798 grandChild->setFixedToContainerLayer(true); |
799 | 799 |
800 // Case 1: scrollDelta of 0, 0 | 800 // Case 1: scrollDelta of 0, 0 |
801 child->setScrollDelta(gfx::Vector2d(0, 0)); | 801 child->setScrollDelta(gfx::Vector2d(0, 0)); |
802 executeCalculateDrawTransformsAndVisibility(root.get()); | 802 executeCalculateDrawTransformsAndVisibility(root.get()); |
803 | 803 |
804 WebTransformationMatrix expectedChildTransform; | 804 Transform expectedChildTransform; |
805 WebTransformationMatrix expectedGrandChildTransform = expectedChildTransform ; | 805 Transform expectedGrandChildTransform = expectedChildTransform; |
806 | 806 |
807 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); | 807 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); |
808 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); | 808 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); |
809 | 809 |
810 // Case 2: scrollDelta of 10, 10 | 810 // Case 2: scrollDelta of 10, 10 |
811 child->setScrollDelta(gfx::Vector2d(10, 10)); | 811 child->setScrollDelta(gfx::Vector2d(10, 10)); |
812 executeCalculateDrawTransformsAndVisibility(root.get()); | 812 executeCalculateDrawTransformsAndVisibility(root.get()); |
813 | 813 |
814 // Here the child is affected by scrollDelta, but the fixed position grandCh ild should not be affected. | 814 // Here the child is affected by scrollDelta, but the fixed position grandCh ild should not be affected. |
815 expectedChildTransform.makeIdentity(); | 815 expectedChildTransform.matrix().setIdentity(); |
danakj
2012/11/24 02:34:54
note: we should have API on gfx::Transform to neve
| |
816 expectedChildTransform.translate(-10, -10); | 816 expectedChildTransform.PreconcatTranslate(-10, -10); |
817 | 817 |
818 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); | 818 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); |
819 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); | 819 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); |
820 } | 820 } |
821 | 821 |
822 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithT ransformedDirectContainer) | 822 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithT ransformedDirectContainer) |
823 { | 823 { |
824 // This test checks for correct scroll compensation when the fixed-position container | 824 // This test checks for correct scroll compensation when the fixed-position container |
825 // is the direct parent of the fixed-position layer, but that container is t ransformed. | 825 // is the direct parent of the fixed-position layer, but that container is t ransformed. |
826 // In this case, the fixed position element inherits the container's transfo rm, | 826 // In this case, the fixed position element inherits the container's transfo rm, |
827 // but the scrollDelta that has to be undone should not be affected by that transform. | 827 // but the scrollDelta that has to be undone should not be affected by that transform. |
828 // | 828 // |
829 // Transforms are in general non-commutative; using something like a non-uni form scale | 829 // Transforms are in general non-commutative; using something like a non-uni form scale |
830 // helps to verify that translations and non-uniform scales are applied in t he correct | 830 // helps to verify that translations and non-uniform scales are applied in t he correct |
831 // order. | 831 // order. |
832 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); | 832 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
833 LayerImpl* child = root->children()[0]; | 833 LayerImpl* child = root->children()[0]; |
834 LayerImpl* grandChild = child->children()[0]; | 834 LayerImpl* grandChild = child->children()[0]; |
835 | 835 |
836 // This scale will cause child and grandChild to be effectively 200 x 800 wi th respect to the renderTarget. | 836 // This scale will cause child and grandChild to be effectively 200 x 800 wi th respect to the renderTarget. |
837 WebTransformationMatrix nonUniformScale; | 837 Transform nonUniformScale; |
838 nonUniformScale.scaleNonUniform(2, 8); | 838 nonUniformScale.PreconcatScale(2, 8); |
839 child->setTransform(nonUniformScale); | 839 child->setTransform(nonUniformScale); |
840 | 840 |
841 child->setIsContainerForFixedPositionLayers(true); | 841 child->setIsContainerForFixedPositionLayers(true); |
842 grandChild->setFixedToContainerLayer(true); | 842 grandChild->setFixedToContainerLayer(true); |
843 | 843 |
844 // Case 1: scrollDelta of 0, 0 | 844 // Case 1: scrollDelta of 0, 0 |
845 child->setScrollDelta(gfx::Vector2d(0, 0)); | 845 child->setScrollDelta(gfx::Vector2d(0, 0)); |
846 executeCalculateDrawTransformsAndVisibility(root.get()); | 846 executeCalculateDrawTransformsAndVisibility(root.get()); |
847 | 847 |
848 WebTransformationMatrix expectedChildTransform; | 848 Transform expectedChildTransform; |
849 expectedChildTransform.multiply(nonUniformScale); | 849 expectedChildTransform.PreconcatTransform(nonUniformScale); |
850 | 850 |
851 WebTransformationMatrix expectedGrandChildTransform = expectedChildTransform ; | 851 Transform expectedGrandChildTransform = expectedChildTransform; |
852 | 852 |
853 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); | 853 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); |
854 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); | 854 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); |
855 | 855 |
856 // Case 2: scrollDelta of 10, 20 | 856 // Case 2: scrollDelta of 10, 20 |
857 child->setScrollDelta(gfx::Vector2d(10, 20)); | 857 child->setScrollDelta(gfx::Vector2d(10, 20)); |
858 executeCalculateDrawTransformsAndVisibility(root.get()); | 858 executeCalculateDrawTransformsAndVisibility(root.get()); |
859 | 859 |
860 // The child should be affected by scrollDelta, but the fixed position grand Child should not be affected. | 860 // The child should be affected by scrollDelta, but the fixed position grand Child should not be affected. |
861 expectedChildTransform.makeIdentity(); | 861 expectedChildTransform.matrix().setIdentity(); |
862 expectedChildTransform.translate(-10, -20); // scrollDelta | 862 expectedChildTransform.PreconcatTranslate(-10, -20); // scrollDelta |
863 expectedChildTransform.multiply(nonUniformScale); | 863 expectedChildTransform.PreconcatTransform(nonUniformScale); |
864 | 864 |
865 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); | 865 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); |
866 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); | 866 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); |
867 } | 867 } |
868 | 868 |
869 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD istantContainer) | 869 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD istantContainer) |
870 { | 870 { |
871 // This test checks for correct scroll compensation when the fixed-position container | 871 // This test checks for correct scroll compensation when the fixed-position container |
872 // is NOT the direct parent of the fixed-position layer. | 872 // is NOT the direct parent of the fixed-position layer. |
873 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); | 873 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
874 LayerImpl* child = root->children()[0]; | 874 LayerImpl* child = root->children()[0]; |
875 LayerImpl* grandChild = child->children()[0]; | 875 LayerImpl* grandChild = child->children()[0]; |
876 LayerImpl* greatGrandChild = grandChild->children()[0]; | 876 LayerImpl* greatGrandChild = grandChild->children()[0]; |
877 | 877 |
878 child->setIsContainerForFixedPositionLayers(true); | 878 child->setIsContainerForFixedPositionLayers(true); |
879 grandChild->setPosition(gfx::PointF(8, 6)); | 879 grandChild->setPosition(gfx::PointF(8, 6)); |
880 greatGrandChild->setFixedToContainerLayer(true); | 880 greatGrandChild->setFixedToContainerLayer(true); |
881 | 881 |
882 // Case 1: scrollDelta of 0, 0 | 882 // Case 1: scrollDelta of 0, 0 |
883 child->setScrollDelta(gfx::Vector2d(0, 0)); | 883 child->setScrollDelta(gfx::Vector2d(0, 0)); |
884 executeCalculateDrawTransformsAndVisibility(root.get()); | 884 executeCalculateDrawTransformsAndVisibility(root.get()); |
885 | 885 |
886 WebTransformationMatrix expectedChildTransform; | 886 Transform expectedChildTransform; |
887 WebTransformationMatrix expectedGrandChildTransform; | 887 Transform expectedGrandChildTransform; |
888 expectedGrandChildTransform.translate(8, 6); | 888 expectedGrandChildTransform.PreconcatTranslate(8, 6); |
889 | 889 |
890 WebTransformationMatrix expectedGreatGrandChildTransform = expectedGrandChil dTransform; | 890 Transform expectedGreatGrandChildTransform = expectedGrandChildTransform; |
891 | 891 |
892 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); | 892 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); |
893 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); | 893 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); |
894 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); | 894 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); |
895 | 895 |
896 // Case 2: scrollDelta of 10, 10 | 896 // Case 2: scrollDelta of 10, 10 |
897 child->setScrollDelta(gfx::Vector2d(10, 10)); | 897 child->setScrollDelta(gfx::Vector2d(10, 10)); |
898 executeCalculateDrawTransformsAndVisibility(root.get()); | 898 executeCalculateDrawTransformsAndVisibility(root.get()); |
899 | 899 |
900 // Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected. | 900 // Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected. |
901 expectedChildTransform.makeIdentity(); | 901 expectedChildTransform.matrix().setIdentity(); |
902 expectedChildTransform.translate(-10, -10); | 902 expectedChildTransform.PreconcatTranslate(-10, -10); |
903 expectedGrandChildTransform.makeIdentity(); | 903 expectedGrandChildTransform.matrix().setIdentity(); |
904 expectedGrandChildTransform.translate(-2, -4); | 904 expectedGrandChildTransform.PreconcatTranslate(-2, -4); |
905 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); | 905 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); |
906 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); | 906 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); |
907 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); | 907 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); |
908 } | 908 } |
909 | 909 |
910 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD istantContainerAndTransforms) | 910 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD istantContainerAndTransforms) |
911 { | 911 { |
912 // This test checks for correct scroll compensation when the fixed-position container | 912 // This test checks for correct scroll compensation when the fixed-position container |
913 // is NOT the direct parent of the fixed-position layer, and the hierarchy h as various | 913 // is NOT the direct parent of the fixed-position layer, and the hierarchy h as various |
914 // transforms that have to be processed in the correct order. | 914 // transforms that have to be processed in the correct order. |
915 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); | 915 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
916 LayerImpl* child = root->children()[0]; | 916 LayerImpl* child = root->children()[0]; |
917 LayerImpl* grandChild = child->children()[0]; | 917 LayerImpl* grandChild = child->children()[0]; |
918 LayerImpl* greatGrandChild = grandChild->children()[0]; | 918 LayerImpl* greatGrandChild = grandChild->children()[0]; |
919 | 919 |
920 WebTransformationMatrix rotationAboutZ; | 920 Transform rotationAboutZ; |
921 rotationAboutZ.rotate3d(0, 0, 90); | 921 MathUtil::rotateEulerAngles(&rotationAboutZ, 0, 0, 90); |
922 | 922 |
923 child->setIsContainerForFixedPositionLayers(true); | 923 child->setIsContainerForFixedPositionLayers(true); |
924 child->setTransform(rotationAboutZ); | 924 child->setTransform(rotationAboutZ); |
925 grandChild->setPosition(gfx::PointF(8, 6)); | 925 grandChild->setPosition(gfx::PointF(8, 6)); |
926 grandChild->setTransform(rotationAboutZ); | 926 grandChild->setTransform(rotationAboutZ); |
927 greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is posit ioned upside-down with respect to the renderTarget. | 927 greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is posit ioned upside-down with respect to the renderTarget. |
928 | 928 |
929 // Case 1: scrollDelta of 0, 0 | 929 // Case 1: scrollDelta of 0, 0 |
930 child->setScrollDelta(gfx::Vector2d(0, 0)); | 930 child->setScrollDelta(gfx::Vector2d(0, 0)); |
931 executeCalculateDrawTransformsAndVisibility(root.get()); | 931 executeCalculateDrawTransformsAndVisibility(root.get()); |
932 | 932 |
933 WebTransformationMatrix expectedChildTransform; | 933 Transform expectedChildTransform; |
934 expectedChildTransform.multiply(rotationAboutZ); | 934 expectedChildTransform.PreconcatTransform(rotationAboutZ); |
935 | 935 |
936 WebTransformationMatrix expectedGrandChildTransform; | 936 Transform expectedGrandChildTransform; |
937 expectedGrandChildTransform.multiply(rotationAboutZ); // child's local trans form is inherited | 937 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // child's l ocal transform is inherited |
938 expectedGrandChildTransform.translate(8, 6); // translation because of posit ion occurs before layer's local transform. | 938 expectedGrandChildTransform.PreconcatTranslate(8, 6); // translation because of position occurs before layer's local transform. |
939 expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local transform | 939 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // grandChil d's local transform |
940 | 940 |
941 WebTransformationMatrix expectedGreatGrandChildTransform = expectedGrandChil dTransform; | 941 Transform expectedGreatGrandChildTransform = expectedGrandChildTransform; |
942 | 942 |
943 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); | 943 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); |
944 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); | 944 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); |
945 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); | 945 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); |
946 | 946 |
947 // Case 2: scrollDelta of 10, 20 | 947 // Case 2: scrollDelta of 10, 20 |
948 child->setScrollDelta(gfx::Vector2d(10, 20)); | 948 child->setScrollDelta(gfx::Vector2d(10, 20)); |
949 executeCalculateDrawTransformsAndVisibility(root.get()); | 949 executeCalculateDrawTransformsAndVisibility(root.get()); |
950 | 950 |
951 // Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected. | 951 // Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected. |
952 expectedChildTransform.makeIdentity(); | 952 expectedChildTransform.matrix().setIdentity(); |
953 expectedChildTransform.translate(-10, -20); // scrollDelta | 953 expectedChildTransform.PreconcatTranslate(-10, -20); // scrollDelta |
954 expectedChildTransform.multiply(rotationAboutZ); | 954 expectedChildTransform.PreconcatTransform(rotationAboutZ); |
955 | 955 |
956 expectedGrandChildTransform.makeIdentity(); | 956 expectedGrandChildTransform.matrix().setIdentity(); |
957 expectedGrandChildTransform.translate(-10, -20); // child's scrollDelta is i nherited | 957 expectedGrandChildTransform.PreconcatTranslate(-10, -20); // child's scrollD elta is inherited |
958 expectedGrandChildTransform.multiply(rotationAboutZ); // child's local trans form is inherited | 958 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // child's l ocal transform is inherited |
959 expectedGrandChildTransform.translate(8, 6); // translation because of posit ion occurs before layer's local transform. | 959 expectedGrandChildTransform.PreconcatTranslate(8, 6); // translation because of position occurs before layer's local transform. |
960 expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local transform | 960 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // grandChil d's local transform |
961 | 961 |
962 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); | 962 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); |
963 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); | 963 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); |
964 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); | 964 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); |
965 } | 965 } |
966 | 966 |
967 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM ultipleScrollDeltas) | 967 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM ultipleScrollDeltas) |
968 { | 968 { |
969 // This test checks for correct scroll compensation when the fixed-position container | 969 // This test checks for correct scroll compensation when the fixed-position container |
970 // has multiple ancestors that have nonzero scrollDelta before reaching the space where the layer is fixed. | 970 // has multiple ancestors that have nonzero scrollDelta before reaching the space where the layer is fixed. |
971 // In this test, each scrollDelta occurs in a different space because of eac h layer's local transform. | 971 // In this test, each scrollDelta occurs in a different space because of eac h layer's local transform. |
972 // This test checks for correct scroll compensation when the fixed-position container | 972 // This test checks for correct scroll compensation when the fixed-position container |
973 // is NOT the direct parent of the fixed-position layer, and the hierarchy h as various | 973 // is NOT the direct parent of the fixed-position layer, and the hierarchy h as various |
974 // transforms that have to be processed in the correct order. | 974 // transforms that have to be processed in the correct order. |
975 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); | 975 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
976 LayerImpl* child = root->children()[0]; | 976 LayerImpl* child = root->children()[0]; |
977 LayerImpl* grandChild = child->children()[0]; | 977 LayerImpl* grandChild = child->children()[0]; |
978 LayerImpl* greatGrandChild = grandChild->children()[0]; | 978 LayerImpl* greatGrandChild = grandChild->children()[0]; |
979 | 979 |
980 WebTransformationMatrix rotationAboutZ; | 980 Transform rotationAboutZ; |
981 rotationAboutZ.rotate3d(0, 0, 90); | 981 MathUtil::rotateEulerAngles(&rotationAboutZ, 0, 0, 90); |
982 | 982 |
983 child->setIsContainerForFixedPositionLayers(true); | 983 child->setIsContainerForFixedPositionLayers(true); |
984 child->setTransform(rotationAboutZ); | 984 child->setTransform(rotationAboutZ); |
985 grandChild->setPosition(gfx::PointF(8, 6)); | 985 grandChild->setPosition(gfx::PointF(8, 6)); |
986 grandChild->setTransform(rotationAboutZ); | 986 grandChild->setTransform(rotationAboutZ); |
987 greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is posit ioned upside-down with respect to the renderTarget. | 987 greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is posit ioned upside-down with respect to the renderTarget. |
988 | 988 |
989 // Case 1: scrollDelta of 0, 0 | 989 // Case 1: scrollDelta of 0, 0 |
990 child->setScrollDelta(gfx::Vector2d(0, 0)); | 990 child->setScrollDelta(gfx::Vector2d(0, 0)); |
991 executeCalculateDrawTransformsAndVisibility(root.get()); | 991 executeCalculateDrawTransformsAndVisibility(root.get()); |
992 | 992 |
993 WebTransformationMatrix expectedChildTransform; | 993 Transform expectedChildTransform; |
994 expectedChildTransform.multiply(rotationAboutZ); | 994 expectedChildTransform.PreconcatTransform(rotationAboutZ); |
995 | 995 |
996 WebTransformationMatrix expectedGrandChildTransform; | 996 Transform expectedGrandChildTransform; |
997 expectedGrandChildTransform.multiply(rotationAboutZ); // child's local trans form is inherited | 997 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // child's l ocal transform is inherited |
998 expectedGrandChildTransform.translate(8, 6); // translation because of posit ion occurs before layer's local transform. | 998 expectedGrandChildTransform.PreconcatTranslate(8, 6); // translation because of position occurs before layer's local transform. |
999 expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local transform | 999 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // grandChil d's local transform |
1000 | 1000 |
1001 WebTransformationMatrix expectedGreatGrandChildTransform = expectedGrandChil dTransform; | 1001 Transform expectedGreatGrandChildTransform = expectedGrandChildTransform; |
1002 | 1002 |
1003 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); | 1003 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); |
1004 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); | 1004 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); |
1005 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); | 1005 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); |
1006 | 1006 |
1007 // Case 2: scrollDelta of 10, 20 | 1007 // Case 2: scrollDelta of 10, 20 |
1008 child->setScrollDelta(gfx::Vector2d(10, 0)); | 1008 child->setScrollDelta(gfx::Vector2d(10, 0)); |
1009 grandChild->setScrollDelta(gfx::Vector2d(5, 0)); | 1009 grandChild->setScrollDelta(gfx::Vector2d(5, 0)); |
1010 executeCalculateDrawTransformsAndVisibility(root.get()); | 1010 executeCalculateDrawTransformsAndVisibility(root.get()); |
1011 | 1011 |
1012 // Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected. | 1012 // Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected. |
1013 expectedChildTransform.makeIdentity(); | 1013 expectedChildTransform.matrix().setIdentity(); |
1014 expectedChildTransform.translate(-10, 0); // scrollDelta | 1014 expectedChildTransform.PreconcatTranslate(-10, 0); // scrollDelta |
1015 expectedChildTransform.multiply(rotationAboutZ); | 1015 expectedChildTransform.PreconcatTransform(rotationAboutZ); |
1016 | 1016 |
1017 expectedGrandChildTransform.makeIdentity(); | 1017 expectedGrandChildTransform.matrix().setIdentity(); |
1018 expectedGrandChildTransform.translate(-10, 0); // child's scrollDelta is inh erited | 1018 expectedGrandChildTransform.PreconcatTranslate(-10, 0); // child's scrollDel ta is inherited |
1019 expectedGrandChildTransform.multiply(rotationAboutZ); // child's local trans form is inherited | 1019 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // child's l ocal transform is inherited |
1020 expectedGrandChildTransform.translate(-5, 0); // grandChild's scrollDelta | 1020 expectedGrandChildTransform.PreconcatTranslate(-5, 0); // grandChild's scrol lDelta |
1021 expectedGrandChildTransform.translate(8, 6); // translation because of posit ion occurs before layer's local transform. | 1021 expectedGrandChildTransform.PreconcatTranslate(8, 6); // translation because of position occurs before layer's local transform. |
1022 expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local transform | 1022 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // grandChil d's local transform |
1023 | 1023 |
1024 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); | 1024 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); |
1025 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); | 1025 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); |
1026 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); | 1026 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); |
1027 } | 1027 } |
1028 | 1028 |
1029 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithI ntermediateSurfaceAndTransforms) | 1029 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithI ntermediateSurfaceAndTransforms) |
1030 { | 1030 { |
1031 // This test checks for correct scroll compensation when the fixed-position container | 1031 // This test checks for correct scroll compensation when the fixed-position container |
1032 // contributes to a different renderSurface than the fixed-position layer. I n this | 1032 // contributes to a different renderSurface than the fixed-position layer. I n this |
1033 // case, the surface drawTransforms also have to be accounted for when check ing the | 1033 // case, the surface drawTransforms also have to be accounted for when check ing the |
1034 // scrollDelta. | 1034 // scrollDelta. |
1035 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); | 1035 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
1036 LayerImpl* child = root->children()[0]; | 1036 LayerImpl* child = root->children()[0]; |
1037 LayerImpl* grandChild = child->children()[0]; | 1037 LayerImpl* grandChild = child->children()[0]; |
1038 LayerImpl* greatGrandChild = grandChild->children()[0]; | 1038 LayerImpl* greatGrandChild = grandChild->children()[0]; |
1039 | 1039 |
1040 child->setIsContainerForFixedPositionLayers(true); | 1040 child->setIsContainerForFixedPositionLayers(true); |
1041 grandChild->setPosition(gfx::PointF(8, 6)); | 1041 grandChild->setPosition(gfx::PointF(8, 6)); |
1042 grandChild->setForceRenderSurface(true); | 1042 grandChild->setForceRenderSurface(true); |
1043 greatGrandChild->setFixedToContainerLayer(true); | 1043 greatGrandChild->setFixedToContainerLayer(true); |
1044 greatGrandChild->setDrawsContent(true); | 1044 greatGrandChild->setDrawsContent(true); |
1045 | 1045 |
1046 WebTransformationMatrix rotationAboutZ; | 1046 Transform rotationAboutZ; |
1047 rotationAboutZ.rotate3d(0, 0, 90); | 1047 MathUtil::rotateEulerAngles(&rotationAboutZ, 0, 0, 90); |
1048 grandChild->setTransform(rotationAboutZ); | 1048 grandChild->setTransform(rotationAboutZ); |
1049 | 1049 |
1050 // Case 1: scrollDelta of 0, 0 | 1050 // Case 1: scrollDelta of 0, 0 |
1051 child->setScrollDelta(gfx::Vector2d(0, 0)); | 1051 child->setScrollDelta(gfx::Vector2d(0, 0)); |
1052 executeCalculateDrawTransformsAndVisibility(root.get()); | 1052 executeCalculateDrawTransformsAndVisibility(root.get()); |
1053 | 1053 |
1054 WebTransformationMatrix expectedChildTransform; | 1054 Transform expectedChildTransform; |
1055 WebTransformationMatrix expectedSurfaceDrawTransform; | 1055 Transform expectedSurfaceDrawTransform; |
1056 expectedSurfaceDrawTransform.translate(8, 6); | 1056 expectedSurfaceDrawTransform.PreconcatTranslate(8, 6); |
1057 expectedSurfaceDrawTransform.multiply(rotationAboutZ); | 1057 expectedSurfaceDrawTransform.PreconcatTransform(rotationAboutZ); |
1058 WebTransformationMatrix expectedGrandChildTransform; | 1058 Transform expectedGrandChildTransform; |
1059 WebTransformationMatrix expectedGreatGrandChildTransform; | 1059 Transform expectedGreatGrandChildTransform; |
1060 ASSERT_TRUE(grandChild->renderSurface()); | 1060 ASSERT_TRUE(grandChild->renderSurface()); |
1061 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); | 1061 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); |
1062 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, grandChild->re nderSurface()->drawTransform()); | 1062 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, grandChild->re nderSurface()->drawTransform()); |
1063 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); | 1063 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); |
1064 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); | 1064 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); |
1065 | 1065 |
1066 // Case 2: scrollDelta of 10, 30 | 1066 // Case 2: scrollDelta of 10, 30 |
1067 child->setScrollDelta(gfx::Vector2d(10, 30)); | 1067 child->setScrollDelta(gfx::Vector2d(10, 30)); |
1068 executeCalculateDrawTransformsAndVisibility(root.get()); | 1068 executeCalculateDrawTransformsAndVisibility(root.get()); |
1069 | 1069 |
1070 // Here the grandChild remains unchanged, because it scrolls along with the | 1070 // Here the grandChild remains unchanged, because it scrolls along with the |
1071 // renderSurface, and the translation is actually in the renderSurface. But, the fixed | 1071 // renderSurface, and the translation is actually in the renderSurface. But, the fixed |
1072 // position greatGrandChild is more awkward: its actually being drawn with r espect to | 1072 // position greatGrandChild is more awkward: its actually being drawn with r espect to |
1073 // the renderSurface, but it needs to remain fixed with resepct to a contain er beyond | 1073 // the renderSurface, but it needs to remain fixed with resepct to a contain er beyond |
1074 // that surface. So, the net result is that, unlike previous tests where the fixed | 1074 // that surface. So, the net result is that, unlike previous tests where the fixed |
1075 // position layer's transform remains unchanged, here the fixed position lay er's | 1075 // position layer's transform remains unchanged, here the fixed position lay er's |
1076 // transform explicitly contains the translation that cancels out the scroll . | 1076 // transform explicitly contains the translation that cancels out the scroll . |
1077 expectedChildTransform.makeIdentity(); | 1077 expectedChildTransform.matrix().setIdentity(); |
1078 expectedChildTransform.translate(-10, -30); // scrollDelta | 1078 expectedChildTransform.PreconcatTranslate(-10, -30); // scrollDelta |
1079 | 1079 |
1080 expectedSurfaceDrawTransform.makeIdentity(); | 1080 expectedSurfaceDrawTransform.matrix().setIdentity(); |
1081 expectedSurfaceDrawTransform.translate(-10, -30); // scrollDelta | 1081 expectedSurfaceDrawTransform.PreconcatTranslate(-10, -30); // scrollDelta |
1082 expectedSurfaceDrawTransform.translate(8, 6); | 1082 expectedSurfaceDrawTransform.PreconcatTranslate(8, 6); |
1083 expectedSurfaceDrawTransform.multiply(rotationAboutZ); | 1083 expectedSurfaceDrawTransform.PreconcatTransform(rotationAboutZ); |
1084 | 1084 |
1085 // The rotation and its inverse are needed to place the scrollDelta compensa tion in | 1085 // The rotation and its inverse are needed to place the scrollDelta compensa tion in |
1086 // the correct space. This test will fail if the rotation/inverse are backwa rds, too, | 1086 // the correct space. This test will fail if the rotation/inverse are backwa rds, too, |
1087 // so it requires perfect order of operations. | 1087 // so it requires perfect order of operations. |
1088 expectedGreatGrandChildTransform.makeIdentity(); | 1088 expectedGreatGrandChildTransform.matrix().setIdentity(); |
1089 expectedGreatGrandChildTransform.multiply(rotationAboutZ.inverse()); | 1089 expectedGreatGrandChildTransform.PreconcatTransform(MathUtil::inverse(rotati onAboutZ)); |
1090 expectedGreatGrandChildTransform.translate(10, 30); // explicit canceling ou t the scrollDelta that gets embedded in the fixed position layer's surface. | 1090 expectedGreatGrandChildTransform.PreconcatTranslate(10, 30); // explicit can celing out the scrollDelta that gets embedded in the fixed position layer's surf ace. |
1091 expectedGreatGrandChildTransform.multiply(rotationAboutZ); | 1091 expectedGreatGrandChildTransform.PreconcatTransform(rotationAboutZ); |
1092 | 1092 |
1093 ASSERT_TRUE(grandChild->renderSurface()); | 1093 ASSERT_TRUE(grandChild->renderSurface()); |
1094 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); | 1094 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); |
1095 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, grandChild->re nderSurface()->drawTransform()); | 1095 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, grandChild->re nderSurface()->drawTransform()); |
1096 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); | 1096 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); |
1097 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); | 1097 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); |
1098 } | 1098 } |
1099 | 1099 |
1100 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM ultipleIntermediateSurfaces) | 1100 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM ultipleIntermediateSurfaces) |
1101 { | 1101 { |
1102 // This test checks for correct scroll compensation when the fixed-position container | 1102 // This test checks for correct scroll compensation when the fixed-position container |
1103 // contributes to a different renderSurface than the fixed-position layer, w ith | 1103 // contributes to a different renderSurface than the fixed-position layer, w ith |
1104 // additional renderSurfaces in-between. This checks that the conversion to ancestor | 1104 // additional renderSurfaces in-between. This checks that the conversion to ancestor |
1105 // surfaces is accumulated properly in the final matrix transform. | 1105 // surfaces is accumulated properly in the final matrix transform. |
1106 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); | 1106 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
1107 LayerImpl* child = root->children()[0]; | 1107 LayerImpl* child = root->children()[0]; |
1108 LayerImpl* grandChild = child->children()[0]; | 1108 LayerImpl* grandChild = child->children()[0]; |
1109 LayerImpl* greatGrandChild = grandChild->children()[0]; | 1109 LayerImpl* greatGrandChild = grandChild->children()[0]; |
1110 | 1110 |
1111 // Add one more layer to the test tree for this scenario. | 1111 // Add one more layer to the test tree for this scenario. |
1112 { | 1112 { |
1113 WebTransformationMatrix identity; | 1113 Transform identity; |
1114 scoped_ptr<LayerImpl> fixedPositionChild = LayerImpl::create(5); | 1114 scoped_ptr<LayerImpl> fixedPositionChild = LayerImpl::create(5); |
1115 setLayerPropertiesForTesting(fixedPositionChild.get(), identity, identit y, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 1115 setLayerPropertiesForTesting(fixedPositionChild.get(), identity, identit y, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
1116 greatGrandChild->addChild(fixedPositionChild.Pass()); | 1116 greatGrandChild->addChild(fixedPositionChild.Pass()); |
1117 } | 1117 } |
1118 LayerImpl* fixedPositionChild = greatGrandChild->children()[0]; | 1118 LayerImpl* fixedPositionChild = greatGrandChild->children()[0]; |
1119 | 1119 |
1120 // Actually set up the scenario here. | 1120 // Actually set up the scenario here. |
1121 child->setIsContainerForFixedPositionLayers(true); | 1121 child->setIsContainerForFixedPositionLayers(true); |
1122 grandChild->setPosition(gfx::PointF(8, 6)); | 1122 grandChild->setPosition(gfx::PointF(8, 6)); |
1123 grandChild->setForceRenderSurface(true); | 1123 grandChild->setForceRenderSurface(true); |
1124 greatGrandChild->setPosition(gfx::PointF(40, 60)); | 1124 greatGrandChild->setPosition(gfx::PointF(40, 60)); |
1125 greatGrandChild->setForceRenderSurface(true); | 1125 greatGrandChild->setForceRenderSurface(true); |
1126 fixedPositionChild->setFixedToContainerLayer(true); | 1126 fixedPositionChild->setFixedToContainerLayer(true); |
1127 fixedPositionChild->setDrawsContent(true); | 1127 fixedPositionChild->setDrawsContent(true); |
1128 | 1128 |
1129 // The additional rotations, which are non-commutative with translations, he lp to | 1129 // The additional rotations, which are non-commutative with translations, he lp to |
1130 // verify that we have correct order-of-operations in the final scroll compe nsation. | 1130 // verify that we have correct order-of-operations in the final scroll compe nsation. |
1131 // Note that rotating about the center of the layer ensures we do not accide ntally | 1131 // Note that rotating about the center of the layer ensures we do not accide ntally |
1132 // clip away layers that we want to test. | 1132 // clip away layers that we want to test. |
1133 WebTransformationMatrix rotationAboutZ; | 1133 Transform rotationAboutZ; |
1134 rotationAboutZ.translate(50, 50); | 1134 rotationAboutZ.PreconcatTranslate(50, 50); |
1135 rotationAboutZ.rotate3d(0, 0, 90); | 1135 MathUtil::rotateEulerAngles(&rotationAboutZ, 0, 0, 90); |
1136 rotationAboutZ.translate(-50, -50); | 1136 rotationAboutZ.PreconcatTranslate(-50, -50); |
1137 grandChild->setTransform(rotationAboutZ); | 1137 grandChild->setTransform(rotationAboutZ); |
1138 greatGrandChild->setTransform(rotationAboutZ); | 1138 greatGrandChild->setTransform(rotationAboutZ); |
1139 | 1139 |
1140 // Case 1: scrollDelta of 0, 0 | 1140 // Case 1: scrollDelta of 0, 0 |
1141 child->setScrollDelta(gfx::Vector2d(0, 0)); | 1141 child->setScrollDelta(gfx::Vector2d(0, 0)); |
1142 executeCalculateDrawTransformsAndVisibility(root.get()); | 1142 executeCalculateDrawTransformsAndVisibility(root.get()); |
1143 | 1143 |
1144 WebTransformationMatrix expectedChildTransform; | 1144 Transform expectedChildTransform; |
1145 | 1145 |
1146 WebTransformationMatrix expectedGrandChildSurfaceDrawTransform; | 1146 Transform expectedGrandChildSurfaceDrawTransform; |
1147 expectedGrandChildSurfaceDrawTransform.translate(8, 6); | 1147 expectedGrandChildSurfaceDrawTransform.PreconcatTranslate(8, 6); |
1148 expectedGrandChildSurfaceDrawTransform.multiply(rotationAboutZ); | 1148 expectedGrandChildSurfaceDrawTransform.PreconcatTransform(rotationAboutZ); |
1149 | 1149 |
1150 WebTransformationMatrix expectedGrandChildTransform; | 1150 Transform expectedGrandChildTransform; |
1151 | 1151 |
1152 WebTransformationMatrix expectedGreatGrandChildSurfaceDrawTransform; | 1152 Transform expectedGreatGrandChildSurfaceDrawTransform; |
1153 expectedGreatGrandChildSurfaceDrawTransform.translate(40, 60); | 1153 expectedGreatGrandChildSurfaceDrawTransform.PreconcatTranslate(40, 60); |
1154 expectedGreatGrandChildSurfaceDrawTransform.multiply(rotationAboutZ); | 1154 expectedGreatGrandChildSurfaceDrawTransform.PreconcatTransform(rotationAbout Z); |
1155 | 1155 |
1156 WebTransformationMatrix expectedGreatGrandChildTransform; | 1156 Transform expectedGreatGrandChildTransform; |
1157 | 1157 |
1158 WebTransformationMatrix expectedFixedPositionChildTransform; | 1158 Transform expectedFixedPositionChildTransform; |
1159 | 1159 |
1160 ASSERT_TRUE(grandChild->renderSurface()); | 1160 ASSERT_TRUE(grandChild->renderSurface()); |
1161 ASSERT_TRUE(greatGrandChild->renderSurface()); | 1161 ASSERT_TRUE(greatGrandChild->renderSurface()); |
1162 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); | 1162 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); |
1163 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildSurfaceDrawTransform, gran dChild->renderSurface()->drawTransform()); | 1163 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildSurfaceDrawTransform, gran dChild->renderSurface()->drawTransform()); |
1164 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); | 1164 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); |
1165 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildSurfaceDrawTransform, greatGrandChild->renderSurface()->drawTransform()); | 1165 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildSurfaceDrawTransform, greatGrandChild->renderSurface()->drawTransform()); |
1166 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); | 1166 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); |
1167 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedFixedPositionChildTransform, fixedPo sitionChild->drawTransform()); | 1167 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedFixedPositionChildTransform, fixedPo sitionChild->drawTransform()); |
1168 | 1168 |
1169 // Case 2: scrollDelta of 10, 30 | 1169 // Case 2: scrollDelta of 10, 30 |
1170 child->setScrollDelta(gfx::Vector2d(10, 30)); | 1170 child->setScrollDelta(gfx::Vector2d(10, 30)); |
1171 executeCalculateDrawTransformsAndVisibility(root.get()); | 1171 executeCalculateDrawTransformsAndVisibility(root.get()); |
1172 | 1172 |
1173 expectedChildTransform.makeIdentity(); | 1173 expectedChildTransform.matrix().setIdentity(); |
1174 expectedChildTransform.translate(-10, -30); // scrollDelta | 1174 expectedChildTransform.PreconcatTranslate(-10, -30); // scrollDelta |
1175 | 1175 |
1176 expectedGrandChildSurfaceDrawTransform.makeIdentity(); | 1176 expectedGrandChildSurfaceDrawTransform.matrix().setIdentity(); |
1177 expectedGrandChildSurfaceDrawTransform.translate(-10, -30); // scrollDelta | 1177 expectedGrandChildSurfaceDrawTransform.PreconcatTranslate(-10, -30); // scro llDelta |
1178 expectedGrandChildSurfaceDrawTransform.translate(8, 6); | 1178 expectedGrandChildSurfaceDrawTransform.PreconcatTranslate(8, 6); |
1179 expectedGrandChildSurfaceDrawTransform.multiply(rotationAboutZ); | 1179 expectedGrandChildSurfaceDrawTransform.PreconcatTransform(rotationAboutZ); |
1180 | 1180 |
1181 // grandChild, greatGrandChild, and greatGrandChild's surface are not expect ed to | 1181 // grandChild, greatGrandChild, and greatGrandChild's surface are not expect ed to |
1182 // change, since they are all not fixed, and they are all drawn with respect to | 1182 // change, since they are all not fixed, and they are all drawn with respect to |
1183 // grandChild's surface that already has the scrollDelta accounted for. | 1183 // grandChild's surface that already has the scrollDelta accounted for. |
1184 | 1184 |
1185 // But the great-great grandchild, "fixedPositionChild", should have a trans form that explicitly cancels out the scrollDelta. | 1185 // But the great-great grandchild, "fixedPositionChild", should have a trans form that explicitly cancels out the scrollDelta. |
1186 // The expected transform is: | 1186 // The expected transform is: |
1187 // compoundDrawTransform.inverse() * translate(positive scrollDelta) * com poundOriginTransform | 1187 // compoundDrawTransform.inverse() * translate(positive scrollDelta) * com poundOriginTransform |
1188 WebTransformationMatrix compoundDrawTransform; // transform from greatGrandC hildSurface's origin to the root surface. | 1188 Transform compoundDrawTransform; // transform from greatGrandChildSurface's origin to the root surface. |
1189 compoundDrawTransform.translate(8, 6); // origin translation of grandChild | 1189 compoundDrawTransform.PreconcatTranslate(8, 6); // origin translation of gra ndChild |
1190 compoundDrawTransform.multiply(rotationAboutZ); // rotation of grandChild | 1190 compoundDrawTransform.PreconcatTransform(rotationAboutZ); // rotation of gra ndChild |
1191 compoundDrawTransform.translate(40, 60); // origin translation of greatGrand Child | 1191 compoundDrawTransform.PreconcatTranslate(40, 60); // origin translation of g reatGrandChild |
1192 compoundDrawTransform.multiply(rotationAboutZ); // rotation of greatGrandChi ld | 1192 compoundDrawTransform.PreconcatTransform(rotationAboutZ); // rotation of gre atGrandChild |
1193 | 1193 |
1194 expectedFixedPositionChildTransform.makeIdentity(); | 1194 expectedFixedPositionChildTransform.matrix().setIdentity(); |
1195 expectedFixedPositionChildTransform.multiply(compoundDrawTransform.inverse() ); | 1195 expectedFixedPositionChildTransform.PreconcatTransform(MathUtil::inverse(com poundDrawTransform)); |
1196 expectedFixedPositionChildTransform.translate(10, 30); // explicit canceling out the scrollDelta that gets embedded in the fixed position layer's surface. | 1196 expectedFixedPositionChildTransform.PreconcatTranslate(10, 30); // explicit canceling out the scrollDelta that gets embedded in the fixed position layer's s urface. |
1197 expectedFixedPositionChildTransform.multiply(compoundDrawTransform); | 1197 expectedFixedPositionChildTransform.PreconcatTransform(compoundDrawTransform ); |
1198 | 1198 |
1199 ASSERT_TRUE(grandChild->renderSurface()); | 1199 ASSERT_TRUE(grandChild->renderSurface()); |
1200 ASSERT_TRUE(greatGrandChild->renderSurface()); | 1200 ASSERT_TRUE(greatGrandChild->renderSurface()); |
1201 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); | 1201 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); |
1202 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildSurfaceDrawTransform, gran dChild->renderSurface()->drawTransform()); | 1202 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildSurfaceDrawTransform, gran dChild->renderSurface()->drawTransform()); |
1203 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); | 1203 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); |
1204 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildSurfaceDrawTransform, greatGrandChild->renderSurface()->drawTransform()); | 1204 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildSurfaceDrawTransform, greatGrandChild->renderSurface()->drawTransform()); |
1205 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); | 1205 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); |
1206 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedFixedPositionChildTransform, fixedPo sitionChild->drawTransform()); | 1206 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedFixedPositionChildTransform, fixedPo sitionChild->drawTransform()); |
1207 } | 1207 } |
(...skipping 10 matching lines...) Expand all Loading... | |
1218 | 1218 |
1219 child->setIsContainerForFixedPositionLayers(true); | 1219 child->setIsContainerForFixedPositionLayers(true); |
1220 child->setForceRenderSurface(true); | 1220 child->setForceRenderSurface(true); |
1221 grandChild->setFixedToContainerLayer(true); | 1221 grandChild->setFixedToContainerLayer(true); |
1222 grandChild->setDrawsContent(true); | 1222 grandChild->setDrawsContent(true); |
1223 | 1223 |
1224 // Case 1: scrollDelta of 0, 0 | 1224 // Case 1: scrollDelta of 0, 0 |
1225 child->setScrollDelta(gfx::Vector2d(0, 0)); | 1225 child->setScrollDelta(gfx::Vector2d(0, 0)); |
1226 executeCalculateDrawTransformsAndVisibility(root.get()); | 1226 executeCalculateDrawTransformsAndVisibility(root.get()); |
1227 | 1227 |
1228 WebTransformationMatrix expectedSurfaceDrawTransform; | 1228 Transform expectedSurfaceDrawTransform; |
1229 expectedSurfaceDrawTransform.translate(0, 0); | 1229 expectedSurfaceDrawTransform.PreconcatTranslate(0, 0); |
1230 WebTransformationMatrix expectedChildTransform; | 1230 Transform expectedChildTransform; |
1231 WebTransformationMatrix expectedGrandChildTransform; | 1231 Transform expectedGrandChildTransform; |
1232 ASSERT_TRUE(child->renderSurface()); | 1232 ASSERT_TRUE(child->renderSurface()); |
1233 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderS urface()->drawTransform()); | 1233 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderS urface()->drawTransform()); |
1234 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); | 1234 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); |
1235 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); | 1235 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); |
1236 | 1236 |
1237 // Case 2: scrollDelta of 10, 10 | 1237 // Case 2: scrollDelta of 10, 10 |
1238 child->setScrollDelta(gfx::Vector2d(10, 10)); | 1238 child->setScrollDelta(gfx::Vector2d(10, 10)); |
1239 executeCalculateDrawTransformsAndVisibility(root.get()); | 1239 executeCalculateDrawTransformsAndVisibility(root.get()); |
1240 | 1240 |
1241 // The surface is translated by scrollDelta, the child transform doesn't cha nge | 1241 // The surface is translated by scrollDelta, the child transform doesn't cha nge |
1242 // because it scrolls along with the surface, but the fixed position grandCh ild | 1242 // because it scrolls along with the surface, but the fixed position grandCh ild |
1243 // needs to compensate for the scroll translation. | 1243 // needs to compensate for the scroll translation. |
1244 expectedSurfaceDrawTransform.makeIdentity(); | 1244 expectedSurfaceDrawTransform.matrix().setIdentity(); |
1245 expectedSurfaceDrawTransform.translate(-10, -10); | 1245 expectedSurfaceDrawTransform.PreconcatTranslate(-10, -10); |
1246 expectedGrandChildTransform.makeIdentity(); | 1246 expectedGrandChildTransform.matrix().setIdentity(); |
1247 expectedGrandChildTransform.translate(10, 10); | 1247 expectedGrandChildTransform.PreconcatTranslate(10, 10); |
1248 | 1248 |
1249 ASSERT_TRUE(child->renderSurface()); | 1249 ASSERT_TRUE(child->renderSurface()); |
1250 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderS urface()->drawTransform()); | 1250 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderS urface()->drawTransform()); |
1251 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); | 1251 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); |
1252 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); | 1252 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); |
1253 } | 1253 } |
1254 | 1254 |
1255 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatI sAlsoFixedPositionContainer) | 1255 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatI sAlsoFixedPositionContainer) |
1256 { | 1256 { |
1257 // This test checks the scenario where a fixed-position layer also happens t o be a | 1257 // This test checks the scenario where a fixed-position layer also happens t o be a |
1258 // container itself for a descendant fixed position layer. In particular, th e layer | 1258 // container itself for a descendant fixed position layer. In particular, th e layer |
1259 // should not accidentally be fixed to itself. | 1259 // should not accidentally be fixed to itself. |
1260 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); | 1260 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
1261 LayerImpl* child = root->children()[0]; | 1261 LayerImpl* child = root->children()[0]; |
1262 LayerImpl* grandChild = child->children()[0]; | 1262 LayerImpl* grandChild = child->children()[0]; |
1263 | 1263 |
1264 child->setIsContainerForFixedPositionLayers(true); | 1264 child->setIsContainerForFixedPositionLayers(true); |
1265 grandChild->setFixedToContainerLayer(true); | 1265 grandChild->setFixedToContainerLayer(true); |
1266 | 1266 |
1267 // This should not confuse the grandChild. If correct, the grandChild would still be considered fixed to its container (i.e. "child"). | 1267 // This should not confuse the grandChild. If correct, the grandChild would still be considered fixed to its container (i.e. "child"). |
1268 grandChild->setIsContainerForFixedPositionLayers(true); | 1268 grandChild->setIsContainerForFixedPositionLayers(true); |
1269 | 1269 |
1270 // Case 1: scrollDelta of 0, 0 | 1270 // Case 1: scrollDelta of 0, 0 |
1271 child->setScrollDelta(gfx::Vector2d(0, 0)); | 1271 child->setScrollDelta(gfx::Vector2d(0, 0)); |
1272 executeCalculateDrawTransformsAndVisibility(root.get()); | 1272 executeCalculateDrawTransformsAndVisibility(root.get()); |
1273 | 1273 |
1274 WebTransformationMatrix expectedChildTransform; | 1274 Transform expectedChildTransform; |
1275 WebTransformationMatrix expectedGrandChildTransform; | 1275 Transform expectedGrandChildTransform; |
1276 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); | 1276 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); |
1277 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); | 1277 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); |
1278 | 1278 |
1279 // Case 2: scrollDelta of 10, 10 | 1279 // Case 2: scrollDelta of 10, 10 |
1280 child->setScrollDelta(gfx::Vector2d(10, 10)); | 1280 child->setScrollDelta(gfx::Vector2d(10, 10)); |
1281 executeCalculateDrawTransformsAndVisibility(root.get()); | 1281 executeCalculateDrawTransformsAndVisibility(root.get()); |
1282 | 1282 |
1283 // Here the child is affected by scrollDelta, but the fixed position grandCh ild should not be affected. | 1283 // Here the child is affected by scrollDelta, but the fixed position grandCh ild should not be affected. |
1284 expectedChildTransform.makeIdentity(); | 1284 expectedChildTransform.matrix().setIdentity(); |
1285 expectedChildTransform.translate(-10, -10); | 1285 expectedChildTransform.PreconcatTranslate(-10, -10); |
1286 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); | 1286 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); |
1287 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); | 1287 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); |
1288 } | 1288 } |
1289 | 1289 |
1290 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatH asNoContainer) | 1290 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatH asNoContainer) |
1291 { | 1291 { |
1292 // This test checks scroll compensation when a fixed-position layer does not find any | 1292 // This test checks scroll compensation when a fixed-position layer does not find any |
1293 // ancestor that is a "containerForFixedPositionLayers". In this situation, the layer should | 1293 // ancestor that is a "containerForFixedPositionLayers". In this situation, the layer should |
1294 // be fixed to the viewport -- not the rootLayer, which may have transforms of its own. | 1294 // be fixed to the viewport -- not the rootLayer, which may have transforms of its own. |
1295 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); | 1295 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
1296 LayerImpl* child = root->children()[0]; | 1296 LayerImpl* child = root->children()[0]; |
1297 LayerImpl* grandChild = child->children()[0]; | 1297 LayerImpl* grandChild = child->children()[0]; |
1298 | 1298 |
1299 WebTransformationMatrix rotationByZ; | 1299 Transform rotationByZ; |
1300 rotationByZ.rotate3d(0, 0, 90); | 1300 MathUtil::rotateEulerAngles(&rotationByZ, 0, 0, 90); |
1301 | 1301 |
1302 root->setTransform(rotationByZ); | 1302 root->setTransform(rotationByZ); |
1303 grandChild->setFixedToContainerLayer(true); | 1303 grandChild->setFixedToContainerLayer(true); |
1304 | 1304 |
1305 // Case 1: root scrollDelta of 0, 0 | 1305 // Case 1: root scrollDelta of 0, 0 |
1306 root->setScrollDelta(gfx::Vector2d(0, 0)); | 1306 root->setScrollDelta(gfx::Vector2d(0, 0)); |
1307 executeCalculateDrawTransformsAndVisibility(root.get()); | 1307 executeCalculateDrawTransformsAndVisibility(root.get()); |
1308 | 1308 |
1309 WebTransformationMatrix identityMatrix; | 1309 Transform identityMatrix; |
1310 | 1310 |
1311 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 1311 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); |
1312 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform()) ; | 1312 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform()) ; |
1313 | 1313 |
1314 // Case 2: root scrollDelta of 10, 10 | 1314 // Case 2: root scrollDelta of 10, 10 |
1315 root->setScrollDelta(gfx::Vector2d(10, 20)); | 1315 root->setScrollDelta(gfx::Vector2d(10, 20)); |
1316 executeCalculateDrawTransformsAndVisibility(root.get()); | 1316 executeCalculateDrawTransformsAndVisibility(root.get()); |
1317 | 1317 |
1318 // The child is affected by scrollDelta, but it is already implcitly account ed for by | 1318 // The child is affected by scrollDelta, but it is already implcitly account ed for by |
1319 // the child's target surface (i.e. the root renderSurface). The grandChild is not | 1319 // the child's target surface (i.e. the root renderSurface). The grandChild is not |
1320 // affected by the scrollDelta, so its drawTransform needs to explicitly | 1320 // affected by the scrollDelta, so its drawTransform needs to explicitly |
1321 // inverse-compensate for the scroll that's embedded in the target surface. | 1321 // inverse-compensate for the scroll that's embedded in the target surface. |
1322 WebTransformationMatrix expectedGrandChildTransform; | 1322 Transform expectedGrandChildTransform; |
1323 expectedGrandChildTransform.multiply(rotationByZ.inverse()); | 1323 expectedGrandChildTransform.PreconcatTransform(MathUtil::inverse(rotationByZ )); |
1324 expectedGrandChildTransform.translate(10, 20); // explicit canceling out the scrollDelta that gets embedded in the fixed position layer's surface. | 1324 expectedGrandChildTransform.PreconcatTranslate(10, 20); // explicit cancelin g out the scrollDelta that gets embedded in the fixed position layer's surface. |
1325 expectedGrandChildTransform.multiply(rotationByZ); | 1325 expectedGrandChildTransform.PreconcatTransform(rotationByZ); |
1326 | 1326 |
1327 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 1327 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); |
1328 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); | 1328 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); |
1329 } | 1329 } |
1330 | 1330 |
1331 TEST(LayerTreeHostCommonTest, verifyClipRectCullsRenderSurfaces) | 1331 TEST(LayerTreeHostCommonTest, verifyClipRectCullsRenderSurfaces) |
1332 { | 1332 { |
1333 // The entire subtree of layers that are outside the clipRect should be cull ed away, | 1333 // The entire subtree of layers that are outside the clipRect should be cull ed away, |
1334 // and should not affect the renderSurfaceLayerList. | 1334 // and should not affect the renderSurfaceLayerList. |
1335 // | 1335 // |
1336 // The test tree is set up as follows: | 1336 // The test tree is set up as follows: |
1337 // - all layers except the leafNodes are forced to be a new renderSurface t hat have something to draw. | 1337 // - all layers except the leafNodes are forced to be a new renderSurface t hat have something to draw. |
1338 // - parent is a large container layer. | 1338 // - parent is a large container layer. |
1339 // - child has masksToBounds=true to cause clipping. | 1339 // - child has masksToBounds=true to cause clipping. |
1340 // - grandChild is positioned outside of the child's bounds | 1340 // - grandChild is positioned outside of the child's bounds |
1341 // - greatGrandChild is also kept outside child's bounds. | 1341 // - greatGrandChild is also kept outside child's bounds. |
1342 // | 1342 // |
1343 // In this configuration, grandChild and greatGrandChild are completely outs ide the | 1343 // In this configuration, grandChild and greatGrandChild are completely outs ide the |
1344 // clipRect, and they should never get scheduled on the list of renderSurfac es. | 1344 // clipRect, and they should never get scheduled on the list of renderSurfac es. |
1345 // | 1345 // |
1346 | 1346 |
1347 const WebTransformationMatrix identityMatrix; | 1347 const Transform identityMatrix; |
1348 scoped_refptr<Layer> parent = Layer::create(); | 1348 scoped_refptr<Layer> parent = Layer::create(); |
1349 scoped_refptr<Layer> child = Layer::create(); | 1349 scoped_refptr<Layer> child = Layer::create(); |
1350 scoped_refptr<Layer> grandChild = Layer::create(); | 1350 scoped_refptr<Layer> grandChild = Layer::create(); |
1351 scoped_refptr<Layer> greatGrandChild = Layer::create(); | 1351 scoped_refptr<Layer> greatGrandChild = Layer::create(); |
1352 scoped_refptr<LayerWithForcedDrawsContent> leafNode1 = make_scoped_refptr(ne w LayerWithForcedDrawsContent()); | 1352 scoped_refptr<LayerWithForcedDrawsContent> leafNode1 = make_scoped_refptr(ne w LayerWithForcedDrawsContent()); |
1353 scoped_refptr<LayerWithForcedDrawsContent> leafNode2 = make_scoped_refptr(ne w LayerWithForcedDrawsContent()); | 1353 scoped_refptr<LayerWithForcedDrawsContent> leafNode2 = make_scoped_refptr(ne w LayerWithForcedDrawsContent()); |
1354 parent->addChild(child); | 1354 parent->addChild(child); |
1355 child->addChild(grandChild); | 1355 child->addChild(grandChild); |
1356 grandChild->addChild(greatGrandChild); | 1356 grandChild->addChild(greatGrandChild); |
1357 | 1357 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1392 // - parent is a container layer that masksToBounds=true to cause clipping. | 1392 // - parent is a container layer that masksToBounds=true to cause clipping. |
1393 // - child is a renderSurface, which has a clipRect set to the bounds of th e parent. | 1393 // - child is a renderSurface, which has a clipRect set to the bounds of th e parent. |
1394 // - grandChild is a renderSurface, and the only visible content in child. It is positioned outside of the clipRect from parent. | 1394 // - grandChild is a renderSurface, and the only visible content in child. It is positioned outside of the clipRect from parent. |
1395 | 1395 |
1396 // In this configuration, grandChild should be outside the clipped | 1396 // In this configuration, grandChild should be outside the clipped |
1397 // contentRect of the child, making grandChild not appear in the | 1397 // contentRect of the child, making grandChild not appear in the |
1398 // renderSurfaceLayerList. However, when we place an animation on the child, | 1398 // renderSurfaceLayerList. However, when we place an animation on the child, |
1399 // this clipping should be avoided and we should keep the grandChild | 1399 // this clipping should be avoided and we should keep the grandChild |
1400 // in the renderSurfaceLayerList. | 1400 // in the renderSurfaceLayerList. |
1401 | 1401 |
1402 const WebTransformationMatrix identityMatrix; | 1402 const Transform identityMatrix; |
1403 scoped_refptr<Layer> parent = Layer::create(); | 1403 scoped_refptr<Layer> parent = Layer::create(); |
1404 scoped_refptr<Layer> child = Layer::create(); | 1404 scoped_refptr<Layer> child = Layer::create(); |
1405 scoped_refptr<Layer> grandChild = Layer::create(); | 1405 scoped_refptr<Layer> grandChild = Layer::create(); |
1406 scoped_refptr<LayerWithForcedDrawsContent> leafNode = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 1406 scoped_refptr<LayerWithForcedDrawsContent> leafNode = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
1407 parent->addChild(child); | 1407 parent->addChild(child); |
1408 child->addChild(grandChild); | 1408 child->addChild(grandChild); |
1409 grandChild->addChild(leafNode); | 1409 grandChild->addChild(leafNode); |
1410 | 1410 |
1411 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 1411 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
1412 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); | 1412 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1450 // renderTarget, | 1450 // renderTarget, |
1451 // - a surface is clipped by an ancestor that contributes to the same | 1451 // - a surface is clipped by an ancestor that contributes to the same |
1452 // renderTarget. | 1452 // renderTarget. |
1453 // | 1453 // |
1454 // In particular, for a layer that owns a renderSurface: | 1454 // In particular, for a layer that owns a renderSurface: |
1455 // - the renderSurfarce inherits any clip from ancestors, and does NOT | 1455 // - the renderSurfarce inherits any clip from ancestors, and does NOT |
1456 // pass that clipped status to the layer itself. | 1456 // pass that clipped status to the layer itself. |
1457 // - but if the layer itself masks to bounds, it is considered clipped | 1457 // - but if the layer itself masks to bounds, it is considered clipped |
1458 // and propagates the clip to the subtree. | 1458 // and propagates the clip to the subtree. |
1459 | 1459 |
1460 const WebTransformationMatrix identityMatrix; | 1460 const Transform identityMatrix; |
1461 scoped_refptr<Layer> root = Layer::create(); | 1461 scoped_refptr<Layer> root = Layer::create(); |
1462 scoped_refptr<Layer> parent = Layer::create(); | 1462 scoped_refptr<Layer> parent = Layer::create(); |
1463 scoped_refptr<Layer> child1 = Layer::create(); | 1463 scoped_refptr<Layer> child1 = Layer::create(); |
1464 scoped_refptr<Layer> child2 = Layer::create(); | 1464 scoped_refptr<Layer> child2 = Layer::create(); |
1465 scoped_refptr<Layer> grandChild = Layer::create(); | 1465 scoped_refptr<Layer> grandChild = Layer::create(); |
1466 scoped_refptr<LayerWithForcedDrawsContent> leafNode1 = make_scoped_refptr(ne w LayerWithForcedDrawsContent()); | 1466 scoped_refptr<LayerWithForcedDrawsContent> leafNode1 = make_scoped_refptr(ne w LayerWithForcedDrawsContent()); |
1467 scoped_refptr<LayerWithForcedDrawsContent> leafNode2 = make_scoped_refptr(ne w LayerWithForcedDrawsContent()); | 1467 scoped_refptr<LayerWithForcedDrawsContent> leafNode2 = make_scoped_refptr(ne w LayerWithForcedDrawsContent()); |
1468 root->addChild(parent); | 1468 root->addChild(parent); |
1469 parent->addChild(child1); | 1469 parent->addChild(child1); |
1470 parent->addChild(child2); | 1470 parent->addChild(child2); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1545 TEST(LayerTreeHostCommonTest, verifyDrawableContentRectForLayers) | 1545 TEST(LayerTreeHostCommonTest, verifyDrawableContentRectForLayers) |
1546 { | 1546 { |
1547 // Verify that layers get the appropriate drawableContentRect when their par ent masksToBounds is true. | 1547 // Verify that layers get the appropriate drawableContentRect when their par ent masksToBounds is true. |
1548 // | 1548 // |
1549 // grandChild1 - completely inside the region; drawableContentRect should be the layer rect expressed in target space. | 1549 // grandChild1 - completely inside the region; drawableContentRect should be the layer rect expressed in target space. |
1550 // grandChild2 - partially clipped but NOT masksToBounds; the clipRect wil l be the intersection of layerBounds and the mask region. | 1550 // grandChild2 - partially clipped but NOT masksToBounds; the clipRect wil l be the intersection of layerBounds and the mask region. |
1551 // grandChild3 - partially clipped and masksToBounds; the drawableContentR ect will still be the intersection of layerBounds and the mask region. | 1551 // grandChild3 - partially clipped and masksToBounds; the drawableContentR ect will still be the intersection of layerBounds and the mask region. |
1552 // grandChild4 - outside parent's clipRect; the drawableContentRect should be empty. | 1552 // grandChild4 - outside parent's clipRect; the drawableContentRect should be empty. |
1553 // | 1553 // |
1554 | 1554 |
1555 const WebTransformationMatrix identityMatrix; | 1555 const Transform identityMatrix; |
1556 scoped_refptr<Layer> parent = Layer::create(); | 1556 scoped_refptr<Layer> parent = Layer::create(); |
1557 scoped_refptr<Layer> child = Layer::create(); | 1557 scoped_refptr<Layer> child = Layer::create(); |
1558 scoped_refptr<Layer> grandChild1 = Layer::create(); | 1558 scoped_refptr<Layer> grandChild1 = Layer::create(); |
1559 scoped_refptr<Layer> grandChild2 = Layer::create(); | 1559 scoped_refptr<Layer> grandChild2 = Layer::create(); |
1560 scoped_refptr<Layer> grandChild3 = Layer::create(); | 1560 scoped_refptr<Layer> grandChild3 = Layer::create(); |
1561 scoped_refptr<Layer> grandChild4 = Layer::create(); | 1561 scoped_refptr<Layer> grandChild4 = Layer::create(); |
1562 | 1562 |
1563 parent->addChild(child); | 1563 parent->addChild(child); |
1564 child->addChild(grandChild1); | 1564 child->addChild(grandChild1); |
1565 child->addChild(grandChild2); | 1565 child->addChild(grandChild2); |
(...skipping 29 matching lines...) Expand all Loading... | |
1595 | 1595 |
1596 TEST(LayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces) | 1596 TEST(LayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces) |
1597 { | 1597 { |
1598 // Verify that renderSurfaces (and their layers) get the appropriate clipRec ts when their parent masksToBounds is true. | 1598 // Verify that renderSurfaces (and their layers) get the appropriate clipRec ts when their parent masksToBounds is true. |
1599 // | 1599 // |
1600 // Layers that own renderSurfaces (at least for now) do not inherit any clip ping; | 1600 // Layers that own renderSurfaces (at least for now) do not inherit any clip ping; |
1601 // instead the surface will enforce the clip for the entire subtree. They ma y still | 1601 // instead the surface will enforce the clip for the entire subtree. They ma y still |
1602 // have a clipRect of their own layer bounds, however, if masksToBounds was true. | 1602 // have a clipRect of their own layer bounds, however, if masksToBounds was true. |
1603 // | 1603 // |
1604 | 1604 |
1605 const WebTransformationMatrix identityMatrix; | 1605 const Transform identityMatrix; |
1606 scoped_refptr<Layer> parent = Layer::create(); | 1606 scoped_refptr<Layer> parent = Layer::create(); |
1607 scoped_refptr<Layer> child = Layer::create(); | 1607 scoped_refptr<Layer> child = Layer::create(); |
1608 scoped_refptr<Layer> grandChild1 = Layer::create(); | 1608 scoped_refptr<Layer> grandChild1 = Layer::create(); |
1609 scoped_refptr<Layer> grandChild2 = Layer::create(); | 1609 scoped_refptr<Layer> grandChild2 = Layer::create(); |
1610 scoped_refptr<Layer> grandChild3 = Layer::create(); | 1610 scoped_refptr<Layer> grandChild3 = Layer::create(); |
1611 scoped_refptr<Layer> grandChild4 = Layer::create(); | 1611 scoped_refptr<Layer> grandChild4 = Layer::create(); |
1612 scoped_refptr<LayerWithForcedDrawsContent> leafNode1 = make_scoped_refptr(ne w LayerWithForcedDrawsContent()); | 1612 scoped_refptr<LayerWithForcedDrawsContent> leafNode1 = make_scoped_refptr(ne w LayerWithForcedDrawsContent()); |
1613 scoped_refptr<LayerWithForcedDrawsContent> leafNode2 = make_scoped_refptr(ne w LayerWithForcedDrawsContent()); | 1613 scoped_refptr<LayerWithForcedDrawsContent> leafNode2 = make_scoped_refptr(ne w LayerWithForcedDrawsContent()); |
1614 scoped_refptr<LayerWithForcedDrawsContent> leafNode3 = make_scoped_refptr(ne w LayerWithForcedDrawsContent()); | 1614 scoped_refptr<LayerWithForcedDrawsContent> leafNode3 = make_scoped_refptr(ne w LayerWithForcedDrawsContent()); |
1615 scoped_refptr<LayerWithForcedDrawsContent> leafNode4 = make_scoped_refptr(ne w LayerWithForcedDrawsContent()); | 1615 scoped_refptr<LayerWithForcedDrawsContent> leafNode4 = make_scoped_refptr(ne w LayerWithForcedDrawsContent()); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1686 // Make our render surfaces. | 1686 // Make our render surfaces. |
1687 renderSurface1->setForceRenderSurface(true); | 1687 renderSurface1->setForceRenderSurface(true); |
1688 renderSurface2->setForceRenderSurface(true); | 1688 renderSurface2->setForceRenderSurface(true); |
1689 | 1689 |
1690 // Put an animated opacity on the render surface. | 1690 // Put an animated opacity on the render surface. |
1691 addOpacityTransitionToController(*renderSurface1->layerAnimationController() , 10, 1, 0, false); | 1691 addOpacityTransitionToController(*renderSurface1->layerAnimationController() , 10, 1, 0, false); |
1692 | 1692 |
1693 // Also put an animated opacity on a layer without descendants. | 1693 // Also put an animated opacity on a layer without descendants. |
1694 addOpacityTransitionToController(*grandChildOfRoot->layerAnimationController (), 10, 1, 0, false); | 1694 addOpacityTransitionToController(*grandChildOfRoot->layerAnimationController (), 10, 1, 0, false); |
1695 | 1695 |
1696 WebTransformationMatrix layerTransform; | 1696 Transform layerTransform; |
1697 layerTransform.translate(1, 1); | 1697 layerTransform.PreconcatTranslate(1, 1); |
1698 WebTransformationMatrix sublayerTransform; | 1698 Transform sublayerTransform; |
1699 sublayerTransform.scale3d(10, 1, 1); | 1699 sublayerTransform.PreconcatScale3d(10, 1, 1); |
1700 | 1700 |
1701 // Put a transform animation on the render surface. | 1701 // Put a transform animation on the render surface. |
1702 addAnimatedTransformToController(*renderSurface2->layerAnimationController() , 10, 30, 0); | 1702 addAnimatedTransformToController(*renderSurface2->layerAnimationController() , 10, 30, 0); |
1703 | 1703 |
1704 // Also put transform animations on grandChildOfRoot, and grandChildOfRS2 | 1704 // Also put transform animations on grandChildOfRoot, and grandChildOfRS2 |
1705 addAnimatedTransformToController(*grandChildOfRoot->layerAnimationController (), 10, 30, 0); | 1705 addAnimatedTransformToController(*grandChildOfRoot->layerAnimationController (), 10, 30, 0); |
1706 addAnimatedTransformToController(*grandChildOfRS2->layerAnimationController( ), 10, 30, 0); | 1706 addAnimatedTransformToController(*grandChildOfRS2->layerAnimationController( ), 10, 30, 0); |
1707 | 1707 |
1708 setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform , gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); | 1708 setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform , gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); |
1709 setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerT ransform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); | 1709 setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerT ransform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1784 EXPECT_FALSE(grandChildOfRS1->screenSpaceTransformIsAnimating()); | 1784 EXPECT_FALSE(grandChildOfRS1->screenSpaceTransformIsAnimating()); |
1785 EXPECT_TRUE(renderSurface2->screenSpaceTransformIsAnimating()); | 1785 EXPECT_TRUE(renderSurface2->screenSpaceTransformIsAnimating()); |
1786 EXPECT_TRUE(renderSurface2->renderSurface()->screenSpaceTransformsAreAnimati ng()); | 1786 EXPECT_TRUE(renderSurface2->renderSurface()->screenSpaceTransformsAreAnimati ng()); |
1787 EXPECT_TRUE(childOfRS2->screenSpaceTransformIsAnimating()); | 1787 EXPECT_TRUE(childOfRS2->screenSpaceTransformIsAnimating()); |
1788 EXPECT_TRUE(grandChildOfRS2->screenSpaceTransformIsAnimating()); | 1788 EXPECT_TRUE(grandChildOfRS2->screenSpaceTransformIsAnimating()); |
1789 | 1789 |
1790 | 1790 |
1791 // Sanity check. If these fail there is probably a bug in the test itself. | 1791 // Sanity check. If these fail there is probably a bug in the test itself. |
1792 // It is expected that we correctly set up transforms so that the y-componen t of the screen-space transform | 1792 // It is expected that we correctly set up transforms so that the y-componen t of the screen-space transform |
1793 // encodes the "depth" of the layer in the tree. | 1793 // encodes the "depth" of the layer in the tree. |
1794 EXPECT_FLOAT_EQ(1, parent->screenSpaceTransform().m42()); | 1794 EXPECT_FLOAT_EQ(1, parent->screenSpaceTransform().matrix().getDouble(1, 3)); |
1795 EXPECT_FLOAT_EQ(2, childOfRoot->screenSpaceTransform().m42()); | 1795 EXPECT_FLOAT_EQ(2, childOfRoot->screenSpaceTransform().matrix().getDouble(1, 3)); |
1796 EXPECT_FLOAT_EQ(3, grandChildOfRoot->screenSpaceTransform().m42()); | 1796 EXPECT_FLOAT_EQ(3, grandChildOfRoot->screenSpaceTransform().matrix().getDoub le(1, 3)); |
1797 | 1797 |
1798 EXPECT_FLOAT_EQ(2, renderSurface1->screenSpaceTransform().m42()); | 1798 EXPECT_FLOAT_EQ(2, renderSurface1->screenSpaceTransform().matrix().getDouble (1, 3)); |
1799 EXPECT_FLOAT_EQ(3, childOfRS1->screenSpaceTransform().m42()); | 1799 EXPECT_FLOAT_EQ(3, childOfRS1->screenSpaceTransform().matrix().getDouble(1, 3)); |
1800 EXPECT_FLOAT_EQ(4, grandChildOfRS1->screenSpaceTransform().m42()); | 1800 EXPECT_FLOAT_EQ(4, grandChildOfRS1->screenSpaceTransform().matrix().getDoubl e(1, 3)); |
1801 | 1801 |
1802 EXPECT_FLOAT_EQ(3, renderSurface2->screenSpaceTransform().m42()); | 1802 EXPECT_FLOAT_EQ(3, renderSurface2->screenSpaceTransform().matrix().getDouble (1, 3)); |
1803 EXPECT_FLOAT_EQ(4, childOfRS2->screenSpaceTransform().m42()); | 1803 EXPECT_FLOAT_EQ(4, childOfRS2->screenSpaceTransform().matrix().getDouble(1, 3)); |
1804 EXPECT_FLOAT_EQ(5, grandChildOfRS2->screenSpaceTransform().m42()); | 1804 EXPECT_FLOAT_EQ(5, grandChildOfRS2->screenSpaceTransform().matrix().getDoubl e(1, 3)); |
1805 } | 1805 } |
1806 | 1806 |
1807 TEST(LayerTreeHostCommonTest, verifyVisibleRectForIdentityTransform) | 1807 TEST(LayerTreeHostCommonTest, verifyVisibleRectForIdentityTransform) |
1808 { | 1808 { |
1809 // Test the calculateVisibleRect() function works correctly for identity tra nsforms. | 1809 // Test the calculateVisibleRect() function works correctly for identity tra nsforms. |
1810 | 1810 |
1811 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100 )); | 1811 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100 )); |
1812 WebTransformationMatrix layerToSurfaceTransform; | 1812 Transform layerToSurfaceTransform; |
1813 | 1813 |
1814 // Case 1: Layer is contained within the surface. | 1814 // Case 1: Layer is contained within the surface. |
1815 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(10, 10), gfx::Size(30, 30) ); | 1815 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(10, 10), gfx::Size(30, 30) ); |
1816 gfx::Rect expected = gfx::Rect(gfx::Point(10, 10), gfx::Size(30, 30)); | 1816 gfx::Rect expected = gfx::Rect(gfx::Point(10, 10), gfx::Size(30, 30)); |
1817 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform); | 1817 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform); |
1818 EXPECT_RECT_EQ(expected, actual); | 1818 EXPECT_RECT_EQ(expected, actual); |
1819 | 1819 |
1820 // Case 2: Layer is outside the surface rect. | 1820 // Case 2: Layer is outside the surface rect. |
1821 layerContentRect = gfx::Rect(gfx::Point(120, 120), gfx::Size(30, 30)); | 1821 layerContentRect = gfx::Rect(gfx::Point(120, 120), gfx::Size(30, 30)); |
1822 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC ontentRect, layerToSurfaceTransform); | 1822 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC ontentRect, layerToSurfaceTransform); |
1823 EXPECT_TRUE(actual.IsEmpty()); | 1823 EXPECT_TRUE(actual.IsEmpty()); |
1824 | 1824 |
1825 // Case 3: Layer is partially overlapping the surface rect. | 1825 // Case 3: Layer is partially overlapping the surface rect. |
1826 layerContentRect = gfx::Rect(gfx::Point(80, 80), gfx::Size(30, 30)); | 1826 layerContentRect = gfx::Rect(gfx::Point(80, 80), gfx::Size(30, 30)); |
1827 expected = gfx::Rect(gfx::Point(80, 80), gfx::Size(20, 20)); | 1827 expected = gfx::Rect(gfx::Point(80, 80), gfx::Size(20, 20)); |
1828 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC ontentRect, layerToSurfaceTransform); | 1828 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC ontentRect, layerToSurfaceTransform); |
1829 EXPECT_RECT_EQ(expected, actual); | 1829 EXPECT_RECT_EQ(expected, actual); |
1830 } | 1830 } |
1831 | 1831 |
1832 TEST(LayerTreeHostCommonTest, verifyVisibleRectForTranslations) | 1832 TEST(LayerTreeHostCommonTest, verifyVisibleRectForTranslations) |
1833 { | 1833 { |
1834 // Test the calculateVisibleRect() function works correctly for scaling tran sforms. | 1834 // Test the calculateVisibleRect() function works correctly for scaling tran sforms. |
1835 | 1835 |
1836 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100 )); | 1836 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100 )); |
1837 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); | 1837 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); |
1838 WebTransformationMatrix layerToSurfaceTransform; | 1838 Transform layerToSurfaceTransform; |
1839 | 1839 |
1840 // Case 1: Layer is contained within the surface. | 1840 // Case 1: Layer is contained within the surface. |
1841 layerToSurfaceTransform.makeIdentity(); | 1841 layerToSurfaceTransform.matrix().setIdentity(); |
1842 layerToSurfaceTransform.translate(10, 10); | 1842 layerToSurfaceTransform.PreconcatTranslate(10, 10); |
1843 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); | 1843 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); |
1844 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform); | 1844 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform); |
1845 EXPECT_RECT_EQ(expected, actual); | 1845 EXPECT_RECT_EQ(expected, actual); |
1846 | 1846 |
1847 // Case 2: Layer is outside the surface rect. | 1847 // Case 2: Layer is outside the surface rect. |
1848 layerToSurfaceTransform.makeIdentity(); | 1848 layerToSurfaceTransform.matrix().setIdentity(); |
1849 layerToSurfaceTransform.translate(120, 120); | 1849 layerToSurfaceTransform.PreconcatTranslate(120, 120); |
1850 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC ontentRect, layerToSurfaceTransform); | 1850 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC ontentRect, layerToSurfaceTransform); |
1851 EXPECT_TRUE(actual.IsEmpty()); | 1851 EXPECT_TRUE(actual.IsEmpty()); |
1852 | 1852 |
1853 // Case 3: Layer is partially overlapping the surface rect. | 1853 // Case 3: Layer is partially overlapping the surface rect. |
1854 layerToSurfaceTransform.makeIdentity(); | 1854 layerToSurfaceTransform.matrix().setIdentity(); |
1855 layerToSurfaceTransform.translate(80, 80); | 1855 layerToSurfaceTransform.PreconcatTranslate(80, 80); |
1856 expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)); | 1856 expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)); |
1857 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC ontentRect, layerToSurfaceTransform); | 1857 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC ontentRect, layerToSurfaceTransform); |
1858 EXPECT_RECT_EQ(expected, actual); | 1858 EXPECT_RECT_EQ(expected, actual); |
1859 } | 1859 } |
1860 | 1860 |
1861 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor2DRotations) | 1861 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor2DRotations) |
1862 { | 1862 { |
1863 // Test the calculateVisibleRect() function works correctly for rotations ab out z-axis (i.e. 2D rotations). | 1863 // Test the calculateVisibleRect() function works correctly for rotations ab out z-axis (i.e. 2D rotations). |
1864 // Remember that calculateVisibleRect() should return the visible rect in th e layer's space. | 1864 // Remember that calculateVisibleRect() should return the visible rect in th e layer's space. |
1865 | 1865 |
1866 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100 )); | 1866 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100 )); |
1867 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); | 1867 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); |
1868 WebTransformationMatrix layerToSurfaceTransform; | 1868 Transform layerToSurfaceTransform; |
1869 | 1869 |
1870 // Case 1: Layer is contained within the surface. | 1870 // Case 1: Layer is contained within the surface. |
1871 layerToSurfaceTransform.makeIdentity(); | 1871 layerToSurfaceTransform.matrix().setIdentity(); |
1872 layerToSurfaceTransform.translate(50, 50); | 1872 layerToSurfaceTransform.PreconcatTranslate(50, 50); |
1873 layerToSurfaceTransform.rotate(45); | 1873 layerToSurfaceTransform.PreconcatRotate(45); |
1874 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); | 1874 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); |
1875 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform); | 1875 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform); |
1876 EXPECT_RECT_EQ(expected, actual); | 1876 EXPECT_RECT_EQ(expected, actual); |
1877 | 1877 |
1878 // Case 2: Layer is outside the surface rect. | 1878 // Case 2: Layer is outside the surface rect. |
1879 layerToSurfaceTransform.makeIdentity(); | 1879 layerToSurfaceTransform.matrix().setIdentity(); |
1880 layerToSurfaceTransform.translate(-50, 0); | 1880 layerToSurfaceTransform.PreconcatTranslate(-50, 0); |
1881 layerToSurfaceTransform.rotate(45); | 1881 layerToSurfaceTransform.PreconcatRotate(45); |
1882 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC ontentRect, layerToSurfaceTransform); | 1882 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC ontentRect, layerToSurfaceTransform); |
1883 EXPECT_TRUE(actual.IsEmpty()); | 1883 EXPECT_TRUE(actual.IsEmpty()); |
1884 | 1884 |
1885 // Case 3: The layer is rotated about its top-left corner. In surface space, the layer | 1885 // Case 3: The layer is rotated about its top-left corner. In surface space, the layer |
1886 // is oriented diagonally, with the left half outside of the renderS urface. In | 1886 // is oriented diagonally, with the left half outside of the renderS urface. In |
1887 // this case, the visible rect should still be the entire layer (rem ember the | 1887 // this case, the visible rect should still be the entire layer (rem ember the |
1888 // visible rect is computed in layer space); both the top-left and | 1888 // visible rect is computed in layer space); both the top-left and |
1889 // bottom-right corners of the layer are still visible. | 1889 // bottom-right corners of the layer are still visible. |
1890 layerToSurfaceTransform.makeIdentity(); | 1890 layerToSurfaceTransform.matrix().setIdentity(); |
1891 layerToSurfaceTransform.rotate(45); | 1891 layerToSurfaceTransform.PreconcatRotate(45); |
1892 expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); | 1892 expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); |
1893 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC ontentRect, layerToSurfaceTransform); | 1893 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC ontentRect, layerToSurfaceTransform); |
1894 EXPECT_RECT_EQ(expected, actual); | 1894 EXPECT_RECT_EQ(expected, actual); |
1895 | 1895 |
1896 // Case 4: The layer is rotated about its top-left corner, and translated up wards. In | 1896 // Case 4: The layer is rotated about its top-left corner, and translated up wards. In |
1897 // surface space, the layer is oriented diagonally, with only the to p corner | 1897 // surface space, the layer is oriented diagonally, with only the to p corner |
1898 // of the surface overlapping the layer. In layer space, the render surface | 1898 // of the surface overlapping the layer. In layer space, the render surface |
1899 // overlaps the right side of the layer. The visible rect should be the | 1899 // overlaps the right side of the layer. The visible rect should be the |
1900 // layer's right half. | 1900 // layer's right half. |
1901 layerToSurfaceTransform.makeIdentity(); | 1901 layerToSurfaceTransform.matrix().setIdentity(); |
1902 layerToSurfaceTransform.translate(0, -sqrt(2.0) * 15); | 1902 layerToSurfaceTransform.PreconcatTranslate(0, -sqrt(2.0) * 15); |
1903 layerToSurfaceTransform.rotate(45); | 1903 layerToSurfaceTransform.PreconcatRotate(45); |
1904 expected = gfx::Rect(gfx::Point(15, 0), gfx::Size(15, 30)); // right half of layer bounds. | 1904 expected = gfx::Rect(gfx::Point(15, 0), gfx::Size(15, 30)); // right half of layer bounds. |
1905 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC ontentRect, layerToSurfaceTransform); | 1905 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC ontentRect, layerToSurfaceTransform); |
1906 EXPECT_RECT_EQ(expected, actual); | 1906 EXPECT_RECT_EQ(expected, actual); |
1907 } | 1907 } |
1908 | 1908 |
1909 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicTransform) | 1909 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicTransform) |
1910 { | 1910 { |
1911 // Test that the calculateVisibleRect() function works correctly for 3d tran sforms. | 1911 // Test that the calculateVisibleRect() function works correctly for 3d tran sforms. |
1912 | 1912 |
1913 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100 )); | 1913 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100 )); |
1914 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100) ); | 1914 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100) ); |
1915 WebTransformationMatrix layerToSurfaceTransform; | 1915 Transform layerToSurfaceTransform; |
1916 | 1916 |
1917 // Case 1: Orthographic projection of a layer rotated about y-axis by 45 deg rees, should be fully contained in the renderSurface. | 1917 // Case 1: Orthographic projection of a layer rotated about y-axis by 45 deg rees, should be fully contained in the renderSurface. |
1918 layerToSurfaceTransform.makeIdentity(); | 1918 layerToSurfaceTransform.matrix().setIdentity(); |
1919 layerToSurfaceTransform.rotate3d(0, 45, 0); | 1919 MathUtil::rotateEulerAngles(&layerToSurfaceTransform, 0, 45, 0); |
1920 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100)); | 1920 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100)); |
1921 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform); | 1921 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform); |
1922 EXPECT_RECT_EQ(expected, actual); | 1922 EXPECT_RECT_EQ(expected, actual); |
1923 | 1923 |
1924 // Case 2: Orthographic projection of a layer rotated about y-axis by 45 deg rees, but | 1924 // Case 2: Orthographic projection of a layer rotated about y-axis by 45 deg rees, but |
1925 // shifted to the side so only the right-half the layer would be vis ible on | 1925 // shifted to the side so only the right-half the layer would be vis ible on |
1926 // the surface. | 1926 // the surface. |
1927 double halfWidthOfRotatedLayer = (100 / sqrt(2.0)) * 0.5; // 100 is the un-r otated layer width; divided by sqrt(2) is the rotated width. | 1927 double halfWidthOfRotatedLayer = (100 / sqrt(2.0)) * 0.5; // 100 is the un-r otated layer width; divided by sqrt(2) is the rotated width. |
1928 layerToSurfaceTransform.makeIdentity(); | 1928 layerToSurfaceTransform.matrix().setIdentity(); |
1929 layerToSurfaceTransform.translate(-halfWidthOfRotatedLayer, 0); | 1929 layerToSurfaceTransform.PreconcatTranslate(-halfWidthOfRotatedLayer, 0); |
1930 layerToSurfaceTransform.rotate3d(0, 45, 0); // rotates about the left edge o f the layer | 1930 MathUtil::rotateEulerAngles(&layerToSurfaceTransform, 0, 45, 0); // rotates about the left edge of the layer |
1931 expected = gfx::Rect(gfx::Point(50, 0), gfx::Size(50, 100)); // right half o f the layer. | 1931 expected = gfx::Rect(gfx::Point(50, 0), gfx::Size(50, 100)); // right half o f the layer. |
1932 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC ontentRect, layerToSurfaceTransform); | 1932 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC ontentRect, layerToSurfaceTransform); |
1933 EXPECT_RECT_EQ(expected, actual); | 1933 EXPECT_RECT_EQ(expected, actual); |
1934 } | 1934 } |
1935 | 1935 |
1936 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveTransform) | 1936 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveTransform) |
1937 { | 1937 { |
1938 // Test the calculateVisibleRect() function works correctly when the layer h as a | 1938 // Test the calculateVisibleRect() function works correctly when the layer h as a |
1939 // perspective projection onto the target surface. | 1939 // perspective projection onto the target surface. |
1940 | 1940 |
1941 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100 )); | 1941 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100 )); |
1942 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(-50, -50), gfx::Size(200, 200)); | 1942 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(-50, -50), gfx::Size(200, 200)); |
1943 WebTransformationMatrix layerToSurfaceTransform; | 1943 Transform layerToSurfaceTransform; |
1944 | 1944 |
1945 // Case 1: Even though the layer is twice as large as the surface, due to pe rspective | 1945 // Case 1: Even though the layer is twice as large as the surface, due to pe rspective |
1946 // foreshortening, the layer will fit fully in the surface when its translated | 1946 // foreshortening, the layer will fit fully in the surface when its translated |
1947 // more than the perspective amount. | 1947 // more than the perspective amount. |
1948 layerToSurfaceTransform.makeIdentity(); | 1948 layerToSurfaceTransform.matrix().setIdentity(); |
1949 | 1949 |
1950 // The following sequence of transforms applies the perspective about the ce nter of the surface. | 1950 // The following sequence of transforms applies the perspective about the ce nter of the surface. |
1951 layerToSurfaceTransform.translate(50, 50); | 1951 layerToSurfaceTransform.PreconcatTranslate(50, 50); |
1952 layerToSurfaceTransform.applyPerspective(9); | 1952 layerToSurfaceTransform.PreconcatPerspectiveDepth(9); |
1953 layerToSurfaceTransform.translate(-50, -50); | 1953 layerToSurfaceTransform.PreconcatTranslate(-50, -50); |
1954 | 1954 |
1955 // This translate places the layer in front of the surface's projection plan e. | 1955 // This translate places the layer in front of the surface's projection plan e. |
1956 layerToSurfaceTransform.translate3d(0, 0, -27); | 1956 layerToSurfaceTransform.PreconcatTranslate3d(0, 0, -27); |
1957 | 1957 |
1958 gfx::Rect expected = gfx::Rect(gfx::Point(-50, -50), gfx::Size(200, 200)); | 1958 gfx::Rect expected = gfx::Rect(gfx::Point(-50, -50), gfx::Size(200, 200)); |
1959 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform); | 1959 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform); |
1960 EXPECT_RECT_EQ(expected, actual); | 1960 EXPECT_RECT_EQ(expected, actual); |
1961 | 1961 |
1962 // Case 2: same projection as before, except that the layer is also translat ed to the | 1962 // Case 2: same projection as before, except that the layer is also translat ed to the |
1963 // side, so that only the right half of the layer should be visible. | 1963 // side, so that only the right half of the layer should be visible. |
1964 // | 1964 // |
1965 // Explanation of expected result: | 1965 // Explanation of expected result: |
1966 // The perspective ratio is (z distance between layer and camera origin) / ( z distance between projection plane and camera origin) == ((-27 - 9) / 9) | 1966 // The perspective ratio is (z distance between layer and camera origin) / ( z distance between projection plane and camera origin) == ((-27 - 9) / 9) |
1967 // Then, by similar triangles, if we want to move a layer by translating -50 units in projected surface units (so that only half of it is | 1967 // Then, by similar triangles, if we want to move a layer by translating -50 units in projected surface units (so that only half of it is |
1968 // visible), then we would need to translate by (-36 / 9) * -50 == -200 in t he layer's units. | 1968 // visible), then we would need to translate by (-36 / 9) * -50 == -200 in t he layer's units. |
1969 // | 1969 // |
1970 layerToSurfaceTransform.translate3d(-200, 0, 0); | 1970 layerToSurfaceTransform.PreconcatTranslate3d(-200, 0, 0); |
1971 expected = gfx::Rect(gfx::Point(50, -50), gfx::Size(100, 200)); // The right half of the layer's bounding rect. | 1971 expected = gfx::Rect(gfx::Point(50, -50), gfx::Size(100, 200)); // The right half of the layer's bounding rect. |
1972 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC ontentRect, layerToSurfaceTransform); | 1972 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC ontentRect, layerToSurfaceTransform); |
1973 EXPECT_RECT_EQ(expected, actual); | 1973 EXPECT_RECT_EQ(expected, actual); |
1974 } | 1974 } |
1975 | 1975 |
1976 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicIsNotClippedBehi ndSurface) | 1976 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicIsNotClippedBehi ndSurface) |
1977 { | 1977 { |
1978 // There is currently no explicit concept of an orthographic projection plan e in our | 1978 // There is currently no explicit concept of an orthographic projection plan e in our |
1979 // code (nor in the CSS spec to my knowledge). Therefore, layers that are te chnically | 1979 // code (nor in the CSS spec to my knowledge). Therefore, layers that are te chnically |
1980 // behind the surface in an orthographic world should not be clipped when th ey are | 1980 // behind the surface in an orthographic world should not be clipped when th ey are |
1981 // flattened to the surface. | 1981 // flattened to the surface. |
1982 | 1982 |
1983 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100 )); | 1983 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100 )); |
1984 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100) ); | 1984 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100) ); |
1985 WebTransformationMatrix layerToSurfaceTransform; | 1985 Transform layerToSurfaceTransform; |
1986 | 1986 |
1987 // This sequence of transforms effectively rotates the layer about the y-axi s at the | 1987 // This sequence of transforms effectively rotates the layer about the y-axi s at the |
1988 // center of the layer. | 1988 // center of the layer. |
1989 layerToSurfaceTransform.makeIdentity(); | 1989 layerToSurfaceTransform.matrix().setIdentity(); |
1990 layerToSurfaceTransform.translate(50, 0); | 1990 layerToSurfaceTransform.PreconcatTranslate(50, 0); |
1991 layerToSurfaceTransform.rotate3d(0, 45, 0); | 1991 MathUtil::rotateEulerAngles(&layerToSurfaceTransform, 0, 45, 0); |
1992 layerToSurfaceTransform.translate(-50, 0); | 1992 layerToSurfaceTransform.PreconcatTranslate(-50, 0); |
1993 | 1993 |
1994 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100)); | 1994 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100)); |
1995 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform); | 1995 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform); |
1996 EXPECT_RECT_EQ(expected, actual); | 1996 EXPECT_RECT_EQ(expected, actual); |
1997 } | 1997 } |
1998 | 1998 |
1999 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveWhenClippedByW) | 1999 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveWhenClippedByW) |
2000 { | 2000 { |
2001 // Test the calculateVisibleRect() function works correctly when projecting a surface | 2001 // Test the calculateVisibleRect() function works correctly when projecting a surface |
2002 // onto a layer, but the layer is partially behind the camera (not just behi nd the | 2002 // onto a layer, but the layer is partially behind the camera (not just behi nd the |
2003 // projection plane). In this case, the cartesian coordinates may seem to be valid, | 2003 // projection plane). In this case, the cartesian coordinates may seem to be valid, |
2004 // but actually they are not. The visibleRect needs to be properly clipped b y the | 2004 // but actually they are not. The visibleRect needs to be properly clipped b y the |
2005 // w = 0 plane in homogeneous coordinates before converting to cartesian coo rdinates. | 2005 // w = 0 plane in homogeneous coordinates before converting to cartesian coo rdinates. |
2006 | 2006 |
2007 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(-50, -50), gfx::Size(100, 100)); | 2007 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(-50, -50), gfx::Size(100, 100)); |
2008 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(-10, -1), gfx::Size(20, 2) ); | 2008 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(-10, -1), gfx::Size(20, 2) ); |
2009 WebTransformationMatrix layerToSurfaceTransform; | 2009 Transform layerToSurfaceTransform; |
2010 | 2010 |
2011 // The layer is positioned so that the right half of the layer should be in front of | 2011 // The layer is positioned so that the right half of the layer should be in front of |
2012 // the camera, while the other half is behind the surface's projection plane . The | 2012 // the camera, while the other half is behind the surface's projection plane . The |
2013 // following sequence of transforms applies the perspective and rotation abo ut the | 2013 // following sequence of transforms applies the perspective and rotation abo ut the |
2014 // center of the layer. | 2014 // center of the layer. |
2015 layerToSurfaceTransform.makeIdentity(); | 2015 layerToSurfaceTransform.matrix().setIdentity(); |
2016 layerToSurfaceTransform.applyPerspective(1); | 2016 layerToSurfaceTransform.PreconcatPerspectiveDepth(1); |
2017 layerToSurfaceTransform.translate3d(-2, 0, 1); | 2017 layerToSurfaceTransform.PreconcatTranslate3d(-2, 0, 1); |
2018 layerToSurfaceTransform.rotate3d(0, 45, 0); | 2018 MathUtil::rotateEulerAngles(&layerToSurfaceTransform, 0, 45, 0); |
2019 | 2019 |
2020 // Sanity check that this transform does indeed cause w < 0 when applying th e | 2020 // Sanity check that this transform does indeed cause w < 0 when applying th e |
2021 // transform, otherwise this code is not testing the intended scenario. | 2021 // transform, otherwise this code is not testing the intended scenario. |
2022 bool clipped = false; | 2022 bool clipped = false; |
2023 MathUtil::mapQuad(layerToSurfaceTransform, gfx::QuadF(gfx::RectF(layerConten tRect)), clipped); | 2023 MathUtil::mapQuad(layerToSurfaceTransform, gfx::QuadF(gfx::RectF(layerConten tRect)), clipped); |
2024 ASSERT_TRUE(clipped); | 2024 ASSERT_TRUE(clipped); |
2025 | 2025 |
2026 int expectedXPosition = 0; | 2026 int expectedXPosition = 0; |
2027 int expectedWidth = 10; | 2027 int expectedWidth = 10; |
2028 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform); | 2028 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform); |
2029 EXPECT_EQ(expectedXPosition, actual.x()); | 2029 EXPECT_EQ(expectedXPosition, actual.x()); |
2030 EXPECT_EQ(expectedWidth, actual.width()); | 2030 EXPECT_EQ(expectedWidth, actual.width()); |
2031 } | 2031 } |
2032 | 2032 |
2033 TEST(LayerTreeHostCommonTest, verifyVisibleRectForPerspectiveUnprojection) | 2033 TEST(LayerTreeHostCommonTest, verifyVisibleRectForPerspectiveUnprojection) |
2034 { | 2034 { |
2035 // To determine visibleRect in layer space, there needs to be an un-projecti on from | 2035 // To determine visibleRect in layer space, there needs to be an un-projecti on from |
2036 // surface space to layer space. When the original transform was a perspecti ve | 2036 // surface space to layer space. When the original transform was a perspecti ve |
2037 // projection that was clipped, it returns a rect that encloses the clipped bounds. | 2037 // projection that was clipped, it returns a rect that encloses the clipped bounds. |
2038 // Un-projecting this new rect may require clipping again. | 2038 // Un-projecting this new rect may require clipping again. |
2039 | 2039 |
2040 // This sequence of transforms causes one corner of the layer to protrude ac ross the w = 0 plane, and should be clipped. | 2040 // This sequence of transforms causes one corner of the layer to protrude ac ross the w = 0 plane, and should be clipped. |
2041 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(-50, -50), gfx::Size(100, 100)); | 2041 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(-50, -50), gfx::Size(100, 100)); |
2042 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(-10, -10), gfx::Size(20, 2 0)); | 2042 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(-10, -10), gfx::Size(20, 2 0)); |
2043 WebTransformationMatrix layerToSurfaceTransform; | 2043 Transform layerToSurfaceTransform; |
2044 layerToSurfaceTransform.makeIdentity(); | 2044 layerToSurfaceTransform.matrix().setIdentity(); |
2045 layerToSurfaceTransform.applyPerspective(1); | 2045 layerToSurfaceTransform.PreconcatPerspectiveDepth(1); |
2046 layerToSurfaceTransform.translate3d(0, 0, -5); | 2046 layerToSurfaceTransform.PreconcatTranslate3d(0, 0, -5); |
2047 layerToSurfaceTransform.rotate3d(0, 45, 0); | 2047 MathUtil::rotateEulerAngles(&layerToSurfaceTransform, 0, 45, 0); |
2048 layerToSurfaceTransform.rotate3d(80, 0, 0); | 2048 MathUtil::rotateEulerAngles(&layerToSurfaceTransform, 80, 0, 0); |
2049 | 2049 |
2050 // Sanity check that un-projection does indeed cause w < 0, otherwise this c ode is not | 2050 // Sanity check that un-projection does indeed cause w < 0, otherwise this c ode is not |
2051 // testing the intended scenario. | 2051 // testing the intended scenario. |
2052 bool clipped = false; | 2052 bool clipped = false; |
2053 gfx::RectF clippedRect = MathUtil::mapClippedRect(layerToSurfaceTransform, l ayerContentRect); | 2053 gfx::RectF clippedRect = MathUtil::mapClippedRect(layerToSurfaceTransform, l ayerContentRect); |
2054 MathUtil::projectQuad(layerToSurfaceTransform.inverse(), gfx::QuadF(clippedR ect), clipped); | 2054 MathUtil::projectQuad(MathUtil::inverse(layerToSurfaceTransform), gfx::QuadF (clippedRect), clipped); |
2055 ASSERT_TRUE(clipped); | 2055 ASSERT_TRUE(clipped); |
2056 | 2056 |
2057 // Only the corner of the layer is not visible on the surface because of bei ng | 2057 // Only the corner of the layer is not visible on the surface because of bei ng |
2058 // clipped. But, the net result of rounding visible region to an axis-aligne d rect is | 2058 // clipped. But, the net result of rounding visible region to an axis-aligne d rect is |
2059 // that the entire layer should still be considered visible. | 2059 // that the entire layer should still be considered visible. |
2060 gfx::Rect expected = gfx::Rect(gfx::Point(-10, -10), gfx::Size(20, 20)); | 2060 gfx::Rect expected = gfx::Rect(gfx::Point(-10, -10), gfx::Size(20, 20)); |
2061 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform); | 2061 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe ct, layerContentRect, layerToSurfaceTransform); |
2062 EXPECT_RECT_EQ(expected, actual); | 2062 EXPECT_RECT_EQ(expected, actual); |
2063 } | 2063 } |
2064 | 2064 |
2065 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForSimpleLayer s) | 2065 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForSimpleLayer s) |
2066 { | 2066 { |
2067 scoped_refptr<Layer> root = Layer::create(); | 2067 scoped_refptr<Layer> root = Layer::create(); |
2068 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); | 2068 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); |
2069 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); | 2069 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); |
2070 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); | 2070 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); |
2071 root->addChild(child1); | 2071 root->addChild(child1); |
2072 root->addChild(child2); | 2072 root->addChild(child2); |
2073 root->addChild(child3); | 2073 root->addChild(child3); |
2074 | 2074 |
2075 WebTransformationMatrix identityMatrix; | 2075 Transform identityMatrix; |
2076 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2076 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2077 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(50, 50), false); | 2077 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(50, 50), false); |
2078 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); | 2078 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); |
2079 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); | 2079 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); |
2080 | 2080 |
2081 executeCalculateDrawTransformsAndVisibility(root.get()); | 2081 executeCalculateDrawTransformsAndVisibility(root.get()); |
2082 | 2082 |
2083 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->renderSurface()->drawableCon tentRect()); | 2083 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->renderSurface()->drawableCon tentRect()); |
2084 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawableContentRect()); | 2084 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawableContentRect()); |
2085 | 2085 |
(...skipping 16 matching lines...) Expand all Loading... | |
2102 scoped_refptr<Layer> root = Layer::create(); | 2102 scoped_refptr<Layer> root = Layer::create(); |
2103 scoped_refptr<Layer> child = Layer::create(); | 2103 scoped_refptr<Layer> child = Layer::create(); |
2104 scoped_refptr<LayerWithForcedDrawsContent> grandChild1 = make_scoped_refptr( new LayerWithForcedDrawsContent()); | 2104 scoped_refptr<LayerWithForcedDrawsContent> grandChild1 = make_scoped_refptr( new LayerWithForcedDrawsContent()); |
2105 scoped_refptr<LayerWithForcedDrawsContent> grandChild2 = make_scoped_refptr( new LayerWithForcedDrawsContent()); | 2105 scoped_refptr<LayerWithForcedDrawsContent> grandChild2 = make_scoped_refptr( new LayerWithForcedDrawsContent()); |
2106 scoped_refptr<LayerWithForcedDrawsContent> grandChild3 = make_scoped_refptr( new LayerWithForcedDrawsContent()); | 2106 scoped_refptr<LayerWithForcedDrawsContent> grandChild3 = make_scoped_refptr( new LayerWithForcedDrawsContent()); |
2107 root->addChild(child); | 2107 root->addChild(child); |
2108 child->addChild(grandChild1); | 2108 child->addChild(grandChild1); |
2109 child->addChild(grandChild2); | 2109 child->addChild(grandChild2); |
2110 child->addChild(grandChild3); | 2110 child->addChild(grandChild3); |
2111 | 2111 |
2112 WebTransformationMatrix identityMatrix; | 2112 Transform identityMatrix; |
2113 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2113 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2114 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2114 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2115 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identityMatr ix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); | 2115 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identityMatr ix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); |
2116 setLayerPropertiesForTesting(grandChild2.get(), identityMatrix, identityMatr ix, gfx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); | 2116 setLayerPropertiesForTesting(grandChild2.get(), identityMatrix, identityMatr ix, gfx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); |
2117 setLayerPropertiesForTesting(grandChild3.get(), identityMatrix, identityMatr ix, gfx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); | 2117 setLayerPropertiesForTesting(grandChild3.get(), identityMatrix, identityMatr ix, gfx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); |
2118 | 2118 |
2119 child->setMasksToBounds(true); | 2119 child->setMasksToBounds(true); |
2120 executeCalculateDrawTransformsAndVisibility(root.get()); | 2120 executeCalculateDrawTransformsAndVisibility(root.get()); |
2121 | 2121 |
2122 ASSERT_FALSE(child->renderSurface()); | 2122 ASSERT_FALSE(child->renderSurface()); |
(...skipping 21 matching lines...) Expand all Loading... | |
2144 scoped_refptr<Layer> root = Layer::create(); | 2144 scoped_refptr<Layer> root = Layer::create(); |
2145 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 2145 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
2146 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); | 2146 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); |
2147 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); | 2147 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); |
2148 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); | 2148 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); |
2149 root->addChild(renderSurface1); | 2149 root->addChild(renderSurface1); |
2150 renderSurface1->addChild(child1); | 2150 renderSurface1->addChild(child1); |
2151 renderSurface1->addChild(child2); | 2151 renderSurface1->addChild(child2); |
2152 renderSurface1->addChild(child3); | 2152 renderSurface1->addChild(child3); |
2153 | 2153 |
2154 WebTransformationMatrix identityMatrix; | 2154 Transform identityMatrix; |
2155 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2155 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2156 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); | 2156 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); |
2157 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); | 2157 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); |
2158 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); | 2158 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); |
2159 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); | 2159 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); |
2160 | 2160 |
2161 renderSurface1->setForceRenderSurface(true); | 2161 renderSurface1->setForceRenderSurface(true); |
2162 executeCalculateDrawTransformsAndVisibility(root.get()); | 2162 executeCalculateDrawTransformsAndVisibility(root.get()); |
2163 | 2163 |
2164 ASSERT_TRUE(renderSurface1->renderSurface()); | 2164 ASSERT_TRUE(renderSurface1->renderSurface()); |
(...skipping 23 matching lines...) Expand all Loading... | |
2188 scoped_refptr<Layer> root = Layer::create(); | 2188 scoped_refptr<Layer> root = Layer::create(); |
2189 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 2189 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
2190 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); | 2190 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); |
2191 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); | 2191 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); |
2192 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); | 2192 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); |
2193 root->addChild(renderSurface1); | 2193 root->addChild(renderSurface1); |
2194 renderSurface1->addChild(child1); | 2194 renderSurface1->addChild(child1); |
2195 renderSurface1->addChild(child2); | 2195 renderSurface1->addChild(child2); |
2196 renderSurface1->addChild(child3); | 2196 renderSurface1->addChild(child3); |
2197 | 2197 |
2198 WebTransformationMatrix identityMatrix; | 2198 Transform identityMatrix; |
2199 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2199 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2200 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); | 2200 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); |
2201 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); | 2201 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); |
2202 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); | 2202 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); |
2203 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); | 2203 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); |
2204 | 2204 |
2205 root->setMasksToBounds(true); | 2205 root->setMasksToBounds(true); |
2206 renderSurface1->setForceRenderSurface(true); | 2206 renderSurface1->setForceRenderSurface(true); |
2207 executeCalculateDrawTransformsAndVisibility(root.get()); | 2207 executeCalculateDrawTransformsAndVisibility(root.get()); |
2208 | 2208 |
(...skipping 29 matching lines...) Expand all Loading... | |
2238 scoped_refptr<Layer> renderSurface2 = Layer::create(); | 2238 scoped_refptr<Layer> renderSurface2 = Layer::create(); |
2239 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); | 2239 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); |
2240 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); | 2240 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); |
2241 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); | 2241 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); |
2242 root->addChild(renderSurface1); | 2242 root->addChild(renderSurface1); |
2243 renderSurface1->addChild(renderSurface2); | 2243 renderSurface1->addChild(renderSurface2); |
2244 renderSurface2->addChild(child1); | 2244 renderSurface2->addChild(child1); |
2245 renderSurface2->addChild(child2); | 2245 renderSurface2->addChild(child2); |
2246 renderSurface2->addChild(child3); | 2246 renderSurface2->addChild(child3); |
2247 | 2247 |
2248 WebTransformationMatrix identityMatrix; | 2248 Transform identityMatrix; |
2249 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2249 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2250 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); | 2250 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); |
2251 setLayerPropertiesForTesting(renderSurface2.get(), identityMatrix, identityM atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(7, 13), false); | 2251 setLayerPropertiesForTesting(renderSurface2.get(), identityMatrix, identityM atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(7, 13), false); |
2252 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); | 2252 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); |
2253 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); | 2253 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); |
2254 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); | 2254 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); |
2255 | 2255 |
2256 root->setMasksToBounds(true); | 2256 root->setMasksToBounds(true); |
2257 renderSurface1->setForceRenderSurface(true); | 2257 renderSurface1->setForceRenderSurface(true); |
2258 renderSurface2->setForceRenderSurface(true); | 2258 renderSurface2->setForceRenderSurface(true); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2293 { | 2293 { |
2294 // Layers that have non-axis aligned bounds (due to transforms) have an expa nded, | 2294 // Layers that have non-axis aligned bounds (due to transforms) have an expa nded, |
2295 // axis-aligned drawableContentRect and visibleContentRect. | 2295 // axis-aligned drawableContentRect and visibleContentRect. |
2296 | 2296 |
2297 scoped_refptr<Layer> root = Layer::create(); | 2297 scoped_refptr<Layer> root = Layer::create(); |
2298 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 2298 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
2299 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); | 2299 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); |
2300 root->addChild(renderSurface1); | 2300 root->addChild(renderSurface1); |
2301 renderSurface1->addChild(child1); | 2301 renderSurface1->addChild(child1); |
2302 | 2302 |
2303 WebTransformationMatrix identityMatrix; | 2303 Transform identityMatrix; |
2304 WebTransformationMatrix childRotation; | 2304 Transform childRotation; |
2305 childRotation.rotate(45); | 2305 childRotation.PreconcatRotate(45); |
2306 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2306 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2307 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); | 2307 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); |
2308 setLayerPropertiesForTesting(child1.get(), childRotation, identityMatrix, gf x::PointF(0.5, 0.5), gfx::PointF(25, 25), gfx::Size(50, 50), false); | 2308 setLayerPropertiesForTesting(child1.get(), childRotation, identityMatrix, gf x::PointF(0.5, 0.5), gfx::PointF(25, 25), gfx::Size(50, 50), false); |
2309 | 2309 |
2310 renderSurface1->setForceRenderSurface(true); | 2310 renderSurface1->setForceRenderSurface(true); |
2311 executeCalculateDrawTransformsAndVisibility(root.get()); | 2311 executeCalculateDrawTransformsAndVisibility(root.get()); |
2312 | 2312 |
2313 ASSERT_TRUE(renderSurface1->renderSurface()); | 2313 ASSERT_TRUE(renderSurface1->renderSurface()); |
2314 | 2314 |
2315 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->renderSurface()->drawableCon tentRect()); | 2315 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->renderSurface()->drawableCon tentRect()); |
(...skipping 17 matching lines...) Expand all Loading... | |
2333 { | 2333 { |
2334 // Layers that have non-axis aligned bounds (due to transforms) have an expa nded, | 2334 // Layers that have non-axis aligned bounds (due to transforms) have an expa nded, |
2335 // axis-aligned drawableContentRect and visibleContentRect. | 2335 // axis-aligned drawableContentRect and visibleContentRect. |
2336 | 2336 |
2337 scoped_refptr<Layer> root = Layer::create(); | 2337 scoped_refptr<Layer> root = Layer::create(); |
2338 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 2338 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
2339 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); | 2339 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); |
2340 root->addChild(renderSurface1); | 2340 root->addChild(renderSurface1); |
2341 renderSurface1->addChild(child1); | 2341 renderSurface1->addChild(child1); |
2342 | 2342 |
2343 WebTransformationMatrix identityMatrix; | 2343 Transform identityMatrix; |
2344 WebTransformationMatrix childRotation; | 2344 Transform childRotation; |
2345 childRotation.rotate(45); | 2345 childRotation.PreconcatRotate(45); |
2346 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(50, 50), false); | 2346 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(50, 50), false); |
2347 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); | 2347 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); |
2348 setLayerPropertiesForTesting(child1.get(), childRotation, identityMatrix, gf x::PointF(0.5, 0.5), gfx::PointF(25, 25), gfx::Size(50, 50), false); | 2348 setLayerPropertiesForTesting(child1.get(), childRotation, identityMatrix, gf x::PointF(0.5, 0.5), gfx::PointF(25, 25), gfx::Size(50, 50), false); |
2349 | 2349 |
2350 root->setMasksToBounds(true); | 2350 root->setMasksToBounds(true); |
2351 renderSurface1->setForceRenderSurface(true); | 2351 renderSurface1->setForceRenderSurface(true); |
2352 executeCalculateDrawTransformsAndVisibility(root.get()); | 2352 executeCalculateDrawTransformsAndVisibility(root.get()); |
2353 | 2353 |
2354 ASSERT_TRUE(renderSurface1->renderSurface()); | 2354 ASSERT_TRUE(renderSurface1->renderSurface()); |
2355 | 2355 |
(...skipping 21 matching lines...) Expand all Loading... | |
2377 scoped_refptr<ContentLayer> renderSurface2 = createDrawableContentLayer(&cli ent); | 2377 scoped_refptr<ContentLayer> renderSurface2 = createDrawableContentLayer(&cli ent); |
2378 scoped_refptr<ContentLayer> child1 = createDrawableContentLayer(&client); | 2378 scoped_refptr<ContentLayer> child1 = createDrawableContentLayer(&client); |
2379 scoped_refptr<ContentLayer> child2 = createDrawableContentLayer(&client); | 2379 scoped_refptr<ContentLayer> child2 = createDrawableContentLayer(&client); |
2380 scoped_refptr<ContentLayer> child3 = createDrawableContentLayer(&client); | 2380 scoped_refptr<ContentLayer> child3 = createDrawableContentLayer(&client); |
2381 root->addChild(renderSurface1); | 2381 root->addChild(renderSurface1); |
2382 renderSurface1->addChild(renderSurface2); | 2382 renderSurface1->addChild(renderSurface2); |
2383 renderSurface2->addChild(child1); | 2383 renderSurface2->addChild(child1); |
2384 renderSurface2->addChild(child2); | 2384 renderSurface2->addChild(child2); |
2385 renderSurface2->addChild(child3); | 2385 renderSurface2->addChild(child3); |
2386 | 2386 |
2387 WebTransformationMatrix identityMatrix; | 2387 Transform identityMatrix; |
2388 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2388 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2389 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(3, 4), false); | 2389 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM atrix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(3, 4), false); |
2390 setLayerPropertiesForTesting(renderSurface2.get(), identityMatrix, identityM atrix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(7, 13), false); | 2390 setLayerPropertiesForTesting(renderSurface2.get(), identityMatrix, identityM atrix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(7, 13), false); |
2391 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); | 2391 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); |
2392 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); | 2392 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); |
2393 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); | 2393 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); |
2394 | 2394 |
2395 const double deviceScaleFactor = 2; | 2395 const double deviceScaleFactor = 2; |
2396 root->setContentsScale(deviceScaleFactor); | 2396 root->setContentsScale(deviceScaleFactor); |
2397 renderSurface1->setContentsScale(deviceScaleFactor); | 2397 renderSurface1->setContentsScale(deviceScaleFactor); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2432 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), child2->visibleContentRect()); | 2432 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), child2->visibleContentRect()); |
2433 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), child3->visibleContentRect()); | 2433 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), child3->visibleContentRect()); |
2434 } | 2434 } |
2435 | 2435 |
2436 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithoutPreserves3d) | 2436 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithoutPreserves3d) |
2437 { | 2437 { |
2438 // Verify the behavior of back-face culling when there are no preserve-3d la yers. Note | 2438 // Verify the behavior of back-face culling when there are no preserve-3d la yers. Note |
2439 // that 3d transforms still apply in this case, but they are "flattened" to each | 2439 // that 3d transforms still apply in this case, but they are "flattened" to each |
2440 // parent layer according to current W3C spec. | 2440 // parent layer according to current W3C spec. |
2441 | 2441 |
2442 const WebTransformationMatrix identityMatrix; | 2442 const Transform identityMatrix; |
2443 scoped_refptr<Layer> parent = Layer::create(); | 2443 scoped_refptr<Layer> parent = Layer::create(); |
2444 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChild = make_scoped_re fptr(new LayerWithForcedDrawsContent()); | 2444 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChild = make_scoped_re fptr(new LayerWithForcedDrawsContent()); |
2445 scoped_refptr<LayerWithForcedDrawsContent> backFacingChild = make_scoped_ref ptr(new LayerWithForcedDrawsContent()); | 2445 scoped_refptr<LayerWithForcedDrawsContent> backFacingChild = make_scoped_ref ptr(new LayerWithForcedDrawsContent()); |
2446 scoped_refptr<LayerWithForcedDrawsContent> frontFacingSurface = make_scoped_ refptr(new LayerWithForcedDrawsContent()); | 2446 scoped_refptr<LayerWithForcedDrawsContent> frontFacingSurface = make_scoped_ refptr(new LayerWithForcedDrawsContent()); |
2447 scoped_refptr<LayerWithForcedDrawsContent> backFacingSurface = make_scoped_r efptr(new LayerWithForcedDrawsContent()); | 2447 scoped_refptr<LayerWithForcedDrawsContent> backFacingSurface = make_scoped_r efptr(new LayerWithForcedDrawsContent()); |
2448 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfFrontFacingSurf ace = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2448 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfFrontFacingSurf ace = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
2449 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfFrontFacingSurfa ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2449 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfFrontFacingSurfa ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
2450 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfBackFacingSurfa ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2450 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfBackFacingSurfa ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
2451 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfBackFacingSurfac e = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2451 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfBackFacingSurfac e = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
2452 | 2452 |
2453 parent->addChild(frontFacingChild); | 2453 parent->addChild(frontFacingChild); |
2454 parent->addChild(backFacingChild); | 2454 parent->addChild(backFacingChild); |
2455 parent->addChild(frontFacingSurface); | 2455 parent->addChild(frontFacingSurface); |
2456 parent->addChild(backFacingSurface); | 2456 parent->addChild(backFacingSurface); |
2457 frontFacingSurface->addChild(frontFacingChildOfFrontFacingSurface); | 2457 frontFacingSurface->addChild(frontFacingChildOfFrontFacingSurface); |
2458 frontFacingSurface->addChild(backFacingChildOfFrontFacingSurface); | 2458 frontFacingSurface->addChild(backFacingChildOfFrontFacingSurface); |
2459 backFacingSurface->addChild(frontFacingChildOfBackFacingSurface); | 2459 backFacingSurface->addChild(frontFacingChildOfBackFacingSurface); |
2460 backFacingSurface->addChild(backFacingChildOfBackFacingSurface); | 2460 backFacingSurface->addChild(backFacingChildOfBackFacingSurface); |
2461 | 2461 |
2462 // Nothing is double-sided | 2462 // Nothing is double-sided |
2463 frontFacingChild->setDoubleSided(false); | 2463 frontFacingChild->setDoubleSided(false); |
2464 backFacingChild->setDoubleSided(false); | 2464 backFacingChild->setDoubleSided(false); |
2465 frontFacingSurface->setDoubleSided(false); | 2465 frontFacingSurface->setDoubleSided(false); |
2466 backFacingSurface->setDoubleSided(false); | 2466 backFacingSurface->setDoubleSided(false); |
2467 frontFacingChildOfFrontFacingSurface->setDoubleSided(false); | 2467 frontFacingChildOfFrontFacingSurface->setDoubleSided(false); |
2468 backFacingChildOfFrontFacingSurface->setDoubleSided(false); | 2468 backFacingChildOfFrontFacingSurface->setDoubleSided(false); |
2469 frontFacingChildOfBackFacingSurface->setDoubleSided(false); | 2469 frontFacingChildOfBackFacingSurface->setDoubleSided(false); |
2470 backFacingChildOfBackFacingSurface->setDoubleSided(false); | 2470 backFacingChildOfBackFacingSurface->setDoubleSided(false); |
2471 | 2471 |
2472 WebTransformationMatrix backfaceMatrix; | 2472 Transform backfaceMatrix; |
2473 backfaceMatrix.translate(50, 50); | 2473 backfaceMatrix.PreconcatTranslate(50, 50); |
2474 backfaceMatrix.rotate3d(0, 1, 0, 180); | 2474 MathUtil::rotateAxisAngle(&backfaceMatrix, 0, 1, 0, 180); |
2475 backfaceMatrix.translate(-50, -50); | 2475 backfaceMatrix.PreconcatTranslate(-50, -50); |
2476 | 2476 |
2477 // Having a descendant and opacity will force these to have render surfaces. | 2477 // Having a descendant and opacity will force these to have render surfaces. |
2478 frontFacingSurface->setOpacity(0.5); | 2478 frontFacingSurface->setOpacity(0.5); |
2479 backFacingSurface->setOpacity(0.5); | 2479 backFacingSurface->setOpacity(0.5); |
2480 | 2480 |
2481 // Nothing preserves 3d. According to current W3C CSS Transforms spec, these layers | 2481 // Nothing preserves 3d. According to current W3C CSS Transforms spec, these layers |
2482 // should blindly use their own local transforms to determine back-face cull ing. | 2482 // should blindly use their own local transforms to determine back-face cull ing. |
2483 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2483 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2484 setLayerPropertiesForTesting(frontFacingChild.get(), identityMatrix, identit yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2484 setLayerPropertiesForTesting(frontFacingChild.get(), identityMatrix, identit yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2485 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2485 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2524 | 2524 |
2525 // Verify backFacingSurface's layerList; its own layer should be culled from the surface list. | 2525 // Verify backFacingSurface's layerList; its own layer should be culled from the surface list. |
2526 ASSERT_EQ(1u, renderSurfaceLayerList[2]->renderSurface()->layerList().size() ); | 2526 ASSERT_EQ(1u, renderSurfaceLayerList[2]->renderSurface()->layerList().size() ); |
2527 EXPECT_EQ(frontFacingChildOfBackFacingSurface->id(), renderSurfaceLayerList[ 2]->renderSurface()->layerList()[0]->id()); | 2527 EXPECT_EQ(frontFacingChildOfBackFacingSurface->id(), renderSurfaceLayerList[ 2]->renderSurface()->layerList()[0]->id()); |
2528 } | 2528 } |
2529 | 2529 |
2530 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3d) | 2530 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3d) |
2531 { | 2531 { |
2532 // Verify the behavior of back-face culling when preserves-3d transform styl e is used. | 2532 // Verify the behavior of back-face culling when preserves-3d transform styl e is used. |
2533 | 2533 |
2534 const WebTransformationMatrix identityMatrix; | 2534 const Transform identityMatrix; |
2535 scoped_refptr<Layer> parent = Layer::create(); | 2535 scoped_refptr<Layer> parent = Layer::create(); |
2536 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChild = make_scoped_re fptr(new LayerWithForcedDrawsContent()); | 2536 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChild = make_scoped_re fptr(new LayerWithForcedDrawsContent()); |
2537 scoped_refptr<LayerWithForcedDrawsContent> backFacingChild = make_scoped_ref ptr(new LayerWithForcedDrawsContent()); | 2537 scoped_refptr<LayerWithForcedDrawsContent> backFacingChild = make_scoped_ref ptr(new LayerWithForcedDrawsContent()); |
2538 scoped_refptr<LayerWithForcedDrawsContent> frontFacingSurface = make_scoped_ refptr(new LayerWithForcedDrawsContent()); | 2538 scoped_refptr<LayerWithForcedDrawsContent> frontFacingSurface = make_scoped_ refptr(new LayerWithForcedDrawsContent()); |
2539 scoped_refptr<LayerWithForcedDrawsContent> backFacingSurface = make_scoped_r efptr(new LayerWithForcedDrawsContent()); | 2539 scoped_refptr<LayerWithForcedDrawsContent> backFacingSurface = make_scoped_r efptr(new LayerWithForcedDrawsContent()); |
2540 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfFrontFacingSurf ace = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2540 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfFrontFacingSurf ace = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
2541 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfFrontFacingSurfa ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2541 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfFrontFacingSurfa ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
2542 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfBackFacingSurfa ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2542 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfBackFacingSurfa ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
2543 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfBackFacingSurfac e = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2543 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfBackFacingSurfac e = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
2544 scoped_refptr<LayerWithForcedDrawsContent> dummyReplicaLayer1 = make_scoped_ refptr(new LayerWithForcedDrawsContent()); | 2544 scoped_refptr<LayerWithForcedDrawsContent> dummyReplicaLayer1 = make_scoped_ refptr(new LayerWithForcedDrawsContent()); |
(...skipping 11 matching lines...) Expand all Loading... | |
2556 // Nothing is double-sided | 2556 // Nothing is double-sided |
2557 frontFacingChild->setDoubleSided(false); | 2557 frontFacingChild->setDoubleSided(false); |
2558 backFacingChild->setDoubleSided(false); | 2558 backFacingChild->setDoubleSided(false); |
2559 frontFacingSurface->setDoubleSided(false); | 2559 frontFacingSurface->setDoubleSided(false); |
2560 backFacingSurface->setDoubleSided(false); | 2560 backFacingSurface->setDoubleSided(false); |
2561 frontFacingChildOfFrontFacingSurface->setDoubleSided(false); | 2561 frontFacingChildOfFrontFacingSurface->setDoubleSided(false); |
2562 backFacingChildOfFrontFacingSurface->setDoubleSided(false); | 2562 backFacingChildOfFrontFacingSurface->setDoubleSided(false); |
2563 frontFacingChildOfBackFacingSurface->setDoubleSided(false); | 2563 frontFacingChildOfBackFacingSurface->setDoubleSided(false); |
2564 backFacingChildOfBackFacingSurface->setDoubleSided(false); | 2564 backFacingChildOfBackFacingSurface->setDoubleSided(false); |
2565 | 2565 |
2566 WebTransformationMatrix backfaceMatrix; | 2566 Transform backfaceMatrix; |
2567 backfaceMatrix.translate(50, 50); | 2567 backfaceMatrix.PreconcatTranslate(50, 50); |
2568 backfaceMatrix.rotate3d(0, 1, 0, 180); | 2568 MathUtil::rotateAxisAngle(&backfaceMatrix, 0, 1, 0, 180); |
2569 backfaceMatrix.translate(-50, -50); | 2569 backfaceMatrix.PreconcatTranslate(-50, -50); |
2570 | 2570 |
2571 // Opacity will not force creation of renderSurfaces in this case because of the | 2571 // Opacity will not force creation of renderSurfaces in this case because of the |
2572 // preserve-3d transform style. Instead, an example of when a surface would be | 2572 // preserve-3d transform style. Instead, an example of when a surface would be |
2573 // created with preserve-3d is when there is a replica layer. | 2573 // created with preserve-3d is when there is a replica layer. |
2574 frontFacingSurface->setReplicaLayer(dummyReplicaLayer1.get()); | 2574 frontFacingSurface->setReplicaLayer(dummyReplicaLayer1.get()); |
2575 backFacingSurface->setReplicaLayer(dummyReplicaLayer2.get()); | 2575 backFacingSurface->setReplicaLayer(dummyReplicaLayer2.get()); |
2576 | 2576 |
2577 // Each surface creates its own new 3d rendering context (as defined by W3C spec). | 2577 // Each surface creates its own new 3d rendering context (as defined by W3C spec). |
2578 // According to current W3C CSS Transforms spec, layers in a 3d rendering co ntext | 2578 // According to current W3C CSS Transforms spec, layers in a 3d rendering co ntext |
2579 // should use the transform with respect to that context. This 3d rendering context | 2579 // should use the transform with respect to that context. This 3d rendering context |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2621 | 2621 |
2622 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithAnimatingTransforms) | 2622 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithAnimatingTransforms) |
2623 { | 2623 { |
2624 // Verify that layers are appropriately culled when their back face is showi ng and | 2624 // Verify that layers are appropriately culled when their back face is showi ng and |
2625 // they are not double sided, while animations are going on. | 2625 // they are not double sided, while animations are going on. |
2626 // | 2626 // |
2627 // Layers that are animating do not get culled on the main thread, as their transforms should be | 2627 // Layers that are animating do not get culled on the main thread, as their transforms should be |
2628 // treated as "unknown" so we can not be sure that their back face is really showing. | 2628 // treated as "unknown" so we can not be sure that their back face is really showing. |
2629 // | 2629 // |
2630 | 2630 |
2631 const WebTransformationMatrix identityMatrix; | 2631 const Transform identityMatrix; |
2632 scoped_refptr<Layer> parent = Layer::create(); | 2632 scoped_refptr<Layer> parent = Layer::create(); |
2633 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La yerWithForcedDrawsContent()); | 2633 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La yerWithForcedDrawsContent()); |
2634 scoped_refptr<LayerWithForcedDrawsContent> animatingSurface = make_scoped_re fptr(new LayerWithForcedDrawsContent()); | 2634 scoped_refptr<LayerWithForcedDrawsContent> animatingSurface = make_scoped_re fptr(new LayerWithForcedDrawsContent()); |
2635 scoped_refptr<LayerWithForcedDrawsContent> childOfAnimatingSurface = make_sc oped_refptr(new LayerWithForcedDrawsContent()); | 2635 scoped_refptr<LayerWithForcedDrawsContent> childOfAnimatingSurface = make_sc oped_refptr(new LayerWithForcedDrawsContent()); |
2636 scoped_refptr<LayerWithForcedDrawsContent> animatingChild = make_scoped_refp tr(new LayerWithForcedDrawsContent()); | 2636 scoped_refptr<LayerWithForcedDrawsContent> animatingChild = make_scoped_refp tr(new LayerWithForcedDrawsContent()); |
2637 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); | 2637 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); |
2638 | 2638 |
2639 parent->addChild(child); | 2639 parent->addChild(child); |
2640 parent->addChild(animatingSurface); | 2640 parent->addChild(animatingSurface); |
2641 animatingSurface->addChild(childOfAnimatingSurface); | 2641 animatingSurface->addChild(childOfAnimatingSurface); |
2642 parent->addChild(animatingChild); | 2642 parent->addChild(animatingChild); |
2643 parent->addChild(child2); | 2643 parent->addChild(child2); |
2644 | 2644 |
2645 // Nothing is double-sided | 2645 // Nothing is double-sided |
2646 child->setDoubleSided(false); | 2646 child->setDoubleSided(false); |
2647 child2->setDoubleSided(false); | 2647 child2->setDoubleSided(false); |
2648 animatingSurface->setDoubleSided(false); | 2648 animatingSurface->setDoubleSided(false); |
2649 childOfAnimatingSurface->setDoubleSided(false); | 2649 childOfAnimatingSurface->setDoubleSided(false); |
2650 animatingChild->setDoubleSided(false); | 2650 animatingChild->setDoubleSided(false); |
2651 | 2651 |
2652 WebTransformationMatrix backfaceMatrix; | 2652 Transform backfaceMatrix; |
2653 backfaceMatrix.translate(50, 50); | 2653 backfaceMatrix.PreconcatTranslate(50, 50); |
2654 backfaceMatrix.rotate3d(0, 1, 0, 180); | 2654 MathUtil::rotateAxisAngle(&backfaceMatrix, 0, 1, 0, 180); |
2655 backfaceMatrix.translate(-50, -50); | 2655 backfaceMatrix.PreconcatTranslate(-50, -50); |
2656 | 2656 |
2657 // Make our render surface. | 2657 // Make our render surface. |
2658 animatingSurface->setForceRenderSurface(true); | 2658 animatingSurface->setForceRenderSurface(true); |
2659 | 2659 |
2660 // Animate the transform on the render surface. | 2660 // Animate the transform on the render surface. |
2661 addAnimatedTransformToController(*animatingSurface->layerAnimationController (), 10, 30, 0); | 2661 addAnimatedTransformToController(*animatingSurface->layerAnimationController (), 10, 30, 0); |
2662 // This is just an animating layer, not a surface. | 2662 // This is just an animating layer, not a surface. |
2663 addAnimatedTransformToController(*animatingChild->layerAnimationController() , 10, 30, 0); | 2663 addAnimatedTransformToController(*animatingChild->layerAnimationController() , 10, 30, 0); |
2664 | 2664 |
2665 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2665 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2701 EXPECT_EQ(animatingSurface->visibleContentRect(), gfx::Rect(gfx::Point(), an imatingSurface->contentBounds())); | 2701 EXPECT_EQ(animatingSurface->visibleContentRect(), gfx::Rect(gfx::Point(), an imatingSurface->contentBounds())); |
2702 // And layers in the subtree of the animating layer should have valid visibl eContentRects also. | 2702 // And layers in the subtree of the animating layer should have valid visibl eContentRects also. |
2703 EXPECT_EQ(childOfAnimatingSurface->visibleContentRect(), gfx::Rect(gfx::Poin t(), childOfAnimatingSurface->contentBounds())); | 2703 EXPECT_EQ(childOfAnimatingSurface->visibleContentRect(), gfx::Rect(gfx::Poin t(), childOfAnimatingSurface->contentBounds())); |
2704 } | 2704 } |
2705 | 2705 |
2706 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3dForFlatteningS urface) | 2706 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3dForFlatteningS urface) |
2707 { | 2707 { |
2708 // Verify the behavior of back-face culling for a renderSurface that is crea ted | 2708 // Verify the behavior of back-face culling for a renderSurface that is crea ted |
2709 // when it flattens its subtree, and its parent has preserves-3d. | 2709 // when it flattens its subtree, and its parent has preserves-3d. |
2710 | 2710 |
2711 const WebTransformationMatrix identityMatrix; | 2711 const Transform identityMatrix; |
2712 scoped_refptr<Layer> parent = Layer::create(); | 2712 scoped_refptr<Layer> parent = Layer::create(); |
2713 scoped_refptr<LayerWithForcedDrawsContent> frontFacingSurface = make_scoped_ refptr(new LayerWithForcedDrawsContent()); | 2713 scoped_refptr<LayerWithForcedDrawsContent> frontFacingSurface = make_scoped_ refptr(new LayerWithForcedDrawsContent()); |
2714 scoped_refptr<LayerWithForcedDrawsContent> backFacingSurface = make_scoped_r efptr(new LayerWithForcedDrawsContent()); | 2714 scoped_refptr<LayerWithForcedDrawsContent> backFacingSurface = make_scoped_r efptr(new LayerWithForcedDrawsContent()); |
2715 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); | 2715 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); |
2716 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); | 2716 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L ayerWithForcedDrawsContent()); |
2717 | 2717 |
2718 parent->addChild(frontFacingSurface); | 2718 parent->addChild(frontFacingSurface); |
2719 parent->addChild(backFacingSurface); | 2719 parent->addChild(backFacingSurface); |
2720 frontFacingSurface->addChild(child1); | 2720 frontFacingSurface->addChild(child1); |
2721 backFacingSurface->addChild(child2); | 2721 backFacingSurface->addChild(child2); |
2722 | 2722 |
2723 // RenderSurfaces are not double-sided | 2723 // RenderSurfaces are not double-sided |
2724 frontFacingSurface->setDoubleSided(false); | 2724 frontFacingSurface->setDoubleSided(false); |
2725 backFacingSurface->setDoubleSided(false); | 2725 backFacingSurface->setDoubleSided(false); |
2726 | 2726 |
2727 WebTransformationMatrix backfaceMatrix; | 2727 Transform backfaceMatrix; |
2728 backfaceMatrix.translate(50, 50); | 2728 backfaceMatrix.PreconcatTranslate(50, 50); |
2729 backfaceMatrix.rotate3d(0, 1, 0, 180); | 2729 MathUtil::rotateAxisAngle(&backfaceMatrix, 0, 1, 0, 180); |
2730 backfaceMatrix.translate(-50, -50); | 2730 backfaceMatrix.PreconcatTranslate(-50, -50); |
2731 | 2731 |
2732 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); // parent trans form style is preserve3d. | 2732 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); // parent trans form style is preserve3d. |
2733 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); // surface transform style is flat. | 2733 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); // surface transform style is flat. |
2734 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, ident ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); // surface transform style is flat. | 2734 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, ident ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); // surface transform style is flat. |
2735 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2735 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2736 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2736 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2737 | 2737 |
2738 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 2738 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
2739 int dummyMaxTextureSize = 512; | 2739 int dummyMaxTextureSize = 512; |
2740 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 2740 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
(...skipping 30 matching lines...) Expand all Loading... | |
2771 | 2771 |
2772 testPoint = gfx::Point(10, 20); | 2772 testPoint = gfx::Point(10, 20); |
2773 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); | 2773 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); |
2774 EXPECT_FALSE(resultLayer); | 2774 EXPECT_FALSE(resultLayer); |
2775 } | 2775 } |
2776 | 2776 |
2777 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayer) | 2777 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayer) |
2778 { | 2778 { |
2779 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); | 2779 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); |
2780 | 2780 |
2781 WebTransformationMatrix identityMatrix; | 2781 Transform identityMatrix; |
2782 gfx::PointF anchor(0, 0); | 2782 gfx::PointF anchor(0, 0); |
2783 gfx::PointF position(0, 0); | 2783 gfx::PointF position(0, 0); |
2784 gfx::Size bounds(100, 100); | 2784 gfx::Size bounds(100, 100); |
2785 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); | 2785 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); |
2786 root->setDrawsContent(true); | 2786 root->setDrawsContent(true); |
2787 | 2787 |
2788 std::vector<LayerImpl*> renderSurfaceLayerList; | 2788 std::vector<LayerImpl*> renderSurfaceLayerList; |
2789 int dummyMaxTextureSize = 512; | 2789 int dummyMaxTextureSize = 512; |
2790 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2790 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
2791 | 2791 |
(...skipping 19 matching lines...) Expand all Loading... | |
2811 testPoint = gfx::Point(99, 99); | 2811 testPoint = gfx::Point(99, 99); |
2812 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); | 2812 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); |
2813 ASSERT_TRUE(resultLayer); | 2813 ASSERT_TRUE(resultLayer); |
2814 EXPECT_EQ(12345, resultLayer->id()); | 2814 EXPECT_EQ(12345, resultLayer->id()); |
2815 } | 2815 } |
2816 | 2816 |
2817 TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) | 2817 TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) |
2818 { | 2818 { |
2819 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); | 2819 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); |
2820 | 2820 |
2821 WebTransformationMatrix uninvertibleTransform; | 2821 Transform uninvertibleTransform; |
2822 uninvertibleTransform.setM11(0); | 2822 uninvertibleTransform.matrix().setDouble(0, 0, 0); |
2823 uninvertibleTransform.setM22(0); | 2823 uninvertibleTransform.matrix().setDouble(1, 1, 0); |
2824 uninvertibleTransform.setM33(0); | 2824 uninvertibleTransform.matrix().setDouble(2, 2, 0); |
2825 uninvertibleTransform.setM44(0); | 2825 uninvertibleTransform.matrix().setDouble(3, 3, 0); |
2826 ASSERT_FALSE(uninvertibleTransform.isInvertible()); | 2826 ASSERT_FALSE(uninvertibleTransform.IsInvertible()); |
2827 | 2827 |
2828 WebTransformationMatrix identityMatrix; | 2828 Transform identityMatrix; |
2829 gfx::PointF anchor(0, 0); | 2829 gfx::PointF anchor(0, 0); |
2830 gfx::PointF position(0, 0); | 2830 gfx::PointF position(0, 0); |
2831 gfx::Size bounds(100, 100); | 2831 gfx::Size bounds(100, 100); |
2832 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr ix, anchor, position, bounds, false); | 2832 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr ix, anchor, position, bounds, false); |
2833 root->setDrawsContent(true); | 2833 root->setDrawsContent(true); |
2834 | 2834 |
2835 std::vector<LayerImpl*> renderSurfaceLayerList; | 2835 std::vector<LayerImpl*> renderSurfaceLayerList; |
2836 int dummyMaxTextureSize = 512; | 2836 int dummyMaxTextureSize = 512; |
2837 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2837 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
2838 | 2838 |
2839 // Sanity check the scenario we just created. | 2839 // Sanity check the scenario we just created. |
2840 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2840 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2841 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2841 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2842 ASSERT_FALSE(root->screenSpaceTransform().isInvertible()); | 2842 ASSERT_FALSE(root->screenSpaceTransform().IsInvertible()); |
2843 | 2843 |
2844 // Hit testing any point should not hit the layer. If the invertible matrix is | 2844 // Hit testing any point should not hit the layer. If the invertible matrix is |
2845 // accidentally ignored and treated like an identity, then the hit testing w ill | 2845 // accidentally ignored and treated like an identity, then the hit testing w ill |
2846 // incorrectly hit the layer when it shouldn't. | 2846 // incorrectly hit the layer when it shouldn't. |
2847 gfx::Point testPoint(1, 1); | 2847 gfx::Point testPoint(1, 1); |
2848 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList); | 2848 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test Point, renderSurfaceLayerList); |
2849 EXPECT_FALSE(resultLayer); | 2849 EXPECT_FALSE(resultLayer); |
2850 | 2850 |
2851 testPoint = gfx::Point(10, 10); | 2851 testPoint = gfx::Point(10, 10); |
2852 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); | 2852 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); |
(...skipping 17 matching lines...) Expand all Loading... | |
2870 | 2870 |
2871 testPoint = gfx::Point(-1, -1); | 2871 testPoint = gfx::Point(-1, -1); |
2872 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); | 2872 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); |
2873 EXPECT_FALSE(resultLayer); | 2873 EXPECT_FALSE(resultLayer); |
2874 } | 2874 } |
2875 | 2875 |
2876 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer) | 2876 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer) |
2877 { | 2877 { |
2878 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); | 2878 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); |
2879 | 2879 |
2880 WebTransformationMatrix identityMatrix; | 2880 Transform identityMatrix; |
2881 gfx::PointF anchor(0, 0); | 2881 gfx::PointF anchor(0, 0); |
2882 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s hould correctly know where the layer is located. | 2882 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s hould correctly know where the layer is located. |
2883 gfx::Size bounds(100, 100); | 2883 gfx::Size bounds(100, 100); |
2884 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); | 2884 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); |
2885 root->setDrawsContent(true); | 2885 root->setDrawsContent(true); |
2886 | 2886 |
2887 std::vector<LayerImpl*> renderSurfaceLayerList; | 2887 std::vector<LayerImpl*> renderSurfaceLayerList; |
2888 int dummyMaxTextureSize = 512; | 2888 int dummyMaxTextureSize = 512; |
2889 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2889 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
2890 | 2890 |
(...skipping 20 matching lines...) Expand all Loading... | |
2911 testPoint = gfx::Point(99, 99); | 2911 testPoint = gfx::Point(99, 99); |
2912 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); | 2912 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); |
2913 ASSERT_TRUE(resultLayer); | 2913 ASSERT_TRUE(resultLayer); |
2914 EXPECT_EQ(12345, resultLayer->id()); | 2914 EXPECT_EQ(12345, resultLayer->id()); |
2915 } | 2915 } |
2916 | 2916 |
2917 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer) | 2917 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer) |
2918 { | 2918 { |
2919 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); | 2919 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); |
2920 | 2920 |
2921 WebTransformationMatrix identityMatrix; | 2921 Transform identityMatrix; |
2922 WebTransformationMatrix rotation45DegreesAboutCenter; | 2922 Transform rotation45DegreesAboutCenter; |
2923 rotation45DegreesAboutCenter.translate(50, 50); | 2923 rotation45DegreesAboutCenter.PreconcatTranslate(50, 50); |
2924 rotation45DegreesAboutCenter.rotate3d(0, 0, 45); | 2924 MathUtil::rotateEulerAngles(&rotation45DegreesAboutCenter, 0, 0, 45); |
2925 rotation45DegreesAboutCenter.translate(-50, -50); | 2925 rotation45DegreesAboutCenter.PreconcatTranslate(-50, -50); |
2926 gfx::PointF anchor(0, 0); | 2926 gfx::PointF anchor(0, 0); |
2927 gfx::PointF position(0, 0); | 2927 gfx::PointF position(0, 0); |
2928 gfx::Size bounds(100, 100); | 2928 gfx::Size bounds(100, 100); |
2929 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident ityMatrix, anchor, position, bounds, false); | 2929 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident ityMatrix, anchor, position, bounds, false); |
2930 root->setDrawsContent(true); | 2930 root->setDrawsContent(true); |
2931 | 2931 |
2932 std::vector<LayerImpl*> renderSurfaceLayerList; | 2932 std::vector<LayerImpl*> renderSurfaceLayerList; |
2933 int dummyMaxTextureSize = 512; | 2933 int dummyMaxTextureSize = 512; |
2934 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2934 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
2935 | 2935 |
(...skipping 24 matching lines...) Expand all Loading... | |
2960 | 2960 |
2961 testPoint = gfx::Point(-1, 50); | 2961 testPoint = gfx::Point(-1, 50); |
2962 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); | 2962 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); |
2963 ASSERT_FALSE(resultLayer); | 2963 ASSERT_FALSE(resultLayer); |
2964 } | 2964 } |
2965 | 2965 |
2966 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer) | 2966 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer) |
2967 { | 2967 { |
2968 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); | 2968 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); |
2969 | 2969 |
2970 WebTransformationMatrix identityMatrix; | 2970 Transform identityMatrix; |
2971 | 2971 |
2972 // perspectiveProjectionAboutCenter * translationByZ is designed so that the 100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). | 2972 // perspectiveProjectionAboutCenter * translationByZ is designed so that the 100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). |
2973 WebTransformationMatrix perspectiveProjectionAboutCenter; | 2973 Transform perspectiveProjectionAboutCenter; |
2974 perspectiveProjectionAboutCenter.translate(50, 50); | 2974 perspectiveProjectionAboutCenter.PreconcatTranslate(50, 50); |
2975 perspectiveProjectionAboutCenter.applyPerspective(1); | 2975 perspectiveProjectionAboutCenter.PreconcatPerspectiveDepth(1); |
2976 perspectiveProjectionAboutCenter.translate(-50, -50); | 2976 perspectiveProjectionAboutCenter.PreconcatTranslate(-50, -50); |
2977 WebTransformationMatrix translationByZ; | 2977 Transform translationByZ; |
2978 translationByZ.translate3d(0, 0, -1); | 2978 translationByZ.PreconcatTranslate3d(0, 0, -1); |
2979 | 2979 |
2980 gfx::PointF anchor(0, 0); | 2980 gfx::PointF anchor(0, 0); |
2981 gfx::PointF position(0, 0); | 2981 gfx::PointF position(0, 0); |
2982 gfx::Size bounds(100, 100); | 2982 gfx::Size bounds(100, 100); |
2983 setLayerPropertiesForTesting(root.get(), perspectiveProjectionAboutCenter * translationByZ, identityMatrix, anchor, position, bounds, false); | 2983 setLayerPropertiesForTesting(root.get(), perspectiveProjectionAboutCenter * translationByZ, identityMatrix, anchor, position, bounds, false); |
2984 root->setDrawsContent(true); | 2984 root->setDrawsContent(true); |
2985 | 2985 |
2986 std::vector<LayerImpl*> renderSurfaceLayerList; | 2986 std::vector<LayerImpl*> renderSurfaceLayerList; |
2987 int dummyMaxTextureSize = 512; | 2987 int dummyMaxTextureSize = 512; |
2988 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2988 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3020 // test makes sure that hit testing works correctly accounts for the content s scale. | 3020 // test makes sure that hit testing works correctly accounts for the content s scale. |
3021 // A contentsScale that is not 1 effectively forces a non-identity transform between | 3021 // A contentsScale that is not 1 effectively forces a non-identity transform between |
3022 // layer's content space and layer's origin space. The hit testing code must take this into account. | 3022 // layer's content space and layer's origin space. The hit testing code must take this into account. |
3023 // | 3023 // |
3024 // To test this, the layer is positioned at (25, 25), and is size (50, 50). If | 3024 // To test this, the layer is positioned at (25, 25), and is size (50, 50). If |
3025 // contentsScale is ignored, then hit testing will mis-interpret the visible ContentRect | 3025 // contentsScale is ignored, then hit testing will mis-interpret the visible ContentRect |
3026 // as being larger than the actual bounds of the layer. | 3026 // as being larger than the actual bounds of the layer. |
3027 // | 3027 // |
3028 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3028 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3029 | 3029 |
3030 WebTransformationMatrix identityMatrix; | 3030 Transform identityMatrix; |
3031 gfx::PointF anchor(0, 0); | 3031 gfx::PointF anchor(0, 0); |
3032 | 3032 |
3033 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 3033 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
3034 | 3034 |
3035 { | 3035 { |
3036 gfx::PointF position(25, 25); | 3036 gfx::PointF position(25, 25); |
3037 gfx::Size bounds(50, 50); | 3037 gfx::Size bounds(50, 50); |
3038 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(12345); | 3038 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(12345); |
3039 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa trix, anchor, position, bounds, false); | 3039 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa trix, anchor, position, bounds, false); |
3040 | 3040 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3079 testPoint = gfx::Point(74, 74); | 3079 testPoint = gfx::Point(74, 74); |
3080 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); | 3080 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); |
3081 ASSERT_TRUE(resultLayer); | 3081 ASSERT_TRUE(resultLayer); |
3082 EXPECT_EQ(12345, resultLayer->id()); | 3082 EXPECT_EQ(12345, resultLayer->id()); |
3083 } | 3083 } |
3084 | 3084 |
3085 TEST(LayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer) | 3085 TEST(LayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer) |
3086 { | 3086 { |
3087 // Test that hit-testing will only work for the visible portion of a layer, and not | 3087 // Test that hit-testing will only work for the visible portion of a layer, and not |
3088 // the entire layer bounds. Here we just test the simple axis-aligned case. | 3088 // the entire layer bounds. Here we just test the simple axis-aligned case. |
3089 WebTransformationMatrix identityMatrix; | 3089 Transform identityMatrix; |
3090 gfx::PointF anchor(0, 0); | 3090 gfx::PointF anchor(0, 0); |
3091 | 3091 |
3092 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3092 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3093 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 3093 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
3094 | 3094 |
3095 { | 3095 { |
3096 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::create(123); | 3096 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::create(123); |
3097 gfx::PointF position(25, 25); // this layer is positioned, and hit testi ng should correctly know where the layer is located. | 3097 gfx::PointF position(25, 25); // this layer is positioned, and hit testi ng should correctly know where the layer is located. |
3098 gfx::Size bounds(50, 50); | 3098 gfx::Size bounds(50, 50); |
3099 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi tyMatrix, anchor, position, bounds, false); | 3099 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi tyMatrix, anchor, position, bounds, false); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3147 // algorithm needs to recognize that multiple parent layers may clip the lay er, and | 3147 // algorithm needs to recognize that multiple parent layers may clip the lay er, and |
3148 // should not actually hit those clipped areas. | 3148 // should not actually hit those clipped areas. |
3149 // | 3149 // |
3150 // The child and grandChild layers are both initialized to clip the rotatedL eaf. The | 3150 // The child and grandChild layers are both initialized to clip the rotatedL eaf. The |
3151 // child layer is rotated about the top-left corner, so that the root + chil d clips | 3151 // child layer is rotated about the top-left corner, so that the root + chil d clips |
3152 // combined create a triangle. The rotatedLeaf will only be visible where it overlaps | 3152 // combined create a triangle. The rotatedLeaf will only be visible where it overlaps |
3153 // this triangle. | 3153 // this triangle. |
3154 // | 3154 // |
3155 scoped_ptr<LayerImpl> root = LayerImpl::create(123); | 3155 scoped_ptr<LayerImpl> root = LayerImpl::create(123); |
3156 | 3156 |
3157 WebTransformationMatrix identityMatrix; | 3157 Transform identityMatrix; |
3158 gfx::PointF anchor(0, 0); | 3158 gfx::PointF anchor(0, 0); |
3159 gfx::PointF position(0, 0); | 3159 gfx::PointF position(0, 0); |
3160 gfx::Size bounds(100, 100); | 3160 gfx::Size bounds(100, 100); |
3161 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); | 3161 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); |
3162 root->setMasksToBounds(true); | 3162 root->setMasksToBounds(true); |
3163 | 3163 |
3164 { | 3164 { |
3165 scoped_ptr<LayerImpl> child = LayerImpl::create(456); | 3165 scoped_ptr<LayerImpl> child = LayerImpl::create(456); |
3166 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(789); | 3166 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(789); |
3167 scoped_ptr<LayerImpl> rotatedLeaf = LayerImpl::create(2468); | 3167 scoped_ptr<LayerImpl> rotatedLeaf = LayerImpl::create(2468); |
3168 | 3168 |
3169 position = gfx::PointF(10, 10); | 3169 position = gfx::PointF(10, 10); |
3170 bounds = gfx::Size(80, 80); | 3170 bounds = gfx::Size(80, 80); |
3171 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false); | 3171 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix , anchor, position, bounds, false); |
3172 child->setMasksToBounds(true); | 3172 child->setMasksToBounds(true); |
3173 | 3173 |
3174 WebTransformationMatrix rotation45DegreesAboutCorner; | 3174 Transform rotation45DegreesAboutCorner; |
3175 rotation45DegreesAboutCorner.rotate3d(0, 0, 45); | 3175 MathUtil::rotateEulerAngles(&rotation45DegreesAboutCorner, 0, 0, 45); |
3176 | 3176 |
3177 position = gfx::PointF(0, 0); // remember, positioned with respect to it s parent which is already at 10, 10 | 3177 position = gfx::PointF(0, 0); // remember, positioned with respect to it s parent which is already at 10, 10 |
3178 bounds = gfx::Size(200, 200); // to ensure it covers at least sqrt(2) * 100. | 3178 bounds = gfx::Size(200, 200); // to ensure it covers at least sqrt(2) * 100. |
3179 setLayerPropertiesForTesting(grandChild.get(), rotation45DegreesAboutCor ner, identityMatrix, anchor, position, bounds, false); | 3179 setLayerPropertiesForTesting(grandChild.get(), rotation45DegreesAboutCor ner, identityMatrix, anchor, position, bounds, false); |
3180 grandChild->setMasksToBounds(true); | 3180 grandChild->setMasksToBounds(true); |
3181 | 3181 |
3182 // Rotates about the center of the layer | 3182 // Rotates about the center of the layer |
3183 WebTransformationMatrix rotatedLeafTransform; | 3183 Transform rotatedLeafTransform; |
3184 rotatedLeafTransform.translate(-10, -10); // cancel out the grandParent' s position | 3184 rotatedLeafTransform.PreconcatTranslate(-10, -10); // cancel out the gra ndParent's position |
3185 rotatedLeafTransform.rotate3d(0, 0, -45); // cancel out the corner 45-de gree rotation of the parent. | 3185 MathUtil::rotateEulerAngles(&rotatedLeafTransform, 0, 0, -45); // cancel out the corner 45-degree rotation of the parent. |
3186 rotatedLeafTransform.translate(50, 50); | 3186 rotatedLeafTransform.PreconcatTranslate(50, 50); |
3187 rotatedLeafTransform.rotate3d(0, 0, 45); | 3187 MathUtil::rotateEulerAngles(&rotatedLeafTransform, 0, 0, 45); |
3188 rotatedLeafTransform.translate(-50, -50); | 3188 rotatedLeafTransform.PreconcatTranslate(-50, -50); |
3189 position = gfx::PointF(0, 0); | 3189 position = gfx::PointF(0, 0); |
3190 bounds = gfx::Size(100, 100); | 3190 bounds = gfx::Size(100, 100); |
3191 setLayerPropertiesForTesting(rotatedLeaf.get(), rotatedLeafTransform, id entityMatrix, anchor, position, bounds, false); | 3191 setLayerPropertiesForTesting(rotatedLeaf.get(), rotatedLeafTransform, id entityMatrix, anchor, position, bounds, false); |
3192 rotatedLeaf->setDrawsContent(true); | 3192 rotatedLeaf->setDrawsContent(true); |
3193 | 3193 |
3194 grandChild->addChild(rotatedLeaf.Pass()); | 3194 grandChild->addChild(rotatedLeaf.Pass()); |
3195 child->addChild(grandChild.Pass()); | 3195 child->addChild(grandChild.Pass()); |
3196 root->addChild(child.Pass()); | 3196 root->addChild(child.Pass()); |
3197 } | 3197 } |
3198 | 3198 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3243 testPoint = gfx::Point(49, 51); | 3243 testPoint = gfx::Point(49, 51); |
3244 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); | 3244 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); |
3245 ASSERT_TRUE(resultLayer); | 3245 ASSERT_TRUE(resultLayer); |
3246 EXPECT_EQ(2468, resultLayer->id()); | 3246 EXPECT_EQ(2468, resultLayer->id()); |
3247 } | 3247 } |
3248 | 3248 |
3249 TEST(LayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer) | 3249 TEST(LayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer) |
3250 { | 3250 { |
3251 // This test checks that hit testing code does not accidentally clip to laye r | 3251 // This test checks that hit testing code does not accidentally clip to laye r |
3252 // bounds for a layer that actually does not clip. | 3252 // bounds for a layer that actually does not clip. |
3253 WebTransformationMatrix identityMatrix; | 3253 Transform identityMatrix; |
3254 gfx::PointF anchor(0, 0); | 3254 gfx::PointF anchor(0, 0); |
3255 | 3255 |
3256 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3256 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3257 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 3257 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
3258 | 3258 |
3259 { | 3259 { |
3260 scoped_ptr<LayerImpl> intermediateLayer = LayerImpl::create(123); | 3260 scoped_ptr<LayerImpl> intermediateLayer = LayerImpl::create(123); |
3261 gfx::PointF position(10, 10); // this layer is positioned, and hit testi ng should correctly know where the layer is located. | 3261 gfx::PointF position(10, 10); // this layer is positioned, and hit testi ng should correctly know where the layer is located. |
3262 gfx::Size bounds(50, 50); | 3262 gfx::Size bounds(50, 50); |
3263 setLayerPropertiesForTesting(intermediateLayer.get(), identityMatrix, id entityMatrix, anchor, position, bounds, false); | 3263 setLayerPropertiesForTesting(intermediateLayer.get(), identityMatrix, id entityMatrix, anchor, position, bounds, false); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3304 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); | 3304 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend erSurfaceLayerList); |
3305 ASSERT_TRUE(resultLayer); | 3305 ASSERT_TRUE(resultLayer); |
3306 EXPECT_EQ(456, resultLayer->id()); | 3306 EXPECT_EQ(456, resultLayer->id()); |
3307 } | 3307 } |
3308 | 3308 |
3309 | 3309 |
3310 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayers) | 3310 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayers) |
3311 { | 3311 { |
3312 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3312 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3313 | 3313 |
3314 WebTransformationMatrix identityMatrix; | 3314 Transform identityMatrix; |
3315 gfx::PointF anchor(0, 0); | 3315 gfx::PointF anchor(0, 0); |
3316 gfx::PointF position(0, 0); | 3316 gfx::PointF position(0, 0); |
3317 gfx::Size bounds(100, 100); | 3317 gfx::Size bounds(100, 100); |
3318 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); | 3318 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); |
3319 root->setDrawsContent(true); | 3319 root->setDrawsContent(true); |
3320 | 3320 |
3321 { | 3321 { |
3322 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 3322 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
3323 // grandChild is set to overlap both child1 and child2 between y=50 and y=60. | 3323 // grandChild is set to overlap both child1 and child2 between y=50 and y=60. |
3324 // The expected stacking order is: | 3324 // The expected stacking order is: |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3407 } | 3407 } |
3408 | 3408 |
3409 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists) | 3409 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists) |
3410 { | 3410 { |
3411 // | 3411 // |
3412 // The geometry is set up similarly to the previous case, but | 3412 // The geometry is set up similarly to the previous case, but |
3413 // all layers are forced to be renderSurfaces now. | 3413 // all layers are forced to be renderSurfaces now. |
3414 // | 3414 // |
3415 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3415 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3416 | 3416 |
3417 WebTransformationMatrix identityMatrix; | 3417 Transform identityMatrix; |
3418 gfx::PointF anchor(0, 0); | 3418 gfx::PointF anchor(0, 0); |
3419 gfx::PointF position(0, 0); | 3419 gfx::PointF position(0, 0); |
3420 gfx::Size bounds(100, 100); | 3420 gfx::Size bounds(100, 100); |
3421 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); | 3421 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); |
3422 root->setDrawsContent(true); | 3422 root->setDrawsContent(true); |
3423 | 3423 |
3424 { | 3424 { |
3425 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 3425 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
3426 // grandChild is set to overlap both child1 and child2 between y=50 and y=60. | 3426 // grandChild is set to overlap both child1 and child2 between y=50 and y=60. |
3427 // The expected stacking order is: | 3427 // The expected stacking order is: |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3529 | 3529 |
3530 testPoint = gfx::Point(10, 20); | 3530 testPoint = gfx::Point(10, 20); |
3531 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList); | 3531 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList); |
3532 EXPECT_FALSE(resultLayer); | 3532 EXPECT_FALSE(resultLayer); |
3533 } | 3533 } |
3534 | 3534 |
3535 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer ) | 3535 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer ) |
3536 { | 3536 { |
3537 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); | 3537 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); |
3538 | 3538 |
3539 WebTransformationMatrix identityMatrix; | 3539 Transform identityMatrix; |
3540 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); | 3540 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); |
3541 gfx::PointF anchor(0, 0); | 3541 gfx::PointF anchor(0, 0); |
3542 gfx::PointF position(0, 0); | 3542 gfx::PointF position(0, 0); |
3543 gfx::Size bounds(100, 100); | 3543 gfx::Size bounds(100, 100); |
3544 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); | 3544 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); |
3545 root->setDrawsContent(true); | 3545 root->setDrawsContent(true); |
3546 | 3546 |
3547 std::vector<LayerImpl*> renderSurfaceLayerList; | 3547 std::vector<LayerImpl*> renderSurfaceLayerList; |
3548 int dummyMaxTextureSize = 512; | 3548 int dummyMaxTextureSize = 512; |
3549 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3549 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3585 testPoint = gfx::Point(59, 59); | 3585 testPoint = gfx::Point(59, 59); |
3586 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList); | 3586 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList); |
3587 ASSERT_TRUE(resultLayer); | 3587 ASSERT_TRUE(resultLayer); |
3588 EXPECT_EQ(12345, resultLayer->id()); | 3588 EXPECT_EQ(12345, resultLayer->id()); |
3589 } | 3589 } |
3590 | 3590 |
3591 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForUninvertibl eTransform) | 3591 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForUninvertibl eTransform) |
3592 { | 3592 { |
3593 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); | 3593 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); |
3594 | 3594 |
3595 WebTransformationMatrix uninvertibleTransform; | 3595 Transform uninvertibleTransform; |
3596 uninvertibleTransform.setM11(0); | 3596 uninvertibleTransform.matrix().setDouble(0, 0, 0); |
3597 uninvertibleTransform.setM22(0); | 3597 uninvertibleTransform.matrix().setDouble(1, 1, 0); |
3598 uninvertibleTransform.setM33(0); | 3598 uninvertibleTransform.matrix().setDouble(2, 2, 0); |
3599 uninvertibleTransform.setM44(0); | 3599 uninvertibleTransform.matrix().setDouble(3, 3, 0); |
3600 ASSERT_FALSE(uninvertibleTransform.isInvertible()); | 3600 ASSERT_FALSE(uninvertibleTransform.IsInvertible()); |
3601 | 3601 |
3602 WebTransformationMatrix identityMatrix; | 3602 Transform identityMatrix; |
3603 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); | 3603 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); |
3604 gfx::PointF anchor(0, 0); | 3604 gfx::PointF anchor(0, 0); |
3605 gfx::PointF position(0, 0); | 3605 gfx::PointF position(0, 0); |
3606 gfx::Size bounds(100, 100); | 3606 gfx::Size bounds(100, 100); |
3607 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr ix, anchor, position, bounds, false); | 3607 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr ix, anchor, position, bounds, false); |
3608 root->setDrawsContent(true); | 3608 root->setDrawsContent(true); |
3609 root->setTouchEventHandlerRegion(touchHandlerRegion); | 3609 root->setTouchEventHandlerRegion(touchHandlerRegion); |
3610 | 3610 |
3611 std::vector<LayerImpl*> renderSurfaceLayerList; | 3611 std::vector<LayerImpl*> renderSurfaceLayerList; |
3612 int dummyMaxTextureSize = 512; | 3612 int dummyMaxTextureSize = 512; |
3613 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3613 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
3614 | 3614 |
3615 // Sanity check the scenario we just created. | 3615 // Sanity check the scenario we just created. |
3616 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3616 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3617 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 3617 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
3618 ASSERT_FALSE(root->screenSpaceTransform().isInvertible()); | 3618 ASSERT_FALSE(root->screenSpaceTransform().IsInvertible()); |
3619 | 3619 |
3620 // Hit checking any point should not hit the touch handler region on the lay er. If the invertible matrix is | 3620 // Hit checking any point should not hit the touch handler region on the lay er. If the invertible matrix is |
3621 // accidentally ignored and treated like an identity, then the hit testing w ill | 3621 // accidentally ignored and treated like an identity, then the hit testing w ill |
3622 // incorrectly hit the layer when it shouldn't. | 3622 // incorrectly hit the layer when it shouldn't. |
3623 gfx::Point testPoint(1, 1); | 3623 gfx::Point testPoint(1, 1); |
3624 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou chHandlerRegion(testPoint, renderSurfaceLayerList); | 3624 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou chHandlerRegion(testPoint, renderSurfaceLayerList); |
3625 EXPECT_FALSE(resultLayer); | 3625 EXPECT_FALSE(resultLayer); |
3626 | 3626 |
3627 testPoint = gfx::Point(10, 10); | 3627 testPoint = gfx::Point(10, 10); |
3628 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList); | 3628 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList); |
(...skipping 17 matching lines...) Expand all Loading... | |
3646 | 3646 |
3647 testPoint = gfx::Point(-1, -1); | 3647 testPoint = gfx::Point(-1, -1); |
3648 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList); | 3648 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList); |
3649 EXPECT_FALSE(resultLayer); | 3649 EXPECT_FALSE(resultLayer); |
3650 } | 3650 } |
3651 | 3651 |
3652 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSinglePosit ionedLayer) | 3652 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSinglePosit ionedLayer) |
3653 { | 3653 { |
3654 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); | 3654 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); |
3655 | 3655 |
3656 WebTransformationMatrix identityMatrix; | 3656 Transform identityMatrix; |
3657 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); | 3657 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); |
3658 gfx::PointF anchor(0, 0); | 3658 gfx::PointF anchor(0, 0); |
3659 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s hould correctly know where the layer is located. | 3659 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s hould correctly know where the layer is located. |
3660 gfx::Size bounds(100, 100); | 3660 gfx::Size bounds(100, 100); |
3661 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); | 3661 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, position, bounds, false); |
3662 root->setDrawsContent(true); | 3662 root->setDrawsContent(true); |
3663 root->setTouchEventHandlerRegion(touchHandlerRegion); | 3663 root->setTouchEventHandlerRegion(touchHandlerRegion); |
3664 | 3664 |
3665 std::vector<LayerImpl*> renderSurfaceLayerList; | 3665 std::vector<LayerImpl*> renderSurfaceLayerList; |
3666 int dummyMaxTextureSize = 512; | 3666 int dummyMaxTextureSize = 512; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3704 // test makes sure that hit testing works correctly accounts for the content s scale. | 3704 // test makes sure that hit testing works correctly accounts for the content s scale. |
3705 // A contentsScale that is not 1 effectively forces a non-identity transform between | 3705 // A contentsScale that is not 1 effectively forces a non-identity transform between |
3706 // layer's content space and layer's origin space. The hit testing code must take this into account. | 3706 // layer's content space and layer's origin space. The hit testing code must take this into account. |
3707 // | 3707 // |
3708 // To test this, the layer is positioned at (25, 25), and is size (50, 50). If | 3708 // To test this, the layer is positioned at (25, 25), and is size (50, 50). If |
3709 // contentsScale is ignored, then hit checking will mis-interpret the visibl eContentRect | 3709 // contentsScale is ignored, then hit checking will mis-interpret the visibl eContentRect |
3710 // as being larger than the actual bounds of the layer. | 3710 // as being larger than the actual bounds of the layer. |
3711 // | 3711 // |
3712 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3712 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3713 | 3713 |
3714 WebTransformationMatrix identityMatrix; | 3714 Transform identityMatrix; |
3715 gfx::PointF anchor(0, 0); | 3715 gfx::PointF anchor(0, 0); |
3716 | 3716 |
3717 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 3717 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
3718 | 3718 |
3719 { | 3719 { |
3720 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30)); | 3720 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30)); |
3721 gfx::PointF position(25, 25); | 3721 gfx::PointF position(25, 25); |
3722 gfx::Size bounds(50, 50); | 3722 gfx::Size bounds(50, 50); |
3723 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(12345); | 3723 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(12345); |
3724 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa trix, anchor, position, bounds, false); | 3724 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa trix, anchor, position, bounds, false); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3776 ASSERT_TRUE(resultLayer); | 3776 ASSERT_TRUE(resultLayer); |
3777 EXPECT_EQ(12345, resultLayer->id()); | 3777 EXPECT_EQ(12345, resultLayer->id()); |
3778 } | 3778 } |
3779 | 3779 |
3780 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer WithDeviceScale) | 3780 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer WithDeviceScale) |
3781 { | 3781 { |
3782 // The layer's deviceScalefactor and pageScaleFactor should scale the conten tRect and we should | 3782 // The layer's deviceScalefactor and pageScaleFactor should scale the conten tRect and we should |
3783 // be able to hit the touch handler region by scaling the points accordingly . | 3783 // be able to hit the touch handler region by scaling the points accordingly . |
3784 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3784 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3785 | 3785 |
3786 WebTransformationMatrix identityMatrix; | 3786 Transform identityMatrix; |
3787 gfx::PointF anchor(0, 0); | 3787 gfx::PointF anchor(0, 0); |
3788 // Set the bounds of the root layer big enough to fit the child when scaled. | 3788 // Set the bounds of the root layer big enough to fit the child when scaled. |
3789 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 3789 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
3790 | 3790 |
3791 { | 3791 { |
3792 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30)); | 3792 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30)); |
3793 gfx::PointF position(25, 25); | 3793 gfx::PointF position(25, 25); |
3794 gfx::Size bounds(50, 50); | 3794 gfx::Size bounds(50, 50); |
3795 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(12345); | 3795 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(12345); |
3796 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa trix, anchor, position, bounds, false); | 3796 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa trix, anchor, position, bounds, false); |
3797 | 3797 |
3798 testLayer->setDrawsContent(true); | 3798 testLayer->setDrawsContent(true); |
3799 testLayer->setTouchEventHandlerRegion(touchHandlerRegion); | 3799 testLayer->setTouchEventHandlerRegion(touchHandlerRegion); |
3800 root->addChild(testLayer.Pass()); | 3800 root->addChild(testLayer.Pass()); |
3801 } | 3801 } |
3802 | 3802 |
3803 std::vector<LayerImpl*> renderSurfaceLayerList; | 3803 std::vector<LayerImpl*> renderSurfaceLayerList; |
3804 int dummyMaxTextureSize = 512; | 3804 int dummyMaxTextureSize = 512; |
3805 float deviceScaleFactor = 3.0f; | 3805 float deviceScaleFactor = 3.0f; |
3806 float pageScaleFactor = 5.0f; | 3806 float pageScaleFactor = 5.0f; |
3807 WebTransformationMatrix pageScaleTransform; | 3807 Transform pageScaleTransform; |
3808 pageScaleTransform.scale(pageScaleFactor); | 3808 pageScaleTransform.PreconcatScale(pageScaleFactor, pageScaleFactor); |
3809 root->setImplTransform(pageScaleTransform); // Applying the pageScaleFactor through implTransform. | 3809 root->setImplTransform(pageScaleTransform); // Applying the pageScaleFactor through implTransform. |
3810 gfx::Size scaledBoundsForRoot = gfx::ToCeiledSize(gfx::ScaleSize(root->bound s(), deviceScaleFactor * pageScaleFactor)); | 3810 gfx::Size scaledBoundsForRoot = gfx::ToCeiledSize(gfx::ScaleSize(root->bound s(), deviceScaleFactor * pageScaleFactor)); |
3811 LayerTreeHostCommon::calculateDrawTransforms(root.get(), scaledBoundsForRoot , deviceScaleFactor, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3811 LayerTreeHostCommon::calculateDrawTransforms(root.get(), scaledBoundsForRoot , deviceScaleFactor, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
3812 | 3812 |
3813 // Sanity check the scenario we just created. | 3813 // Sanity check the scenario we just created. |
3814 // The visibleContentRect for testLayer is actually 100x100, even though its layout size is 50x50, positioned at 25x25. | 3814 // The visibleContentRect for testLayer is actually 100x100, even though its layout size is 50x50, positioned at 25x25. |
3815 LayerImpl* testLayer = root->children()[0]; | 3815 LayerImpl* testLayer = root->children()[0]; |
3816 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3816 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3817 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 3817 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
3818 | 3818 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3857 testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); | 3857 testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); |
3858 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList); | 3858 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe gion(testPoint, renderSurfaceLayerList); |
3859 ASSERT_TRUE(resultLayer); | 3859 ASSERT_TRUE(resultLayer); |
3860 EXPECT_EQ(12345, resultLayer->id()); | 3860 EXPECT_EQ(12345, resultLayer->id()); |
3861 } | 3861 } |
3862 | 3862 |
3863 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSimpleClipp edLayer) | 3863 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSimpleClipp edLayer) |
3864 { | 3864 { |
3865 // Test that hit-checking will only work for the visible portion of a layer, and not | 3865 // Test that hit-checking will only work for the visible portion of a layer, and not |
3866 // the entire layer bounds. Here we just test the simple axis-aligned case. | 3866 // the entire layer bounds. Here we just test the simple axis-aligned case. |
3867 WebTransformationMatrix identityMatrix; | 3867 Transform identityMatrix; |
3868 gfx::PointF anchor(0, 0); | 3868 gfx::PointF anchor(0, 0); |
3869 | 3869 |
3870 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3870 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3871 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 3871 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
3872 | 3872 |
3873 { | 3873 { |
3874 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::create(123); | 3874 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::create(123); |
3875 gfx::PointF position(25, 25); // this layer is positioned, and hit testi ng should correctly know where the layer is located. | 3875 gfx::PointF position(25, 25); // this layer is positioned, and hit testi ng should correctly know where the layer is located. |
3876 gfx::Size bounds(50, 50); | 3876 gfx::Size bounds(50, 50); |
3877 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi tyMatrix, anchor, position, bounds, false); | 3877 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi tyMatrix, anchor, position, bounds, false); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3942 { | 3942 { |
3943 scoped_refptr<NoScaleContentLayer> toReturn = NoScaleContentLayer::create(de legate); | 3943 scoped_refptr<NoScaleContentLayer> toReturn = NoScaleContentLayer::create(de legate); |
3944 toReturn->setIsDrawable(true); | 3944 toReturn->setIsDrawable(true); |
3945 return toReturn; | 3945 return toReturn; |
3946 } | 3946 } |
3947 | 3947 |
3948 TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPI) | 3948 TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPI) |
3949 { | 3949 { |
3950 // Verify draw and screen space transforms of layers not in a surface. | 3950 // Verify draw and screen space transforms of layers not in a surface. |
3951 MockContentLayerClient delegate; | 3951 MockContentLayerClient delegate; |
3952 WebTransformationMatrix identityMatrix; | 3952 Transform identityMatrix; |
3953 | 3953 |
3954 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); | 3954 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
3955 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); | 3955 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); |
3956 | 3956 |
3957 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); | 3957 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); |
3958 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 3958 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
3959 | 3959 |
3960 scoped_refptr<ContentLayer> childEmpty = createDrawableContentLayer(&delegat e); | 3960 scoped_refptr<ContentLayer> childEmpty = createDrawableContentLayer(&delegat e); |
3961 setLayerPropertiesForTesting(childEmpty.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(0, 0), true); | 3961 setLayerPropertiesForTesting(childEmpty.get(), identityMatrix, identityMatri x, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(0, 0), true); |
3962 | 3962 |
(...skipping 13 matching lines...) Expand all Loading... | |
3976 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); | 3976 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); |
3977 | 3977 |
3978 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); | 3978 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); |
3979 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); | 3979 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); |
3980 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childEmpty); | 3980 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childEmpty); |
3981 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 3981 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
3982 | 3982 |
3983 EXPECT_EQ(1u, renderSurfaceLayerList.size()); | 3983 EXPECT_EQ(1u, renderSurfaceLayerList.size()); |
3984 | 3984 |
3985 // Verify parent transforms | 3985 // Verify parent transforms |
3986 WebTransformationMatrix expectedParentTransform; | 3986 Transform expectedParentTransform; |
3987 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace Transform()); | 3987 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace Transform()); |
3988 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo rm()); | 3988 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo rm()); |
3989 | 3989 |
3990 // Verify results of transformed parent rects | 3990 // Verify results of transformed parent rects |
3991 gfx::RectF parentContentBounds(gfx::PointF(), gfx::SizeF(parent->contentBoun ds())); | 3991 gfx::RectF parentContentBounds(gfx::PointF(), gfx::SizeF(parent->contentBoun ds())); |
3992 | 3992 |
3993 gfx::RectF parentDrawRect = MathUtil::mapClippedRect(parent->drawTransform() , parentContentBounds); | 3993 gfx::RectF parentDrawRect = MathUtil::mapClippedRect(parent->drawTransform() , parentContentBounds); |
3994 gfx::RectF parentScreenSpaceRect = MathUtil::mapClippedRect(parent->screenSp aceTransform(), parentContentBounds); | 3994 gfx::RectF parentScreenSpaceRect = MathUtil::mapClippedRect(parent->screenSp aceTransform(), parentContentBounds); |
3995 | 3995 |
3996 gfx::RectF expectedParentDrawRect(gfx::PointF(), parent->bounds()); | 3996 gfx::RectF expectedParentDrawRect(gfx::PointF(), parent->bounds()); |
3997 expectedParentDrawRect.Scale(deviceScaleFactor); | 3997 expectedParentDrawRect.Scale(deviceScaleFactor); |
3998 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentDrawRect); | 3998 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentDrawRect); |
3999 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentScreenSpaceRect); | 3999 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentScreenSpaceRect); |
4000 | 4000 |
4001 // Verify child and childEmpty transforms. They should match. | 4001 // Verify child and childEmpty transforms. They should match. |
4002 WebTransformationMatrix expectedChildTransform; | 4002 Transform expectedChildTransform; |
4003 expectedChildTransform.translate(deviceScaleFactor * child->position().x(), deviceScaleFactor * child->position().y()); | 4003 expectedChildTransform.PreconcatTranslate(deviceScaleFactor * child->positio n().x(), deviceScaleFactor * child->position().y()); |
4004 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); | 4004 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); |
4005 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->screenSpaceTr ansform()); | 4005 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->screenSpaceTr ansform()); |
4006 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, childEmpty->drawTran sform()); | 4006 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, childEmpty->drawTran sform()); |
4007 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, childEmpty->screenSp aceTransform()); | 4007 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, childEmpty->screenSp aceTransform()); |
4008 | 4008 |
4009 // Verify results of transformed child and childEmpty rects. They should mat ch. | 4009 // Verify results of transformed child and childEmpty rects. They should mat ch. |
4010 gfx::RectF childContentBounds(gfx::PointF(), gfx::SizeF(child->contentBounds ())); | 4010 gfx::RectF childContentBounds(gfx::PointF(), gfx::SizeF(child->contentBounds ())); |
4011 | 4011 |
4012 gfx::RectF childDrawRect = MathUtil::mapClippedRect(child->drawTransform(), childContentBounds); | 4012 gfx::RectF childDrawRect = MathUtil::mapClippedRect(child->drawTransform(), childContentBounds); |
4013 gfx::RectF childScreenSpaceRect = MathUtil::mapClippedRect(child->screenSpac eTransform(), childContentBounds); | 4013 gfx::RectF childScreenSpaceRect = MathUtil::mapClippedRect(child->screenSpac eTransform(), childContentBounds); |
4014 | 4014 |
4015 gfx::RectF childEmptyDrawRect = MathUtil::mapClippedRect(childEmpty->drawTra nsform(), childContentBounds); | 4015 gfx::RectF childEmptyDrawRect = MathUtil::mapClippedRect(childEmpty->drawTra nsform(), childContentBounds); |
4016 gfx::RectF childEmptyScreenSpaceRect = MathUtil::mapClippedRect(childEmpty-> screenSpaceTransform(), childContentBounds); | 4016 gfx::RectF childEmptyScreenSpaceRect = MathUtil::mapClippedRect(childEmpty-> screenSpaceTransform(), childContentBounds); |
4017 | 4017 |
4018 gfx::RectF expectedChildDrawRect(child->position(), child->bounds()); | 4018 gfx::RectF expectedChildDrawRect(child->position(), child->bounds()); |
4019 expectedChildDrawRect.Scale(deviceScaleFactor); | 4019 expectedChildDrawRect.Scale(deviceScaleFactor); |
4020 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childDrawRect); | 4020 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childDrawRect); |
4021 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childScreenSpaceRect); | 4021 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childScreenSpaceRect); |
4022 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childEmptyDrawRect); | 4022 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childEmptyDrawRect); |
4023 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childEmptyScreenSpaceRect); | 4023 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childEmptyScreenSpaceRect); |
4024 | 4024 |
4025 // Verify childNoScale transforms | 4025 // Verify childNoScale transforms |
4026 WebTransformationMatrix expectedChildNoScaleTransform = child->drawTransform (); | 4026 Transform expectedChildNoScaleTransform = child->drawTransform(); |
4027 // All transforms operate on content rects. The child's content rect | 4027 // All transforms operate on content rects. The child's content rect |
4028 // incorporates device scale, but the childNoScale does not; add it here. | 4028 // incorporates device scale, but the childNoScale does not; add it here. |
4029 expectedChildNoScaleTransform.scale(deviceScaleFactor); | 4029 expectedChildNoScaleTransform.PreconcatScale(deviceScaleFactor, deviceScaleF actor); |
4030 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale- >drawTransform()); | 4030 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale- >drawTransform()); |
4031 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale- >screenSpaceTransform()); | 4031 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale- >screenSpaceTransform()); |
4032 } | 4032 } |
4033 | 4033 |
4034 TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPIAccurateScaleZeroChi ldPosition) | 4034 TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPIAccurateScaleZeroChi ldPosition) |
4035 { | 4035 { |
4036 // Verify draw and screen space transforms of layers not in a surface. | 4036 // Verify draw and screen space transforms of layers not in a surface. |
4037 MockContentLayerClient delegate; | 4037 MockContentLayerClient delegate; |
4038 WebTransformationMatrix identityMatrix; | 4038 Transform identityMatrix; |
4039 | 4039 |
4040 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); | 4040 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
4041 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(133, 133), true); | 4041 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(133, 133), true); |
4042 | 4042 |
4043 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); | 4043 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); |
4044 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 13), true); | 4044 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 13), true); |
4045 | 4045 |
4046 scoped_refptr<NoScaleContentLayer> childNoScale = createNoScaleDrawableConte ntLayer(&delegate); | 4046 scoped_refptr<NoScaleContentLayer> childNoScale = createNoScaleDrawableConte ntLayer(&delegate); |
4047 setLayerPropertiesForTesting(childNoScale.get(), identityMatrix, identityMat rix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 13), true); | 4047 setLayerPropertiesForTesting(childNoScale.get(), identityMatrix, identityMat rix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 13), true); |
4048 | 4048 |
4049 parent->addChild(child); | 4049 parent->addChild(child); |
4050 parent->addChild(childNoScale); | 4050 parent->addChild(childNoScale); |
4051 | 4051 |
4052 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4052 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
4053 int dummyMaxTextureSize = 512; | 4053 int dummyMaxTextureSize = 512; |
4054 | 4054 |
4055 const float deviceScaleFactor = 1.7f; | 4055 const float deviceScaleFactor = 1.7f; |
4056 const float pageScaleFactor = 1; | 4056 const float pageScaleFactor = 1; |
4057 | 4057 |
4058 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); | 4058 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); |
4059 | 4059 |
4060 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); | 4060 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); |
4061 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); | 4061 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); |
4062 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 4062 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
4063 | 4063 |
4064 EXPECT_EQ(1u, renderSurfaceLayerList.size()); | 4064 EXPECT_EQ(1u, renderSurfaceLayerList.size()); |
4065 | 4065 |
4066 // Verify parent transforms | 4066 // Verify parent transforms |
4067 WebTransformationMatrix expectedParentTransform; | 4067 Transform expectedParentTransform; |
4068 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace Transform()); | 4068 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace Transform()); |
4069 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo rm()); | 4069 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo rm()); |
4070 | 4070 |
4071 // Verify results of transformed parent rects | 4071 // Verify results of transformed parent rects |
4072 gfx::RectF parentContentBounds(gfx::PointF(), gfx::SizeF(parent->contentBoun ds())); | 4072 gfx::RectF parentContentBounds(gfx::PointF(), gfx::SizeF(parent->contentBoun ds())); |
4073 | 4073 |
4074 gfx::RectF parentDrawRect = MathUtil::mapClippedRect(parent->drawTransform() , parentContentBounds); | 4074 gfx::RectF parentDrawRect = MathUtil::mapClippedRect(parent->drawTransform() , parentContentBounds); |
4075 gfx::RectF parentScreenSpaceRect = MathUtil::mapClippedRect(parent->screenSp aceTransform(), parentContentBounds); | 4075 gfx::RectF parentScreenSpaceRect = MathUtil::mapClippedRect(parent->screenSp aceTransform(), parentContentBounds); |
4076 | 4076 |
4077 gfx::RectF expectedParentDrawRect(gfx::PointF(), parent->bounds()); | 4077 gfx::RectF expectedParentDrawRect(gfx::PointF(), parent->bounds()); |
4078 expectedParentDrawRect.Scale(deviceScaleFactor); | 4078 expectedParentDrawRect.Scale(deviceScaleFactor); |
4079 expectedParentDrawRect.set_width(ceil(expectedParentDrawRect.width())); | 4079 expectedParentDrawRect.set_width(ceil(expectedParentDrawRect.width())); |
4080 expectedParentDrawRect.set_height(ceil(expectedParentDrawRect.height())); | 4080 expectedParentDrawRect.set_height(ceil(expectedParentDrawRect.height())); |
4081 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentDrawRect); | 4081 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentDrawRect); |
4082 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentScreenSpaceRect); | 4082 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentScreenSpaceRect); |
4083 | 4083 |
4084 // Verify child transforms | 4084 // Verify child transforms |
4085 WebTransformationMatrix expectedChildTransform; | 4085 Transform expectedChildTransform; |
4086 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); | 4086 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); |
4087 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->screenSpaceTr ansform()); | 4087 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->screenSpaceTr ansform()); |
4088 | 4088 |
4089 // Verify results of transformed child rects | 4089 // Verify results of transformed child rects |
4090 gfx::RectF childContentBounds(gfx::PointF(), gfx::SizeF(child->contentBounds ())); | 4090 gfx::RectF childContentBounds(gfx::PointF(), gfx::SizeF(child->contentBounds ())); |
4091 | 4091 |
4092 gfx::RectF childDrawRect = MathUtil::mapClippedRect(child->drawTransform(), childContentBounds); | 4092 gfx::RectF childDrawRect = MathUtil::mapClippedRect(child->drawTransform(), childContentBounds); |
4093 gfx::RectF childScreenSpaceRect = MathUtil::mapClippedRect(child->screenSpac eTransform(), childContentBounds); | 4093 gfx::RectF childScreenSpaceRect = MathUtil::mapClippedRect(child->screenSpac eTransform(), childContentBounds); |
4094 | 4094 |
4095 gfx::RectF expectedChildDrawRect(gfx::PointF(), child->bounds()); | 4095 gfx::RectF expectedChildDrawRect(gfx::PointF(), child->bounds()); |
4096 expectedChildDrawRect.Scale(deviceScaleFactor); | 4096 expectedChildDrawRect.Scale(deviceScaleFactor); |
4097 expectedChildDrawRect.set_width(ceil(expectedChildDrawRect.width())); | 4097 expectedChildDrawRect.set_width(ceil(expectedChildDrawRect.width())); |
4098 expectedChildDrawRect.set_height(ceil(expectedChildDrawRect.height())); | 4098 expectedChildDrawRect.set_height(ceil(expectedChildDrawRect.height())); |
4099 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childDrawRect); | 4099 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childDrawRect); |
4100 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childScreenSpaceRect); | 4100 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childScreenSpaceRect); |
4101 | 4101 |
4102 // Verify childNoScale transforms | 4102 // Verify childNoScale transforms |
4103 WebTransformationMatrix expectedChildNoScaleTransform = child->drawTransform (); | 4103 Transform expectedChildNoScaleTransform = child->drawTransform(); |
4104 // All transforms operate on content rects. The child's content rect | 4104 // All transforms operate on content rects. The child's content rect |
4105 // incorporates device scale, but the childNoScale does not; add it here. | 4105 // incorporates device scale, but the childNoScale does not; add it here. |
4106 expectedChildNoScaleTransform.scale(deviceScaleFactor); | 4106 expectedChildNoScaleTransform.PreconcatScale(deviceScaleFactor, deviceScaleF actor); |
4107 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale- >drawTransform()); | 4107 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale- >drawTransform()); |
4108 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale- >screenSpaceTransform()); | 4108 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale- >screenSpaceTransform()); |
4109 } | 4109 } |
4110 | 4110 |
4111 TEST(LayerTreeHostCommonTest, verifyContentsScale) | 4111 TEST(LayerTreeHostCommonTest, verifyContentsScale) |
4112 { | 4112 { |
4113 MockContentLayerClient delegate; | 4113 MockContentLayerClient delegate; |
4114 WebTransformationMatrix identityMatrix; | 4114 Transform identityMatrix; |
4115 | 4115 |
4116 WebTransformationMatrix parentScaleMatrix; | 4116 Transform parentScaleMatrix; |
4117 const double initialParentScale = 1.75; | 4117 const double initialParentScale = 1.75; |
4118 parentScaleMatrix.scale(initialParentScale); | 4118 parentScaleMatrix.PreconcatScale(initialParentScale, initialParentScale); |
4119 | 4119 |
4120 WebTransformationMatrix childScaleMatrix; | 4120 Transform childScaleMatrix; |
4121 const double initialChildScale = 1.25; | 4121 const double initialChildScale = 1.25; |
4122 childScaleMatrix.scale(initialChildScale); | 4122 childScaleMatrix.PreconcatScale(initialChildScale, initialChildScale); |
4123 | 4123 |
4124 float fixedRasterScale = 2.5; | 4124 float fixedRasterScale = 2.5; |
4125 | 4125 |
4126 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); | 4126 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
4127 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); | 4127 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); |
4128 | 4128 |
4129 scoped_refptr<ContentLayer> childScale = createDrawableContentLayer(&delegat e); | 4129 scoped_refptr<ContentLayer> childScale = createDrawableContentLayer(&delegat e); |
4130 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 4130 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
4131 | 4131 |
4132 scoped_refptr<ContentLayer> childEmpty = createDrawableContentLayer(&delegat e); | 4132 scoped_refptr<ContentLayer> childEmpty = createDrawableContentLayer(&delegat e); |
(...skipping 16 matching lines...) Expand all Loading... | |
4149 parent->addChild(childNoScale); | 4149 parent->addChild(childNoScale); |
4150 parent->addChild(childNoAutoScale); | 4150 parent->addChild(childNoAutoScale); |
4151 | 4151 |
4152 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4152 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
4153 int dummyMaxTextureSize = 512; | 4153 int dummyMaxTextureSize = 512; |
4154 | 4154 |
4155 double deviceScaleFactor = 2.5; | 4155 double deviceScaleFactor = 2.5; |
4156 double pageScaleFactor = 1.5; | 4156 double pageScaleFactor = 1.5; |
4157 | 4157 |
4158 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 4158 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
4159 WebTransformationMatrix pageScaleMatrix; | 4159 Transform pageScaleMatrix; |
4160 pageScaleMatrix.scale(pageScaleFactor); | 4160 pageScaleMatrix.PreconcatScale(pageScaleFactor, pageScaleFactor); |
4161 parent->setSublayerTransform(pageScaleMatrix); | 4161 parent->setSublayerTransform(pageScaleMatrix); |
4162 | 4162 |
4163 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); | 4163 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); |
4164 | 4164 |
4165 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4165 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
4166 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childScale); | 4166 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childScale); |
4167 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childEmpty); | 4167 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childEmpty); |
4168 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 4168 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
4169 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc ale, childNoAutoScale); | 4169 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc ale, childNoAutoScale); |
4170 | 4170 |
4171 // The parent is scaled up and shouldn't need to scale during draw. The chil d that can scale its contents should | 4171 // The parent is scaled up and shouldn't need to scale during draw. The chil d that can scale its contents should |
4172 // also not need to scale during draw. This shouldn't change if the child ha s empty bounds. The other children should. | 4172 // also not need to scale during draw. This shouldn't change if the child ha s empty bounds. The other children should. |
4173 EXPECT_FLOAT_EQ(1, parent->drawTransform().m11()); | 4173 EXPECT_FLOAT_EQ(1, parent->drawTransform().matrix().getDouble(0, 0)); |
4174 EXPECT_FLOAT_EQ(1, parent->drawTransform().m22()); | 4174 EXPECT_FLOAT_EQ(1, parent->drawTransform().matrix().getDouble(1, 1)); |
4175 EXPECT_FLOAT_EQ(1, childScale->drawTransform().m11()); | 4175 EXPECT_FLOAT_EQ(1, childScale->drawTransform().matrix().getDouble(0, 0)); |
4176 EXPECT_FLOAT_EQ(1, childScale->drawTransform().m22()); | 4176 EXPECT_FLOAT_EQ(1, childScale->drawTransform().matrix().getDouble(1, 1)); |
4177 EXPECT_FLOAT_EQ(1, childEmpty->drawTransform().m11()); | 4177 EXPECT_FLOAT_EQ(1, childEmpty->drawTransform().matrix().getDouble(0, 0)); |
4178 EXPECT_FLOAT_EQ(1, childEmpty->drawTransform().m22()); | 4178 EXPECT_FLOAT_EQ(1, childEmpty->drawTransform().matrix().getDouble(1, 1)); |
4179 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale, childNoScale->drawTransform().m11()); | 4179 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale, childNoScale->drawTransform().matrix().getDouble(0, 0)); |
4180 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale, childNoScale->drawTransform().m22()); | 4180 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale, childNoScale->drawTransform().matrix().getDouble(1, 1)); |
4181 EXPECT_FLOAT_EQ(initialParentScale * initialChildScale / fixedRasterScale, c hildNoAutoScale->drawTransform().m11()); | 4181 EXPECT_FLOAT_EQ(initialParentScale * initialChildScale / fixedRasterScale, c hildNoAutoScale->drawTransform().matrix().getDouble(0, 0)); |
4182 EXPECT_FLOAT_EQ(initialParentScale * initialChildScale / fixedRasterScale, c hildNoAutoScale->drawTransform().m22()); | 4182 EXPECT_FLOAT_EQ(initialParentScale * initialChildScale / fixedRasterScale, c hildNoAutoScale->drawTransform().matrix().getDouble(1, 1)); |
4183 | 4183 |
4184 // If the transform changes, we expect the contentsScale to remain unchanged . | 4184 // If the transform changes, we expect the contentsScale to remain unchanged . |
4185 childScale->setTransform(identityMatrix); | 4185 childScale->setTransform(identityMatrix); |
4186 childEmpty->setTransform(identityMatrix); | 4186 childEmpty->setTransform(identityMatrix); |
4187 | 4187 |
4188 renderSurfaceLayerList.clear(); | 4188 renderSurfaceLayerList.clear(); |
4189 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); | 4189 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); |
4190 | 4190 |
4191 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4191 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
4192 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childScale); | 4192 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childScale); |
4193 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childEmpty); | 4193 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childEmpty); |
4194 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 4194 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
4195 | 4195 |
4196 // But if the deviceScaleFactor or pageScaleFactor changes, then it should b e updated, but using the initial transform. | 4196 // But if the deviceScaleFactor or pageScaleFactor changes, then it should b e updated, but using the initial transform. |
4197 deviceScaleFactor = 2.25; | 4197 deviceScaleFactor = 2.25; |
4198 pageScaleFactor = 1.25; | 4198 pageScaleFactor = 1.25; |
4199 | 4199 |
4200 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 4200 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
4201 pageScaleMatrix = identityMatrix; | 4201 pageScaleMatrix = identityMatrix; |
4202 pageScaleMatrix.scale(pageScaleFactor); | 4202 pageScaleMatrix.PreconcatScale(pageScaleFactor, pageScaleFactor); |
4203 parent->setSublayerTransform(pageScaleMatrix); | 4203 parent->setSublayerTransform(pageScaleMatrix); |
4204 | 4204 |
4205 renderSurfaceLayerList.clear(); | 4205 renderSurfaceLayerList.clear(); |
4206 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); | 4206 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); |
4207 | 4207 |
4208 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4208 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
4209 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childScale); | 4209 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childScale); |
4210 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childEmpty); | 4210 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, childEmpty); |
4211 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 4211 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
4212 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc ale, childNoAutoScale); | 4212 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc ale, childNoAutoScale); |
4213 } | 4213 } |
4214 | 4214 |
4215 TEST(LayerTreeHostCommonTest, verifySmallContentsScale) | 4215 TEST(LayerTreeHostCommonTest, verifySmallContentsScale) |
4216 { | 4216 { |
4217 MockContentLayerClient delegate; | 4217 MockContentLayerClient delegate; |
4218 WebTransformationMatrix identityMatrix; | 4218 Transform identityMatrix; |
4219 | 4219 |
4220 WebTransformationMatrix parentScaleMatrix; | 4220 Transform parentScaleMatrix; |
4221 const double initialParentScale = 1.75; | 4221 const double initialParentScale = 1.75; |
4222 parentScaleMatrix.scale(initialParentScale); | 4222 parentScaleMatrix.PreconcatScale(initialParentScale, initialParentScale); |
4223 | 4223 |
4224 WebTransformationMatrix childScaleMatrix; | 4224 Transform childScaleMatrix; |
4225 const double initialChildScale = 0.25; | 4225 const double initialChildScale = 0.25; |
4226 childScaleMatrix.scale(initialChildScale); | 4226 childScaleMatrix.PreconcatScale(initialChildScale, initialChildScale); |
4227 | 4227 |
4228 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); | 4228 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
4229 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); | 4229 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); |
4230 | 4230 |
4231 scoped_refptr<ContentLayer> childScale = createDrawableContentLayer(&delegat e); | 4231 scoped_refptr<ContentLayer> childScale = createDrawableContentLayer(&delegat e); |
4232 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 4232 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
4233 | 4233 |
4234 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 4234 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
4235 // Page scale should not apply to the parent. | 4235 // Page scale should not apply to the parent. |
4236 parent->setBoundsContainPageScale(true); | 4236 parent->setBoundsContainPageScale(true); |
4237 | 4237 |
4238 parent->addChild(childScale); | 4238 parent->addChild(childScale); |
4239 | 4239 |
4240 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4240 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
4241 int dummyMaxTextureSize = 512; | 4241 int dummyMaxTextureSize = 512; |
4242 | 4242 |
4243 double deviceScaleFactor = 2.5; | 4243 double deviceScaleFactor = 2.5; |
4244 double pageScaleFactor = 0.01; | 4244 double pageScaleFactor = 0.01; |
4245 | 4245 |
4246 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 4246 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
4247 WebTransformationMatrix pageScaleMatrix; | 4247 Transform pageScaleMatrix; |
4248 pageScaleMatrix.scale(pageScaleFactor); | 4248 pageScaleMatrix.PreconcatScale(pageScaleFactor, pageScaleFactor); |
4249 parent->setSublayerTransform(pageScaleMatrix); | 4249 parent->setSublayerTransform(pageScaleMatrix); |
4250 | 4250 |
4251 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); | 4251 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); |
4252 | 4252 |
4253 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4253 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
4254 // The child's scale is < 1, so we should not save and use that scale factor . | 4254 // The child's scale is < 1, so we should not save and use that scale factor . |
4255 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * 1, childScale ); | 4255 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * 1, childScale ); |
4256 | 4256 |
4257 // When chilld's total scale becomes >= 1, we should save and use that scale factor. | 4257 // When chilld's total scale becomes >= 1, we should save and use that scale factor. |
4258 childScaleMatrix.makeIdentity(); | 4258 childScaleMatrix.matrix().setIdentity(); |
4259 const double finalChildScale = 0.75; | 4259 const double finalChildScale = 0.75; |
4260 childScaleMatrix.scale(finalChildScale); | 4260 childScaleMatrix.PreconcatScale(finalChildScale, finalChildScale); |
4261 childScale->setTransform(childScaleMatrix); | 4261 childScale->setTransform(childScaleMatrix); |
4262 | 4262 |
4263 renderSurfaceLayerList.clear(); | 4263 renderSurfaceLayerList.clear(); |
4264 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); | 4264 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); |
4265 | 4265 |
4266 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4266 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
4267 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * finalChildScale, childScale); | 4267 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * finalChildScale, childScale); |
4268 } | 4268 } |
4269 | 4269 |
4270 TEST(LayerTreeHostCommonTest, verifyContentsScaleForSurfaces) | 4270 TEST(LayerTreeHostCommonTest, verifyContentsScaleForSurfaces) |
4271 { | 4271 { |
4272 MockContentLayerClient delegate; | 4272 MockContentLayerClient delegate; |
4273 WebTransformationMatrix identityMatrix; | 4273 Transform identityMatrix; |
4274 | 4274 |
4275 WebTransformationMatrix parentScaleMatrix; | 4275 Transform parentScaleMatrix; |
4276 const double initialParentScale = 2; | 4276 const double initialParentScale = 2; |
4277 parentScaleMatrix.scale(initialParentScale); | 4277 parentScaleMatrix.PreconcatScale(initialParentScale, initialParentScale); |
4278 | 4278 |
4279 WebTransformationMatrix childScaleMatrix; | 4279 Transform childScaleMatrix; |
4280 const double initialChildScale = 3; | 4280 const double initialChildScale = 3; |
4281 childScaleMatrix.scale(initialChildScale); | 4281 childScaleMatrix.PreconcatScale(initialChildScale, initialChildScale); |
4282 | 4282 |
4283 float fixedRasterScale = 4; | 4283 float fixedRasterScale = 4; |
4284 | 4284 |
4285 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); | 4285 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
4286 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); | 4286 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); |
4287 | 4287 |
4288 scoped_refptr<ContentLayer> surfaceScale = createDrawableContentLayer(&deleg ate); | 4288 scoped_refptr<ContentLayer> surfaceScale = createDrawableContentLayer(&deleg ate); |
4289 setLayerPropertiesForTesting(surfaceScale.get(), childScaleMatrix, identityM atrix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 4289 setLayerPropertiesForTesting(surfaceScale.get(), childScaleMatrix, identityM atrix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
4290 | 4290 |
4291 scoped_refptr<ContentLayer> surfaceScaleChildScale = createDrawableContentLa yer(&delegate); | 4291 scoped_refptr<ContentLayer> surfaceScaleChildScale = createDrawableContentLa yer(&delegate); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4334 surfaceNoAutoScale->addChild(surfaceNoAutoScaleChildScale); | 4334 surfaceNoAutoScale->addChild(surfaceNoAutoScaleChildScale); |
4335 surfaceNoAutoScale->addChild(surfaceNoAutoScaleChildNoScale); | 4335 surfaceNoAutoScale->addChild(surfaceNoAutoScaleChildNoScale); |
4336 | 4336 |
4337 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4337 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
4338 int dummyMaxTextureSize = 512; | 4338 int dummyMaxTextureSize = 512; |
4339 | 4339 |
4340 double deviceScaleFactor = 5; | 4340 double deviceScaleFactor = 5; |
4341 double pageScaleFactor = 7; | 4341 double pageScaleFactor = 7; |
4342 | 4342 |
4343 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 4343 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
4344 WebTransformationMatrix pageScaleMatrix; | 4344 Transform pageScaleMatrix; |
4345 pageScaleMatrix.scale(pageScaleFactor); | 4345 pageScaleMatrix.PreconcatScale(pageScaleFactor, pageScaleFactor); |
4346 parent->setSublayerTransform(pageScaleMatrix); | 4346 parent->setSublayerTransform(pageScaleMatrix); |
4347 | 4347 |
4348 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); | 4348 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList ); |
4349 | 4349 |
4350 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4350 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
4351 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, surfaceScale); | 4351 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale, surfaceScale); |
4352 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScale); | 4352 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScale); |
4353 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc ale, surfaceNoAutoScale); | 4353 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc ale, surfaceNoAutoScale); |
4354 | 4354 |
4355 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale * initialChildScale, surfaceScaleChildScale); | 4355 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale * initialChildScale, surfaceScaleChildScale); |
4356 EXPECT_CONTENTS_SCALE_EQ(1, surfaceScaleChildNoScale); | 4356 EXPECT_CONTENTS_SCALE_EQ(1, surfaceScaleChildNoScale); |
4357 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale * initialChildScale, surfaceNoScaleChildScale); | 4357 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale * initialChildScale, surfaceNoScaleChildScale); |
4358 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScaleChildNoScale); | 4358 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScaleChildNoScale); |
4359 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale * initialChildScale, surfaceNoAutoScaleChildScale); | 4359 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent Scale * initialChildScale * initialChildScale, surfaceNoAutoScaleChildScale); |
4360 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoAutoScaleChildNoScale); | 4360 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoAutoScaleChildNoScale); |
4361 | 4361 |
4362 // The parent is scaled up and shouldn't need to scale during draw. | 4362 // The parent is scaled up and shouldn't need to scale during draw. |
4363 EXPECT_FLOAT_EQ(1, parent->drawTransform().m11()); | 4363 EXPECT_FLOAT_EQ(1, parent->drawTransform().matrix().getDouble(0, 0)); |
4364 EXPECT_FLOAT_EQ(1, parent->drawTransform().m22()); | 4364 EXPECT_FLOAT_EQ(1, parent->drawTransform().matrix().getDouble(1, 1)); |
4365 | 4365 |
4366 // RenderSurfaces should always be 1:1 with their target. | 4366 // RenderSurfaces should always be 1:1 with their target. |
4367 EXPECT_FLOAT_EQ(1, surfaceScale->renderSurface()->drawTransform().m11()); | 4367 EXPECT_FLOAT_EQ(1, surfaceScale->renderSurface()->drawTransform().matrix().g etDouble(0, 0)); |
4368 EXPECT_FLOAT_EQ(1, surfaceScale->renderSurface()->drawTransform().m22()); | 4368 EXPECT_FLOAT_EQ(1, surfaceScale->renderSurface()->drawTransform().matrix().g etDouble(1, 1)); |
4369 | 4369 |
4370 // The surfaceScale can apply contents scale so the layer shouldn't need to scale during draw. | 4370 // The surfaceScale can apply contents scale so the layer shouldn't need to scale during draw. |
4371 EXPECT_FLOAT_EQ(1, surfaceScale->drawTransform().m11()); | 4371 EXPECT_FLOAT_EQ(1, surfaceScale->drawTransform().matrix().getDouble(0, 0)); |
4372 EXPECT_FLOAT_EQ(1, surfaceScale->drawTransform().m22()); | 4372 EXPECT_FLOAT_EQ(1, surfaceScale->drawTransform().matrix().getDouble(1, 1)); |
4373 | 4373 |
4374 // The surfaceScaleChildScale can apply contents scale so it shouldn't need to scale during draw. | 4374 // The surfaceScaleChildScale can apply contents scale so it shouldn't need to scale during draw. |
4375 EXPECT_FLOAT_EQ(1, surfaceScaleChildScale->drawTransform().m11()); | 4375 EXPECT_FLOAT_EQ(1, surfaceScaleChildScale->drawTransform().matrix().getDoubl e(0, 0)); |
4376 EXPECT_FLOAT_EQ(1, surfaceScaleChildScale->drawTransform().m22()); | 4376 EXPECT_FLOAT_EQ(1, surfaceScaleChildScale->drawTransform().matrix().getDoubl e(1, 1)); |
4377 | 4377 |
4378 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to be scaled during draw. | 4378 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to be scaled during draw. |
4379 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale * initialChildScale, surfaceScaleChildNoScale->drawTransform(). m11()); | 4379 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale * initialChildScale, surfaceScaleChildNoScale->drawTransform(). matrix().getDouble(0, 0)); |
4380 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale * initialChildScale, surfaceScaleChildNoScale->drawTransform(). m22()); | 4380 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale * initialChildScale, surfaceScaleChildNoScale->drawTransform(). matrix().getDouble(1, 1)); |
4381 | 4381 |
4382 // RenderSurfaces should always be 1:1 with their target. | 4382 // RenderSurfaces should always be 1:1 with their target. |
4383 EXPECT_FLOAT_EQ(1, surfaceNoScale->renderSurface()->drawTransform().m11()); | 4383 EXPECT_FLOAT_EQ(1, surfaceNoScale->renderSurface()->drawTransform().matrix() .getDouble(0, 0)); |
4384 EXPECT_FLOAT_EQ(1, surfaceNoScale->renderSurface()->drawTransform().m22()); | 4384 EXPECT_FLOAT_EQ(1, surfaceNoScale->renderSurface()->drawTransform().matrix() .getDouble(1, 1)); |
4385 | 4385 |
4386 // The surfaceNoScale layer can not apply contents scale, so it needs to be scaled during draw. | 4386 // The surfaceNoScale layer can not apply contents scale, so it needs to be scaled during draw. |
4387 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale, surfaceNoScale->drawTransform().m11()); | 4387 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale, surfaceNoScale->drawTransform().matrix().getDouble(0, 0)); |
4388 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale, surfaceNoScale->drawTransform().m22()); | 4388 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale, surfaceNoScale->drawTransform().matrix().getDouble(1, 1)); |
4389 | 4389 |
4390 // The surfaceScaleChildScale can apply contents scale so it shouldn't need to scale during draw. | 4390 // The surfaceScaleChildScale can apply contents scale so it shouldn't need to scale during draw. |
4391 EXPECT_FLOAT_EQ(1, surfaceNoScaleChildScale->drawTransform().m11()); | 4391 EXPECT_FLOAT_EQ(1, surfaceNoScaleChildScale->drawTransform().matrix().getDou ble(0, 0)); |
4392 EXPECT_FLOAT_EQ(1, surfaceNoScaleChildScale->drawTransform().m22()); | 4392 EXPECT_FLOAT_EQ(1, surfaceNoScaleChildScale->drawTransform().matrix().getDou ble(1, 1)); |
4393 | 4393 |
4394 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to be scaled during draw. | 4394 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to be scaled during draw. |
4395 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale * initialChildScale, surfaceNoScaleChildNoScale->drawTransform( ).m11()); | 4395 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale * initialChildScale, surfaceNoScaleChildNoScale->drawTransform( ).matrix().getDouble(0, 0)); |
4396 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale * initialChildScale, surfaceNoScaleChildNoScale->drawTransform( ).m22()); | 4396 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale * initialChildScale, surfaceNoScaleChildNoScale->drawTransform( ).matrix().getDouble(1, 1)); |
4397 | 4397 |
4398 // RenderSurfaces should always be 1:1 with their target. | 4398 // RenderSurfaces should always be 1:1 with their target. |
4399 EXPECT_FLOAT_EQ(1, surfaceNoAutoScale->renderSurface()->drawTransform().m11( )); | 4399 EXPECT_FLOAT_EQ(1, surfaceNoAutoScale->renderSurface()->drawTransform().matr ix().getDouble(0, 0)); |
4400 EXPECT_FLOAT_EQ(1, surfaceNoAutoScale->renderSurface()->drawTransform().m22( )); | 4400 EXPECT_FLOAT_EQ(1, surfaceNoAutoScale->renderSurface()->drawTransform().matr ix().getDouble(1, 1)); |
4401 | 4401 |
4402 // The surfaceNoAutoScale layer has a fixed contents scale, so it needs to b e scaled during draw. | 4402 // The surfaceNoAutoScale layer has a fixed contents scale, so it needs to b e scaled during draw. |
4403 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale / (deviceScaleFactor * pageScaleFactor * fixedRasterScale), sur faceNoAutoScale->drawTransform().m11()); | 4403 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale / (deviceScaleFactor * pageScaleFactor * fixedRasterScale), sur faceNoAutoScale->drawTransform().matrix().getDouble(0, 0)); |
4404 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale / (deviceScaleFactor * pageScaleFactor * fixedRasterScale), sur faceNoAutoScale->drawTransform().m22()); | 4404 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale / (deviceScaleFactor * pageScaleFactor * fixedRasterScale), sur faceNoAutoScale->drawTransform().matrix().getDouble(1, 1)); |
4405 | 4405 |
4406 // The surfaceScaleChildScale can apply contents scale so it shouldn't need to scale during draw. | 4406 // The surfaceScaleChildScale can apply contents scale so it shouldn't need to scale during draw. |
4407 EXPECT_FLOAT_EQ(1, surfaceNoAutoScaleChildScale->drawTransform().m11()); | 4407 EXPECT_FLOAT_EQ(1, surfaceNoAutoScaleChildScale->drawTransform().matrix().ge tDouble(0, 0)); |
4408 EXPECT_FLOAT_EQ(1, surfaceNoAutoScaleChildScale->drawTransform().m22()); | 4408 EXPECT_FLOAT_EQ(1, surfaceNoAutoScaleChildScale->drawTransform().matrix().ge tDouble(1, 1)); |
4409 | 4409 |
4410 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to be scaled during draw. | 4410 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to be scaled during draw. |
4411 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale * initialChildScale, surfaceNoAutoScaleChildNoScale->drawTransf orm().m11()); | 4411 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale * initialChildScale, surfaceNoAutoScaleChildNoScale->drawTransf orm().matrix().getDouble(0, 0)); |
4412 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale * initialChildScale, surfaceNoAutoScaleChildNoScale->drawTransf orm().m22()); | 4412 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i nitialChildScale * initialChildScale, surfaceNoAutoScaleChildNoScale->drawTransf orm().matrix().getDouble(1, 1)); |
4413 } | 4413 } |
4414 | 4414 |
4415 TEST(LayerTreeHostCommonTest, verifyContentsScaleForAnimatingLayer) | 4415 TEST(LayerTreeHostCommonTest, verifyContentsScaleForAnimatingLayer) |
4416 { | 4416 { |
4417 MockContentLayerClient delegate; | 4417 MockContentLayerClient delegate; |
4418 WebTransformationMatrix identityMatrix; | 4418 Transform identityMatrix; |
4419 | 4419 |
4420 WebTransformationMatrix parentScaleMatrix; | 4420 Transform parentScaleMatrix; |
4421 const double initialParentScale = 1.75; | 4421 const double initialParentScale = 1.75; |
4422 parentScaleMatrix.scale(initialParentScale); | 4422 parentScaleMatrix.PreconcatScale(initialParentScale, initialParentScale); |
4423 | 4423 |
4424 WebTransformationMatrix childScaleMatrix; | 4424 Transform childScaleMatrix; |
4425 const double initialChildScale = 1.25; | 4425 const double initialChildScale = 1.25; |
4426 childScaleMatrix.scale(initialChildScale); | 4426 childScaleMatrix.PreconcatScale(initialChildScale, initialChildScale); |
4427 | 4427 |
4428 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); | 4428 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
4429 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); | 4429 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); |
4430 | 4430 |
4431 scoped_refptr<ContentLayer> childScale = createDrawableContentLayer(&delegat e); | 4431 scoped_refptr<ContentLayer> childScale = createDrawableContentLayer(&delegat e); |
4432 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 4432 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
4433 | 4433 |
4434 parent->addChild(childScale); | 4434 parent->addChild(childScale); |
4435 | 4435 |
4436 // Now put an animating transform on child. | 4436 // Now put an animating transform on child. |
(...skipping 15 matching lines...) Expand all Loading... | |
4452 | 4452 |
4453 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent); | 4453 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent); |
4454 // The layers with animating transforms should not compute a contentsScale o ther than 1 until they finish animating. | 4454 // The layers with animating transforms should not compute a contentsScale o ther than 1 until they finish animating. |
4455 EXPECT_CONTENTS_SCALE_EQ(initialParentScale * initialChildScale, childScale) ; | 4455 EXPECT_CONTENTS_SCALE_EQ(initialParentScale * initialChildScale, childScale) ; |
4456 } | 4456 } |
4457 | 4457 |
4458 | 4458 |
4459 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI) | 4459 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI) |
4460 { | 4460 { |
4461 MockContentLayerClient delegate; | 4461 MockContentLayerClient delegate; |
4462 WebTransformationMatrix identityMatrix; | 4462 Transform identityMatrix; |
4463 | 4463 |
4464 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); | 4464 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
4465 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(30, 30), true); | 4465 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(30, 30), true); |
4466 | 4466 |
4467 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); | 4467 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); |
4468 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 4468 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
4469 | 4469 |
4470 WebTransformationMatrix replicaTransform; | 4470 Transform replicaTransform; |
4471 replicaTransform.scaleNonUniform(1, -1); | 4471 replicaTransform.PreconcatScale(1, -1); |
4472 scoped_refptr<ContentLayer> replica = createDrawableContentLayer(&delegate); | 4472 scoped_refptr<ContentLayer> replica = createDrawableContentLayer(&delegate); |
4473 setLayerPropertiesForTesting(replica.get(), replicaTransform, identityMatrix , gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 4473 setLayerPropertiesForTesting(replica.get(), replicaTransform, identityMatrix , gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
4474 | 4474 |
4475 // This layer should end up in the same surface as child, with the same draw | 4475 // This layer should end up in the same surface as child, with the same draw |
4476 // and screen space transforms. | 4476 // and screen space transforms. |
4477 scoped_refptr<ContentLayer> duplicateChildNonOwner = createDrawableContentLa yer(&delegate); | 4477 scoped_refptr<ContentLayer> duplicateChildNonOwner = createDrawableContentLa yer(&delegate); |
4478 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i dentityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), true); | 4478 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i dentityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), true); |
4479 | 4479 |
4480 parent->addChild(child); | 4480 parent->addChild(child); |
4481 child->addChild(duplicateChildNonOwner); | 4481 child->addChild(duplicateChildNonOwner); |
4482 child->setReplicaLayer(replica.get()); | 4482 child->setReplicaLayer(replica.get()); |
4483 | 4483 |
4484 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4484 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
4485 int dummyMaxTextureSize = 512; | 4485 int dummyMaxTextureSize = 512; |
4486 | 4486 |
4487 const double deviceScaleFactor = 1.5; | 4487 const double deviceScaleFactor = 1.5; |
4488 parent->setContentsScale(deviceScaleFactor); | 4488 parent->setContentsScale(deviceScaleFactor); |
4489 child->setContentsScale(deviceScaleFactor); | 4489 child->setContentsScale(deviceScaleFactor); |
4490 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); | 4490 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); |
4491 replica->setContentsScale(deviceScaleFactor); | 4491 replica->setContentsScale(deviceScaleFactor); |
4492 | 4492 |
4493 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 4493 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
4494 | 4494 |
4495 // We should have two render surfaces. The root's render surface and child's | 4495 // We should have two render surfaces. The root's render surface and child's |
4496 // render surface (it needs one because it has a replica layer). | 4496 // render surface (it needs one because it has a replica layer). |
4497 EXPECT_EQ(2u, renderSurfaceLayerList.size()); | 4497 EXPECT_EQ(2u, renderSurfaceLayerList.size()); |
4498 | 4498 |
4499 WebTransformationMatrix expectedParentTransform; | 4499 Transform expectedParentTransform; |
4500 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace Transform()); | 4500 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace Transform()); |
4501 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo rm()); | 4501 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo rm()); |
4502 | 4502 |
4503 WebTransformationMatrix expectedDrawTransform; | 4503 Transform expectedDrawTransform; |
4504 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedDrawTransform, child->drawTransform( )); | 4504 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedDrawTransform, child->drawTransform( )); |
4505 | 4505 |
4506 WebTransformationMatrix expectedScreenSpaceTransform; | 4506 Transform expectedScreenSpaceTransform; |
4507 expectedScreenSpaceTransform.translate(deviceScaleFactor * child->position() .x(), deviceScaleFactor * child->position().y()); | 4507 expectedScreenSpaceTransform.PreconcatTranslate(deviceScaleFactor * child->p osition().x(), deviceScaleFactor * child->position().y()); |
4508 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedScreenSpaceTransform, child->screenS paceTransform()); | 4508 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedScreenSpaceTransform, child->screenS paceTransform()); |
4509 | 4509 |
4510 WebTransformationMatrix expectedDuplicateChildDrawTransform = child->drawTra nsform(); | 4510 Transform expectedDuplicateChildDrawTransform = child->drawTransform(); |
4511 EXPECT_TRANSFORMATION_MATRIX_EQ(child->drawTransform(), duplicateChildNonOwn er->drawTransform()); | 4511 EXPECT_TRANSFORMATION_MATRIX_EQ(child->drawTransform(), duplicateChildNonOwn er->drawTransform()); |
4512 EXPECT_TRANSFORMATION_MATRIX_EQ(child->screenSpaceTransform(), duplicateChil dNonOwner->screenSpaceTransform()); | 4512 EXPECT_TRANSFORMATION_MATRIX_EQ(child->screenSpaceTransform(), duplicateChil dNonOwner->screenSpaceTransform()); |
4513 EXPECT_RECT_EQ(child->drawableContentRect(), duplicateChildNonOwner->drawabl eContentRect()); | 4513 EXPECT_RECT_EQ(child->drawableContentRect(), duplicateChildNonOwner->drawabl eContentRect()); |
4514 EXPECT_EQ(child->contentBounds(), duplicateChildNonOwner->contentBounds()); | 4514 EXPECT_EQ(child->contentBounds(), duplicateChildNonOwner->contentBounds()); |
4515 | 4515 |
4516 WebTransformationMatrix expectedRenderSurfaceDrawTransform; | 4516 Transform expectedRenderSurfaceDrawTransform; |
4517 expectedRenderSurfaceDrawTransform.translate(deviceScaleFactor * child->posi tion().x(), deviceScaleFactor * child->position().y()); | 4517 expectedRenderSurfaceDrawTransform.PreconcatTranslate(deviceScaleFactor * ch ild->position().x(), deviceScaleFactor * child->position().y()); |
4518 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedRenderSurfaceDrawTransform, child->r enderSurface()->drawTransform()); | 4518 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedRenderSurfaceDrawTransform, child->r enderSurface()->drawTransform()); |
4519 | 4519 |
4520 WebTransformationMatrix expectedSurfaceDrawTransform; | 4520 Transform expectedSurfaceDrawTransform; |
4521 expectedSurfaceDrawTransform.translate(deviceScaleFactor * 2, deviceScaleFac tor * 2); | 4521 expectedSurfaceDrawTransform.PreconcatTranslate(deviceScaleFactor * 2, devic eScaleFactor * 2); |
4522 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderS urface()->drawTransform()); | 4522 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderS urface()->drawTransform()); |
4523 | 4523 |
4524 WebTransformationMatrix expectedSurfaceScreenSpaceTransform; | 4524 Transform expectedSurfaceScreenSpaceTransform; |
4525 expectedSurfaceScreenSpaceTransform.translate(deviceScaleFactor * 2, deviceS caleFactor * 2); | 4525 expectedSurfaceScreenSpaceTransform.PreconcatTranslate(deviceScaleFactor * 2 , deviceScaleFactor * 2); |
4526 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceScreenSpaceTransform, child-> renderSurface()->screenSpaceTransform()); | 4526 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceScreenSpaceTransform, child-> renderSurface()->screenSpaceTransform()); |
4527 | 4527 |
4528 WebTransformationMatrix expectedReplicaDrawTransform; | 4528 Transform expectedReplicaDrawTransform; |
4529 expectedReplicaDrawTransform.setM22(-1); | 4529 expectedReplicaDrawTransform.matrix().setDouble(1, 1, -1); |
4530 expectedReplicaDrawTransform.setM41(6); | 4530 expectedReplicaDrawTransform.matrix().setDouble(0, 3, 6); |
4531 expectedReplicaDrawTransform.setM42(6); | 4531 expectedReplicaDrawTransform.matrix().setDouble(1, 3, 6); |
4532 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaDrawTransform, child->renderS urface()->replicaDrawTransform()); | 4532 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaDrawTransform, child->renderS urface()->replicaDrawTransform()); |
4533 | 4533 |
4534 WebTransformationMatrix expectedReplicaScreenSpaceTransform; | 4534 Transform expectedReplicaScreenSpaceTransform; |
4535 expectedReplicaScreenSpaceTransform.setM22(-1); | 4535 expectedReplicaScreenSpaceTransform.matrix().setDouble(1, 1, -1); |
4536 expectedReplicaScreenSpaceTransform.setM41(6); | 4536 expectedReplicaScreenSpaceTransform.matrix().setDouble(0, 3, 6); |
4537 expectedReplicaScreenSpaceTransform.setM42(6); | 4537 expectedReplicaScreenSpaceTransform.matrix().setDouble(1, 3, 6); |
4538 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child-> renderSurface()->replicaScreenSpaceTransform()); | 4538 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child-> renderSurface()->replicaScreenSpaceTransform()); |
4539 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child-> renderSurface()->replicaScreenSpaceTransform()); | 4539 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child-> renderSurface()->replicaScreenSpaceTransform()); |
4540 } | 4540 } |
4541 | 4541 |
4542 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPIAccurateScal eZeroPosition) | 4542 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPIAccurateScal eZeroPosition) |
4543 { | 4543 { |
4544 MockContentLayerClient delegate; | 4544 MockContentLayerClient delegate; |
4545 WebTransformationMatrix identityMatrix; | 4545 Transform identityMatrix; |
4546 | 4546 |
4547 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); | 4547 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
4548 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(33, 31), true); | 4548 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(33, 31), true); |
4549 | 4549 |
4550 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); | 4550 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); |
4551 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true); | 4551 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true); |
4552 | 4552 |
4553 WebTransformationMatrix replicaTransform; | 4553 Transform replicaTransform; |
4554 replicaTransform.scaleNonUniform(1, -1); | 4554 replicaTransform.PreconcatScale(1, -1); |
4555 scoped_refptr<ContentLayer> replica = createDrawableContentLayer(&delegate); | 4555 scoped_refptr<ContentLayer> replica = createDrawableContentLayer(&delegate); |
4556 setLayerPropertiesForTesting(replica.get(), replicaTransform, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true); | 4556 setLayerPropertiesForTesting(replica.get(), replicaTransform, identityMatrix , gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true); |
4557 | 4557 |
4558 // This layer should end up in the same surface as child, with the same draw | 4558 // This layer should end up in the same surface as child, with the same draw |
4559 // and screen space transforms. | 4559 // and screen space transforms. |
4560 scoped_refptr<ContentLayer> duplicateChildNonOwner = createDrawableContentLa yer(&delegate); | 4560 scoped_refptr<ContentLayer> duplicateChildNonOwner = createDrawableContentLa yer(&delegate); |
4561 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i dentityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true); | 4561 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i dentityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true); |
4562 | 4562 |
4563 parent->addChild(child); | 4563 parent->addChild(child); |
4564 child->addChild(duplicateChildNonOwner); | 4564 child->addChild(duplicateChildNonOwner); |
4565 child->setReplicaLayer(replica.get()); | 4565 child->setReplicaLayer(replica.get()); |
4566 | 4566 |
4567 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4567 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
4568 int dummyMaxTextureSize = 512; | 4568 int dummyMaxTextureSize = 512; |
4569 | 4569 |
4570 const float deviceScaleFactor = 1.7f; | 4570 const float deviceScaleFactor = 1.7f; |
4571 parent->setContentsScale(deviceScaleFactor); | 4571 parent->setContentsScale(deviceScaleFactor); |
4572 child->setContentsScale(deviceScaleFactor); | 4572 child->setContentsScale(deviceScaleFactor); |
4573 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); | 4573 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); |
4574 replica->setContentsScale(deviceScaleFactor); | 4574 replica->setContentsScale(deviceScaleFactor); |
4575 | 4575 |
4576 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 4576 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
4577 | 4577 |
4578 // We should have two render surfaces. The root's render surface and child's | 4578 // We should have two render surfaces. The root's render surface and child's |
4579 // render surface (it needs one because it has a replica layer). | 4579 // render surface (it needs one because it has a replica layer). |
4580 EXPECT_EQ(2u, renderSurfaceLayerList.size()); | 4580 EXPECT_EQ(2u, renderSurfaceLayerList.size()); |
4581 | 4581 |
4582 WebTransformationMatrix identityTransform; | 4582 Transform identityTransform; |
4583 | 4583 |
4584 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->screenSpaceTransf orm()); | 4584 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->screenSpaceTransf orm()); |
4585 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->drawTransform()); | 4585 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->drawTransform()); |
4586 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->drawTransform()); | 4586 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->drawTransform()); |
4587 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->screenSpaceTransfo rm()); | 4587 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->screenSpaceTransfo rm()); |
4588 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, duplicateChildNonOwner->d rawTransform()); | 4588 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, duplicateChildNonOwner->d rawTransform()); |
4589 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, duplicateChildNonOwner->s creenSpaceTransform()); | 4589 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, duplicateChildNonOwner->s creenSpaceTransform()); |
4590 EXPECT_RECT_EQ(child->drawableContentRect(), duplicateChildNonOwner->drawabl eContentRect()); | 4590 EXPECT_RECT_EQ(child->drawableContentRect(), duplicateChildNonOwner->drawabl eContentRect()); |
4591 EXPECT_EQ(child->contentBounds(), duplicateChildNonOwner->contentBounds()); | 4591 EXPECT_EQ(child->contentBounds(), duplicateChildNonOwner->contentBounds()); |
4592 | 4592 |
4593 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->renderSurface()->d rawTransform()); | 4593 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->renderSurface()->d rawTransform()); |
4594 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->renderSurface()->d rawTransform()); | 4594 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->renderSurface()->d rawTransform()); |
4595 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->renderSurface()->s creenSpaceTransform()); | 4595 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->renderSurface()->s creenSpaceTransform()); |
4596 | 4596 |
4597 WebTransformationMatrix expectedReplicaDrawTransform; | 4597 Transform expectedReplicaDrawTransform; |
4598 expectedReplicaDrawTransform.setM22(-1); | 4598 expectedReplicaDrawTransform.matrix().setDouble(1, 1, -1); |
4599 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaDrawTransform, child->renderS urface()->replicaDrawTransform()); | 4599 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaDrawTransform, child->renderS urface()->replicaDrawTransform()); |
4600 | 4600 |
4601 WebTransformationMatrix expectedReplicaScreenSpaceTransform; | 4601 Transform expectedReplicaScreenSpaceTransform; |
4602 expectedReplicaScreenSpaceTransform.setM22(-1); | 4602 expectedReplicaScreenSpaceTransform.matrix().setDouble(1, 1, -1); |
4603 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child-> renderSurface()->replicaScreenSpaceTransform()); | 4603 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child-> renderSurface()->replicaScreenSpaceTransform()); |
4604 } | 4604 } |
4605 | 4605 |
4606 TEST(LayerTreeHostCommonTest, verifySubtreeSearch) | 4606 TEST(LayerTreeHostCommonTest, verifySubtreeSearch) |
4607 { | 4607 { |
4608 scoped_refptr<Layer> root = Layer::create(); | 4608 scoped_refptr<Layer> root = Layer::create(); |
4609 scoped_refptr<Layer> child = Layer::create(); | 4609 scoped_refptr<Layer> child = Layer::create(); |
4610 scoped_refptr<Layer> grandChild = Layer::create(); | 4610 scoped_refptr<Layer> grandChild = Layer::create(); |
4611 scoped_refptr<Layer> maskLayer = Layer::create(); | 4611 scoped_refptr<Layer> maskLayer = Layer::create(); |
4612 scoped_refptr<Layer> replicaLayer = Layer::create(); | 4612 scoped_refptr<Layer> replicaLayer = Layer::create(); |
4613 | 4613 |
4614 grandChild->setReplicaLayer(replicaLayer.get()); | 4614 grandChild->setReplicaLayer(replicaLayer.get()); |
4615 child->addChild(grandChild.get()); | 4615 child->addChild(grandChild.get()); |
4616 child->setMaskLayer(maskLayer.get()); | 4616 child->setMaskLayer(maskLayer.get()); |
4617 root->addChild(child.get()); | 4617 root->addChild(child.get()); |
4618 | 4618 |
4619 int nonexistentId = -1; | 4619 int nonexistentId = -1; |
4620 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id ())); | 4620 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id ())); |
4621 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child-> id())); | 4621 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child-> id())); |
4622 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr andChild->id())); | 4622 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr andChild->id())); |
4623 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas kLayer->id())); | 4623 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas kLayer->id())); |
4624 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), replicaLayer->id())); | 4624 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), replicaLayer->id())); |
4625 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent Id)); | 4625 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent Id)); |
4626 } | 4626 } |
4627 | 4627 |
4628 } // namespace | 4628 } // namespace |
4629 } // namespace cc | 4629 } // namespace cc |
OLD | NEW |