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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 // Choose different values for x and y to avoid coincidental values in the | 503 // Choose different values for x and y to avoid coincidental values in the |
504 // observed transforms. | 504 // observed transforms. |
505 const float delta_x = 3; | 505 const float delta_x = 3; |
506 const float delta_y = 4; | 506 const float delta_y = 4; |
507 | 507 |
508 scoped_ptr<KeyframedTransformAnimationCurve> curve( | 508 scoped_ptr<KeyframedTransformAnimationCurve> curve( |
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(TransformKeyframe::Create(0, operations, nullptr)); |
514 TransformKeyframe::Create(0, operations, scoped_ptr<TimingFunction>())); | |
515 operations.AppendTranslate(delta_x, delta_y, 0); | 514 operations.AppendTranslate(delta_x, delta_y, 0); |
516 curve->AddKeyframe( | 515 curve->AddKeyframe(TransformKeyframe::Create(1, operations, nullptr)); |
517 TransformKeyframe::Create(1, operations, scoped_ptr<TimingFunction>())); | |
518 | 516 |
519 scoped_ptr<Animation> animation( | 517 scoped_ptr<Animation> animation( |
520 Animation::Create(curve.Pass(), 1, 0, Animation::Transform)); | 518 Animation::Create(curve.Pass(), 1, 0, Animation::Transform)); |
521 animation->set_is_impl_only(true); | 519 animation->set_is_impl_only(true); |
522 controller_impl->AddAnimation(animation.Pass()); | 520 controller_impl->AddAnimation(animation.Pass()); |
523 | 521 |
524 // Run animation. | 522 // Run animation. |
525 controller_impl->Animate(kInitialTickTime); | 523 controller_impl->Animate(kInitialTickTime); |
526 controller_impl->UpdateState(true, events.get()); | 524 controller_impl->UpdateState(true, events.get()); |
527 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 525 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
(...skipping 26 matching lines...) Expand all Loading... |
554 FakeLayerAnimationValueObserver dummy; | 552 FakeLayerAnimationValueObserver dummy; |
555 scoped_refptr<LayerAnimationController> controller( | 553 scoped_refptr<LayerAnimationController> controller( |
556 LayerAnimationController::Create(0)); | 554 LayerAnimationController::Create(0)); |
557 controller->AddValueObserver(&dummy); | 555 controller->AddValueObserver(&dummy); |
558 | 556 |
559 scoped_ptr<KeyframedFilterAnimationCurve> curve( | 557 scoped_ptr<KeyframedFilterAnimationCurve> curve( |
560 KeyframedFilterAnimationCurve::Create()); | 558 KeyframedFilterAnimationCurve::Create()); |
561 | 559 |
562 FilterOperations start_filters; | 560 FilterOperations start_filters; |
563 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); | 561 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); |
564 curve->AddKeyframe( | 562 curve->AddKeyframe(FilterKeyframe::Create(0, start_filters, nullptr)); |
565 FilterKeyframe::Create(0, start_filters, scoped_ptr<TimingFunction>())); | |
566 FilterOperations end_filters; | 563 FilterOperations end_filters; |
567 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); | 564 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); |
568 curve->AddKeyframe( | 565 curve->AddKeyframe(FilterKeyframe::Create(1, end_filters, nullptr)); |
569 FilterKeyframe::Create(1, end_filters, scoped_ptr<TimingFunction>())); | |
570 | 566 |
571 scoped_ptr<Animation> animation( | 567 scoped_ptr<Animation> animation( |
572 Animation::Create(curve.Pass(), 1, 0, Animation::Filter)); | 568 Animation::Create(curve.Pass(), 1, 0, Animation::Filter)); |
573 controller->AddAnimation(animation.Pass()); | 569 controller->AddAnimation(animation.Pass()); |
574 | 570 |
575 controller->Animate(kInitialTickTime); | 571 controller->Animate(kInitialTickTime); |
576 controller->UpdateState(true, events.get()); | 572 controller->UpdateState(true, events.get()); |
577 EXPECT_TRUE(controller->HasActiveAnimation()); | 573 EXPECT_TRUE(controller->HasActiveAnimation()); |
578 EXPECT_EQ(start_filters, dummy.filters()); | 574 EXPECT_EQ(start_filters, dummy.filters()); |
579 // A non-impl-only animation should not generate property updates. | 575 // A non-impl-only animation should not generate property updates. |
(...skipping 23 matching lines...) Expand all Loading... |
603 scoped_refptr<LayerAnimationController> controller_impl( | 599 scoped_refptr<LayerAnimationController> controller_impl( |
604 LayerAnimationController::Create(0)); | 600 LayerAnimationController::Create(0)); |
605 controller_impl->AddValueObserver(&dummy_impl); | 601 controller_impl->AddValueObserver(&dummy_impl); |
606 | 602 |
607 scoped_ptr<KeyframedFilterAnimationCurve> curve( | 603 scoped_ptr<KeyframedFilterAnimationCurve> curve( |
608 KeyframedFilterAnimationCurve::Create()); | 604 KeyframedFilterAnimationCurve::Create()); |
609 | 605 |
610 // Create simple Filter animation. | 606 // Create simple Filter animation. |
611 FilterOperations start_filters; | 607 FilterOperations start_filters; |
612 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); | 608 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); |
613 curve->AddKeyframe( | 609 curve->AddKeyframe(FilterKeyframe::Create(0, start_filters, nullptr)); |
614 FilterKeyframe::Create(0, start_filters, scoped_ptr<TimingFunction>())); | |
615 FilterOperations end_filters; | 610 FilterOperations end_filters; |
616 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); | 611 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); |
617 curve->AddKeyframe( | 612 curve->AddKeyframe(FilterKeyframe::Create(1, end_filters, nullptr)); |
618 FilterKeyframe::Create(1, end_filters, scoped_ptr<TimingFunction>())); | |
619 | 613 |
620 scoped_ptr<Animation> animation( | 614 scoped_ptr<Animation> animation( |
621 Animation::Create(curve.Pass(), 1, 0, Animation::Filter)); | 615 Animation::Create(curve.Pass(), 1, 0, Animation::Filter)); |
622 animation->set_is_impl_only(true); | 616 animation->set_is_impl_only(true); |
623 controller_impl->AddAnimation(animation.Pass()); | 617 controller_impl->AddAnimation(animation.Pass()); |
624 | 618 |
625 // Run animation. | 619 // Run animation. |
626 controller_impl->Animate(kInitialTickTime); | 620 controller_impl->Animate(kInitialTickTime); |
627 controller_impl->UpdateState(true, events.get()); | 621 controller_impl->UpdateState(true, events.get()); |
628 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 622 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1470 } | 1464 } |
1471 | 1465 |
1472 TEST(LayerAnimationControllerTest, TransformAnimationBounds) { | 1466 TEST(LayerAnimationControllerTest, TransformAnimationBounds) { |
1473 scoped_refptr<LayerAnimationController> controller_impl( | 1467 scoped_refptr<LayerAnimationController> controller_impl( |
1474 LayerAnimationController::Create(0)); | 1468 LayerAnimationController::Create(0)); |
1475 | 1469 |
1476 scoped_ptr<KeyframedTransformAnimationCurve> curve1( | 1470 scoped_ptr<KeyframedTransformAnimationCurve> curve1( |
1477 KeyframedTransformAnimationCurve::Create()); | 1471 KeyframedTransformAnimationCurve::Create()); |
1478 | 1472 |
1479 TransformOperations operations1; | 1473 TransformOperations operations1; |
1480 curve1->AddKeyframe(TransformKeyframe::Create( | 1474 curve1->AddKeyframe(TransformKeyframe::Create(0.0, operations1, nullptr)); |
1481 0.0, operations1, scoped_ptr<TimingFunction>())); | |
1482 operations1.AppendTranslate(10.0, 15.0, 0.0); | 1475 operations1.AppendTranslate(10.0, 15.0, 0.0); |
1483 curve1->AddKeyframe(TransformKeyframe::Create( | 1476 curve1->AddKeyframe(TransformKeyframe::Create(1.0, operations1, nullptr)); |
1484 1.0, operations1, scoped_ptr<TimingFunction>())); | |
1485 | 1477 |
1486 scoped_ptr<Animation> animation( | 1478 scoped_ptr<Animation> animation( |
1487 Animation::Create(curve1.Pass(), 1, 1, Animation::Transform)); | 1479 Animation::Create(curve1.Pass(), 1, 1, Animation::Transform)); |
1488 controller_impl->AddAnimation(animation.Pass()); | 1480 controller_impl->AddAnimation(animation.Pass()); |
1489 | 1481 |
1490 scoped_ptr<KeyframedTransformAnimationCurve> curve2( | 1482 scoped_ptr<KeyframedTransformAnimationCurve> curve2( |
1491 KeyframedTransformAnimationCurve::Create()); | 1483 KeyframedTransformAnimationCurve::Create()); |
1492 | 1484 |
1493 TransformOperations operations2; | 1485 TransformOperations operations2; |
1494 curve2->AddKeyframe(TransformKeyframe::Create( | 1486 curve2->AddKeyframe(TransformKeyframe::Create(0.0, operations2, nullptr)); |
1495 0.0, operations2, scoped_ptr<TimingFunction>())); | |
1496 operations2.AppendScale(2.0, 3.0, 4.0); | 1487 operations2.AppendScale(2.0, 3.0, 4.0); |
1497 curve2->AddKeyframe(TransformKeyframe::Create( | 1488 curve2->AddKeyframe(TransformKeyframe::Create(1.0, operations2, nullptr)); |
1498 1.0, operations2, scoped_ptr<TimingFunction>())); | |
1499 | 1489 |
1500 animation = Animation::Create(curve2.Pass(), 2, 2, Animation::Transform); | 1490 animation = Animation::Create(curve2.Pass(), 2, 2, Animation::Transform); |
1501 controller_impl->AddAnimation(animation.Pass()); | 1491 controller_impl->AddAnimation(animation.Pass()); |
1502 | 1492 |
1503 gfx::BoxF box(1.f, 2.f, -1.f, 3.f, 4.f, 5.f); | 1493 gfx::BoxF box(1.f, 2.f, -1.f, 3.f, 4.f, 5.f); |
1504 gfx::BoxF bounds; | 1494 gfx::BoxF bounds; |
1505 | 1495 |
1506 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); | 1496 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); |
1507 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 13.f, 19.f, 20.f).ToString(), | 1497 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 13.f, 19.f, 20.f).ToString(), |
1508 bounds.ToString()); | 1498 bounds.ToString()); |
(...skipping 11 matching lines...) Expand all Loading... |
1520 | 1510 |
1521 // There are no longer any running animations. | 1511 // There are no longer any running animations. |
1522 EXPECT_FALSE(controller_impl->HasTransformAnimationThatInflatesBounds()); | 1512 EXPECT_FALSE(controller_impl->HasTransformAnimationThatInflatesBounds()); |
1523 | 1513 |
1524 // Add an animation whose bounds we don't yet support computing. | 1514 // Add an animation whose bounds we don't yet support computing. |
1525 scoped_ptr<KeyframedTransformAnimationCurve> curve3( | 1515 scoped_ptr<KeyframedTransformAnimationCurve> curve3( |
1526 KeyframedTransformAnimationCurve::Create()); | 1516 KeyframedTransformAnimationCurve::Create()); |
1527 TransformOperations operations3; | 1517 TransformOperations operations3; |
1528 gfx::Transform transform3; | 1518 gfx::Transform transform3; |
1529 transform3.Scale3d(1.0, 2.0, 3.0); | 1519 transform3.Scale3d(1.0, 2.0, 3.0); |
1530 curve3->AddKeyframe(TransformKeyframe::Create( | 1520 curve3->AddKeyframe(TransformKeyframe::Create(0.0, operations3, nullptr)); |
1531 0.0, operations3, scoped_ptr<TimingFunction>())); | |
1532 operations3.AppendMatrix(transform3); | 1521 operations3.AppendMatrix(transform3); |
1533 curve3->AddKeyframe(TransformKeyframe::Create( | 1522 curve3->AddKeyframe(TransformKeyframe::Create(1.0, operations3, nullptr)); |
1534 1.0, operations3, scoped_ptr<TimingFunction>())); | |
1535 animation = Animation::Create(curve3.Pass(), 3, 3, Animation::Transform); | 1523 animation = Animation::Create(curve3.Pass(), 3, 3, Animation::Transform); |
1536 controller_impl->AddAnimation(animation.Pass()); | 1524 controller_impl->AddAnimation(animation.Pass()); |
1537 EXPECT_FALSE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); | 1525 EXPECT_FALSE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); |
1538 } | 1526 } |
1539 | 1527 |
1540 // Tests that AbortAnimations aborts all animations targeting the specified | 1528 // Tests that AbortAnimations aborts all animations targeting the specified |
1541 // property. | 1529 // property. |
1542 TEST(LayerAnimationControllerTest, AbortAnimations) { | 1530 TEST(LayerAnimationControllerTest, AbortAnimations) { |
1543 FakeLayerAnimationValueObserver dummy; | 1531 FakeLayerAnimationValueObserver dummy; |
1544 scoped_refptr<LayerAnimationController> controller( | 1532 scoped_refptr<LayerAnimationController> controller( |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1792 1, | 1780 1, |
1793 Animation::Opacity)); | 1781 Animation::Opacity)); |
1794 | 1782 |
1795 // Opacity animations don't affect scale. | 1783 // Opacity animations don't affect scale. |
1796 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); | 1784 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); |
1797 | 1785 |
1798 scoped_ptr<KeyframedTransformAnimationCurve> curve1( | 1786 scoped_ptr<KeyframedTransformAnimationCurve> curve1( |
1799 KeyframedTransformAnimationCurve::Create()); | 1787 KeyframedTransformAnimationCurve::Create()); |
1800 | 1788 |
1801 TransformOperations operations1; | 1789 TransformOperations operations1; |
1802 curve1->AddKeyframe(TransformKeyframe::Create( | 1790 curve1->AddKeyframe(TransformKeyframe::Create(0.0, operations1, nullptr)); |
1803 0.0, operations1, scoped_ptr<TimingFunction>())); | |
1804 operations1.AppendTranslate(10.0, 15.0, 0.0); | 1791 operations1.AppendTranslate(10.0, 15.0, 0.0); |
1805 curve1->AddKeyframe(TransformKeyframe::Create( | 1792 curve1->AddKeyframe(TransformKeyframe::Create(1.0, operations1, nullptr)); |
1806 1.0, operations1, scoped_ptr<TimingFunction>())); | |
1807 | 1793 |
1808 scoped_ptr<Animation> animation( | 1794 scoped_ptr<Animation> animation( |
1809 Animation::Create(curve1.Pass(), 2, 2, Animation::Transform)); | 1795 Animation::Create(curve1.Pass(), 2, 2, Animation::Transform)); |
1810 controller_impl->AddAnimation(animation.Pass()); | 1796 controller_impl->AddAnimation(animation.Pass()); |
1811 | 1797 |
1812 // Translations don't affect scale. | 1798 // Translations don't affect scale. |
1813 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); | 1799 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); |
1814 | 1800 |
1815 scoped_ptr<KeyframedTransformAnimationCurve> curve2( | 1801 scoped_ptr<KeyframedTransformAnimationCurve> curve2( |
1816 KeyframedTransformAnimationCurve::Create()); | 1802 KeyframedTransformAnimationCurve::Create()); |
1817 | 1803 |
1818 TransformOperations operations2; | 1804 TransformOperations operations2; |
1819 curve2->AddKeyframe(TransformKeyframe::Create( | 1805 curve2->AddKeyframe(TransformKeyframe::Create(0.0, operations2, nullptr)); |
1820 0.0, operations2, scoped_ptr<TimingFunction>())); | |
1821 operations2.AppendScale(2.0, 3.0, 4.0); | 1806 operations2.AppendScale(2.0, 3.0, 4.0); |
1822 curve2->AddKeyframe(TransformKeyframe::Create( | 1807 curve2->AddKeyframe(TransformKeyframe::Create(1.0, operations2, nullptr)); |
1823 1.0, operations2, scoped_ptr<TimingFunction>())); | |
1824 | 1808 |
1825 animation = Animation::Create(curve2.Pass(), 3, 3, Animation::Transform); | 1809 animation = Animation::Create(curve2.Pass(), 3, 3, Animation::Transform); |
1826 controller_impl->AddAnimation(animation.Pass()); | 1810 controller_impl->AddAnimation(animation.Pass()); |
1827 | 1811 |
1828 EXPECT_TRUE(controller_impl->HasAnimationThatAffectsScale()); | 1812 EXPECT_TRUE(controller_impl->HasAnimationThatAffectsScale()); |
1829 | 1813 |
1830 controller_impl->GetAnimation(3, Animation::Transform) | 1814 controller_impl->GetAnimation(3, Animation::Transform) |
1831 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); | 1815 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); |
1832 | 1816 |
1833 // Only unfinished animations should be considered by | 1817 // Only unfinished animations should be considered by |
(...skipping 12 matching lines...) Expand all Loading... |
1846 1, | 1830 1, |
1847 Animation::Opacity)); | 1831 Animation::Opacity)); |
1848 | 1832 |
1849 // Opacity animations aren't non-translation transforms. | 1833 // Opacity animations aren't non-translation transforms. |
1850 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms()); | 1834 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms()); |
1851 | 1835 |
1852 scoped_ptr<KeyframedTransformAnimationCurve> curve1( | 1836 scoped_ptr<KeyframedTransformAnimationCurve> curve1( |
1853 KeyframedTransformAnimationCurve::Create()); | 1837 KeyframedTransformAnimationCurve::Create()); |
1854 | 1838 |
1855 TransformOperations operations1; | 1839 TransformOperations operations1; |
1856 curve1->AddKeyframe(TransformKeyframe::Create( | 1840 curve1->AddKeyframe(TransformKeyframe::Create(0.0, operations1, nullptr)); |
1857 0.0, operations1, scoped_ptr<TimingFunction>())); | |
1858 operations1.AppendTranslate(10.0, 15.0, 0.0); | 1841 operations1.AppendTranslate(10.0, 15.0, 0.0); |
1859 curve1->AddKeyframe(TransformKeyframe::Create( | 1842 curve1->AddKeyframe(TransformKeyframe::Create(1.0, operations1, nullptr)); |
1860 1.0, operations1, scoped_ptr<TimingFunction>())); | |
1861 | 1843 |
1862 scoped_ptr<Animation> animation( | 1844 scoped_ptr<Animation> animation( |
1863 Animation::Create(curve1.Pass(), 2, 2, Animation::Transform)); | 1845 Animation::Create(curve1.Pass(), 2, 2, Animation::Transform)); |
1864 controller_impl->AddAnimation(animation.Pass()); | 1846 controller_impl->AddAnimation(animation.Pass()); |
1865 | 1847 |
1866 // The only transform animation we've added is a translation. | 1848 // The only transform animation we've added is a translation. |
1867 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms()); | 1849 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms()); |
1868 | 1850 |
1869 scoped_ptr<KeyframedTransformAnimationCurve> curve2( | 1851 scoped_ptr<KeyframedTransformAnimationCurve> curve2( |
1870 KeyframedTransformAnimationCurve::Create()); | 1852 KeyframedTransformAnimationCurve::Create()); |
1871 | 1853 |
1872 TransformOperations operations2; | 1854 TransformOperations operations2; |
1873 curve2->AddKeyframe(TransformKeyframe::Create( | 1855 curve2->AddKeyframe(TransformKeyframe::Create(0.0, operations2, nullptr)); |
1874 0.0, operations2, scoped_ptr<TimingFunction>())); | |
1875 operations2.AppendScale(2.0, 3.0, 4.0); | 1856 operations2.AppendScale(2.0, 3.0, 4.0); |
1876 curve2->AddKeyframe(TransformKeyframe::Create( | 1857 curve2->AddKeyframe(TransformKeyframe::Create(1.0, operations2, nullptr)); |
1877 1.0, operations2, scoped_ptr<TimingFunction>())); | |
1878 | 1858 |
1879 animation = Animation::Create(curve2.Pass(), 3, 3, Animation::Transform); | 1859 animation = Animation::Create(curve2.Pass(), 3, 3, Animation::Transform); |
1880 controller_impl->AddAnimation(animation.Pass()); | 1860 controller_impl->AddAnimation(animation.Pass()); |
1881 | 1861 |
1882 // A scale animation is not a translation. | 1862 // A scale animation is not a translation. |
1883 EXPECT_FALSE(controller_impl->HasOnlyTranslationTransforms()); | 1863 EXPECT_FALSE(controller_impl->HasOnlyTranslationTransforms()); |
1884 | 1864 |
1885 controller_impl->GetAnimation(3, Animation::Transform) | 1865 controller_impl->GetAnimation(3, Animation::Transform) |
1886 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); | 1866 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); |
1887 | 1867 |
1888 // Only unfinished animations should be considered by | 1868 // Only unfinished animations should be considered by |
1889 // HasOnlyTranslationTransforms. | 1869 // HasOnlyTranslationTransforms. |
1890 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms()); | 1870 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms()); |
1891 } | 1871 } |
1892 | 1872 |
1893 TEST(LayerAnimationControllerTest, MaximumTargetScale) { | 1873 TEST(LayerAnimationControllerTest, MaximumTargetScale) { |
1894 scoped_refptr<LayerAnimationController> controller_impl( | 1874 scoped_refptr<LayerAnimationController> controller_impl( |
1895 LayerAnimationController::Create(0)); | 1875 LayerAnimationController::Create(0)); |
1896 | 1876 |
1897 float max_scale = 0.f; | 1877 float max_scale = 0.f; |
1898 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); | 1878 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); |
1899 EXPECT_EQ(0.f, max_scale); | 1879 EXPECT_EQ(0.f, max_scale); |
1900 | 1880 |
1901 scoped_ptr<KeyframedTransformAnimationCurve> curve1( | 1881 scoped_ptr<KeyframedTransformAnimationCurve> curve1( |
1902 KeyframedTransformAnimationCurve::Create()); | 1882 KeyframedTransformAnimationCurve::Create()); |
1903 | 1883 |
1904 TransformOperations operations1; | 1884 TransformOperations operations1; |
1905 curve1->AddKeyframe(TransformKeyframe::Create( | 1885 curve1->AddKeyframe(TransformKeyframe::Create(0.0, operations1, nullptr)); |
1906 0.0, operations1, scoped_ptr<TimingFunction>())); | |
1907 operations1.AppendScale(2.0, 3.0, 4.0); | 1886 operations1.AppendScale(2.0, 3.0, 4.0); |
1908 curve1->AddKeyframe(TransformKeyframe::Create( | 1887 curve1->AddKeyframe(TransformKeyframe::Create(1.0, operations1, nullptr)); |
1909 1.0, operations1, scoped_ptr<TimingFunction>())); | |
1910 | 1888 |
1911 scoped_ptr<Animation> animation( | 1889 scoped_ptr<Animation> animation( |
1912 Animation::Create(curve1.Pass(), 1, 1, Animation::Transform)); | 1890 Animation::Create(curve1.Pass(), 1, 1, Animation::Transform)); |
1913 controller_impl->AddAnimation(animation.Pass()); | 1891 controller_impl->AddAnimation(animation.Pass()); |
1914 | 1892 |
1915 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); | 1893 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); |
1916 EXPECT_EQ(4.f, max_scale); | 1894 EXPECT_EQ(4.f, max_scale); |
1917 | 1895 |
1918 scoped_ptr<KeyframedTransformAnimationCurve> curve2( | 1896 scoped_ptr<KeyframedTransformAnimationCurve> curve2( |
1919 KeyframedTransformAnimationCurve::Create()); | 1897 KeyframedTransformAnimationCurve::Create()); |
1920 | 1898 |
1921 TransformOperations operations2; | 1899 TransformOperations operations2; |
1922 curve2->AddKeyframe(TransformKeyframe::Create( | 1900 curve2->AddKeyframe(TransformKeyframe::Create(0.0, operations2, nullptr)); |
1923 0.0, operations2, scoped_ptr<TimingFunction>())); | |
1924 operations2.AppendScale(6.0, 5.0, 4.0); | 1901 operations2.AppendScale(6.0, 5.0, 4.0); |
1925 curve2->AddKeyframe(TransformKeyframe::Create( | 1902 curve2->AddKeyframe(TransformKeyframe::Create(1.0, operations2, nullptr)); |
1926 1.0, operations2, scoped_ptr<TimingFunction>())); | |
1927 | 1903 |
1928 animation = Animation::Create(curve2.Pass(), 2, 2, Animation::Transform); | 1904 animation = Animation::Create(curve2.Pass(), 2, 2, Animation::Transform); |
1929 controller_impl->AddAnimation(animation.Pass()); | 1905 controller_impl->AddAnimation(animation.Pass()); |
1930 | 1906 |
1931 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); | 1907 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); |
1932 EXPECT_EQ(6.f, max_scale); | 1908 EXPECT_EQ(6.f, max_scale); |
1933 | 1909 |
1934 scoped_ptr<KeyframedTransformAnimationCurve> curve3( | 1910 scoped_ptr<KeyframedTransformAnimationCurve> curve3( |
1935 KeyframedTransformAnimationCurve::Create()); | 1911 KeyframedTransformAnimationCurve::Create()); |
1936 | 1912 |
1937 TransformOperations operations3; | 1913 TransformOperations operations3; |
1938 curve3->AddKeyframe(TransformKeyframe::Create( | 1914 curve3->AddKeyframe(TransformKeyframe::Create(0.0, operations3, nullptr)); |
1939 0.0, operations3, scoped_ptr<TimingFunction>())); | |
1940 operations3.AppendPerspective(6.0); | 1915 operations3.AppendPerspective(6.0); |
1941 curve3->AddKeyframe(TransformKeyframe::Create( | 1916 curve3->AddKeyframe(TransformKeyframe::Create(1.0, operations3, nullptr)); |
1942 1.0, operations3, scoped_ptr<TimingFunction>())); | |
1943 | 1917 |
1944 animation = Animation::Create(curve3.Pass(), 3, 3, Animation::Transform); | 1918 animation = Animation::Create(curve3.Pass(), 3, 3, Animation::Transform); |
1945 controller_impl->AddAnimation(animation.Pass()); | 1919 controller_impl->AddAnimation(animation.Pass()); |
1946 | 1920 |
1947 EXPECT_FALSE(controller_impl->MaximumTargetScale(&max_scale)); | 1921 EXPECT_FALSE(controller_impl->MaximumTargetScale(&max_scale)); |
1948 | 1922 |
1949 controller_impl->GetAnimation(3, Animation::Transform) | 1923 controller_impl->GetAnimation(3, Animation::Transform) |
1950 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); | 1924 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); |
1951 controller_impl->GetAnimation(2, Animation::Transform) | 1925 controller_impl->GetAnimation(2, Animation::Transform) |
1952 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); | 1926 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); |
1953 | 1927 |
1954 // Only unfinished animations should be considered by | 1928 // Only unfinished animations should be considered by |
1955 // MaximumTargetScale. | 1929 // MaximumTargetScale. |
1956 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); | 1930 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); |
1957 EXPECT_EQ(4.f, max_scale); | 1931 EXPECT_EQ(4.f, max_scale); |
1958 } | 1932 } |
1959 | 1933 |
1960 TEST(LayerAnimationControllerTest, MaximumTargetScaleWithDirection) { | 1934 TEST(LayerAnimationControllerTest, MaximumTargetScaleWithDirection) { |
1961 scoped_refptr<LayerAnimationController> controller_impl( | 1935 scoped_refptr<LayerAnimationController> controller_impl( |
1962 LayerAnimationController::Create(0)); | 1936 LayerAnimationController::Create(0)); |
1963 | 1937 |
1964 scoped_ptr<KeyframedTransformAnimationCurve> curve1( | 1938 scoped_ptr<KeyframedTransformAnimationCurve> curve1( |
1965 KeyframedTransformAnimationCurve::Create()); | 1939 KeyframedTransformAnimationCurve::Create()); |
1966 TransformOperations operations1; | 1940 TransformOperations operations1; |
1967 operations1.AppendScale(1.0, 2.0, 3.0); | 1941 operations1.AppendScale(1.0, 2.0, 3.0); |
1968 curve1->AddKeyframe(TransformKeyframe::Create( | 1942 curve1->AddKeyframe(TransformKeyframe::Create(0.0, operations1, nullptr)); |
1969 0.0, operations1, scoped_ptr<TimingFunction>())); | |
1970 TransformOperations operations2; | 1943 TransformOperations operations2; |
1971 operations2.AppendScale(4.0, 5.0, 6.0); | 1944 operations2.AppendScale(4.0, 5.0, 6.0); |
1972 curve1->AddKeyframe(TransformKeyframe::Create( | 1945 curve1->AddKeyframe(TransformKeyframe::Create(1.0, operations2, nullptr)); |
1973 1.0, operations2, scoped_ptr<TimingFunction>())); | |
1974 | 1946 |
1975 scoped_ptr<Animation> animation_owned( | 1947 scoped_ptr<Animation> animation_owned( |
1976 Animation::Create(curve1.Pass(), 1, 1, Animation::Transform)); | 1948 Animation::Create(curve1.Pass(), 1, 1, Animation::Transform)); |
1977 Animation* animation = animation_owned.get(); | 1949 Animation* animation = animation_owned.get(); |
1978 controller_impl->AddAnimation(animation_owned.Pass()); | 1950 controller_impl->AddAnimation(animation_owned.Pass()); |
1979 | 1951 |
1980 float max_scale = 0.f; | 1952 float max_scale = 0.f; |
1981 | 1953 |
1982 EXPECT_GT(animation->playback_rate(), 0.0); | 1954 EXPECT_GT(animation->playback_rate(), 0.0); |
1983 | 1955 |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2321 // been ticked at the new animation's starting point. | 2293 // been ticked at the new animation's starting point. |
2322 EXPECT_EQ(Animation::Running, | 2294 EXPECT_EQ(Animation::Running, |
2323 controller_impl->GetAnimation(second_animation_group_id, | 2295 controller_impl->GetAnimation(second_animation_group_id, |
2324 Animation::Opacity)->run_state()); | 2296 Animation::Opacity)->run_state()); |
2325 EXPECT_EQ(1.f, pending_dummy_impl.opacity()); | 2297 EXPECT_EQ(1.f, pending_dummy_impl.opacity()); |
2326 EXPECT_EQ(1.f, dummy_impl.opacity()); | 2298 EXPECT_EQ(1.f, dummy_impl.opacity()); |
2327 } | 2299 } |
2328 | 2300 |
2329 } // namespace | 2301 } // namespace |
2330 } // namespace cc | 2302 } // namespace cc |
OLD | NEW |