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" |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 duration, start, end); | 248 duration, start, end); |
249 | 249 |
250 // Make the anchor point not the default 0.5 value and line up with the | 250 // Make the anchor point not the default 0.5 value and line up with the |
251 // child center to make the math easier. | 251 // child center to make the math easier. |
252 parent1()->test_properties()->transform_origin = | 252 parent1()->test_properties()->transform_origin = |
253 gfx::Point3F(0.375f * 400.f, 0.375f * 400.f, 0.f); | 253 gfx::Point3F(0.375f * 400.f, 0.375f * 400.f, 0.f); |
254 parent1()->SetBounds(gfx::Size(400, 400)); | 254 parent1()->SetBounds(gfx::Size(400, 400)); |
255 | 255 |
256 gfx::Transform perspective; | 256 gfx::Transform perspective; |
257 perspective.ApplyPerspectiveDepth(100.f); | 257 perspective.ApplyPerspectiveDepth(100.f); |
258 parent1()->SetTransform(perspective); | 258 parent1()->test_properties()->transform = perspective; |
259 | 259 |
260 gfx::Size bounds(100, 100); | 260 gfx::Size bounds(100, 100); |
261 child1()->SetDrawsContent(true); | 261 child1()->SetDrawsContent(true); |
262 child1()->SetPosition(gfx::PointF(100.f, 100.f)); | 262 child1()->SetPosition(gfx::PointF(100.f, 100.f)); |
263 child1()->SetBounds(bounds); | 263 child1()->SetBounds(bounds); |
264 child1()->test_properties()->transform_origin = | 264 child1()->test_properties()->transform_origin = |
265 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0); | 265 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0); |
266 | 266 |
267 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 267 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
268 | 268 |
(...skipping 20 matching lines...) Expand all Loading... |
289 duration, start, end); | 289 duration, start, end); |
290 | 290 |
291 // Make the anchor point not the default 0.5 value and line up | 291 // Make the anchor point not the default 0.5 value and line up |
292 // with the child center to make the math easier. | 292 // with the child center to make the math easier. |
293 parent1()->test_properties()->transform_origin = | 293 parent1()->test_properties()->transform_origin = |
294 gfx::Point3F(0.375f * 400.f, 0.375f * 400.f, 0.f); | 294 gfx::Point3F(0.375f * 400.f, 0.375f * 400.f, 0.f); |
295 parent1()->SetBounds(gfx::Size(400, 400)); | 295 parent1()->SetBounds(gfx::Size(400, 400)); |
296 | 296 |
297 gfx::Transform perspective; | 297 gfx::Transform perspective; |
298 perspective.ApplyPerspectiveDepth(100.f); | 298 perspective.ApplyPerspectiveDepth(100.f); |
299 parent1()->SetTransform(perspective); | 299 parent1()->test_properties()->transform = perspective; |
300 | 300 |
301 gfx::Size bounds(100, 100); | 301 gfx::Size bounds(100, 100); |
302 child1()->SetDrawsContent(true); | 302 child1()->SetDrawsContent(true); |
303 child1()->SetPosition(gfx::PointF(100.f, 100.f)); | 303 child1()->SetPosition(gfx::PointF(100.f, 100.f)); |
304 child1()->SetBounds(bounds); | 304 child1()->SetBounds(bounds); |
305 child1()->test_properties()->transform_origin = | 305 child1()->test_properties()->transform_origin = |
306 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0); | 306 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0); |
307 | 307 |
308 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 308 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
309 | 309 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 TransformOperations great_grand_child_end; | 391 TransformOperations great_grand_child_end; |
392 great_grand_child_end.AppendTranslate(50.f, 0.f, 0.f); | 392 great_grand_child_end.AppendTranslate(50.f, 0.f, 0.f); |
393 AddAnimatedTransformToElementWithPlayer(grand_child()->element_id(), | 393 AddAnimatedTransformToElementWithPlayer(grand_child()->element_id(), |
394 timeline(), duration, start, | 394 timeline(), duration, start, |
395 great_grand_child_end); | 395 great_grand_child_end); |
396 | 396 |
397 gfx::Transform translate_2d_transform; | 397 gfx::Transform translate_2d_transform; |
398 translate_2d_transform.Translate(80.f, 60.f); | 398 translate_2d_transform.Translate(80.f, 60.f); |
399 root()->SetBounds(gfx::Size(350, 200)); | 399 root()->SetBounds(gfx::Size(350, 200)); |
400 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); | 400 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); |
401 child2()->SetTransform(translate_2d_transform); | 401 child2()->test_properties()->transform = translate_2d_transform; |
402 great_grand_child()->SetDrawsContent(true); | 402 great_grand_child()->SetDrawsContent(true); |
403 great_grand_child()->SetPosition(gfx::PointF(150.f, 50.f)); | 403 great_grand_child()->SetPosition(gfx::PointF(150.f, 50.f)); |
404 great_grand_child()->SetBounds(gfx::Size(100, 200)); | 404 great_grand_child()->SetBounds(gfx::Size(100, 200)); |
405 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 405 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
406 | 406 |
407 gfx::BoxF box; | 407 gfx::BoxF box; |
408 bool success = LayerUtils::GetAnimationBounds(*great_grand_child(), &box); | 408 bool success = LayerUtils::GetAnimationBounds(*great_grand_child(), &box); |
409 EXPECT_TRUE(success); | 409 EXPECT_TRUE(success); |
410 gfx::BoxF expected(270.f, 155.f, 0.f, 150.f, 200.f, 0.f); | 410 gfx::BoxF expected(270.f, 155.f, 0.f, 150.f, 200.f, 0.f); |
411 EXPECT_BOXF_EQ(expected, box); | 411 EXPECT_BOXF_EQ(expected, box); |
412 } | 412 } |
413 | 413 |
414 TEST_F(LayerUtilsGetAnimationBoundsTest, | 414 TEST_F(LayerUtilsGetAnimationBoundsTest, |
415 RotateZUnderAncestorsWithPositionOr2DTransform) { | 415 RotateZUnderAncestorsWithPositionOr2DTransform) { |
416 double duration = 1.0; | 416 double duration = 1.0; |
417 | 417 |
418 TransformOperations start; | 418 TransformOperations start; |
419 start.AppendRotate(0.f, 0.f, 1.f, 0.f); | 419 start.AppendRotate(0.f, 0.f, 1.f, 0.f); |
420 TransformOperations great_grand_child_end; | 420 TransformOperations great_grand_child_end; |
421 great_grand_child_end.AppendRotate(0.f, 0.f, 1.f, 90.f); | 421 great_grand_child_end.AppendRotate(0.f, 0.f, 1.f, 90.f); |
422 AddAnimatedTransformToElementWithPlayer(grand_child()->element_id(), | 422 AddAnimatedTransformToElementWithPlayer(grand_child()->element_id(), |
423 timeline(), duration, start, | 423 timeline(), duration, start, |
424 great_grand_child_end); | 424 great_grand_child_end); |
425 | 425 |
426 gfx::Transform translate_2d_transform; | 426 gfx::Transform translate_2d_transform; |
427 translate_2d_transform.Translate(80.f, 60.f); | 427 translate_2d_transform.Translate(80.f, 60.f); |
428 root()->SetBounds(gfx::Size(350, 200)); | 428 root()->SetBounds(gfx::Size(350, 200)); |
429 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); | 429 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); |
430 child2()->SetTransform(translate_2d_transform); | 430 child2()->test_properties()->transform = translate_2d_transform; |
431 | 431 |
432 gfx::Size bounds(100, 100); | 432 gfx::Size bounds(100, 100); |
433 grand_child()->SetPosition(gfx::PointF(150.f, 50.f)); | 433 grand_child()->SetPosition(gfx::PointF(150.f, 50.f)); |
434 grand_child()->SetBounds(bounds); | 434 grand_child()->SetBounds(bounds); |
435 grand_child()->test_properties()->transform_origin = | 435 grand_child()->test_properties()->transform_origin = |
436 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0); | 436 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0); |
437 | 437 |
438 great_grand_child()->SetPosition(gfx::PointF(25.f, 25.f)); | 438 great_grand_child()->SetPosition(gfx::PointF(25.f, 25.f)); |
439 great_grand_child()->SetBounds(gfx::Size(50.f, 50.f)); | 439 great_grand_child()->SetBounds(gfx::Size(50.f, 50.f)); |
440 great_grand_child()->SetDrawsContent(true); | 440 great_grand_child()->SetDrawsContent(true); |
(...skipping 28 matching lines...) Expand all Loading... |
469 great_grand_child_end.AppendRotate(1.f, 0.f, 0.f, 90.f); | 469 great_grand_child_end.AppendRotate(1.f, 0.f, 0.f, 90.f); |
470 AddAnimatedTransformToElementWithPlayer(great_grand_child()->element_id(), | 470 AddAnimatedTransformToElementWithPlayer(great_grand_child()->element_id(), |
471 timeline(), duration, start, | 471 timeline(), duration, start, |
472 great_grand_child_end); | 472 great_grand_child_end); |
473 | 473 |
474 gfx::Transform translate_2d_transform; | 474 gfx::Transform translate_2d_transform; |
475 translate_2d_transform.Translate(80.f, 60.f); | 475 translate_2d_transform.Translate(80.f, 60.f); |
476 | 476 |
477 root()->SetBounds(gfx::Size(350, 200)); | 477 root()->SetBounds(gfx::Size(350, 200)); |
478 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); | 478 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); |
479 child2()->SetTransform(translate_2d_transform); | 479 child2()->test_properties()->transform = translate_2d_transform; |
480 | 480 |
481 gfx::Transform perspective; | 481 gfx::Transform perspective; |
482 perspective.ApplyPerspectiveDepth(100.f); | 482 perspective.ApplyPerspectiveDepth(100.f); |
483 | 483 |
484 gfx::Size bounds(100.f, 100.f); | 484 gfx::Size bounds(100.f, 100.f); |
485 grand_child()->SetPosition(gfx::PointF(150.f, 50.f)); | 485 grand_child()->SetPosition(gfx::PointF(150.f, 50.f)); |
486 grand_child()->SetBounds(bounds); | 486 grand_child()->SetBounds(bounds); |
487 grand_child()->SetTransform(perspective); | 487 grand_child()->test_properties()->transform = perspective; |
488 grand_child()->test_properties()->transform_origin = | 488 grand_child()->test_properties()->transform_origin = |
489 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0); | 489 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0); |
490 | 490 |
491 great_grand_child()->test_properties()->transform_origin = | 491 great_grand_child()->test_properties()->transform_origin = |
492 gfx::Point3F(bounds.width() * 0.25f, bounds.height() * 0.25f, 0); | 492 gfx::Point3F(bounds.width() * 0.25f, bounds.height() * 0.25f, 0); |
493 great_grand_child()->SetPosition(gfx::PointF(25.f, 25.f)); | 493 great_grand_child()->SetPosition(gfx::PointF(25.f, 25.f)); |
494 great_grand_child()->SetBounds(gfx::Size(50.f, 50.f)); | 494 great_grand_child()->SetBounds(gfx::Size(50.f, 50.f)); |
495 great_grand_child()->SetDrawsContent(true); | 495 great_grand_child()->SetDrawsContent(true); |
496 | 496 |
497 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 497 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 rotate_x_end.AppendRotate(1.f, 0.f, 0.f, 90.f); | 551 rotate_x_end.AppendRotate(1.f, 0.f, 0.f, 90.f); |
552 AddAnimatedTransformToElementWithPlayer(great_grand_child()->element_id(), | 552 AddAnimatedTransformToElementWithPlayer(great_grand_child()->element_id(), |
553 timeline(), duration, start, | 553 timeline(), duration, start, |
554 rotate_x_end); | 554 rotate_x_end); |
555 | 555 |
556 gfx::Transform translate_2d_transform; | 556 gfx::Transform translate_2d_transform; |
557 translate_2d_transform.Translate(80.f, 60.f); | 557 translate_2d_transform.Translate(80.f, 60.f); |
558 | 558 |
559 root()->SetBounds(gfx::Size(350, 200)); | 559 root()->SetBounds(gfx::Size(350, 200)); |
560 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); | 560 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); |
561 child2()->SetTransform(translate_2d_transform); | 561 child2()->test_properties()->transform = translate_2d_transform; |
562 | 562 |
563 gfx::Size bounds(100.f, 100.f); | 563 gfx::Size bounds(100.f, 100.f); |
564 grand_child()->SetPosition(gfx::PointF(150.f, 50.f)); | 564 grand_child()->SetPosition(gfx::PointF(150.f, 50.f)); |
565 grand_child()->SetBounds(bounds); | 565 grand_child()->SetBounds(bounds); |
566 | 566 |
567 great_grand_child()->test_properties()->transform_origin = | 567 great_grand_child()->test_properties()->transform_origin = |
568 gfx::Point3F(bounds.width() * 0.25f, bounds.height() * 0.25f, 0); | 568 gfx::Point3F(bounds.width() * 0.25f, bounds.height() * 0.25f, 0); |
569 great_grand_child()->SetPosition(gfx::PointF(25.f, 25.f)); | 569 great_grand_child()->SetPosition(gfx::PointF(25.f, 25.f)); |
570 great_grand_child()->SetBounds( | 570 great_grand_child()->SetBounds( |
571 gfx::Size(bounds.width() * 0.5f, bounds.height() * 0.5f)); | 571 gfx::Size(bounds.width() * 0.5f, bounds.height() * 0.5f)); |
572 great_grand_child()->SetDrawsContent(true); | 572 great_grand_child()->SetDrawsContent(true); |
573 | 573 |
574 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 574 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
575 | 575 |
576 gfx::BoxF box; | 576 gfx::BoxF box; |
577 bool success = LayerUtils::GetAnimationBounds(*great_grand_child(), &box); | 577 bool success = LayerUtils::GetAnimationBounds(*great_grand_child(), &box); |
578 EXPECT_TRUE(success); | 578 EXPECT_TRUE(success); |
579 | 579 |
580 // Same as RotateXWithPerspectiveUnderAncestorsWithPositionOr2DTransform test, | 580 // Same as RotateXWithPerspectiveUnderAncestorsWithPositionOr2DTransform test, |
581 // except for the perspective calculations. | 581 // except for the perspective calculations. |
582 | 582 |
583 gfx::BoxF expected(295.f, 180.f, -25.f, 50.f, 50.f, 50.f); | 583 gfx::BoxF expected(295.f, 180.f, -25.f, 50.f, 50.f, 50.f); |
584 EXPECT_BOXF_EQ(expected, box); | 584 EXPECT_BOXF_EQ(expected, box); |
585 } | 585 } |
586 | 586 |
587 } // namespace | 587 } // namespace |
588 | 588 |
589 } // namespace cc | 589 } // namespace cc |
OLD | NEW |