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/timing_function.h" | 9 #include "cc/animation/timing_function.h" |
10 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 host_impl->active_tree()->root_layer()->layer_animation_controller(); | 141 host_impl->active_tree()->root_layer()->layer_animation_controller(); |
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(double wall_clock_time) OVERRIDE { | 151 virtual void NotifyAnimationStarted( |
| 152 double wall_clock_time, |
| 153 double monotonic_time, |
| 154 Animation::TargetProperty target_property) OVERRIDE { |
152 received_animation_started_notification_ = true; | 155 received_animation_started_notification_ = true; |
153 start_time_ = wall_clock_time; | 156 start_time_ = monotonic_time; |
154 if (num_animates_) { | 157 if (num_animates_) { |
155 EXPECT_LT(0.0, start_time_); | 158 EXPECT_LT(0.0, start_time_); |
156 | 159 |
157 LayerAnimationController* controller = | 160 LayerAnimationController* controller = |
158 layer_tree_host()->root_layer()->layer_animation_controller(); | 161 layer_tree_host()->root_layer()->layer_animation_controller(); |
159 Animation* animation = | 162 Animation* animation = |
160 controller->GetAnimation(Animation::Opacity); | 163 controller->GetAnimation(Animation::Opacity); |
161 if (animation) | 164 if (animation) |
162 controller->RemoveAnimation(animation->id()); | 165 controller->RemoveAnimation(animation->id()); |
163 | 166 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 active_animation_controllers().empty(); | 235 active_animation_controllers().empty(); |
233 if (!started_animating_ && have_animations) { | 236 if (!started_animating_ && have_animations) { |
234 started_animating_ = true; | 237 started_animating_ = true; |
235 return; | 238 return; |
236 } | 239 } |
237 | 240 |
238 if (started_animating_ && !have_animations) | 241 if (started_animating_ && !have_animations) |
239 EndTest(); | 242 EndTest(); |
240 } | 243 } |
241 | 244 |
242 virtual void NotifyAnimationFinished(double time) OVERRIDE { | 245 virtual void NotifyAnimationFinished( |
| 246 double wall_clock_time, |
| 247 double monotonic_time, |
| 248 Animation::TargetProperty target_property) OVERRIDE { |
243 // Animations on the impl-side controller only get deleted during a commit, | 249 // Animations on the impl-side controller only get deleted during a commit, |
244 // so we need to schedule a commit. | 250 // so we need to schedule a commit. |
245 layer_tree_host()->SetNeedsCommit(); | 251 layer_tree_host()->SetNeedsCommit(); |
246 } | 252 } |
247 | 253 |
248 virtual void AfterTest() OVERRIDE {} | 254 virtual void AfterTest() OVERRIDE {} |
249 | 255 |
250 private: | 256 private: |
251 bool started_animating_; | 257 bool started_animating_; |
252 }; | 258 }; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 : active_tree_was_animated_(false) {} | 308 : active_tree_was_animated_(false) {} |
303 | 309 |
304 virtual base::TimeDelta LowFrequencyAnimationInterval() const OVERRIDE { | 310 virtual base::TimeDelta LowFrequencyAnimationInterval() const OVERRIDE { |
305 return base::TimeDelta::FromMilliseconds(4); | 311 return base::TimeDelta::FromMilliseconds(4); |
306 } | 312 } |
307 | 313 |
308 virtual void BeginTest() OVERRIDE { | 314 virtual void BeginTest() OVERRIDE { |
309 PostAddAnimationToMainThread(layer_tree_host()->root_layer()); | 315 PostAddAnimationToMainThread(layer_tree_host()->root_layer()); |
310 } | 316 } |
311 | 317 |
312 virtual void NotifyAnimationFinished(double time) OVERRIDE { | 318 virtual void NotifyAnimationFinished( |
| 319 double wall_clock_time, |
| 320 double monotonic_time, |
| 321 Animation::TargetProperty target_property) OVERRIDE { |
313 // Replace animated commits with an empty tree. | 322 // Replace animated commits with an empty tree. |
314 layer_tree_host()->SetRootLayer(make_scoped_refptr<Layer>(NULL)); | 323 layer_tree_host()->SetRootLayer(make_scoped_refptr<Layer>(NULL)); |
315 } | 324 } |
316 | 325 |
317 virtual void DidCommit() OVERRIDE { | 326 virtual void DidCommit() OVERRIDE { |
318 // This alternates setting an empty tree and a non-empty tree with an | 327 // This alternates setting an empty tree and a non-empty tree with an |
319 // animation. | 328 // animation. |
320 switch (layer_tree_host()->source_frame_number()) { | 329 switch (layer_tree_host()->source_frame_number()) { |
321 case 1: | 330 case 1: |
322 // Wait for NotifyAnimationFinished to commit an empty tree. | 331 // Wait for NotifyAnimationFinished to commit an empty tree. |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 content_ = FakeContentLayer::Create(&client_); | 501 content_ = FakeContentLayer::Create(&client_); |
493 content_->SetBounds(gfx::Size(4, 4)); | 502 content_->SetBounds(gfx::Size(4, 4)); |
494 content_->set_layer_animation_delegate(this); | 503 content_->set_layer_animation_delegate(this); |
495 layer_tree_host()->root_layer()->AddChild(content_); | 504 layer_tree_host()->root_layer()->AddChild(content_); |
496 } | 505 } |
497 | 506 |
498 virtual void BeginTest() OVERRIDE { | 507 virtual void BeginTest() OVERRIDE { |
499 PostAddAnimationToMainThread(content_.get()); | 508 PostAddAnimationToMainThread(content_.get()); |
500 } | 509 } |
501 | 510 |
502 virtual void NotifyAnimationStarted(double time) OVERRIDE { | 511 virtual void NotifyAnimationStarted( |
| 512 double wall_clock_time, |
| 513 double monotonic_time, |
| 514 Animation::TargetProperty target_property) OVERRIDE { |
503 LayerAnimationController* controller = | 515 LayerAnimationController* controller = |
504 layer_tree_host()->root_layer()->children()[0]-> | 516 layer_tree_host()->root_layer()->children()[0]-> |
505 layer_animation_controller(); | 517 layer_animation_controller(); |
506 Animation* animation = | 518 Animation* animation = |
507 controller->GetAnimation(Animation::Opacity); | 519 controller->GetAnimation(Animation::Opacity); |
508 main_start_time_ = animation->start_time(); | 520 main_start_time_ = animation->start_time(); |
509 controller->RemoveAnimation(animation->id()); | 521 controller->RemoveAnimation(animation->id()); |
510 | 522 |
511 if (impl_start_time_ > 0.0) | 523 if (impl_start_time_ > 0.0) |
512 EndTest(); | 524 EndTest(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 // Ensures that notify animation finished is called. | 559 // Ensures that notify animation finished is called. |
548 class LayerTreeHostAnimationTestAnimationFinishedEvents | 560 class LayerTreeHostAnimationTestAnimationFinishedEvents |
549 : public LayerTreeHostAnimationTest { | 561 : public LayerTreeHostAnimationTest { |
550 public: | 562 public: |
551 LayerTreeHostAnimationTestAnimationFinishedEvents() {} | 563 LayerTreeHostAnimationTestAnimationFinishedEvents() {} |
552 | 564 |
553 virtual void BeginTest() OVERRIDE { | 565 virtual void BeginTest() OVERRIDE { |
554 PostAddInstantAnimationToMainThread(layer_tree_host()->root_layer()); | 566 PostAddInstantAnimationToMainThread(layer_tree_host()->root_layer()); |
555 } | 567 } |
556 | 568 |
557 virtual void NotifyAnimationFinished(double time) OVERRIDE { | 569 virtual void NotifyAnimationFinished( |
| 570 double wall_clock_time, |
| 571 double monotonic_time, |
| 572 Animation::TargetProperty target_property) OVERRIDE { |
558 LayerAnimationController* controller = | 573 LayerAnimationController* controller = |
559 layer_tree_host()->root_layer()->layer_animation_controller(); | 574 layer_tree_host()->root_layer()->layer_animation_controller(); |
560 Animation* animation = | 575 Animation* animation = |
561 controller->GetAnimation(Animation::Opacity); | 576 controller->GetAnimation(Animation::Opacity); |
562 if (animation) | 577 if (animation) |
563 controller->RemoveAnimation(animation->id()); | 578 controller->RemoveAnimation(animation->id()); |
564 EndTest(); | 579 EndTest(); |
565 } | 580 } |
566 | 581 |
567 virtual void AfterTest() OVERRIDE {} | 582 virtual void AfterTest() OVERRIDE {} |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 content_->SetBounds(gfx::Size(4, 4)); | 778 content_->SetBounds(gfx::Size(4, 4)); |
764 content_->set_layer_animation_delegate(this); | 779 content_->set_layer_animation_delegate(this); |
765 layer_tree_host()->root_layer()->AddChild(content_); | 780 layer_tree_host()->root_layer()->AddChild(content_); |
766 } | 781 } |
767 | 782 |
768 virtual void BeginTest() OVERRIDE { | 783 virtual void BeginTest() OVERRIDE { |
769 layer_tree_host()->SetViewportSize(gfx::Size()); | 784 layer_tree_host()->SetViewportSize(gfx::Size()); |
770 PostAddAnimationToMainThread(content_.get()); | 785 PostAddAnimationToMainThread(content_.get()); |
771 } | 786 } |
772 | 787 |
773 virtual void NotifyAnimationStarted(double wall_clock_time) OVERRIDE { | 788 virtual void NotifyAnimationStarted( |
| 789 double wall_clock_time, |
| 790 double monotonic_time, |
| 791 Animation::TargetProperty target_property) OVERRIDE { |
774 started_times_++; | 792 started_times_++; |
775 } | 793 } |
776 | 794 |
777 virtual void NotifyAnimationFinished(double wall_clock_time) OVERRIDE { | 795 virtual void NotifyAnimationFinished( |
| 796 double wall_clock_time, |
| 797 double monotonic_time, |
| 798 Animation::TargetProperty target_property) OVERRIDE { |
778 EndTest(); | 799 EndTest(); |
779 } | 800 } |
780 | 801 |
781 virtual void AfterTest() OVERRIDE { | 802 virtual void AfterTest() OVERRIDE { |
782 EXPECT_EQ(1, started_times_); | 803 EXPECT_EQ(1, started_times_); |
783 } | 804 } |
784 | 805 |
785 private: | 806 private: |
786 int started_times_; | 807 int started_times_; |
787 FakeContentLayerClient client_; | 808 FakeContentLayerClient client_; |
(...skipping 21 matching lines...) Expand all Loading... |
809 virtual void BeginTest() OVERRIDE { | 830 virtual void BeginTest() OVERRIDE { |
810 visible_ = true; | 831 visible_ = true; |
811 PostAddAnimationToMainThread(content_.get()); | 832 PostAddAnimationToMainThread(content_.get()); |
812 } | 833 } |
813 | 834 |
814 virtual void DidCommit() OVERRIDE { | 835 virtual void DidCommit() OVERRIDE { |
815 visible_ = false; | 836 visible_ = false; |
816 layer_tree_host()->SetVisible(false); | 837 layer_tree_host()->SetVisible(false); |
817 } | 838 } |
818 | 839 |
819 virtual void NotifyAnimationStarted(double wall_clock_time) OVERRIDE { | 840 virtual void NotifyAnimationStarted( |
| 841 double wall_clock_time, |
| 842 double monotonic_time, |
| 843 Animation::TargetProperty target_property) OVERRIDE { |
820 EXPECT_FALSE(visible_); | 844 EXPECT_FALSE(visible_); |
821 started_times_++; | 845 started_times_++; |
822 } | 846 } |
823 | 847 |
824 virtual void NotifyAnimationFinished(double wall_clock_time) OVERRIDE { | 848 virtual void NotifyAnimationFinished( |
| 849 double wall_clock_time, |
| 850 double monotonic_time, |
| 851 Animation::TargetProperty target_property) OVERRIDE { |
825 EXPECT_FALSE(visible_); | 852 EXPECT_FALSE(visible_); |
826 EXPECT_EQ(1, started_times_); | 853 EXPECT_EQ(1, started_times_); |
827 EndTest(); | 854 EndTest(); |
828 } | 855 } |
829 | 856 |
830 virtual void AfterTest() OVERRIDE {} | 857 virtual void AfterTest() OVERRIDE {} |
831 | 858 |
832 private: | 859 private: |
833 bool visible_; | 860 bool visible_; |
834 int started_times_; | 861 int started_times_; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 added_animations_++; | 913 added_animations_++; |
887 break; | 914 break; |
888 case 2: | 915 case 2: |
889 // This second animation will not be drawn so it should not start. | 916 // This second animation will not be drawn so it should not start. |
890 AddAnimatedTransformToLayer(content_.get(), 0.1, 5, 5); | 917 AddAnimatedTransformToLayer(content_.get(), 0.1, 5, 5); |
891 added_animations_++; | 918 added_animations_++; |
892 break; | 919 break; |
893 } | 920 } |
894 } | 921 } |
895 | 922 |
896 virtual void NotifyAnimationStarted(double wall_clock_time) OVERRIDE { | 923 virtual void NotifyAnimationStarted( |
| 924 double wall_clock_time, |
| 925 double monotonic_time, |
| 926 Animation::TargetProperty target_property) OVERRIDE { |
897 if (TestEnded()) | 927 if (TestEnded()) |
898 return; | 928 return; |
899 started_times_++; | 929 started_times_++; |
900 } | 930 } |
901 | 931 |
902 virtual void NotifyAnimationFinished(double wall_clock_time) OVERRIDE { | 932 virtual void NotifyAnimationFinished( |
| 933 double wall_clock_time, |
| 934 double monotonic_time, |
| 935 Animation::TargetProperty target_property) OVERRIDE { |
903 // We should be checkerboarding already, but it should still finish the | 936 // We should be checkerboarding already, but it should still finish the |
904 // first animation. | 937 // first animation. |
905 EXPECT_EQ(2, added_animations_); | 938 EXPECT_EQ(2, added_animations_); |
906 finished_times_++; | 939 finished_times_++; |
907 EndTest(); | 940 EndTest(); |
908 } | 941 } |
909 | 942 |
910 virtual void AfterTest() OVERRIDE { | 943 virtual void AfterTest() OVERRIDE { |
911 // Make sure we tried to draw the second animation but failed. | 944 // Make sure we tried to draw the second animation but failed. |
912 EXPECT_LT(0, prevented_draw_); | 945 EXPECT_LT(0, prevented_draw_); |
(...skipping 10 matching lines...) Expand all Loading... |
923 int finished_times_; | 956 int finished_times_; |
924 FakeContentLayerClient client_; | 957 FakeContentLayerClient client_; |
925 scoped_refptr<FakeContentLayer> content_; | 958 scoped_refptr<FakeContentLayer> content_; |
926 }; | 959 }; |
927 | 960 |
928 MULTI_THREAD_TEST_F( | 961 MULTI_THREAD_TEST_F( |
929 LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations); | 962 LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations); |
930 | 963 |
931 } // namespace | 964 } // namespace |
932 } // namespace cc | 965 } // namespace cc |
OLD | NEW |