OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/layers/layer_utils.h" | 5 #include "cc/layers/layer_utils.h" |
6 | 6 |
7 #include "cc/animation/animation_host.h" | 7 #include "cc/animation/animation_host.h" |
8 #include "cc/animation/animation_id_provider.h" | 8 #include "cc/animation/animation_id_provider.h" |
9 #include "cc/animation/transform_operations.h" | 9 #include "cc/animation/transform_operations.h" |
10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
11 #include "cc/test/animation_test_common.h" | 11 #include "cc/test/animation_test_common.h" |
12 #include "cc/test/fake_impl_task_runner_provider.h" | 12 #include "cc/test/fake_impl_task_runner_provider.h" |
13 #include "cc/test/fake_layer_tree_host_impl.h" | 13 #include "cc/test/fake_layer_tree_host_impl.h" |
14 #include "cc/test/test_shared_bitmap_manager.h" | 14 #include "cc/test/test_shared_bitmap_manager.h" |
15 #include "cc/test/test_task_graph_runner.h" | 15 #include "cc/test/test_task_graph_runner.h" |
16 #include "cc/trees/layer_tree_host_common.h" | |
17 #include "cc/trees/layer_tree_impl.h" | 16 #include "cc/trees/layer_tree_impl.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "ui/gfx/geometry/box_f.h" | 18 #include "ui/gfx/geometry/box_f.h" |
20 #include "ui/gfx/test/gfx_util.h" | 19 #include "ui/gfx/test/gfx_util.h" |
21 | 20 |
22 namespace cc { | 21 namespace cc { |
23 namespace { | 22 namespace { |
24 | 23 |
25 float diagonal(float width, float height) { | 24 float diagonal(float width, float height) { |
26 return std::sqrt(width * width + height * height); | 25 return std::sqrt(width * width + height * height); |
27 } | 26 } |
28 | 27 |
29 class LayerUtilsGetAnimationBoundsTest : public testing::Test { | 28 class LayerUtilsGetAnimationBoundsTest : public testing::Test { |
30 public: | 29 public: |
31 LayerUtilsGetAnimationBoundsTest() | 30 LayerUtilsGetAnimationBoundsTest() |
32 : host_impl_(&task_runner_provider_, | 31 : host_impl_(&task_runner_provider_, |
33 &shared_bitmap_manager_, | 32 &shared_bitmap_manager_, |
34 &task_graph_runner_), | 33 &task_graph_runner_), |
35 root_(CreateTwoForkTree(&host_impl_)), | 34 root_(CreateTwoForkTree(&host_impl_)), |
36 parent1_(root_->children()[0]), | 35 parent1_(root_->children()[0]), |
37 parent2_(root_->children()[1]), | 36 parent2_(root_->children()[1]), |
38 child1_(parent1_->children()[0]), | 37 child1_(parent1_->children()[0]), |
39 child2_(parent2_->children()[0]), | 38 child2_(parent2_->children()[0]), |
40 grand_child_(child2_->children()[0]), | 39 grand_child_(child2_->children()[0]), |
41 great_grand_child_(grand_child_->children()[0]) { | 40 great_grand_child_(grand_child_->children()[0]) { |
42 timeline_ = | 41 timeline_ = |
43 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 42 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
44 host_impl_.animation_host()->AddAnimationTimeline(timeline_); | 43 host_impl_.animation_host()->AddAnimationTimeline(timeline_); |
45 host_impl_.active_tree()->SetElementIdsForTesting(); | |
46 } | 44 } |
47 | 45 |
48 LayerImpl* root() { return root_; } | 46 LayerImpl* root() { return root_; } |
49 LayerImpl* parent1() { return parent1_; } | 47 LayerImpl* parent1() { return parent1_; } |
50 LayerImpl* child1() { return child1_; } | 48 LayerImpl* child1() { return child1_; } |
51 LayerImpl* parent2() { return parent2_; } | 49 LayerImpl* parent2() { return parent2_; } |
52 LayerImpl* child2() { return child2_; } | 50 LayerImpl* child2() { return child2_; } |
53 LayerImpl* grand_child() { return grand_child_; } | 51 LayerImpl* grand_child() { return grand_child_; } |
54 LayerImpl* great_grand_child() { return great_grand_child_; } | 52 LayerImpl* great_grand_child() { return great_grand_child_; } |
55 | 53 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 scoped_refptr<AnimationTimeline> timeline_; | 87 scoped_refptr<AnimationTimeline> timeline_; |
90 }; | 88 }; |
91 | 89 |
92 TEST_F(LayerUtilsGetAnimationBoundsTest, ScaleRoot) { | 90 TEST_F(LayerUtilsGetAnimationBoundsTest, ScaleRoot) { |
93 double duration = 1.0; | 91 double duration = 1.0; |
94 | 92 |
95 TransformOperations start; | 93 TransformOperations start; |
96 start.AppendScale(1.f, 1.f, 1.f); | 94 start.AppendScale(1.f, 1.f, 1.f); |
97 TransformOperations end; | 95 TransformOperations end; |
98 end.AppendScale(2.f, 2.f, 1.f); | 96 end.AppendScale(2.f, 2.f, 1.f); |
99 AddAnimatedTransformToElementWithPlayer(root()->element_id(), timeline(), | 97 AddAnimatedTransformToLayerWithPlayer(root()->id(), timeline(), duration, |
100 duration, start, end); | 98 start, end); |
101 | 99 |
102 root()->SetPosition(gfx::PointF()); | 100 root()->SetPosition(gfx::PointF()); |
103 parent1()->SetPosition(gfx::PointF()); | 101 parent1()->SetPosition(gfx::PointF()); |
104 parent1()->SetBounds(gfx::Size(350, 200)); | 102 parent1()->SetBounds(gfx::Size(350, 200)); |
105 | 103 |
106 child1()->SetDrawsContent(true); | 104 child1()->SetDrawsContent(true); |
107 child1()->SetPosition(gfx::PointF(150.f, 50.f)); | 105 child1()->SetPosition(gfx::PointF(150.f, 50.f)); |
108 child1()->SetBounds(gfx::Size(100, 200)); | 106 child1()->SetBounds(gfx::Size(100, 200)); |
109 | 107 |
110 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 108 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
111 | 109 |
112 gfx::BoxF box; | 110 gfx::BoxF box; |
113 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); | 111 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); |
114 EXPECT_TRUE(success); | 112 EXPECT_TRUE(success); |
115 gfx::BoxF expected(150.f, 50.f, 0.f, 350.f, 450.f, 0.f); | 113 gfx::BoxF expected(150.f, 50.f, 0.f, 350.f, 450.f, 0.f); |
116 EXPECT_BOXF_EQ(expected, box); | 114 EXPECT_BOXF_EQ(expected, box); |
117 } | 115 } |
118 | 116 |
119 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateParentLayer) { | 117 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateParentLayer) { |
120 double duration = 1.0; | 118 double duration = 1.0; |
121 | 119 |
122 TransformOperations start; | 120 TransformOperations start; |
123 start.AppendTranslate(0.f, 0.f, 0.f); | 121 start.AppendTranslate(0.f, 0.f, 0.f); |
124 TransformOperations end; | 122 TransformOperations end; |
125 end.AppendTranslate(50.f, 50.f, 0.f); | 123 end.AppendTranslate(50.f, 50.f, 0.f); |
126 AddAnimatedTransformToElementWithPlayer(parent1()->element_id(), timeline(), | 124 AddAnimatedTransformToLayerWithPlayer(parent1()->id(), timeline(), duration, |
127 duration, start, end); | 125 start, end); |
128 | 126 |
129 parent1()->SetBounds(gfx::Size(350, 200)); | 127 parent1()->SetBounds(gfx::Size(350, 200)); |
130 | 128 |
131 child1()->SetDrawsContent(true); | 129 child1()->SetDrawsContent(true); |
132 child1()->SetPosition(gfx::PointF(150.f, 50.f)); | 130 child1()->SetPosition(gfx::PointF(150.f, 50.f)); |
133 child1()->SetBounds(gfx::Size(100, 200)); | 131 child1()->SetBounds(gfx::Size(100, 200)); |
134 | 132 |
135 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 133 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
136 | 134 |
137 gfx::BoxF box; | 135 gfx::BoxF box; |
138 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); | 136 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); |
139 EXPECT_TRUE(success); | 137 EXPECT_TRUE(success); |
140 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f); | 138 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f); |
141 EXPECT_BOXF_EQ(expected, box); | 139 EXPECT_BOXF_EQ(expected, box); |
142 } | 140 } |
143 | 141 |
144 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateChildLayer) { | 142 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateChildLayer) { |
145 double duration = 1.0; | 143 double duration = 1.0; |
146 | 144 |
147 TransformOperations start; | 145 TransformOperations start; |
148 start.AppendTranslate(0.f, 0.f, 0.f); | 146 start.AppendTranslate(0.f, 0.f, 0.f); |
149 TransformOperations end; | 147 TransformOperations end; |
150 end.AppendTranslate(50.f, 50.f, 0.f); | 148 end.AppendTranslate(50.f, 50.f, 0.f); |
151 AddAnimatedTransformToElementWithPlayer(child1()->element_id(), timeline(), | 149 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, |
152 duration, start, end); | 150 start, end); |
153 parent1()->SetBounds(gfx::Size(350, 200)); | 151 parent1()->SetBounds(gfx::Size(350, 200)); |
154 | 152 |
155 child1()->SetDrawsContent(true); | 153 child1()->SetDrawsContent(true); |
156 child1()->SetPosition(gfx::PointF(150.f, 50.f)); | 154 child1()->SetPosition(gfx::PointF(150.f, 50.f)); |
157 child1()->SetBounds(gfx::Size(100, 200)); | 155 child1()->SetBounds(gfx::Size(100, 200)); |
158 | 156 |
159 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 157 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
160 | 158 |
161 gfx::BoxF box; | 159 gfx::BoxF box; |
162 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); | 160 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); |
163 EXPECT_TRUE(success); | 161 EXPECT_TRUE(success); |
164 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f); | 162 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f); |
165 EXPECT_BOXF_EQ(expected, box); | 163 EXPECT_BOXF_EQ(expected, box); |
166 } | 164 } |
167 | 165 |
168 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateBothLayers) { | 166 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateBothLayers) { |
169 double duration = 1.0; | 167 double duration = 1.0; |
170 | 168 |
171 TransformOperations start; | 169 TransformOperations start; |
172 start.AppendTranslate(0.f, 0.f, 0.f); | 170 start.AppendTranslate(0.f, 0.f, 0.f); |
173 TransformOperations child_end; | 171 TransformOperations child_end; |
174 child_end.AppendTranslate(50.f, 0.f, 0.f); | 172 child_end.AppendTranslate(50.f, 0.f, 0.f); |
175 AddAnimatedTransformToElementWithPlayer(parent1()->element_id(), timeline(), | 173 AddAnimatedTransformToLayerWithPlayer(parent1()->id(), timeline(), duration, |
176 duration, start, child_end); | 174 start, child_end); |
177 | 175 |
178 TransformOperations grand_child_end; | 176 TransformOperations grand_child_end; |
179 grand_child_end.AppendTranslate(0.f, 50.f, 0.f); | 177 grand_child_end.AppendTranslate(0.f, 50.f, 0.f); |
180 AddAnimatedTransformToElementWithPlayer(child1()->element_id(), timeline(), | 178 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, |
181 duration, start, grand_child_end); | 179 start, grand_child_end); |
182 | 180 |
183 parent1()->SetBounds(gfx::Size(350, 200)); | 181 parent1()->SetBounds(gfx::Size(350, 200)); |
184 | 182 |
185 child1()->SetDrawsContent(true); | 183 child1()->SetDrawsContent(true); |
186 child1()->SetPosition(gfx::PointF(150.f, 50.f)); | 184 child1()->SetPosition(gfx::PointF(150.f, 50.f)); |
187 child1()->SetBounds(gfx::Size(100, 200)); | 185 child1()->SetBounds(gfx::Size(100, 200)); |
188 | 186 |
189 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 187 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
190 | 188 |
191 gfx::BoxF box; | 189 gfx::BoxF box; |
192 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); | 190 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); |
193 EXPECT_TRUE(success); | 191 EXPECT_TRUE(success); |
194 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f); | 192 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f); |
195 EXPECT_BOXF_EQ(expected, box); | 193 EXPECT_BOXF_EQ(expected, box); |
196 } | 194 } |
197 | 195 |
198 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateXNoPerspective) { | 196 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateXNoPerspective) { |
199 double duration = 1.0; | 197 double duration = 1.0; |
200 | 198 |
201 TransformOperations start; | 199 TransformOperations start; |
202 start.AppendRotate(1.f, 0.f, 0.f, 0.f); | 200 start.AppendRotate(1.f, 0.f, 0.f, 0.f); |
203 TransformOperations end; | 201 TransformOperations end; |
204 end.AppendRotate(1.f, 0.f, 0.f, 90.f); | 202 end.AppendRotate(1.f, 0.f, 0.f, 90.f); |
205 | 203 |
206 AddAnimatedTransformToElementWithPlayer(child1()->element_id(), timeline(), | 204 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, |
207 duration, start, end); | 205 start, end); |
208 | 206 |
209 parent1()->SetBounds(gfx::Size(350, 200)); | 207 parent1()->SetBounds(gfx::Size(350, 200)); |
210 | 208 |
211 gfx::Size bounds(100, 100); | 209 gfx::Size bounds(100, 100); |
212 child1()->SetDrawsContent(true); | 210 child1()->SetDrawsContent(true); |
213 child1()->SetPosition(gfx::PointF(150.f, 50.f)); | 211 child1()->SetPosition(gfx::PointF(150.f, 50.f)); |
214 child1()->SetBounds(bounds); | 212 child1()->SetBounds(bounds); |
215 child1()->test_properties()->transform_origin = | 213 child1()->test_properties()->transform_origin = |
216 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0); | 214 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0); |
217 | 215 |
218 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 216 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
219 | 217 |
220 gfx::BoxF box; | 218 gfx::BoxF box; |
221 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); | 219 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); |
222 EXPECT_TRUE(success); | 220 EXPECT_TRUE(success); |
223 gfx::BoxF expected(150.f, 50.f, -50.f, 100.f, 100.f, 100.f); | 221 gfx::BoxF expected(150.f, 50.f, -50.f, 100.f, 100.f, 100.f); |
224 EXPECT_BOXF_EQ(expected, box); | 222 EXPECT_BOXF_EQ(expected, box); |
225 } | 223 } |
226 | 224 |
227 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateXWithPerspective) { | 225 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateXWithPerspective) { |
228 double duration = 1.0; | 226 double duration = 1.0; |
229 | 227 |
230 TransformOperations start; | 228 TransformOperations start; |
231 start.AppendRotate(1.f, 0.f, 0.f, 0.f); | 229 start.AppendRotate(1.f, 0.f, 0.f, 0.f); |
232 TransformOperations end; | 230 TransformOperations end; |
233 end.AppendRotate(1.f, 0.f, 0.f, 90.f); | 231 end.AppendRotate(1.f, 0.f, 0.f, 90.f); |
234 | 232 |
235 AddAnimatedTransformToElementWithPlayer(child1()->element_id(), timeline(), | 233 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, |
236 duration, start, end); | 234 start, end); |
237 | 235 |
238 // Make the anchor point not the default 0.5 value and line up with the | 236 // Make the anchor point not the default 0.5 value and line up with the |
239 // child center to make the math easier. | 237 // child center to make the math easier. |
240 parent1()->test_properties()->transform_origin = | 238 parent1()->test_properties()->transform_origin = |
241 gfx::Point3F(0.375f * 400.f, 0.375f * 400.f, 0.f); | 239 gfx::Point3F(0.375f * 400.f, 0.375f * 400.f, 0.f); |
242 parent1()->SetBounds(gfx::Size(400, 400)); | 240 parent1()->SetBounds(gfx::Size(400, 400)); |
243 | 241 |
244 gfx::Transform perspective; | 242 gfx::Transform perspective; |
245 perspective.ApplyPerspectiveDepth(100.f); | 243 perspective.ApplyPerspectiveDepth(100.f); |
246 parent1()->SetTransform(perspective); | 244 parent1()->SetTransform(perspective); |
(...skipping 19 matching lines...) Expand all Loading... |
266 // local transform when there is an animation applied to the layer / node. | 264 // local transform when there is an animation applied to the layer / node. |
267 // The intended behavior is that the animation should overwrite the transform. | 265 // The intended behavior is that the animation should overwrite the transform. |
268 | 266 |
269 double duration = 1.0; | 267 double duration = 1.0; |
270 | 268 |
271 TransformOperations start; | 269 TransformOperations start; |
272 start.AppendRotate(1.f, 0.f, 0.f, 0.f); | 270 start.AppendRotate(1.f, 0.f, 0.f, 0.f); |
273 TransformOperations end; | 271 TransformOperations end; |
274 end.AppendRotate(1.f, 0.f, 0.f, 90.f); | 272 end.AppendRotate(1.f, 0.f, 0.f, 90.f); |
275 | 273 |
276 AddAnimatedTransformToElementWithPlayer(parent1()->element_id(), timeline(), | 274 AddAnimatedTransformToLayerWithPlayer(parent1()->id(), timeline(), duration, |
277 duration, start, end); | 275 start, end); |
278 | 276 |
279 // Make the anchor point not the default 0.5 value and line up | 277 // Make the anchor point not the default 0.5 value and line up |
280 // with the child center to make the math easier. | 278 // with the child center to make the math easier. |
281 parent1()->test_properties()->transform_origin = | 279 parent1()->test_properties()->transform_origin = |
282 gfx::Point3F(0.375f * 400.f, 0.375f * 400.f, 0.f); | 280 gfx::Point3F(0.375f * 400.f, 0.375f * 400.f, 0.f); |
283 parent1()->SetBounds(gfx::Size(400, 400)); | 281 parent1()->SetBounds(gfx::Size(400, 400)); |
284 | 282 |
285 gfx::Transform perspective; | 283 gfx::Transform perspective; |
286 perspective.ApplyPerspectiveDepth(100.f); | 284 perspective.ApplyPerspectiveDepth(100.f); |
287 parent1()->SetTransform(perspective); | 285 parent1()->SetTransform(perspective); |
(...skipping 14 matching lines...) Expand all Loading... |
302 EXPECT_BOXF_EQ(expected, box); | 300 EXPECT_BOXF_EQ(expected, box); |
303 } | 301 } |
304 | 302 |
305 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateZ) { | 303 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateZ) { |
306 double duration = 1.0; | 304 double duration = 1.0; |
307 | 305 |
308 TransformOperations start; | 306 TransformOperations start; |
309 start.AppendRotate(0.f, 0.f, 1.f, 0.f); | 307 start.AppendRotate(0.f, 0.f, 1.f, 0.f); |
310 TransformOperations end; | 308 TransformOperations end; |
311 end.AppendRotate(0.f, 0.f, 1.f, 90.f); | 309 end.AppendRotate(0.f, 0.f, 1.f, 90.f); |
312 AddAnimatedTransformToElementWithPlayer(child1()->element_id(), timeline(), | 310 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, |
313 duration, start, end); | 311 start, end); |
314 | 312 |
315 parent1()->SetBounds(gfx::Size(350, 200)); | 313 parent1()->SetBounds(gfx::Size(350, 200)); |
316 | 314 |
317 gfx::Size bounds(100, 100); | 315 gfx::Size bounds(100, 100); |
318 child1()->SetDrawsContent(true); | 316 child1()->SetDrawsContent(true); |
319 child1()->SetPosition(gfx::PointF(150.f, 50.f)); | 317 child1()->SetPosition(gfx::PointF(150.f, 50.f)); |
320 child1()->SetBounds(bounds); | 318 child1()->SetBounds(bounds); |
321 child1()->test_properties()->transform_origin = | 319 child1()->test_properties()->transform_origin = |
322 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0); | 320 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0); |
323 | 321 |
(...skipping 12 matching lines...) Expand all Loading... |
336 EXPECT_BOXF_EQ(expected, box); | 334 EXPECT_BOXF_EQ(expected, box); |
337 } | 335 } |
338 | 336 |
339 TEST_F(LayerUtilsGetAnimationBoundsTest, MismatchedTransforms) { | 337 TEST_F(LayerUtilsGetAnimationBoundsTest, MismatchedTransforms) { |
340 double duration = 1.0; | 338 double duration = 1.0; |
341 | 339 |
342 TransformOperations start; | 340 TransformOperations start; |
343 start.AppendTranslate(5, 6, 7); | 341 start.AppendTranslate(5, 6, 7); |
344 TransformOperations end; | 342 TransformOperations end; |
345 end.AppendRotate(0.f, 0.f, 1.f, 90.f); | 343 end.AppendRotate(0.f, 0.f, 1.f, 90.f); |
346 AddAnimatedTransformToElementWithPlayer(child1()->element_id(), timeline(), | 344 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, |
347 duration, start, end); | 345 start, end); |
348 | 346 |
349 parent1()->SetBounds(gfx::Size(350, 200)); | 347 parent1()->SetBounds(gfx::Size(350, 200)); |
350 | 348 |
351 gfx::Size bounds(100, 100); | 349 gfx::Size bounds(100, 100); |
352 child1()->SetDrawsContent(true); | 350 child1()->SetDrawsContent(true); |
353 child1()->SetPosition(gfx::PointF(150.f, 50.f)); | 351 child1()->SetPosition(gfx::PointF(150.f, 50.f)); |
354 child1()->SetBounds(bounds); | 352 child1()->SetBounds(bounds); |
355 | 353 |
356 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 354 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
357 | 355 |
(...skipping 13 matching lines...) Expand all Loading... |
371 // This test is used to check if GetAnimationBounds correctly skips layers and | 369 // This test is used to check if GetAnimationBounds correctly skips layers and |
372 // take layers which do not own a transform_node into consideration. | 370 // take layers which do not own a transform_node into consideration. |
373 // Under this topology, only root and grand_child own transform_nodes. | 371 // Under this topology, only root and grand_child own transform_nodes. |
374 | 372 |
375 double duration = 1.0; | 373 double duration = 1.0; |
376 | 374 |
377 TransformOperations start; | 375 TransformOperations start; |
378 start.AppendTranslate(0.f, 0.f, 0.f); | 376 start.AppendTranslate(0.f, 0.f, 0.f); |
379 TransformOperations great_grand_child_end; | 377 TransformOperations great_grand_child_end; |
380 great_grand_child_end.AppendTranslate(50.f, 0.f, 0.f); | 378 great_grand_child_end.AppendTranslate(50.f, 0.f, 0.f); |
381 AddAnimatedTransformToElementWithPlayer(grand_child()->element_id(), | 379 AddAnimatedTransformToLayerWithPlayer(grand_child()->id(), timeline(), |
382 timeline(), duration, start, | 380 duration, start, great_grand_child_end); |
383 great_grand_child_end); | |
384 | 381 |
385 gfx::Transform translate_2d_transform; | 382 gfx::Transform translate_2d_transform; |
386 translate_2d_transform.Translate(80.f, 60.f); | 383 translate_2d_transform.Translate(80.f, 60.f); |
387 root()->SetBounds(gfx::Size(350, 200)); | 384 root()->SetBounds(gfx::Size(350, 200)); |
388 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); | 385 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); |
389 child2()->SetTransform(translate_2d_transform); | 386 child2()->SetTransform(translate_2d_transform); |
390 great_grand_child()->SetDrawsContent(true); | 387 great_grand_child()->SetDrawsContent(true); |
391 great_grand_child()->SetPosition(gfx::PointF(150.f, 50.f)); | 388 great_grand_child()->SetPosition(gfx::PointF(150.f, 50.f)); |
392 great_grand_child()->SetBounds(gfx::Size(100, 200)); | 389 great_grand_child()->SetBounds(gfx::Size(100, 200)); |
393 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 390 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
394 | 391 |
395 gfx::BoxF box; | 392 gfx::BoxF box; |
396 bool success = LayerUtils::GetAnimationBounds(*great_grand_child(), &box); | 393 bool success = LayerUtils::GetAnimationBounds(*great_grand_child(), &box); |
397 EXPECT_TRUE(success); | 394 EXPECT_TRUE(success); |
398 gfx::BoxF expected(270.f, 155.f, 0.f, 150.f, 200.f, 0.f); | 395 gfx::BoxF expected(270.f, 155.f, 0.f, 150.f, 200.f, 0.f); |
399 EXPECT_BOXF_EQ(expected, box); | 396 EXPECT_BOXF_EQ(expected, box); |
400 } | 397 } |
401 | 398 |
402 TEST_F(LayerUtilsGetAnimationBoundsTest, | 399 TEST_F(LayerUtilsGetAnimationBoundsTest, |
403 RotateZUnderAncestorsWithPositionOr2DTransform) { | 400 RotateZUnderAncestorsWithPositionOr2DTransform) { |
404 double duration = 1.0; | 401 double duration = 1.0; |
405 | 402 |
406 TransformOperations start; | 403 TransformOperations start; |
407 start.AppendRotate(0.f, 0.f, 1.f, 0.f); | 404 start.AppendRotate(0.f, 0.f, 1.f, 0.f); |
408 TransformOperations great_grand_child_end; | 405 TransformOperations great_grand_child_end; |
409 great_grand_child_end.AppendRotate(0.f, 0.f, 1.f, 90.f); | 406 great_grand_child_end.AppendRotate(0.f, 0.f, 1.f, 90.f); |
410 AddAnimatedTransformToElementWithPlayer(grand_child()->element_id(), | 407 AddAnimatedTransformToLayerWithPlayer(grand_child()->id(), timeline(), |
411 timeline(), duration, start, | 408 duration, start, great_grand_child_end); |
412 great_grand_child_end); | |
413 | 409 |
414 gfx::Transform translate_2d_transform; | 410 gfx::Transform translate_2d_transform; |
415 translate_2d_transform.Translate(80.f, 60.f); | 411 translate_2d_transform.Translate(80.f, 60.f); |
416 root()->SetBounds(gfx::Size(350, 200)); | 412 root()->SetBounds(gfx::Size(350, 200)); |
417 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); | 413 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); |
418 child2()->SetTransform(translate_2d_transform); | 414 child2()->SetTransform(translate_2d_transform); |
419 | 415 |
420 gfx::Size bounds(100, 100); | 416 gfx::Size bounds(100, 100); |
421 grand_child()->SetPosition(gfx::PointF(150.f, 50.f)); | 417 grand_child()->SetPosition(gfx::PointF(150.f, 50.f)); |
422 grand_child()->SetBounds(bounds); | 418 grand_child()->SetBounds(bounds); |
(...skipping 25 matching lines...) Expand all Loading... |
448 // +------grand_child (Perspective) | 444 // +------grand_child (Perspective) |
449 // +--------great_grand_child (RotateX, DrawsContent) | 445 // +--------great_grand_child (RotateX, DrawsContent) |
450 // Due to the RotateX animation, great_grand_child also owns a transform_node | 446 // Due to the RotateX animation, great_grand_child also owns a transform_node |
451 | 447 |
452 double duration = 1.0; | 448 double duration = 1.0; |
453 | 449 |
454 TransformOperations start; | 450 TransformOperations start; |
455 start.AppendRotate(1.f, 0.f, 0.f, 0.f); | 451 start.AppendRotate(1.f, 0.f, 0.f, 0.f); |
456 TransformOperations great_grand_child_end; | 452 TransformOperations great_grand_child_end; |
457 great_grand_child_end.AppendRotate(1.f, 0.f, 0.f, 90.f); | 453 great_grand_child_end.AppendRotate(1.f, 0.f, 0.f, 90.f); |
458 AddAnimatedTransformToElementWithPlayer(great_grand_child()->element_id(), | 454 AddAnimatedTransformToLayerWithPlayer(great_grand_child()->id(), timeline(), |
459 timeline(), duration, start, | 455 duration, start, great_grand_child_end); |
460 great_grand_child_end); | |
461 | 456 |
462 gfx::Transform translate_2d_transform; | 457 gfx::Transform translate_2d_transform; |
463 translate_2d_transform.Translate(80.f, 60.f); | 458 translate_2d_transform.Translate(80.f, 60.f); |
464 | 459 |
465 root()->SetBounds(gfx::Size(350, 200)); | 460 root()->SetBounds(gfx::Size(350, 200)); |
466 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); | 461 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); |
467 child2()->SetTransform(translate_2d_transform); | 462 child2()->SetTransform(translate_2d_transform); |
468 | 463 |
469 gfx::Transform perspective; | 464 gfx::Transform perspective; |
470 perspective.ApplyPerspectiveDepth(100.f); | 465 perspective.ApplyPerspectiveDepth(100.f); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 } | 525 } |
531 | 526 |
532 TEST_F(LayerUtilsGetAnimationBoundsTest, | 527 TEST_F(LayerUtilsGetAnimationBoundsTest, |
533 RotateXNoPerspectiveUnderAncestorsWithPositionOr2DTransform) { | 528 RotateXNoPerspectiveUnderAncestorsWithPositionOr2DTransform) { |
534 double duration = 1.0; | 529 double duration = 1.0; |
535 | 530 |
536 TransformOperations start; | 531 TransformOperations start; |
537 start.AppendRotate(1.f, 0.f, 0.f, 0.f); | 532 start.AppendRotate(1.f, 0.f, 0.f, 0.f); |
538 TransformOperations rotate_x_end; | 533 TransformOperations rotate_x_end; |
539 rotate_x_end.AppendRotate(1.f, 0.f, 0.f, 90.f); | 534 rotate_x_end.AppendRotate(1.f, 0.f, 0.f, 90.f); |
540 AddAnimatedTransformToElementWithPlayer(great_grand_child()->element_id(), | 535 AddAnimatedTransformToLayerWithPlayer(great_grand_child()->id(), timeline(), |
541 timeline(), duration, start, | 536 duration, start, rotate_x_end); |
542 rotate_x_end); | |
543 | 537 |
544 gfx::Transform translate_2d_transform; | 538 gfx::Transform translate_2d_transform; |
545 translate_2d_transform.Translate(80.f, 60.f); | 539 translate_2d_transform.Translate(80.f, 60.f); |
546 | 540 |
547 root()->SetBounds(gfx::Size(350, 200)); | 541 root()->SetBounds(gfx::Size(350, 200)); |
548 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); | 542 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); |
549 child2()->SetTransform(translate_2d_transform); | 543 child2()->SetTransform(translate_2d_transform); |
550 | 544 |
551 gfx::Size bounds(100.f, 100.f); | 545 gfx::Size bounds(100.f, 100.f); |
552 grand_child()->SetPosition(gfx::PointF(150.f, 50.f)); | 546 grand_child()->SetPosition(gfx::PointF(150.f, 50.f)); |
(...skipping 15 matching lines...) Expand all Loading... |
568 // Same as RotateXWithPerspectiveUnderAncestorsWithPositionOr2DTransform test, | 562 // Same as RotateXWithPerspectiveUnderAncestorsWithPositionOr2DTransform test, |
569 // except for the perspective calculations. | 563 // except for the perspective calculations. |
570 | 564 |
571 gfx::BoxF expected(295.f, 180.f, -25.f, 50.f, 50.f, 50.f); | 565 gfx::BoxF expected(295.f, 180.f, -25.f, 50.f, 50.f, 50.f); |
572 EXPECT_BOXF_EQ(expected, box); | 566 EXPECT_BOXF_EQ(expected, box); |
573 } | 567 } |
574 | 568 |
575 } // namespace | 569 } // namespace |
576 | 570 |
577 } // namespace cc | 571 } // namespace cc |
OLD | NEW |