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 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
776 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestCompositeAndReadbackAnimateCount); | 776 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestCompositeAndReadbackAnimateCount); |
777 | 777 |
778 class LayerTreeHostAnimationTestContinuousAnimate | 778 class LayerTreeHostAnimationTestContinuousAnimate |
779 : public LayerTreeHostAnimationTest { | 779 : public LayerTreeHostAnimationTest { |
780 public: | 780 public: |
781 LayerTreeHostAnimationTestContinuousAnimate() | 781 LayerTreeHostAnimationTestContinuousAnimate() |
782 : num_commit_complete_(0), | 782 : num_commit_complete_(0), |
783 num_draw_layers_(0) { | 783 num_draw_layers_(0) { |
784 } | 784 } |
785 | 785 |
786 virtual void SetupTree() OVERRIDE { | |
787 LayerTreeHostAnimationTest::SetupTree(); | |
788 // Create a fake content layer so we actually produce new content for every | |
789 // animation frame. | |
790 content_ = FakeContentLayer::Create(&client_); | |
791 content_->set_always_update_resources(true); | |
792 layer_tree_host()->root_layer()->AddChild(content_); | |
793 } | |
794 | |
786 virtual void BeginTest() OVERRIDE { | 795 virtual void BeginTest() OVERRIDE { |
787 PostSetNeedsCommitToMainThread(); | 796 PostSetNeedsCommitToMainThread(); |
788 } | 797 } |
789 | 798 |
790 virtual void Animate(base::TimeTicks) OVERRIDE { | 799 virtual void Animate(base::TimeTicks) OVERRIDE { |
791 if (num_draw_layers_ == 2) | 800 if (num_draw_layers_ == 2) |
792 return; | 801 return; |
793 layer_tree_host()->SetNeedsAnimate(); | 802 layer_tree_host()->SetNeedsAnimate(); |
794 } | 803 } |
795 | 804 |
(...skipping 13 matching lines...) Expand all Loading... | |
809 } | 818 } |
810 | 819 |
811 virtual void AfterTest() OVERRIDE { | 820 virtual void AfterTest() OVERRIDE { |
812 // Check that we didn't commit twice between first and second draw. | 821 // Check that we didn't commit twice between first and second draw. |
813 EXPECT_EQ(1, num_commit_complete_); | 822 EXPECT_EQ(1, num_commit_complete_); |
814 } | 823 } |
815 | 824 |
816 private: | 825 private: |
817 int num_commit_complete_; | 826 int num_commit_complete_; |
818 int num_draw_layers_; | 827 int num_draw_layers_; |
828 FakeContentLayerClient client_; | |
829 scoped_refptr<FakeContentLayer> content_; | |
819 }; | 830 }; |
820 | 831 |
821 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestContinuousAnimate); | 832 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestContinuousAnimate); |
822 | 833 |
834 class LayerTreeHostAnimationTestCancelAnimateCommit | |
835 : public LayerTreeHostAnimationTest { | |
836 public: | |
837 LayerTreeHostAnimationTestCancelAnimateCommit() : num_animate_calls_(0) {} | |
838 | |
839 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | |
840 | |
841 virtual void Animate(base::TimeTicks) OVERRIDE { | |
842 // No-op animate will cancel the commit. | |
843 if (++num_animate_calls_ == 2) { | |
844 EndTest(); | |
845 return; | |
846 } | |
847 layer_tree_host()->SetNeedsAnimate(); | |
848 } | |
849 | |
850 virtual void CommitCompleteOnThread(LayerTreeHostImpl* tree_impl) OVERRIDE { | |
851 FAIL() << "Commit should have been canceled."; | |
852 } | |
853 | |
854 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | |
855 FAIL() << "Draw should have been canceled."; | |
856 } | |
857 | |
858 virtual void AfterTest() OVERRIDE { EXPECT_EQ(2, num_animate_calls_); } | |
859 | |
860 private: | |
861 int num_animate_calls_; | |
862 FakeContentLayerClient client_; | |
863 scoped_refptr<FakeContentLayer> content_; | |
864 }; | |
865 | |
866 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestCancelAnimateCommit); | |
867 | |
868 class LayerTreeHostAnimationTestForceRedraw | |
869 : public LayerTreeHostAnimationTest { | |
870 public: | |
871 LayerTreeHostAnimationTestForceRedraw() | |
872 : num_animate_(0), num_draw_layers_(0) {} | |
873 | |
874 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | |
875 | |
876 virtual void Animate(base::TimeTicks) OVERRIDE { | |
877 if (++num_animate_ < 2) | |
878 layer_tree_host()->SetNeedsAnimate(); | |
879 } | |
880 | |
881 virtual void Layout() OVERRIDE { | |
882 layer_tree_host()->SetNextCommitForcesRedraw(); | |
883 } | |
884 | |
885 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | |
886 if (++num_draw_layers_ == 1) | |
887 EndTest(); | |
888 } | |
889 | |
890 virtual void AfterTest() OVERRIDE { | |
891 // Make sure the draw was not cancelled. | |
892 EXPECT_GT(num_draw_layers_, 0); | |
danakj
2014/02/26 19:09:05
The first commit will always draw. Do you want thi
danakj
2014/02/26 19:09:05
The first commit will always draw, maybe you want
| |
893 EXPECT_EQ(2, num_animate_); | |
894 } | |
895 | |
896 private: | |
897 int num_animate_; | |
898 int num_draw_layers_; | |
899 }; | |
900 | |
901 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestForceRedraw); | |
902 | |
823 // Make sure the main thread can still execute animations when CanDraw() is not | 903 // Make sure the main thread can still execute animations when CanDraw() is not |
824 // true. | 904 // true. |
825 class LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw | 905 class LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw |
826 : public LayerTreeHostAnimationTest { | 906 : public LayerTreeHostAnimationTest { |
827 public: | 907 public: |
828 LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw() : started_times_(0) {} | 908 LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw() : started_times_(0) {} |
829 | 909 |
830 virtual void SetupTree() OVERRIDE { | 910 virtual void SetupTree() OVERRIDE { |
831 LayerTreeHostAnimationTest::SetupTree(); | 911 LayerTreeHostAnimationTest::SetupTree(); |
832 content_ = FakeContentLayer::Create(&client_); | 912 content_ = FakeContentLayer::Create(&client_); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1122 int num_draw_attempts_; | 1202 int num_draw_attempts_; |
1123 base::TimeTicks last_main_thread_tick_time_; | 1203 base::TimeTicks last_main_thread_tick_time_; |
1124 base::TimeTicks expected_impl_tick_time_; | 1204 base::TimeTicks expected_impl_tick_time_; |
1125 }; | 1205 }; |
1126 | 1206 |
1127 // Only the non-impl-paint multi-threaded compositor freezes animations. | 1207 // Only the non-impl-paint multi-threaded compositor freezes animations. |
1128 MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostAnimationTestFrozenAnimationTickTime); | 1208 MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostAnimationTestFrozenAnimationTickTime); |
1129 | 1209 |
1130 } // namespace | 1210 } // namespace |
1131 } // namespace cc | 1211 } // namespace cc |
OLD | NEW |