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 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1072 virtual void AfterTest() override {} | 1072 virtual void AfterTest() override {} |
1073 | 1073 |
1074 private: | 1074 private: |
1075 FakeContentLayerClient client_; | 1075 FakeContentLayerClient client_; |
1076 scoped_refptr<FakeContentLayer> scroll_layer_; | 1076 scoped_refptr<FakeContentLayer> scroll_layer_; |
1077 }; | 1077 }; |
1078 | 1078 |
1079 SINGLE_AND_MULTI_THREAD_TEST_F( | 1079 SINGLE_AND_MULTI_THREAD_TEST_F( |
1080 LayerTreeHostAnimationTestScrollOffsetChangesArePropagated); | 1080 LayerTreeHostAnimationTestScrollOffsetChangesArePropagated); |
1081 | 1081 |
1082 // Ensure that animation time is correctly updated when animations are frozen | |
1083 // because of checkerboarding. | |
1084 class LayerTreeHostAnimationTestFrozenAnimationTickTime | |
1085 : public LayerTreeHostAnimationTest { | |
1086 public: | |
1087 LayerTreeHostAnimationTestFrozenAnimationTickTime() | |
1088 : started_animating_(false), num_commits_(0), num_draw_attempts_(2) {} | |
1089 | |
1090 virtual void InitializeSettings(LayerTreeSettings* settings) override { | |
1091 // Make sure that drawing many times doesn't cause a checkerboarded | |
1092 // animation to start so we avoid flake in this test. | |
1093 settings->timeout_and_draw_when_animation_checkerboards = false; | |
1094 } | |
1095 | |
1096 virtual void BeginTest() override { | |
1097 PostAddAnimationToMainThread(layer_tree_host()->root_layer()); | |
1098 } | |
1099 | |
1100 virtual void BeginMainFrame(const BeginFrameArgs& args) override { | |
1101 last_main_thread_tick_time_ = args.frame_time; | |
1102 } | |
1103 | |
1104 virtual void AnimateLayers(LayerTreeHostImpl* host_impl, | |
1105 base::TimeTicks monotonic_time) override { | |
1106 if (TestEnded()) | |
1107 return; | |
1108 if (!started_animating_) { | |
1109 started_animating_ = true; | |
1110 expected_impl_tick_time_ = monotonic_time; | |
1111 } else { | |
1112 EXPECT_EQ(expected_impl_tick_time_, monotonic_time); | |
1113 if (num_commits_ > 2) | |
1114 EndTest(); | |
1115 } | |
1116 } | |
1117 | |
1118 virtual DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | |
1119 LayerTreeHostImpl::FrameData* frame, | |
1120 DrawResult draw_result) override { | |
1121 if (TestEnded()) | |
1122 return draw_result; | |
1123 num_draw_attempts_++; | |
1124 if (num_draw_attempts_ > 2) { | |
1125 num_draw_attempts_ = 0; | |
1126 PostSetNeedsCommitToMainThread(); | |
1127 } | |
1128 return DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; | |
1129 } | |
1130 | |
1131 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { | |
1132 if (!started_animating_) | |
1133 return; | |
1134 expected_impl_tick_time_ = | |
1135 std::max(expected_impl_tick_time_, last_main_thread_tick_time_); | |
1136 num_commits_++; | |
1137 } | |
1138 | |
1139 virtual void AfterTest() override {} | |
1140 | |
1141 private: | |
1142 bool started_animating_; | |
1143 int num_commits_; | |
1144 int num_draw_attempts_; | |
1145 base::TimeTicks last_main_thread_tick_time_; | |
1146 base::TimeTicks expected_impl_tick_time_; | |
1147 }; | |
1148 | |
1149 // Only the non-impl-paint multi-threaded compositor freezes animations. | |
1150 MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostAnimationTestFrozenAnimationTickTime); | |
1151 | |
1152 // When animations are simultaneously added to an existing layer and to a new | 1082 // When animations are simultaneously added to an existing layer and to a new |
1153 // layer, they should start at the same time, even when there's already a | 1083 // layer, they should start at the same time, even when there's already a |
1154 // running animation on the existing layer. | 1084 // running animation on the existing layer. |
1155 class LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers | 1085 class LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers |
1156 : public LayerTreeHostAnimationTest { | 1086 : public LayerTreeHostAnimationTest { |
1157 public: | 1087 public: |
1158 LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers() | 1088 LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers() |
1159 : frame_count_with_pending_tree_(0) {} | 1089 : frame_count_with_pending_tree_(0) {} |
1160 | 1090 |
1161 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1091 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1295 private: | 1225 private: |
1296 scoped_refptr<Layer> content_; | 1226 scoped_refptr<Layer> content_; |
1297 int num_swap_buffers_; | 1227 int num_swap_buffers_; |
1298 }; | 1228 }; |
1299 | 1229 |
1300 SINGLE_AND_MULTI_THREAD_TEST_F( | 1230 SINGLE_AND_MULTI_THREAD_TEST_F( |
1301 LayerTreeHostAnimationTestAddAnimationAfterAnimating); | 1231 LayerTreeHostAnimationTestAddAnimationAfterAnimating); |
1302 | 1232 |
1303 } // namespace | 1233 } // namespace |
1304 } // namespace cc | 1234 } // namespace cc |
OLD | NEW |