Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(721)

Side by Side Diff: cc/layers/layer_utils_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698