OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/animation/layer_animation_controller.h" | 5 #include "cc/animation/layer_animation_controller.h" |
6 | 6 |
7 #include "cc/animation/animation.h" | 7 #include "cc/animation/animation.h" |
8 #include "cc/animation/animation_curve.h" | 8 #include "cc/animation/animation_curve.h" |
9 #include "cc/animation/animation_delegate.h" | 9 #include "cc/animation/animation_delegate.h" |
10 #include "cc/animation/animation_registrar.h" | 10 #include "cc/animation/animation_registrar.h" |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 KeyframedTransformAnimationCurve::Create()); | 509 KeyframedTransformAnimationCurve::Create()); |
510 | 510 |
511 // Create simple Transform animation. | 511 // Create simple Transform animation. |
512 TransformOperations operations; | 512 TransformOperations operations; |
513 curve->AddKeyframe( | 513 curve->AddKeyframe( |
514 TransformKeyframe::Create(0, operations, scoped_ptr<TimingFunction>())); | 514 TransformKeyframe::Create(0, operations, scoped_ptr<TimingFunction>())); |
515 operations.AppendTranslate(delta_x, delta_y, 0); | 515 operations.AppendTranslate(delta_x, delta_y, 0); |
516 curve->AddKeyframe( | 516 curve->AddKeyframe( |
517 TransformKeyframe::Create(1, operations, scoped_ptr<TimingFunction>())); | 517 TransformKeyframe::Create(1, operations, scoped_ptr<TimingFunction>())); |
518 | 518 |
519 scoped_ptr<Animation> animation(Animation::Create( | 519 scoped_ptr<Animation> animation( |
520 curve.PassAs<AnimationCurve>(), 1, 0, Animation::Transform)); | 520 Animation::Create(curve.Pass(), 1, 0, Animation::Transform)); |
521 animation->set_is_impl_only(true); | 521 animation->set_is_impl_only(true); |
522 controller_impl->AddAnimation(animation.Pass()); | 522 controller_impl->AddAnimation(animation.Pass()); |
523 | 523 |
524 // Run animation. | 524 // Run animation. |
525 controller_impl->Animate(kInitialTickTime); | 525 controller_impl->Animate(kInitialTickTime); |
526 controller_impl->UpdateState(true, events.get()); | 526 controller_impl->UpdateState(true, events.get()); |
527 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 527 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
528 EXPECT_EQ(gfx::Transform(), dummy_impl.transform()); | 528 EXPECT_EQ(gfx::Transform(), dummy_impl.transform()); |
529 EXPECT_EQ(1u, events->size()); | 529 EXPECT_EQ(1u, events->size()); |
530 const AnimationEvent* start_transform_event = | 530 const AnimationEvent* start_transform_event = |
(...skipping 30 matching lines...) Expand all Loading... |
561 | 561 |
562 FilterOperations start_filters; | 562 FilterOperations start_filters; |
563 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); | 563 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); |
564 curve->AddKeyframe( | 564 curve->AddKeyframe( |
565 FilterKeyframe::Create(0, start_filters, scoped_ptr<TimingFunction>())); | 565 FilterKeyframe::Create(0, start_filters, scoped_ptr<TimingFunction>())); |
566 FilterOperations end_filters; | 566 FilterOperations end_filters; |
567 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); | 567 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); |
568 curve->AddKeyframe( | 568 curve->AddKeyframe( |
569 FilterKeyframe::Create(1, end_filters, scoped_ptr<TimingFunction>())); | 569 FilterKeyframe::Create(1, end_filters, scoped_ptr<TimingFunction>())); |
570 | 570 |
571 scoped_ptr<Animation> animation(Animation::Create( | 571 scoped_ptr<Animation> animation( |
572 curve.PassAs<AnimationCurve>(), 1, 0, Animation::Filter)); | 572 Animation::Create(curve.Pass(), 1, 0, Animation::Filter)); |
573 controller->AddAnimation(animation.Pass()); | 573 controller->AddAnimation(animation.Pass()); |
574 | 574 |
575 controller->Animate(kInitialTickTime); | 575 controller->Animate(kInitialTickTime); |
576 controller->UpdateState(true, events.get()); | 576 controller->UpdateState(true, events.get()); |
577 EXPECT_TRUE(controller->HasActiveAnimation()); | 577 EXPECT_TRUE(controller->HasActiveAnimation()); |
578 EXPECT_EQ(start_filters, dummy.filters()); | 578 EXPECT_EQ(start_filters, dummy.filters()); |
579 // A non-impl-only animation should not generate property updates. | 579 // A non-impl-only animation should not generate property updates. |
580 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 580 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
581 EXPECT_FALSE(event); | 581 EXPECT_FALSE(event); |
582 | 582 |
(...skipping 27 matching lines...) Expand all Loading... |
610 // Create simple Filter animation. | 610 // Create simple Filter animation. |
611 FilterOperations start_filters; | 611 FilterOperations start_filters; |
612 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); | 612 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); |
613 curve->AddKeyframe( | 613 curve->AddKeyframe( |
614 FilterKeyframe::Create(0, start_filters, scoped_ptr<TimingFunction>())); | 614 FilterKeyframe::Create(0, start_filters, scoped_ptr<TimingFunction>())); |
615 FilterOperations end_filters; | 615 FilterOperations end_filters; |
616 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); | 616 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); |
617 curve->AddKeyframe( | 617 curve->AddKeyframe( |
618 FilterKeyframe::Create(1, end_filters, scoped_ptr<TimingFunction>())); | 618 FilterKeyframe::Create(1, end_filters, scoped_ptr<TimingFunction>())); |
619 | 619 |
620 scoped_ptr<Animation> animation(Animation::Create( | 620 scoped_ptr<Animation> animation( |
621 curve.PassAs<AnimationCurve>(), 1, 0, Animation::Filter)); | 621 Animation::Create(curve.Pass(), 1, 0, Animation::Filter)); |
622 animation->set_is_impl_only(true); | 622 animation->set_is_impl_only(true); |
623 controller_impl->AddAnimation(animation.Pass()); | 623 controller_impl->AddAnimation(animation.Pass()); |
624 | 624 |
625 // Run animation. | 625 // Run animation. |
626 controller_impl->Animate(kInitialTickTime); | 626 controller_impl->Animate(kInitialTickTime); |
627 controller_impl->UpdateState(true, events.get()); | 627 controller_impl->UpdateState(true, events.get()); |
628 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 628 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
629 EXPECT_EQ(start_filters, dummy_impl.filters()); | 629 EXPECT_EQ(start_filters, dummy_impl.filters()); |
630 EXPECT_EQ(1u, events->size()); | 630 EXPECT_EQ(1u, events->size()); |
631 const AnimationEvent* start_filter_event = | 631 const AnimationEvent* start_filter_event = |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 controller->AddValueObserver(&dummy); | 663 controller->AddValueObserver(&dummy); |
664 controller->set_value_provider(&dummy_provider); | 664 controller->set_value_provider(&dummy_provider); |
665 | 665 |
666 gfx::Vector2dF initial_value(100.f, 300.f); | 666 gfx::Vector2dF initial_value(100.f, 300.f); |
667 gfx::Vector2dF target_value(300.f, 200.f); | 667 gfx::Vector2dF target_value(300.f, 200.f); |
668 scoped_ptr<ScrollOffsetAnimationCurve> curve( | 668 scoped_ptr<ScrollOffsetAnimationCurve> curve( |
669 ScrollOffsetAnimationCurve::Create( | 669 ScrollOffsetAnimationCurve::Create( |
670 target_value, | 670 target_value, |
671 EaseInOutTimingFunction::Create().Pass())); | 671 EaseInOutTimingFunction::Create().Pass())); |
672 | 672 |
673 scoped_ptr<Animation> animation(Animation::Create( | 673 scoped_ptr<Animation> animation( |
674 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset)); | 674 Animation::Create(curve.Pass(), 1, 0, Animation::ScrollOffset)); |
675 animation->set_needs_synchronized_start_time(true); | 675 animation->set_needs_synchronized_start_time(true); |
676 controller->AddAnimation(animation.Pass()); | 676 controller->AddAnimation(animation.Pass()); |
677 | 677 |
678 dummy_provider_impl.set_scroll_offset(initial_value); | 678 dummy_provider_impl.set_scroll_offset(initial_value); |
679 controller->PushAnimationUpdatesTo(controller_impl.get()); | 679 controller->PushAnimationUpdatesTo(controller_impl.get()); |
680 controller_impl->ActivateAnimations(); | 680 controller_impl->ActivateAnimations(); |
681 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset)); | 681 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset)); |
682 double duration_in_seconds = | 682 double duration_in_seconds = |
683 controller_impl->GetAnimation(Animation::ScrollOffset) | 683 controller_impl->GetAnimation(Animation::ScrollOffset) |
684 ->curve() | 684 ->curve() |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 controller->AddValueObserver(&dummy); | 745 controller->AddValueObserver(&dummy); |
746 controller->set_value_provider(&dummy_provider); | 746 controller->set_value_provider(&dummy_provider); |
747 | 747 |
748 gfx::Vector2dF initial_value(500.f, 100.f); | 748 gfx::Vector2dF initial_value(500.f, 100.f); |
749 gfx::Vector2dF target_value(300.f, 200.f); | 749 gfx::Vector2dF target_value(300.f, 200.f); |
750 scoped_ptr<ScrollOffsetAnimationCurve> curve( | 750 scoped_ptr<ScrollOffsetAnimationCurve> curve( |
751 ScrollOffsetAnimationCurve::Create( | 751 ScrollOffsetAnimationCurve::Create( |
752 target_value, | 752 target_value, |
753 EaseInOutTimingFunction::Create().Pass())); | 753 EaseInOutTimingFunction::Create().Pass())); |
754 | 754 |
755 scoped_ptr<Animation> animation(Animation::Create( | 755 scoped_ptr<Animation> animation( |
756 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset)); | 756 Animation::Create(curve.Pass(), 1, 0, Animation::ScrollOffset)); |
757 animation->set_needs_synchronized_start_time(true); | 757 animation->set_needs_synchronized_start_time(true); |
758 controller->AddAnimation(animation.Pass()); | 758 controller->AddAnimation(animation.Pass()); |
759 | 759 |
760 dummy_provider.set_scroll_offset(initial_value); | 760 dummy_provider.set_scroll_offset(initial_value); |
761 controller->PushAnimationUpdatesTo(controller_impl.get()); | 761 controller->PushAnimationUpdatesTo(controller_impl.get()); |
762 controller_impl->ActivateAnimations(); | 762 controller_impl->ActivateAnimations(); |
763 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset)); | 763 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset)); |
764 double duration_in_seconds = | 764 double duration_in_seconds = |
765 controller_impl->GetAnimation(Animation::ScrollOffset) | 765 controller_impl->GetAnimation(Animation::ScrollOffset) |
766 ->curve() | 766 ->curve() |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 | 821 |
822 gfx::Vector2dF initial_value(100.f, 300.f); | 822 gfx::Vector2dF initial_value(100.f, 300.f); |
823 gfx::Vector2dF target_value(300.f, 200.f); | 823 gfx::Vector2dF target_value(300.f, 200.f); |
824 scoped_ptr<ScrollOffsetAnimationCurve> curve( | 824 scoped_ptr<ScrollOffsetAnimationCurve> curve( |
825 ScrollOffsetAnimationCurve::Create( | 825 ScrollOffsetAnimationCurve::Create( |
826 target_value, | 826 target_value, |
827 EaseInOutTimingFunction::Create().Pass())); | 827 EaseInOutTimingFunction::Create().Pass())); |
828 curve->SetInitialValue(initial_value); | 828 curve->SetInitialValue(initial_value); |
829 double duration_in_seconds = curve->Duration(); | 829 double duration_in_seconds = curve->Duration(); |
830 | 830 |
831 scoped_ptr<Animation> animation(Animation::Create( | 831 scoped_ptr<Animation> animation( |
832 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset)); | 832 Animation::Create(curve.Pass(), 1, 0, Animation::ScrollOffset)); |
833 animation->set_is_impl_only(true); | 833 animation->set_is_impl_only(true); |
834 controller_impl->AddAnimation(animation.Pass()); | 834 controller_impl->AddAnimation(animation.Pass()); |
835 | 835 |
836 controller_impl->Animate(kInitialTickTime); | 836 controller_impl->Animate(kInitialTickTime); |
837 controller_impl->UpdateState(true, events.get()); | 837 controller_impl->UpdateState(true, events.get()); |
838 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 838 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
839 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); | 839 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); |
840 // Scroll offset animations should not generate property updates. | 840 // Scroll offset animations should not generate property updates. |
841 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 841 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
842 EXPECT_FALSE(event); | 842 EXPECT_FALSE(event); |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1476 scoped_ptr<KeyframedTransformAnimationCurve> curve1( | 1476 scoped_ptr<KeyframedTransformAnimationCurve> curve1( |
1477 KeyframedTransformAnimationCurve::Create()); | 1477 KeyframedTransformAnimationCurve::Create()); |
1478 | 1478 |
1479 TransformOperations operations1; | 1479 TransformOperations operations1; |
1480 curve1->AddKeyframe(TransformKeyframe::Create( | 1480 curve1->AddKeyframe(TransformKeyframe::Create( |
1481 0.0, operations1, scoped_ptr<TimingFunction>())); | 1481 0.0, operations1, scoped_ptr<TimingFunction>())); |
1482 operations1.AppendTranslate(10.0, 15.0, 0.0); | 1482 operations1.AppendTranslate(10.0, 15.0, 0.0); |
1483 curve1->AddKeyframe(TransformKeyframe::Create( | 1483 curve1->AddKeyframe(TransformKeyframe::Create( |
1484 1.0, operations1, scoped_ptr<TimingFunction>())); | 1484 1.0, operations1, scoped_ptr<TimingFunction>())); |
1485 | 1485 |
1486 scoped_ptr<Animation> animation(Animation::Create( | 1486 scoped_ptr<Animation> animation( |
1487 curve1.PassAs<AnimationCurve>(), 1, 1, Animation::Transform)); | 1487 Animation::Create(curve1.Pass(), 1, 1, Animation::Transform)); |
1488 controller_impl->AddAnimation(animation.Pass()); | 1488 controller_impl->AddAnimation(animation.Pass()); |
1489 | 1489 |
1490 scoped_ptr<KeyframedTransformAnimationCurve> curve2( | 1490 scoped_ptr<KeyframedTransformAnimationCurve> curve2( |
1491 KeyframedTransformAnimationCurve::Create()); | 1491 KeyframedTransformAnimationCurve::Create()); |
1492 | 1492 |
1493 TransformOperations operations2; | 1493 TransformOperations operations2; |
1494 curve2->AddKeyframe(TransformKeyframe::Create( | 1494 curve2->AddKeyframe(TransformKeyframe::Create( |
1495 0.0, operations2, scoped_ptr<TimingFunction>())); | 1495 0.0, operations2, scoped_ptr<TimingFunction>())); |
1496 operations2.AppendScale(2.0, 3.0, 4.0); | 1496 operations2.AppendScale(2.0, 3.0, 4.0); |
1497 curve2->AddKeyframe(TransformKeyframe::Create( | 1497 curve2->AddKeyframe(TransformKeyframe::Create( |
1498 1.0, operations2, scoped_ptr<TimingFunction>())); | 1498 1.0, operations2, scoped_ptr<TimingFunction>())); |
1499 | 1499 |
1500 animation = Animation::Create( | 1500 animation = Animation::Create(curve2.Pass(), 2, 2, Animation::Transform); |
1501 curve2.PassAs<AnimationCurve>(), 2, 2, Animation::Transform); | |
1502 controller_impl->AddAnimation(animation.Pass()); | 1501 controller_impl->AddAnimation(animation.Pass()); |
1503 | 1502 |
1504 gfx::BoxF box(1.f, 2.f, -1.f, 3.f, 4.f, 5.f); | 1503 gfx::BoxF box(1.f, 2.f, -1.f, 3.f, 4.f, 5.f); |
1505 gfx::BoxF bounds; | 1504 gfx::BoxF bounds; |
1506 | 1505 |
1507 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); | 1506 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); |
1508 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 13.f, 19.f, 20.f).ToString(), | 1507 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 13.f, 19.f, 20.f).ToString(), |
1509 bounds.ToString()); | 1508 bounds.ToString()); |
1510 | 1509 |
1511 controller_impl->GetAnimation(1, Animation::Transform) | 1510 controller_impl->GetAnimation(1, Animation::Transform) |
(...skipping 14 matching lines...) Expand all Loading... |
1526 scoped_ptr<KeyframedTransformAnimationCurve> curve3( | 1525 scoped_ptr<KeyframedTransformAnimationCurve> curve3( |
1527 KeyframedTransformAnimationCurve::Create()); | 1526 KeyframedTransformAnimationCurve::Create()); |
1528 TransformOperations operations3; | 1527 TransformOperations operations3; |
1529 gfx::Transform transform3; | 1528 gfx::Transform transform3; |
1530 transform3.Scale3d(1.0, 2.0, 3.0); | 1529 transform3.Scale3d(1.0, 2.0, 3.0); |
1531 curve3->AddKeyframe(TransformKeyframe::Create( | 1530 curve3->AddKeyframe(TransformKeyframe::Create( |
1532 0.0, operations3, scoped_ptr<TimingFunction>())); | 1531 0.0, operations3, scoped_ptr<TimingFunction>())); |
1533 operations3.AppendMatrix(transform3); | 1532 operations3.AppendMatrix(transform3); |
1534 curve3->AddKeyframe(TransformKeyframe::Create( | 1533 curve3->AddKeyframe(TransformKeyframe::Create( |
1535 1.0, operations3, scoped_ptr<TimingFunction>())); | 1534 1.0, operations3, scoped_ptr<TimingFunction>())); |
1536 animation = Animation::Create( | 1535 animation = Animation::Create(curve3.Pass(), 3, 3, Animation::Transform); |
1537 curve3.PassAs<AnimationCurve>(), 3, 3, Animation::Transform); | |
1538 controller_impl->AddAnimation(animation.Pass()); | 1536 controller_impl->AddAnimation(animation.Pass()); |
1539 EXPECT_FALSE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); | 1537 EXPECT_FALSE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); |
1540 } | 1538 } |
1541 | 1539 |
1542 // Tests that AbortAnimations aborts all animations targeting the specified | 1540 // Tests that AbortAnimations aborts all animations targeting the specified |
1543 // property. | 1541 // property. |
1544 TEST(LayerAnimationControllerTest, AbortAnimations) { | 1542 TEST(LayerAnimationControllerTest, AbortAnimations) { |
1545 FakeLayerAnimationValueObserver dummy; | 1543 FakeLayerAnimationValueObserver dummy; |
1546 scoped_refptr<LayerAnimationController> controller( | 1544 scoped_refptr<LayerAnimationController> controller( |
1547 LayerAnimationController::Create(0)); | 1545 LayerAnimationController::Create(0)); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1800 scoped_ptr<KeyframedTransformAnimationCurve> curve1( | 1798 scoped_ptr<KeyframedTransformAnimationCurve> curve1( |
1801 KeyframedTransformAnimationCurve::Create()); | 1799 KeyframedTransformAnimationCurve::Create()); |
1802 | 1800 |
1803 TransformOperations operations1; | 1801 TransformOperations operations1; |
1804 curve1->AddKeyframe(TransformKeyframe::Create( | 1802 curve1->AddKeyframe(TransformKeyframe::Create( |
1805 0.0, operations1, scoped_ptr<TimingFunction>())); | 1803 0.0, operations1, scoped_ptr<TimingFunction>())); |
1806 operations1.AppendTranslate(10.0, 15.0, 0.0); | 1804 operations1.AppendTranslate(10.0, 15.0, 0.0); |
1807 curve1->AddKeyframe(TransformKeyframe::Create( | 1805 curve1->AddKeyframe(TransformKeyframe::Create( |
1808 1.0, operations1, scoped_ptr<TimingFunction>())); | 1806 1.0, operations1, scoped_ptr<TimingFunction>())); |
1809 | 1807 |
1810 scoped_ptr<Animation> animation(Animation::Create( | 1808 scoped_ptr<Animation> animation( |
1811 curve1.PassAs<AnimationCurve>(), 2, 2, Animation::Transform)); | 1809 Animation::Create(curve1.Pass(), 2, 2, Animation::Transform)); |
1812 controller_impl->AddAnimation(animation.Pass()); | 1810 controller_impl->AddAnimation(animation.Pass()); |
1813 | 1811 |
1814 // Translations don't affect scale. | 1812 // Translations don't affect scale. |
1815 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); | 1813 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); |
1816 | 1814 |
1817 scoped_ptr<KeyframedTransformAnimationCurve> curve2( | 1815 scoped_ptr<KeyframedTransformAnimationCurve> curve2( |
1818 KeyframedTransformAnimationCurve::Create()); | 1816 KeyframedTransformAnimationCurve::Create()); |
1819 | 1817 |
1820 TransformOperations operations2; | 1818 TransformOperations operations2; |
1821 curve2->AddKeyframe(TransformKeyframe::Create( | 1819 curve2->AddKeyframe(TransformKeyframe::Create( |
1822 0.0, operations2, scoped_ptr<TimingFunction>())); | 1820 0.0, operations2, scoped_ptr<TimingFunction>())); |
1823 operations2.AppendScale(2.0, 3.0, 4.0); | 1821 operations2.AppendScale(2.0, 3.0, 4.0); |
1824 curve2->AddKeyframe(TransformKeyframe::Create( | 1822 curve2->AddKeyframe(TransformKeyframe::Create( |
1825 1.0, operations2, scoped_ptr<TimingFunction>())); | 1823 1.0, operations2, scoped_ptr<TimingFunction>())); |
1826 | 1824 |
1827 animation = Animation::Create( | 1825 animation = Animation::Create(curve2.Pass(), 3, 3, Animation::Transform); |
1828 curve2.PassAs<AnimationCurve>(), 3, 3, Animation::Transform); | |
1829 controller_impl->AddAnimation(animation.Pass()); | 1826 controller_impl->AddAnimation(animation.Pass()); |
1830 | 1827 |
1831 EXPECT_TRUE(controller_impl->HasAnimationThatAffectsScale()); | 1828 EXPECT_TRUE(controller_impl->HasAnimationThatAffectsScale()); |
1832 | 1829 |
1833 controller_impl->GetAnimation(3, Animation::Transform) | 1830 controller_impl->GetAnimation(3, Animation::Transform) |
1834 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); | 1831 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); |
1835 | 1832 |
1836 // Only unfinished animations should be considered by | 1833 // Only unfinished animations should be considered by |
1837 // HasAnimationThatAffectsScale. | 1834 // HasAnimationThatAffectsScale. |
1838 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); | 1835 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); |
(...skipping 16 matching lines...) Expand all Loading... |
1855 scoped_ptr<KeyframedTransformAnimationCurve> curve1( | 1852 scoped_ptr<KeyframedTransformAnimationCurve> curve1( |
1856 KeyframedTransformAnimationCurve::Create()); | 1853 KeyframedTransformAnimationCurve::Create()); |
1857 | 1854 |
1858 TransformOperations operations1; | 1855 TransformOperations operations1; |
1859 curve1->AddKeyframe(TransformKeyframe::Create( | 1856 curve1->AddKeyframe(TransformKeyframe::Create( |
1860 0.0, operations1, scoped_ptr<TimingFunction>())); | 1857 0.0, operations1, scoped_ptr<TimingFunction>())); |
1861 operations1.AppendTranslate(10.0, 15.0, 0.0); | 1858 operations1.AppendTranslate(10.0, 15.0, 0.0); |
1862 curve1->AddKeyframe(TransformKeyframe::Create( | 1859 curve1->AddKeyframe(TransformKeyframe::Create( |
1863 1.0, operations1, scoped_ptr<TimingFunction>())); | 1860 1.0, operations1, scoped_ptr<TimingFunction>())); |
1864 | 1861 |
1865 scoped_ptr<Animation> animation(Animation::Create( | 1862 scoped_ptr<Animation> animation( |
1866 curve1.PassAs<AnimationCurve>(), 2, 2, Animation::Transform)); | 1863 Animation::Create(curve1.Pass(), 2, 2, Animation::Transform)); |
1867 controller_impl->AddAnimation(animation.Pass()); | 1864 controller_impl->AddAnimation(animation.Pass()); |
1868 | 1865 |
1869 // The only transform animation we've added is a translation. | 1866 // The only transform animation we've added is a translation. |
1870 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms()); | 1867 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms()); |
1871 | 1868 |
1872 scoped_ptr<KeyframedTransformAnimationCurve> curve2( | 1869 scoped_ptr<KeyframedTransformAnimationCurve> curve2( |
1873 KeyframedTransformAnimationCurve::Create()); | 1870 KeyframedTransformAnimationCurve::Create()); |
1874 | 1871 |
1875 TransformOperations operations2; | 1872 TransformOperations operations2; |
1876 curve2->AddKeyframe(TransformKeyframe::Create( | 1873 curve2->AddKeyframe(TransformKeyframe::Create( |
1877 0.0, operations2, scoped_ptr<TimingFunction>())); | 1874 0.0, operations2, scoped_ptr<TimingFunction>())); |
1878 operations2.AppendScale(2.0, 3.0, 4.0); | 1875 operations2.AppendScale(2.0, 3.0, 4.0); |
1879 curve2->AddKeyframe(TransformKeyframe::Create( | 1876 curve2->AddKeyframe(TransformKeyframe::Create( |
1880 1.0, operations2, scoped_ptr<TimingFunction>())); | 1877 1.0, operations2, scoped_ptr<TimingFunction>())); |
1881 | 1878 |
1882 animation = Animation::Create( | 1879 animation = Animation::Create(curve2.Pass(), 3, 3, Animation::Transform); |
1883 curve2.PassAs<AnimationCurve>(), 3, 3, Animation::Transform); | |
1884 controller_impl->AddAnimation(animation.Pass()); | 1880 controller_impl->AddAnimation(animation.Pass()); |
1885 | 1881 |
1886 // A scale animation is not a translation. | 1882 // A scale animation is not a translation. |
1887 EXPECT_FALSE(controller_impl->HasOnlyTranslationTransforms()); | 1883 EXPECT_FALSE(controller_impl->HasOnlyTranslationTransforms()); |
1888 | 1884 |
1889 controller_impl->GetAnimation(3, Animation::Transform) | 1885 controller_impl->GetAnimation(3, Animation::Transform) |
1890 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); | 1886 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); |
1891 | 1887 |
1892 // Only unfinished animations should be considered by | 1888 // Only unfinished animations should be considered by |
1893 // HasOnlyTranslationTransforms. | 1889 // HasOnlyTranslationTransforms. |
(...skipping 11 matching lines...) Expand all Loading... |
1905 scoped_ptr<KeyframedTransformAnimationCurve> curve1( | 1901 scoped_ptr<KeyframedTransformAnimationCurve> curve1( |
1906 KeyframedTransformAnimationCurve::Create()); | 1902 KeyframedTransformAnimationCurve::Create()); |
1907 | 1903 |
1908 TransformOperations operations1; | 1904 TransformOperations operations1; |
1909 curve1->AddKeyframe(TransformKeyframe::Create( | 1905 curve1->AddKeyframe(TransformKeyframe::Create( |
1910 0.0, operations1, scoped_ptr<TimingFunction>())); | 1906 0.0, operations1, scoped_ptr<TimingFunction>())); |
1911 operations1.AppendScale(2.0, 3.0, 4.0); | 1907 operations1.AppendScale(2.0, 3.0, 4.0); |
1912 curve1->AddKeyframe(TransformKeyframe::Create( | 1908 curve1->AddKeyframe(TransformKeyframe::Create( |
1913 1.0, operations1, scoped_ptr<TimingFunction>())); | 1909 1.0, operations1, scoped_ptr<TimingFunction>())); |
1914 | 1910 |
1915 scoped_ptr<Animation> animation(Animation::Create( | 1911 scoped_ptr<Animation> animation( |
1916 curve1.PassAs<AnimationCurve>(), 1, 1, Animation::Transform)); | 1912 Animation::Create(curve1.Pass(), 1, 1, Animation::Transform)); |
1917 controller_impl->AddAnimation(animation.Pass()); | 1913 controller_impl->AddAnimation(animation.Pass()); |
1918 | 1914 |
1919 EXPECT_TRUE(controller_impl->MaximumScale(&max_scale)); | 1915 EXPECT_TRUE(controller_impl->MaximumScale(&max_scale)); |
1920 EXPECT_EQ(4.f, max_scale); | 1916 EXPECT_EQ(4.f, max_scale); |
1921 | 1917 |
1922 scoped_ptr<KeyframedTransformAnimationCurve> curve2( | 1918 scoped_ptr<KeyframedTransformAnimationCurve> curve2( |
1923 KeyframedTransformAnimationCurve::Create()); | 1919 KeyframedTransformAnimationCurve::Create()); |
1924 | 1920 |
1925 TransformOperations operations2; | 1921 TransformOperations operations2; |
1926 curve2->AddKeyframe(TransformKeyframe::Create( | 1922 curve2->AddKeyframe(TransformKeyframe::Create( |
1927 0.0, operations2, scoped_ptr<TimingFunction>())); | 1923 0.0, operations2, scoped_ptr<TimingFunction>())); |
1928 operations2.AppendScale(6.0, 5.0, 4.0); | 1924 operations2.AppendScale(6.0, 5.0, 4.0); |
1929 curve2->AddKeyframe(TransformKeyframe::Create( | 1925 curve2->AddKeyframe(TransformKeyframe::Create( |
1930 1.0, operations2, scoped_ptr<TimingFunction>())); | 1926 1.0, operations2, scoped_ptr<TimingFunction>())); |
1931 | 1927 |
1932 animation = Animation::Create( | 1928 animation = Animation::Create(curve2.Pass(), 2, 2, Animation::Transform); |
1933 curve2.PassAs<AnimationCurve>(), 2, 2, Animation::Transform); | |
1934 controller_impl->AddAnimation(animation.Pass()); | 1929 controller_impl->AddAnimation(animation.Pass()); |
1935 | 1930 |
1936 EXPECT_TRUE(controller_impl->MaximumScale(&max_scale)); | 1931 EXPECT_TRUE(controller_impl->MaximumScale(&max_scale)); |
1937 EXPECT_EQ(6.f, max_scale); | 1932 EXPECT_EQ(6.f, max_scale); |
1938 | 1933 |
1939 scoped_ptr<KeyframedTransformAnimationCurve> curve3( | 1934 scoped_ptr<KeyframedTransformAnimationCurve> curve3( |
1940 KeyframedTransformAnimationCurve::Create()); | 1935 KeyframedTransformAnimationCurve::Create()); |
1941 | 1936 |
1942 TransformOperations operations3; | 1937 TransformOperations operations3; |
1943 curve3->AddKeyframe(TransformKeyframe::Create( | 1938 curve3->AddKeyframe(TransformKeyframe::Create( |
1944 0.0, operations3, scoped_ptr<TimingFunction>())); | 1939 0.0, operations3, scoped_ptr<TimingFunction>())); |
1945 operations3.AppendPerspective(6.0); | 1940 operations3.AppendPerspective(6.0); |
1946 curve3->AddKeyframe(TransformKeyframe::Create( | 1941 curve3->AddKeyframe(TransformKeyframe::Create( |
1947 1.0, operations3, scoped_ptr<TimingFunction>())); | 1942 1.0, operations3, scoped_ptr<TimingFunction>())); |
1948 | 1943 |
1949 animation = Animation::Create( | 1944 animation = Animation::Create(curve3.Pass(), 3, 3, Animation::Transform); |
1950 curve3.PassAs<AnimationCurve>(), 3, 3, Animation::Transform); | |
1951 controller_impl->AddAnimation(animation.Pass()); | 1945 controller_impl->AddAnimation(animation.Pass()); |
1952 | 1946 |
1953 EXPECT_FALSE(controller_impl->MaximumScale(&max_scale)); | 1947 EXPECT_FALSE(controller_impl->MaximumScale(&max_scale)); |
1954 | 1948 |
1955 controller_impl->GetAnimation(3, Animation::Transform) | 1949 controller_impl->GetAnimation(3, Animation::Transform) |
1956 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); | 1950 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); |
1957 controller_impl->GetAnimation(2, Animation::Transform) | 1951 controller_impl->GetAnimation(2, Animation::Transform) |
1958 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); | 1952 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); |
1959 | 1953 |
1960 // Only unfinished animations should be considered by | 1954 // Only unfinished animations should be considered by |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2260 // been ticked at the new animation's starting point. | 2254 // been ticked at the new animation's starting point. |
2261 EXPECT_EQ(Animation::Running, | 2255 EXPECT_EQ(Animation::Running, |
2262 controller_impl->GetAnimation(second_animation_group_id, | 2256 controller_impl->GetAnimation(second_animation_group_id, |
2263 Animation::Opacity)->run_state()); | 2257 Animation::Opacity)->run_state()); |
2264 EXPECT_EQ(1.f, pending_dummy_impl.opacity()); | 2258 EXPECT_EQ(1.f, pending_dummy_impl.opacity()); |
2265 EXPECT_EQ(1.f, dummy_impl.opacity()); | 2259 EXPECT_EQ(1.f, dummy_impl.opacity()); |
2266 } | 2260 } |
2267 | 2261 |
2268 } // namespace | 2262 } // namespace |
2269 } // namespace cc | 2263 } // namespace cc |
OLD | NEW |