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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 host_impl->active_tree()->root_layer()->layer_animation_controller(); | 139 host_impl->active_tree()->root_layer()->layer_animation_controller(); |
140 Animation* animation_impl = | 140 Animation* animation_impl = |
141 controller_impl->GetAnimation(Animation::Opacity); | 141 controller_impl->GetAnimation(Animation::Opacity); |
142 if (animation_impl) | 142 if (animation_impl) |
143 controller_impl->RemoveAnimation(animation_impl->id()); | 143 controller_impl->RemoveAnimation(animation_impl->id()); |
144 | 144 |
145 EndTest(); | 145 EndTest(); |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 virtual void NotifyAnimationStarted( | 149 virtual void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
150 base::TimeTicks monotonic_time, | 150 Animation::TargetProperty target_property, |
151 Animation::TargetProperty target_property) override { | 151 int group) override { |
152 received_animation_started_notification_ = true; | 152 received_animation_started_notification_ = true; |
153 start_time_ = monotonic_time; | 153 start_time_ = monotonic_time; |
154 if (num_begin_frames_) { | 154 if (num_begin_frames_) { |
155 EXPECT_LT(base::TimeTicks(), start_time_); | 155 EXPECT_LT(base::TimeTicks(), start_time_); |
156 | 156 |
157 LayerAnimationController* controller = | 157 LayerAnimationController* controller = |
158 layer_tree_host()->root_layer()->layer_animation_controller(); | 158 layer_tree_host()->root_layer()->layer_animation_controller(); |
159 Animation* animation = | 159 Animation* animation = |
160 controller->GetAnimation(Animation::Opacity); | 160 controller->GetAnimation(Animation::Opacity); |
161 if (animation) | 161 if (animation) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 started_animating_ = true; | 234 started_animating_ = true; |
235 return; | 235 return; |
236 } | 236 } |
237 | 237 |
238 if (started_animating_ && !have_animations) | 238 if (started_animating_ && !have_animations) |
239 EndTest(); | 239 EndTest(); |
240 } | 240 } |
241 | 241 |
242 virtual void NotifyAnimationFinished( | 242 virtual void NotifyAnimationFinished( |
243 base::TimeTicks monotonic_time, | 243 base::TimeTicks monotonic_time, |
244 Animation::TargetProperty target_property) override { | 244 Animation::TargetProperty target_property, |
| 245 int group) override { |
245 // Animations on the impl-side controller only get deleted during a commit, | 246 // Animations on the impl-side controller only get deleted during a commit, |
246 // so we need to schedule a commit. | 247 // so we need to schedule a commit. |
247 layer_tree_host()->SetNeedsCommit(); | 248 layer_tree_host()->SetNeedsCommit(); |
248 } | 249 } |
249 | 250 |
250 virtual void AfterTest() override {} | 251 virtual void AfterTest() override {} |
251 | 252 |
252 private: | 253 private: |
253 bool started_animating_; | 254 bool started_animating_; |
254 }; | 255 }; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 virtual base::TimeDelta LowFrequencyAnimationInterval() const override { | 362 virtual base::TimeDelta LowFrequencyAnimationInterval() const override { |
362 return base::TimeDelta::FromMilliseconds(4); | 363 return base::TimeDelta::FromMilliseconds(4); |
363 } | 364 } |
364 | 365 |
365 virtual void BeginTest() override { | 366 virtual void BeginTest() override { |
366 PostAddAnimationToMainThread(layer_tree_host()->root_layer()); | 367 PostAddAnimationToMainThread(layer_tree_host()->root_layer()); |
367 } | 368 } |
368 | 369 |
369 virtual void NotifyAnimationFinished( | 370 virtual void NotifyAnimationFinished( |
370 base::TimeTicks monotonic_time, | 371 base::TimeTicks monotonic_time, |
371 Animation::TargetProperty target_property) override { | 372 Animation::TargetProperty target_property, |
| 373 int group) override { |
372 // Replace animated commits with an empty tree. | 374 // Replace animated commits with an empty tree. |
373 layer_tree_host()->SetRootLayer(make_scoped_refptr<Layer>(NULL)); | 375 layer_tree_host()->SetRootLayer(make_scoped_refptr<Layer>(NULL)); |
374 } | 376 } |
375 | 377 |
376 virtual void DidCommit() override { | 378 virtual void DidCommit() override { |
377 // 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 |
378 // animation. | 380 // animation. |
379 switch (layer_tree_host()->source_frame_number()) { | 381 switch (layer_tree_host()->source_frame_number()) { |
380 case 1: | 382 case 1: |
381 // Wait for NotifyAnimationFinished to commit an empty tree. | 383 // Wait for NotifyAnimationFinished to commit an empty tree. |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 content_ = FakeContentLayer::Create(&client_); | 555 content_ = FakeContentLayer::Create(&client_); |
554 content_->SetBounds(gfx::Size(4, 4)); | 556 content_->SetBounds(gfx::Size(4, 4)); |
555 content_->set_layer_animation_delegate(this); | 557 content_->set_layer_animation_delegate(this); |
556 layer_tree_host()->root_layer()->AddChild(content_); | 558 layer_tree_host()->root_layer()->AddChild(content_); |
557 } | 559 } |
558 | 560 |
559 virtual void BeginTest() override { | 561 virtual void BeginTest() override { |
560 PostAddAnimationToMainThread(content_.get()); | 562 PostAddAnimationToMainThread(content_.get()); |
561 } | 563 } |
562 | 564 |
563 virtual void NotifyAnimationStarted( | 565 virtual void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
564 base::TimeTicks monotonic_time, | 566 Animation::TargetProperty target_property, |
565 Animation::TargetProperty target_property) override { | 567 int group) override { |
566 LayerAnimationController* controller = | 568 LayerAnimationController* controller = |
567 layer_tree_host()->root_layer()->children()[0]-> | 569 layer_tree_host()->root_layer()->children()[0]-> |
568 layer_animation_controller(); | 570 layer_animation_controller(); |
569 Animation* animation = | 571 Animation* animation = |
570 controller->GetAnimation(Animation::Opacity); | 572 controller->GetAnimation(Animation::Opacity); |
571 main_start_time_ = | 573 main_start_time_ = |
572 (animation->start_time() - base::TimeTicks()).InSecondsF(); | 574 (animation->start_time() - base::TimeTicks()).InSecondsF(); |
573 controller->RemoveAnimation(animation->id()); | 575 controller->RemoveAnimation(animation->id()); |
574 | 576 |
575 if (impl_start_time_ > 0.0) | 577 if (impl_start_time_ > 0.0) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 : public LayerTreeHostAnimationTest { | 616 : public LayerTreeHostAnimationTest { |
615 public: | 617 public: |
616 LayerTreeHostAnimationTestAnimationFinishedEvents() {} | 618 LayerTreeHostAnimationTestAnimationFinishedEvents() {} |
617 | 619 |
618 virtual void BeginTest() override { | 620 virtual void BeginTest() override { |
619 PostAddInstantAnimationToMainThread(layer_tree_host()->root_layer()); | 621 PostAddInstantAnimationToMainThread(layer_tree_host()->root_layer()); |
620 } | 622 } |
621 | 623 |
622 virtual void NotifyAnimationFinished( | 624 virtual void NotifyAnimationFinished( |
623 base::TimeTicks monotonic_time, | 625 base::TimeTicks monotonic_time, |
624 Animation::TargetProperty target_property) override { | 626 Animation::TargetProperty target_property, |
| 627 int group) override { |
625 LayerAnimationController* controller = | 628 LayerAnimationController* controller = |
626 layer_tree_host()->root_layer()->layer_animation_controller(); | 629 layer_tree_host()->root_layer()->layer_animation_controller(); |
627 Animation* animation = | 630 Animation* animation = |
628 controller->GetAnimation(Animation::Opacity); | 631 controller->GetAnimation(Animation::Opacity); |
629 if (animation) | 632 if (animation) |
630 controller->RemoveAnimation(animation->id()); | 633 controller->RemoveAnimation(animation->id()); |
631 EndTest(); | 634 EndTest(); |
632 } | 635 } |
633 | 636 |
634 virtual void AfterTest() override {} | 637 virtual void AfterTest() override {} |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 content_->SetBounds(gfx::Size(4, 4)); | 854 content_->SetBounds(gfx::Size(4, 4)); |
852 content_->set_layer_animation_delegate(this); | 855 content_->set_layer_animation_delegate(this); |
853 layer_tree_host()->root_layer()->AddChild(content_); | 856 layer_tree_host()->root_layer()->AddChild(content_); |
854 } | 857 } |
855 | 858 |
856 virtual void BeginTest() override { | 859 virtual void BeginTest() override { |
857 layer_tree_host()->SetViewportSize(gfx::Size()); | 860 layer_tree_host()->SetViewportSize(gfx::Size()); |
858 PostAddAnimationToMainThread(content_.get()); | 861 PostAddAnimationToMainThread(content_.get()); |
859 } | 862 } |
860 | 863 |
861 virtual void NotifyAnimationStarted( | 864 virtual void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
862 base::TimeTicks monotonic_time, | 865 Animation::TargetProperty target_property, |
863 Animation::TargetProperty target_property) override { | 866 int group) override { |
864 started_times_++; | 867 started_times_++; |
865 } | 868 } |
866 | 869 |
867 virtual void NotifyAnimationFinished( | 870 virtual void NotifyAnimationFinished( |
868 base::TimeTicks monotonic_time, | 871 base::TimeTicks monotonic_time, |
869 Animation::TargetProperty target_property) override { | 872 Animation::TargetProperty target_property, |
| 873 int group) override { |
870 EndTest(); | 874 EndTest(); |
871 } | 875 } |
872 | 876 |
873 virtual void AfterTest() override { | 877 virtual void AfterTest() override { |
874 EXPECT_EQ(1, started_times_); | 878 EXPECT_EQ(1, started_times_); |
875 } | 879 } |
876 | 880 |
877 private: | 881 private: |
878 int started_times_; | 882 int started_times_; |
879 FakeContentLayerClient client_; | 883 FakeContentLayerClient client_; |
(...skipping 21 matching lines...) Expand all Loading... |
901 virtual void BeginTest() override { | 905 virtual void BeginTest() override { |
902 visible_ = true; | 906 visible_ = true; |
903 PostAddAnimationToMainThread(content_.get()); | 907 PostAddAnimationToMainThread(content_.get()); |
904 } | 908 } |
905 | 909 |
906 virtual void DidCommit() override { | 910 virtual void DidCommit() override { |
907 visible_ = false; | 911 visible_ = false; |
908 layer_tree_host()->SetVisible(false); | 912 layer_tree_host()->SetVisible(false); |
909 } | 913 } |
910 | 914 |
911 virtual void NotifyAnimationStarted( | 915 virtual void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
912 base::TimeTicks monotonic_time, | 916 Animation::TargetProperty target_property, |
913 Animation::TargetProperty target_property) override { | 917 int group) override { |
914 EXPECT_FALSE(visible_); | 918 EXPECT_FALSE(visible_); |
915 started_times_++; | 919 started_times_++; |
916 } | 920 } |
917 | 921 |
918 virtual void NotifyAnimationFinished( | 922 virtual void NotifyAnimationFinished( |
919 base::TimeTicks monotonic_time, | 923 base::TimeTicks monotonic_time, |
920 Animation::TargetProperty target_property) override { | 924 Animation::TargetProperty target_property, |
| 925 int group) override { |
921 EXPECT_FALSE(visible_); | 926 EXPECT_FALSE(visible_); |
922 EXPECT_EQ(1, started_times_); | 927 EXPECT_EQ(1, started_times_); |
923 EndTest(); | 928 EndTest(); |
924 } | 929 } |
925 | 930 |
926 virtual void AfterTest() override {} | 931 virtual void AfterTest() override {} |
927 | 932 |
928 private: | 933 private: |
929 bool visible_; | 934 bool visible_; |
930 int started_times_; | 935 int started_times_; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
984 added_animations_++; | 989 added_animations_++; |
985 break; | 990 break; |
986 case 2: | 991 case 2: |
987 // This second animation will not be drawn so it should not start. | 992 // This second animation will not be drawn so it should not start. |
988 AddAnimatedTransformToLayer(content_.get(), 0.1, 5, 5); | 993 AddAnimatedTransformToLayer(content_.get(), 0.1, 5, 5); |
989 added_animations_++; | 994 added_animations_++; |
990 break; | 995 break; |
991 } | 996 } |
992 } | 997 } |
993 | 998 |
994 virtual void NotifyAnimationStarted( | 999 virtual void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
995 base::TimeTicks monotonic_time, | 1000 Animation::TargetProperty target_property, |
996 Animation::TargetProperty target_property) override { | 1001 int group) override { |
997 if (TestEnded()) | 1002 if (TestEnded()) |
998 return; | 1003 return; |
999 started_times_++; | 1004 started_times_++; |
1000 } | 1005 } |
1001 | 1006 |
1002 virtual void AfterTest() override { | 1007 virtual void AfterTest() override { |
1003 // Make sure we tried to draw the second animation but failed. | 1008 // Make sure we tried to draw the second animation but failed. |
1004 EXPECT_LT(0, prevented_draw_); | 1009 EXPECT_LT(0, prevented_draw_); |
1005 // The first animation should be started, but the second should not because | 1010 // The first animation should be started, but the second should not because |
1006 // of checkerboard. | 1011 // of checkerboard. |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 private: | 1295 private: |
1291 scoped_refptr<Layer> content_; | 1296 scoped_refptr<Layer> content_; |
1292 int num_swap_buffers_; | 1297 int num_swap_buffers_; |
1293 }; | 1298 }; |
1294 | 1299 |
1295 SINGLE_AND_MULTI_THREAD_TEST_F( | 1300 SINGLE_AND_MULTI_THREAD_TEST_F( |
1296 LayerTreeHostAnimationTestAddAnimationAfterAnimating); | 1301 LayerTreeHostAnimationTestAddAnimationAfterAnimating); |
1297 | 1302 |
1298 } // namespace | 1303 } // namespace |
1299 } // namespace cc | 1304 } // namespace cc |
OLD | NEW |