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