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

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

Issue 1782433002: CC Animation: Erase old animation system. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@erasetests
Patch Set: Remove vtbl in LayerAnimationController. Fix formatting. Created 4 years, 9 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
« no previous file with comments | « cc/layers/layer_unittest.cc ('k') | cc/test/animation_test_common.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 28 matching lines...) Expand all
39 &task_runner_provider_, 39 &task_runner_provider_,
40 &shared_bitmap_manager_, 40 &shared_bitmap_manager_,
41 &task_graph_runner_), 41 &task_graph_runner_),
42 root_(CreateTwoForkTree(&host_impl_)), 42 root_(CreateTwoForkTree(&host_impl_)),
43 parent1_(root_->children()[0].get()), 43 parent1_(root_->children()[0].get()),
44 parent2_(root_->children()[1].get()), 44 parent2_(root_->children()[1].get()),
45 child1_(parent1_->children()[0].get()), 45 child1_(parent1_->children()[0].get()),
46 child2_(parent2_->children()[0].get()), 46 child2_(parent2_->children()[0].get()),
47 grand_child_(child2_->children()[0].get()), 47 grand_child_(child2_->children()[0].get()),
48 great_grand_child_(grand_child_->children()[0].get()) { 48 great_grand_child_(grand_child_->children()[0].get()) {
49 if (host_impl_.settings().use_compositor_animation_timelines) { 49 timeline_ =
50 timeline_ = 50 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
51 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); 51 host_impl_.animation_host()->AddAnimationTimeline(timeline_);
52 host_impl_.animation_host()->AddAnimationTimeline(timeline_);
53 }
54 } 52 }
55 53
56 LayerImpl* root() { return root_; } 54 LayerImpl* root() { return root_; }
57 LayerImpl* parent1() { return parent1_; } 55 LayerImpl* parent1() { return parent1_; }
58 LayerImpl* child1() { return child1_; } 56 LayerImpl* child1() { return child1_; }
59 LayerImpl* parent2() { return parent2_; } 57 LayerImpl* parent2() { return parent2_; }
60 LayerImpl* child2() { return child2_; } 58 LayerImpl* child2() { return child2_; }
61 LayerImpl* grand_child() { return grand_child_; } 59 LayerImpl* grand_child() { return grand_child_; }
62 LayerImpl* great_grand_child() { return great_grand_child_; } 60 LayerImpl* great_grand_child() { return great_grand_child_; }
63 61
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 scoped_refptr<AnimationTimeline> timeline_; 94 scoped_refptr<AnimationTimeline> timeline_;
97 }; 95 };
98 96
99 TEST_F(LayerUtilsGetAnimationBoundsTest, ScaleRoot) { 97 TEST_F(LayerUtilsGetAnimationBoundsTest, ScaleRoot) {
100 double duration = 1.0; 98 double duration = 1.0;
101 99
102 TransformOperations start; 100 TransformOperations start;
103 start.AppendScale(1.f, 1.f, 1.f); 101 start.AppendScale(1.f, 1.f, 1.f);
104 TransformOperations end; 102 TransformOperations end;
105 end.AppendScale(2.f, 2.f, 1.f); 103 end.AppendScale(2.f, 2.f, 1.f);
106 if (host_impl().settings().use_compositor_animation_timelines) { 104 AddAnimatedTransformToLayerWithPlayer(root()->id(), timeline(), duration,
107 AddAnimatedTransformToLayerWithPlayer(root()->id(), timeline(), duration, 105 start, end);
108 start, end);
109 } else {
110 AddAnimatedTransformToLayer(root(), duration, start, end);
111 }
112 106
113 root()->SetPosition(gfx::PointF()); 107 root()->SetPosition(gfx::PointF());
114 parent1()->SetPosition(gfx::PointF()); 108 parent1()->SetPosition(gfx::PointF());
115 parent1()->SetBounds(gfx::Size(350, 200)); 109 parent1()->SetBounds(gfx::Size(350, 200));
116 110
117 child1()->SetDrawsContent(true); 111 child1()->SetDrawsContent(true);
118 child1()->SetPosition(gfx::PointF(150.f, 50.f)); 112 child1()->SetPosition(gfx::PointF(150.f, 50.f));
119 child1()->SetBounds(gfx::Size(100, 200)); 113 child1()->SetBounds(gfx::Size(100, 200));
120 114
121 host_impl().active_tree()->BuildPropertyTreesForTesting(); 115 host_impl().active_tree()->BuildPropertyTreesForTesting();
122 116
123 gfx::BoxF box; 117 gfx::BoxF box;
124 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); 118 bool success = LayerUtils::GetAnimationBounds(*child1(), &box);
125 EXPECT_TRUE(success); 119 EXPECT_TRUE(success);
126 gfx::BoxF expected(150.f, 50.f, 0.f, 350.f, 450.f, 0.f); 120 gfx::BoxF expected(150.f, 50.f, 0.f, 350.f, 450.f, 0.f);
127 EXPECT_BOXF_EQ(expected, box); 121 EXPECT_BOXF_EQ(expected, box);
128 } 122 }
129 123
130 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateParentLayer) { 124 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateParentLayer) {
131 double duration = 1.0; 125 double duration = 1.0;
132 126
133 TransformOperations start; 127 TransformOperations start;
134 start.AppendTranslate(0.f, 0.f, 0.f); 128 start.AppendTranslate(0.f, 0.f, 0.f);
135 TransformOperations end; 129 TransformOperations end;
136 end.AppendTranslate(50.f, 50.f, 0.f); 130 end.AppendTranslate(50.f, 50.f, 0.f);
137 if (host_impl().settings().use_compositor_animation_timelines) { 131 AddAnimatedTransformToLayerWithPlayer(parent1()->id(), timeline(), duration,
138 AddAnimatedTransformToLayerWithPlayer(parent1()->id(), timeline(), duration, 132 start, end);
139 start, end);
140 } else {
141 AddAnimatedTransformToLayer(parent1(), duration, start, end);
142 }
143 133
144 parent1()->SetBounds(gfx::Size(350, 200)); 134 parent1()->SetBounds(gfx::Size(350, 200));
145 135
146 child1()->SetDrawsContent(true); 136 child1()->SetDrawsContent(true);
147 child1()->SetPosition(gfx::PointF(150.f, 50.f)); 137 child1()->SetPosition(gfx::PointF(150.f, 50.f));
148 child1()->SetBounds(gfx::Size(100, 200)); 138 child1()->SetBounds(gfx::Size(100, 200));
149 139
150 host_impl().active_tree()->BuildPropertyTreesForTesting(); 140 host_impl().active_tree()->BuildPropertyTreesForTesting();
151 141
152 gfx::BoxF box; 142 gfx::BoxF box;
153 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); 143 bool success = LayerUtils::GetAnimationBounds(*child1(), &box);
154 EXPECT_TRUE(success); 144 EXPECT_TRUE(success);
155 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f); 145 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f);
156 EXPECT_BOXF_EQ(expected, box); 146 EXPECT_BOXF_EQ(expected, box);
157 } 147 }
158 148
159 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateChildLayer) { 149 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateChildLayer) {
160 double duration = 1.0; 150 double duration = 1.0;
161 151
162 TransformOperations start; 152 TransformOperations start;
163 start.AppendTranslate(0.f, 0.f, 0.f); 153 start.AppendTranslate(0.f, 0.f, 0.f);
164 TransformOperations end; 154 TransformOperations end;
165 end.AppendTranslate(50.f, 50.f, 0.f); 155 end.AppendTranslate(50.f, 50.f, 0.f);
166 if (host_impl().settings().use_compositor_animation_timelines) { 156 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration,
167 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, 157 start, end);
168 start, end);
169 } else {
170 AddAnimatedTransformToLayer(child1(), duration, start, end);
171 }
172
173 parent1()->SetBounds(gfx::Size(350, 200)); 158 parent1()->SetBounds(gfx::Size(350, 200));
174 159
175 child1()->SetDrawsContent(true); 160 child1()->SetDrawsContent(true);
176 child1()->SetPosition(gfx::PointF(150.f, 50.f)); 161 child1()->SetPosition(gfx::PointF(150.f, 50.f));
177 child1()->SetBounds(gfx::Size(100, 200)); 162 child1()->SetBounds(gfx::Size(100, 200));
178 163
179 host_impl().active_tree()->BuildPropertyTreesForTesting(); 164 host_impl().active_tree()->BuildPropertyTreesForTesting();
180 165
181 gfx::BoxF box; 166 gfx::BoxF box;
182 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); 167 bool success = LayerUtils::GetAnimationBounds(*child1(), &box);
183 EXPECT_TRUE(success); 168 EXPECT_TRUE(success);
184 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f); 169 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f);
185 EXPECT_BOXF_EQ(expected, box); 170 EXPECT_BOXF_EQ(expected, box);
186 } 171 }
187 172
188 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateBothLayers) { 173 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateBothLayers) {
189 double duration = 1.0; 174 double duration = 1.0;
190 175
191 TransformOperations start; 176 TransformOperations start;
192 start.AppendTranslate(0.f, 0.f, 0.f); 177 start.AppendTranslate(0.f, 0.f, 0.f);
193 TransformOperations child_end; 178 TransformOperations child_end;
194 child_end.AppendTranslate(50.f, 0.f, 0.f); 179 child_end.AppendTranslate(50.f, 0.f, 0.f);
195 if (host_impl().settings().use_compositor_animation_timelines) { 180 AddAnimatedTransformToLayerWithPlayer(parent1()->id(), timeline(), duration,
196 AddAnimatedTransformToLayerWithPlayer(parent1()->id(), timeline(), duration, 181 start, child_end);
197 start, child_end);
198 } else {
199 AddAnimatedTransformToLayer(parent1(), duration, start, child_end);
200 }
201 182
202 TransformOperations grand_child_end; 183 TransformOperations grand_child_end;
203 grand_child_end.AppendTranslate(0.f, 50.f, 0.f); 184 grand_child_end.AppendTranslate(0.f, 50.f, 0.f);
204 if (host_impl().settings().use_compositor_animation_timelines) { 185 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration,
205 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, 186 start, grand_child_end);
206 start, grand_child_end);
207 } else {
208 AddAnimatedTransformToLayer(child1(), duration, start, grand_child_end);
209 }
210 187
211 parent1()->SetBounds(gfx::Size(350, 200)); 188 parent1()->SetBounds(gfx::Size(350, 200));
212 189
213 child1()->SetDrawsContent(true); 190 child1()->SetDrawsContent(true);
214 child1()->SetPosition(gfx::PointF(150.f, 50.f)); 191 child1()->SetPosition(gfx::PointF(150.f, 50.f));
215 child1()->SetBounds(gfx::Size(100, 200)); 192 child1()->SetBounds(gfx::Size(100, 200));
216 193
217 host_impl().active_tree()->BuildPropertyTreesForTesting(); 194 host_impl().active_tree()->BuildPropertyTreesForTesting();
218 195
219 gfx::BoxF box; 196 gfx::BoxF box;
220 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); 197 bool success = LayerUtils::GetAnimationBounds(*child1(), &box);
221 EXPECT_TRUE(success); 198 EXPECT_TRUE(success);
222 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f); 199 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f);
223 EXPECT_BOXF_EQ(expected, box); 200 EXPECT_BOXF_EQ(expected, box);
224 } 201 }
225 202
226 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateXNoPerspective) { 203 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateXNoPerspective) {
227 double duration = 1.0; 204 double duration = 1.0;
228 205
229 TransformOperations start; 206 TransformOperations start;
230 start.AppendRotate(1.f, 0.f, 0.f, 0.f); 207 start.AppendRotate(1.f, 0.f, 0.f, 0.f);
231 TransformOperations end; 208 TransformOperations end;
232 end.AppendRotate(1.f, 0.f, 0.f, 90.f); 209 end.AppendRotate(1.f, 0.f, 0.f, 90.f);
233 if (host_impl().settings().use_compositor_animation_timelines) { 210
234 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, 211 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration,
235 start, end); 212 start, end);
236 } else {
237 AddAnimatedTransformToLayer(child1(), duration, start, end);
238 }
239 213
240 parent1()->SetBounds(gfx::Size(350, 200)); 214 parent1()->SetBounds(gfx::Size(350, 200));
241 215
242 gfx::Size bounds(100, 100); 216 gfx::Size bounds(100, 100);
243 child1()->SetDrawsContent(true); 217 child1()->SetDrawsContent(true);
244 child1()->SetPosition(gfx::PointF(150.f, 50.f)); 218 child1()->SetPosition(gfx::PointF(150.f, 50.f));
245 child1()->SetBounds(bounds); 219 child1()->SetBounds(bounds);
246 child1()->SetTransformOrigin( 220 child1()->SetTransformOrigin(
247 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0)); 221 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0));
248 222
249 host_impl().active_tree()->BuildPropertyTreesForTesting(); 223 host_impl().active_tree()->BuildPropertyTreesForTesting();
250 224
251 gfx::BoxF box; 225 gfx::BoxF box;
252 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); 226 bool success = LayerUtils::GetAnimationBounds(*child1(), &box);
253 EXPECT_TRUE(success); 227 EXPECT_TRUE(success);
254 gfx::BoxF expected(150.f, 50.f, -50.f, 100.f, 100.f, 100.f); 228 gfx::BoxF expected(150.f, 50.f, -50.f, 100.f, 100.f, 100.f);
255 EXPECT_BOXF_EQ(expected, box); 229 EXPECT_BOXF_EQ(expected, box);
256 } 230 }
257 231
258 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateXWithPerspective) { 232 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateXWithPerspective) {
259 double duration = 1.0; 233 double duration = 1.0;
260 234
261 TransformOperations start; 235 TransformOperations start;
262 start.AppendRotate(1.f, 0.f, 0.f, 0.f); 236 start.AppendRotate(1.f, 0.f, 0.f, 0.f);
263 TransformOperations end; 237 TransformOperations end;
264 end.AppendRotate(1.f, 0.f, 0.f, 90.f); 238 end.AppendRotate(1.f, 0.f, 0.f, 90.f);
265 239
266 if (host_impl().settings().use_compositor_animation_timelines) { 240 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration,
267 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, 241 start, end);
268 start, end);
269 } else {
270 AddAnimatedTransformToLayer(child1(), duration, start, end);
271 }
272 242
273 // Make the anchor point not the default 0.5 value and line up with the 243 // Make the anchor point not the default 0.5 value and line up with the
274 // child center to make the math easier. 244 // child center to make the math easier.
275 parent1()->SetTransformOrigin( 245 parent1()->SetTransformOrigin(
276 gfx::Point3F(0.375f * 400.f, 0.375f * 400.f, 0.f)); 246 gfx::Point3F(0.375f * 400.f, 0.375f * 400.f, 0.f));
277 parent1()->SetBounds(gfx::Size(400, 400)); 247 parent1()->SetBounds(gfx::Size(400, 400));
278 248
279 gfx::Transform perspective; 249 gfx::Transform perspective;
280 perspective.ApplyPerspectiveDepth(100.f); 250 perspective.ApplyPerspectiveDepth(100.f);
281 parent1()->SetTransform(perspective); 251 parent1()->SetTransform(perspective);
(...skipping 19 matching lines...) Expand all
301 // local transform when there is an animation applied to the layer / node. 271 // local transform when there is an animation applied to the layer / node.
302 // The intended behavior is that the animation should overwrite the transform. 272 // The intended behavior is that the animation should overwrite the transform.
303 273
304 double duration = 1.0; 274 double duration = 1.0;
305 275
306 TransformOperations start; 276 TransformOperations start;
307 start.AppendRotate(1.f, 0.f, 0.f, 0.f); 277 start.AppendRotate(1.f, 0.f, 0.f, 0.f);
308 TransformOperations end; 278 TransformOperations end;
309 end.AppendRotate(1.f, 0.f, 0.f, 90.f); 279 end.AppendRotate(1.f, 0.f, 0.f, 90.f);
310 280
311 if (host_impl().settings().use_compositor_animation_timelines) { 281 AddAnimatedTransformToLayerWithPlayer(parent1()->id(), timeline(), duration,
312 AddAnimatedTransformToLayerWithPlayer(parent1()->id(), timeline(), duration, 282 start, end);
313 start, end);
314 } else {
315 AddAnimatedTransformToLayer(parent1(), duration, start, end);
316 }
317 283
318 // Make the anchor point not the default 0.5 value and line up 284 // Make the anchor point not the default 0.5 value and line up
319 // with the child center to make the math easier. 285 // with the child center to make the math easier.
320 parent1()->SetTransformOrigin( 286 parent1()->SetTransformOrigin(
321 gfx::Point3F(0.375f * 400.f, 0.375f * 400.f, 0.f)); 287 gfx::Point3F(0.375f * 400.f, 0.375f * 400.f, 0.f));
322 parent1()->SetBounds(gfx::Size(400, 400)); 288 parent1()->SetBounds(gfx::Size(400, 400));
323 289
324 gfx::Transform perspective; 290 gfx::Transform perspective;
325 perspective.ApplyPerspectiveDepth(100.f); 291 perspective.ApplyPerspectiveDepth(100.f);
326 parent1()->SetTransform(perspective); 292 parent1()->SetTransform(perspective);
(...skipping 14 matching lines...) Expand all
341 EXPECT_BOXF_EQ(expected, box); 307 EXPECT_BOXF_EQ(expected, box);
342 } 308 }
343 309
344 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateZ) { 310 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateZ) {
345 double duration = 1.0; 311 double duration = 1.0;
346 312
347 TransformOperations start; 313 TransformOperations start;
348 start.AppendRotate(0.f, 0.f, 1.f, 0.f); 314 start.AppendRotate(0.f, 0.f, 1.f, 0.f);
349 TransformOperations end; 315 TransformOperations end;
350 end.AppendRotate(0.f, 0.f, 1.f, 90.f); 316 end.AppendRotate(0.f, 0.f, 1.f, 90.f);
351 if (host_impl().settings().use_compositor_animation_timelines) { 317 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration,
352 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, 318 start, end);
353 start, end);
354 } else {
355 AddAnimatedTransformToLayer(child1(), duration, start, end);
356 }
357 319
358 parent1()->SetBounds(gfx::Size(350, 200)); 320 parent1()->SetBounds(gfx::Size(350, 200));
359 321
360 gfx::Size bounds(100, 100); 322 gfx::Size bounds(100, 100);
361 child1()->SetDrawsContent(true); 323 child1()->SetDrawsContent(true);
362 child1()->SetPosition(gfx::PointF(150.f, 50.f)); 324 child1()->SetPosition(gfx::PointF(150.f, 50.f));
363 child1()->SetBounds(bounds); 325 child1()->SetBounds(bounds);
364 child1()->SetTransformOrigin( 326 child1()->SetTransformOrigin(
365 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0)); 327 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0));
366 328
(...skipping 12 matching lines...) Expand all
379 EXPECT_BOXF_EQ(expected, box); 341 EXPECT_BOXF_EQ(expected, box);
380 } 342 }
381 343
382 TEST_F(LayerUtilsGetAnimationBoundsTest, MismatchedTransforms) { 344 TEST_F(LayerUtilsGetAnimationBoundsTest, MismatchedTransforms) {
383 double duration = 1.0; 345 double duration = 1.0;
384 346
385 TransformOperations start; 347 TransformOperations start;
386 start.AppendTranslate(5, 6, 7); 348 start.AppendTranslate(5, 6, 7);
387 TransformOperations end; 349 TransformOperations end;
388 end.AppendRotate(0.f, 0.f, 1.f, 90.f); 350 end.AppendRotate(0.f, 0.f, 1.f, 90.f);
389 if (host_impl().settings().use_compositor_animation_timelines) { 351 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration,
390 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, 352 start, end);
391 start, end);
392 } else {
393 AddAnimatedTransformToLayer(child1(), duration, start, end);
394 }
395 353
396 parent1()->SetBounds(gfx::Size(350, 200)); 354 parent1()->SetBounds(gfx::Size(350, 200));
397 355
398 gfx::Size bounds(100, 100); 356 gfx::Size bounds(100, 100);
399 child1()->SetDrawsContent(true); 357 child1()->SetDrawsContent(true);
400 child1()->SetPosition(gfx::PointF(150.f, 50.f)); 358 child1()->SetPosition(gfx::PointF(150.f, 50.f));
401 child1()->SetBounds(bounds); 359 child1()->SetBounds(bounds);
402 360
403 host_impl().active_tree()->BuildPropertyTreesForTesting(); 361 host_impl().active_tree()->BuildPropertyTreesForTesting();
404 362
(...skipping 13 matching lines...) Expand all
418 // This test is used to check if GetAnimationBounds correctly skips layers and 376 // This test is used to check if GetAnimationBounds correctly skips layers and
419 // take layers which do not own a transform_node into consideration. 377 // take layers which do not own a transform_node into consideration.
420 // Under this topology, only root and grand_child own transform_nodes. 378 // Under this topology, only root and grand_child own transform_nodes.
421 379
422 double duration = 1.0; 380 double duration = 1.0;
423 381
424 TransformOperations start; 382 TransformOperations start;
425 start.AppendTranslate(0.f, 0.f, 0.f); 383 start.AppendTranslate(0.f, 0.f, 0.f);
426 TransformOperations great_grand_child_end; 384 TransformOperations great_grand_child_end;
427 great_grand_child_end.AppendTranslate(50.f, 0.f, 0.f); 385 great_grand_child_end.AppendTranslate(50.f, 0.f, 0.f);
428 if (host_impl().settings().use_compositor_animation_timelines) { 386 AddAnimatedTransformToLayerWithPlayer(grand_child()->id(), timeline(),
429 AddAnimatedTransformToLayerWithPlayer(grand_child()->id(), timeline(), 387 duration, start, great_grand_child_end);
430 duration, start,
431 great_grand_child_end);
432 } else {
433 AddAnimatedTransformToLayer(grand_child(), duration, start,
434 great_grand_child_end);
435 }
436 388
437 gfx::Transform translate_2d_transform; 389 gfx::Transform translate_2d_transform;
438 translate_2d_transform.Translate(80.f, 60.f); 390 translate_2d_transform.Translate(80.f, 60.f);
439 root()->SetBounds(gfx::Size(350, 200)); 391 root()->SetBounds(gfx::Size(350, 200));
440 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); 392 parent2()->SetPosition(gfx::PointF(40.f, 45.f));
441 child2()->SetTransform(translate_2d_transform); 393 child2()->SetTransform(translate_2d_transform);
442 great_grand_child()->SetDrawsContent(true); 394 great_grand_child()->SetDrawsContent(true);
443 great_grand_child()->SetPosition(gfx::PointF(150.f, 50.f)); 395 great_grand_child()->SetPosition(gfx::PointF(150.f, 50.f));
444 great_grand_child()->SetBounds(gfx::Size(100, 200)); 396 great_grand_child()->SetBounds(gfx::Size(100, 200));
445 host_impl().active_tree()->BuildPropertyTreesForTesting(); 397 host_impl().active_tree()->BuildPropertyTreesForTesting();
446 398
447 gfx::BoxF box; 399 gfx::BoxF box;
448 bool success = LayerUtils::GetAnimationBounds(*great_grand_child(), &box); 400 bool success = LayerUtils::GetAnimationBounds(*great_grand_child(), &box);
449 EXPECT_TRUE(success); 401 EXPECT_TRUE(success);
450 gfx::BoxF expected(270.f, 155.f, 0.f, 150.f, 200.f, 0.f); 402 gfx::BoxF expected(270.f, 155.f, 0.f, 150.f, 200.f, 0.f);
451 EXPECT_BOXF_EQ(expected, box); 403 EXPECT_BOXF_EQ(expected, box);
452 } 404 }
453 405
454 TEST_F(LayerUtilsGetAnimationBoundsTest, 406 TEST_F(LayerUtilsGetAnimationBoundsTest,
455 RotateZUnderAncestorsWithPositionOr2DTransform) { 407 RotateZUnderAncestorsWithPositionOr2DTransform) {
456 double duration = 1.0; 408 double duration = 1.0;
457 409
458 TransformOperations start; 410 TransformOperations start;
459 start.AppendRotate(0.f, 0.f, 1.f, 0.f); 411 start.AppendRotate(0.f, 0.f, 1.f, 0.f);
460 TransformOperations great_grand_child_end; 412 TransformOperations great_grand_child_end;
461 great_grand_child_end.AppendRotate(0.f, 0.f, 1.f, 90.f); 413 great_grand_child_end.AppendRotate(0.f, 0.f, 1.f, 90.f);
462 if (host_impl().settings().use_compositor_animation_timelines) { 414 AddAnimatedTransformToLayerWithPlayer(grand_child()->id(), timeline(),
463 AddAnimatedTransformToLayerWithPlayer(grand_child()->id(), timeline(), 415 duration, start, great_grand_child_end);
464 duration, start,
465 great_grand_child_end);
466 } else {
467 AddAnimatedTransformToLayer(grand_child(), duration, start,
468 great_grand_child_end);
469 }
470 416
471 gfx::Transform translate_2d_transform; 417 gfx::Transform translate_2d_transform;
472 translate_2d_transform.Translate(80.f, 60.f); 418 translate_2d_transform.Translate(80.f, 60.f);
473 root()->SetBounds(gfx::Size(350, 200)); 419 root()->SetBounds(gfx::Size(350, 200));
474 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); 420 parent2()->SetPosition(gfx::PointF(40.f, 45.f));
475 child2()->SetTransform(translate_2d_transform); 421 child2()->SetTransform(translate_2d_transform);
476 422
477 gfx::Size bounds(100, 100); 423 gfx::Size bounds(100, 100);
478 grand_child()->SetPosition(gfx::PointF(150.f, 50.f)); 424 grand_child()->SetPosition(gfx::PointF(150.f, 50.f));
479 grand_child()->SetBounds(bounds); 425 grand_child()->SetBounds(bounds);
(...skipping 25 matching lines...) Expand all
505 // +------grand_child (Perspective) 451 // +------grand_child (Perspective)
506 // +--------great_grand_child (RotateX, DrawsContent) 452 // +--------great_grand_child (RotateX, DrawsContent)
507 // Due to the RotateX animation, great_grand_child also owns a transform_node 453 // Due to the RotateX animation, great_grand_child also owns a transform_node
508 454
509 double duration = 1.0; 455 double duration = 1.0;
510 456
511 TransformOperations start; 457 TransformOperations start;
512 start.AppendRotate(1.f, 0.f, 0.f, 0.f); 458 start.AppendRotate(1.f, 0.f, 0.f, 0.f);
513 TransformOperations great_grand_child_end; 459 TransformOperations great_grand_child_end;
514 great_grand_child_end.AppendRotate(1.f, 0.f, 0.f, 90.f); 460 great_grand_child_end.AppendRotate(1.f, 0.f, 0.f, 90.f);
515 if (host_impl().settings().use_compositor_animation_timelines) { 461 AddAnimatedTransformToLayerWithPlayer(great_grand_child()->id(), timeline(),
516 AddAnimatedTransformToLayerWithPlayer(great_grand_child()->id(), timeline(), 462 duration, start, great_grand_child_end);
517 duration, start,
518 great_grand_child_end);
519 } else {
520 AddAnimatedTransformToLayer(great_grand_child(), duration, start,
521 great_grand_child_end);
522 }
523 463
524 gfx::Transform translate_2d_transform; 464 gfx::Transform translate_2d_transform;
525 translate_2d_transform.Translate(80.f, 60.f); 465 translate_2d_transform.Translate(80.f, 60.f);
526 466
527 root()->SetBounds(gfx::Size(350, 200)); 467 root()->SetBounds(gfx::Size(350, 200));
528 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); 468 parent2()->SetPosition(gfx::PointF(40.f, 45.f));
529 child2()->SetTransform(translate_2d_transform); 469 child2()->SetTransform(translate_2d_transform);
530 470
531 gfx::Transform perspective; 471 gfx::Transform perspective;
532 perspective.ApplyPerspectiveDepth(100.f); 472 perspective.ApplyPerspectiveDepth(100.f);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 } 532 }
593 533
594 TEST_F(LayerUtilsGetAnimationBoundsTest, 534 TEST_F(LayerUtilsGetAnimationBoundsTest,
595 RotateXNoPerspectiveUnderAncestorsWithPositionOr2DTransform) { 535 RotateXNoPerspectiveUnderAncestorsWithPositionOr2DTransform) {
596 double duration = 1.0; 536 double duration = 1.0;
597 537
598 TransformOperations start; 538 TransformOperations start;
599 start.AppendRotate(1.f, 0.f, 0.f, 0.f); 539 start.AppendRotate(1.f, 0.f, 0.f, 0.f);
600 TransformOperations rotate_x_end; 540 TransformOperations rotate_x_end;
601 rotate_x_end.AppendRotate(1.f, 0.f, 0.f, 90.f); 541 rotate_x_end.AppendRotate(1.f, 0.f, 0.f, 90.f);
602 if (host_impl().settings().use_compositor_animation_timelines) { 542 AddAnimatedTransformToLayerWithPlayer(great_grand_child()->id(), timeline(),
603 AddAnimatedTransformToLayerWithPlayer(great_grand_child()->id(), timeline(), 543 duration, start, rotate_x_end);
604 duration, start, rotate_x_end);
605 } else {
606 AddAnimatedTransformToLayer(great_grand_child(), duration, start,
607 rotate_x_end);
608 }
609 544
610 gfx::Transform translate_2d_transform; 545 gfx::Transform translate_2d_transform;
611 translate_2d_transform.Translate(80.f, 60.f); 546 translate_2d_transform.Translate(80.f, 60.f);
612 547
613 root()->SetBounds(gfx::Size(350, 200)); 548 root()->SetBounds(gfx::Size(350, 200));
614 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); 549 parent2()->SetPosition(gfx::PointF(40.f, 45.f));
615 child2()->SetTransform(translate_2d_transform); 550 child2()->SetTransform(translate_2d_transform);
616 551
617 gfx::Size bounds(100.f, 100.f); 552 gfx::Size bounds(100.f, 100.f);
618 grand_child()->SetPosition(gfx::PointF(150.f, 50.f)); 553 grand_child()->SetPosition(gfx::PointF(150.f, 50.f));
(...skipping 15 matching lines...) Expand all
634 // Same as RotateXWithPerspectiveUnderAncestorsWithPositionOr2DTransform test, 569 // Same as RotateXWithPerspectiveUnderAncestorsWithPositionOr2DTransform test,
635 // except for the perspective calculations. 570 // except for the perspective calculations.
636 571
637 gfx::BoxF expected(295.f, 180.f, -25.f, 50.f, 50.f, 50.f); 572 gfx::BoxF expected(295.f, 180.f, -25.f, 50.f, 50.f, 50.f);
638 EXPECT_BOXF_EQ(expected, box); 573 EXPECT_BOXF_EQ(expected, box);
639 } 574 }
640 575
641 } // namespace 576 } // namespace
642 577
643 } // namespace cc 578 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_unittest.cc ('k') | cc/test/animation_test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698