| 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/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include "cc/animation/animation_curve.h" | 7 #include "cc/animation/animation_curve.h" |
| 8 #include "cc/animation/layer_animation_controller.h" | 8 #include "cc/animation/layer_animation_controller.h" |
| 9 #include "cc/animation/scroll_offset_animation_curve.h" | 9 #include "cc/animation/scroll_offset_animation_curve.h" |
| 10 #include "cc/animation/timing_function.h" | 10 #include "cc/animation/timing_function.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 Animation* animation_impl = | 142 Animation* animation_impl = |
| 143 controller_impl->GetAnimation(Animation::Opacity); | 143 controller_impl->GetAnimation(Animation::Opacity); |
| 144 if (animation_impl) | 144 if (animation_impl) |
| 145 controller_impl->RemoveAnimation(animation_impl->id()); | 145 controller_impl->RemoveAnimation(animation_impl->id()); |
| 146 | 146 |
| 147 EndTest(); | 147 EndTest(); |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 | 150 |
| 151 virtual void NotifyAnimationStarted( | 151 virtual void NotifyAnimationStarted( |
| 152 double wall_clock_time, | |
| 153 base::TimeTicks monotonic_time, | 152 base::TimeTicks monotonic_time, |
| 154 Animation::TargetProperty target_property) OVERRIDE { | 153 Animation::TargetProperty target_property) OVERRIDE { |
| 155 received_animation_started_notification_ = true; | 154 received_animation_started_notification_ = true; |
| 156 start_time_ = monotonic_time; | 155 start_time_ = monotonic_time; |
| 157 if (num_animates_) { | 156 if (num_animates_) { |
| 158 EXPECT_LT(base::TimeTicks(), start_time_); | 157 EXPECT_LT(base::TimeTicks(), start_time_); |
| 159 | 158 |
| 160 LayerAnimationController* controller = | 159 LayerAnimationController* controller = |
| 161 layer_tree_host()->root_layer()->layer_animation_controller(); | 160 layer_tree_host()->root_layer()->layer_animation_controller(); |
| 162 Animation* animation = | 161 Animation* animation = |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 if (!started_animating_ && have_animations) { | 235 if (!started_animating_ && have_animations) { |
| 237 started_animating_ = true; | 236 started_animating_ = true; |
| 238 return; | 237 return; |
| 239 } | 238 } |
| 240 | 239 |
| 241 if (started_animating_ && !have_animations) | 240 if (started_animating_ && !have_animations) |
| 242 EndTest(); | 241 EndTest(); |
| 243 } | 242 } |
| 244 | 243 |
| 245 virtual void NotifyAnimationFinished( | 244 virtual void NotifyAnimationFinished( |
| 246 double wall_clock_time, | |
| 247 base::TimeTicks monotonic_time, | 245 base::TimeTicks monotonic_time, |
| 248 Animation::TargetProperty target_property) OVERRIDE { | 246 Animation::TargetProperty target_property) OVERRIDE { |
| 249 // Animations on the impl-side controller only get deleted during a commit, | 247 // Animations on the impl-side controller only get deleted during a commit, |
| 250 // so we need to schedule a commit. | 248 // so we need to schedule a commit. |
| 251 layer_tree_host()->SetNeedsCommit(); | 249 layer_tree_host()->SetNeedsCommit(); |
| 252 } | 250 } |
| 253 | 251 |
| 254 virtual void AfterTest() OVERRIDE {} | 252 virtual void AfterTest() OVERRIDE {} |
| 255 | 253 |
| 256 private: | 254 private: |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 | 362 |
| 365 virtual base::TimeDelta LowFrequencyAnimationInterval() const OVERRIDE { | 363 virtual base::TimeDelta LowFrequencyAnimationInterval() const OVERRIDE { |
| 366 return base::TimeDelta::FromMilliseconds(4); | 364 return base::TimeDelta::FromMilliseconds(4); |
| 367 } | 365 } |
| 368 | 366 |
| 369 virtual void BeginTest() OVERRIDE { | 367 virtual void BeginTest() OVERRIDE { |
| 370 PostAddAnimationToMainThread(layer_tree_host()->root_layer()); | 368 PostAddAnimationToMainThread(layer_tree_host()->root_layer()); |
| 371 } | 369 } |
| 372 | 370 |
| 373 virtual void NotifyAnimationFinished( | 371 virtual void NotifyAnimationFinished( |
| 374 double wall_clock_time, | |
| 375 base::TimeTicks monotonic_time, | 372 base::TimeTicks monotonic_time, |
| 376 Animation::TargetProperty target_property) OVERRIDE { | 373 Animation::TargetProperty target_property) OVERRIDE { |
| 377 // Replace animated commits with an empty tree. | 374 // Replace animated commits with an empty tree. |
| 378 layer_tree_host()->SetRootLayer(make_scoped_refptr<Layer>(NULL)); | 375 layer_tree_host()->SetRootLayer(make_scoped_refptr<Layer>(NULL)); |
| 379 } | 376 } |
| 380 | 377 |
| 381 virtual void DidCommit() OVERRIDE { | 378 virtual void DidCommit() OVERRIDE { |
| 382 // This alternates setting an empty tree and a non-empty tree with an | 379 // This alternates setting an empty tree and a non-empty tree with an |
| 383 // animation. | 380 // animation. |
| 384 switch (layer_tree_host()->source_frame_number()) { | 381 switch (layer_tree_host()->source_frame_number()) { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 content_->SetBounds(gfx::Size(4, 4)); | 554 content_->SetBounds(gfx::Size(4, 4)); |
| 558 content_->set_layer_animation_delegate(this); | 555 content_->set_layer_animation_delegate(this); |
| 559 layer_tree_host()->root_layer()->AddChild(content_); | 556 layer_tree_host()->root_layer()->AddChild(content_); |
| 560 } | 557 } |
| 561 | 558 |
| 562 virtual void BeginTest() OVERRIDE { | 559 virtual void BeginTest() OVERRIDE { |
| 563 PostAddAnimationToMainThread(content_.get()); | 560 PostAddAnimationToMainThread(content_.get()); |
| 564 } | 561 } |
| 565 | 562 |
| 566 virtual void NotifyAnimationStarted( | 563 virtual void NotifyAnimationStarted( |
| 567 double wall_clock_time, | |
| 568 base::TimeTicks monotonic_time, | 564 base::TimeTicks monotonic_time, |
| 569 Animation::TargetProperty target_property) OVERRIDE { | 565 Animation::TargetProperty target_property) OVERRIDE { |
| 570 LayerAnimationController* controller = | 566 LayerAnimationController* controller = |
| 571 layer_tree_host()->root_layer()->children()[0]-> | 567 layer_tree_host()->root_layer()->children()[0]-> |
| 572 layer_animation_controller(); | 568 layer_animation_controller(); |
| 573 Animation* animation = | 569 Animation* animation = |
| 574 controller->GetAnimation(Animation::Opacity); | 570 controller->GetAnimation(Animation::Opacity); |
| 575 main_start_time_ = animation->start_time(); | 571 main_start_time_ = animation->start_time(); |
| 576 controller->RemoveAnimation(animation->id()); | 572 controller->RemoveAnimation(animation->id()); |
| 577 | 573 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 class LayerTreeHostAnimationTestAnimationFinishedEvents | 611 class LayerTreeHostAnimationTestAnimationFinishedEvents |
| 616 : public LayerTreeHostAnimationTest { | 612 : public LayerTreeHostAnimationTest { |
| 617 public: | 613 public: |
| 618 LayerTreeHostAnimationTestAnimationFinishedEvents() {} | 614 LayerTreeHostAnimationTestAnimationFinishedEvents() {} |
| 619 | 615 |
| 620 virtual void BeginTest() OVERRIDE { | 616 virtual void BeginTest() OVERRIDE { |
| 621 PostAddInstantAnimationToMainThread(layer_tree_host()->root_layer()); | 617 PostAddInstantAnimationToMainThread(layer_tree_host()->root_layer()); |
| 622 } | 618 } |
| 623 | 619 |
| 624 virtual void NotifyAnimationFinished( | 620 virtual void NotifyAnimationFinished( |
| 625 double wall_clock_time, | |
| 626 base::TimeTicks monotonic_time, | 621 base::TimeTicks monotonic_time, |
| 627 Animation::TargetProperty target_property) OVERRIDE { | 622 Animation::TargetProperty target_property) OVERRIDE { |
| 628 LayerAnimationController* controller = | 623 LayerAnimationController* controller = |
| 629 layer_tree_host()->root_layer()->layer_animation_controller(); | 624 layer_tree_host()->root_layer()->layer_animation_controller(); |
| 630 Animation* animation = | 625 Animation* animation = |
| 631 controller->GetAnimation(Animation::Opacity); | 626 controller->GetAnimation(Animation::Opacity); |
| 632 if (animation) | 627 if (animation) |
| 633 controller->RemoveAnimation(animation->id()); | 628 controller->RemoveAnimation(animation->id()); |
| 634 EndTest(); | 629 EndTest(); |
| 635 } | 630 } |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 content_->set_layer_animation_delegate(this); | 829 content_->set_layer_animation_delegate(this); |
| 835 layer_tree_host()->root_layer()->AddChild(content_); | 830 layer_tree_host()->root_layer()->AddChild(content_); |
| 836 } | 831 } |
| 837 | 832 |
| 838 virtual void BeginTest() OVERRIDE { | 833 virtual void BeginTest() OVERRIDE { |
| 839 layer_tree_host()->SetViewportSize(gfx::Size()); | 834 layer_tree_host()->SetViewportSize(gfx::Size()); |
| 840 PostAddAnimationToMainThread(content_.get()); | 835 PostAddAnimationToMainThread(content_.get()); |
| 841 } | 836 } |
| 842 | 837 |
| 843 virtual void NotifyAnimationStarted( | 838 virtual void NotifyAnimationStarted( |
| 844 double wall_clock_time, | |
| 845 base::TimeTicks monotonic_time, | 839 base::TimeTicks monotonic_time, |
| 846 Animation::TargetProperty target_property) OVERRIDE { | 840 Animation::TargetProperty target_property) OVERRIDE { |
| 847 started_times_++; | 841 started_times_++; |
| 848 } | 842 } |
| 849 | 843 |
| 850 virtual void NotifyAnimationFinished( | 844 virtual void NotifyAnimationFinished( |
| 851 double wall_clock_time, | |
| 852 base::TimeTicks monotonic_time, | 845 base::TimeTicks monotonic_time, |
| 853 Animation::TargetProperty target_property) OVERRIDE { | 846 Animation::TargetProperty target_property) OVERRIDE { |
| 854 EndTest(); | 847 EndTest(); |
| 855 } | 848 } |
| 856 | 849 |
| 857 virtual void AfterTest() OVERRIDE { | 850 virtual void AfterTest() OVERRIDE { |
| 858 EXPECT_EQ(1, started_times_); | 851 EXPECT_EQ(1, started_times_); |
| 859 } | 852 } |
| 860 | 853 |
| 861 private: | 854 private: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 886 visible_ = true; | 879 visible_ = true; |
| 887 PostAddAnimationToMainThread(content_.get()); | 880 PostAddAnimationToMainThread(content_.get()); |
| 888 } | 881 } |
| 889 | 882 |
| 890 virtual void DidCommit() OVERRIDE { | 883 virtual void DidCommit() OVERRIDE { |
| 891 visible_ = false; | 884 visible_ = false; |
| 892 layer_tree_host()->SetVisible(false); | 885 layer_tree_host()->SetVisible(false); |
| 893 } | 886 } |
| 894 | 887 |
| 895 virtual void NotifyAnimationStarted( | 888 virtual void NotifyAnimationStarted( |
| 896 double wall_clock_time, | |
| 897 base::TimeTicks monotonic_time, | 889 base::TimeTicks monotonic_time, |
| 898 Animation::TargetProperty target_property) OVERRIDE { | 890 Animation::TargetProperty target_property) OVERRIDE { |
| 899 EXPECT_FALSE(visible_); | 891 EXPECT_FALSE(visible_); |
| 900 started_times_++; | 892 started_times_++; |
| 901 } | 893 } |
| 902 | 894 |
| 903 virtual void NotifyAnimationFinished( | 895 virtual void NotifyAnimationFinished( |
| 904 double wall_clock_time, | |
| 905 base::TimeTicks monotonic_time, | 896 base::TimeTicks monotonic_time, |
| 906 Animation::TargetProperty target_property) OVERRIDE { | 897 Animation::TargetProperty target_property) OVERRIDE { |
| 907 EXPECT_FALSE(visible_); | 898 EXPECT_FALSE(visible_); |
| 908 EXPECT_EQ(1, started_times_); | 899 EXPECT_EQ(1, started_times_); |
| 909 EndTest(); | 900 EndTest(); |
| 910 } | 901 } |
| 911 | 902 |
| 912 virtual void AfterTest() OVERRIDE {} | 903 virtual void AfterTest() OVERRIDE {} |
| 913 | 904 |
| 914 private: | 905 private: |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 break; | 962 break; |
| 972 case 2: | 963 case 2: |
| 973 // This second animation will not be drawn so it should not start. | 964 // This second animation will not be drawn so it should not start. |
| 974 AddAnimatedTransformToLayer(content_.get(), 0.1, 5, 5); | 965 AddAnimatedTransformToLayer(content_.get(), 0.1, 5, 5); |
| 975 added_animations_++; | 966 added_animations_++; |
| 976 break; | 967 break; |
| 977 } | 968 } |
| 978 } | 969 } |
| 979 | 970 |
| 980 virtual void NotifyAnimationStarted( | 971 virtual void NotifyAnimationStarted( |
| 981 double wall_clock_time, | |
| 982 base::TimeTicks monotonic_time, | 972 base::TimeTicks monotonic_time, |
| 983 Animation::TargetProperty target_property) OVERRIDE { | 973 Animation::TargetProperty target_property) OVERRIDE { |
| 984 if (TestEnded()) | 974 if (TestEnded()) |
| 985 return; | 975 return; |
| 986 started_times_++; | 976 started_times_++; |
| 987 } | 977 } |
| 988 | 978 |
| 989 virtual void AfterTest() OVERRIDE { | 979 virtual void AfterTest() OVERRIDE { |
| 990 // Make sure we tried to draw the second animation but failed. | 980 // Make sure we tried to draw the second animation but failed. |
| 991 EXPECT_LT(0, prevented_draw_); | 981 EXPECT_LT(0, prevented_draw_); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 int num_draw_attempts_; | 1112 int num_draw_attempts_; |
| 1123 base::TimeTicks last_main_thread_tick_time_; | 1113 base::TimeTicks last_main_thread_tick_time_; |
| 1124 base::TimeTicks expected_impl_tick_time_; | 1114 base::TimeTicks expected_impl_tick_time_; |
| 1125 }; | 1115 }; |
| 1126 | 1116 |
| 1127 // Only the non-impl-paint multi-threaded compositor freezes animations. | 1117 // Only the non-impl-paint multi-threaded compositor freezes animations. |
| 1128 MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostAnimationTestFrozenAnimationTickTime); | 1118 MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostAnimationTestFrozenAnimationTickTime); |
| 1129 | 1119 |
| 1130 } // namespace | 1120 } // namespace |
| 1131 } // namespace cc | 1121 } // namespace cc |
| OLD | NEW |