| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 LayerTreeHostImpl* host_impl, | 193 LayerTreeHostImpl* host_impl, |
| 194 base::TimeTicks monotonic_time) OVERRIDE { | 194 base::TimeTicks monotonic_time) OVERRIDE { |
| 195 started_animating_ = true; | 195 started_animating_ = true; |
| 196 } | 196 } |
| 197 | 197 |
| 198 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 198 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 199 if (started_animating_) | 199 if (started_animating_) |
| 200 EndTest(); | 200 EndTest(); |
| 201 } | 201 } |
| 202 | 202 |
| 203 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread( | 203 virtual DrawResult PrepareToDrawOnThread( |
| 204 LayerTreeHostImpl* host_impl, | 204 LayerTreeHostImpl* host_impl, |
| 205 LayerTreeHostImpl::FrameData* frame, | 205 LayerTreeHostImpl::FrameData* frame, |
| 206 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE { | 206 DrawResult draw_result) OVERRIDE { |
| 207 return DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; | 207 return DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; |
| 208 } | 208 } |
| 209 | 209 |
| 210 virtual void AfterTest() OVERRIDE { } | 210 virtual void AfterTest() OVERRIDE { } |
| 211 | 211 |
| 212 private: | 212 private: |
| 213 bool started_animating_; | 213 bool started_animating_; |
| 214 }; | 214 }; |
| 215 | 215 |
| 216 // Starvation can only be an issue with the MT compositor. | 216 // Starvation can only be an issue with the MT compositor. |
| 217 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws); | 217 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 if (num_foreground_animates_ > 1 && !has_background_ticked_) | 325 if (num_foreground_animates_ > 1 && !has_background_ticked_) |
| 326 PostSetVisibleToMainThread(false); | 326 PostSetVisibleToMainThread(false); |
| 327 else if (has_background_ticked_) | 327 else if (has_background_ticked_) |
| 328 EndTest(); | 328 EndTest(); |
| 329 } else { | 329 } else { |
| 330 has_background_ticked_ = true; | 330 has_background_ticked_ = true; |
| 331 PostSetVisibleToMainThread(true); | 331 PostSetVisibleToMainThread(true); |
| 332 } | 332 } |
| 333 } | 333 } |
| 334 | 334 |
| 335 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread( | 335 virtual DrawResult PrepareToDrawOnThread( |
| 336 LayerTreeHostImpl* host_impl, | 336 LayerTreeHostImpl* host_impl, |
| 337 LayerTreeHostImpl::FrameData* frame, | 337 LayerTreeHostImpl::FrameData* frame, |
| 338 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE { | 338 DrawResult draw_result) OVERRIDE { |
| 339 if (TestEnded()) | 339 if (TestEnded()) |
| 340 return draw_result; | 340 return draw_result; |
| 341 return DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; | 341 return DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; |
| 342 } | 342 } |
| 343 | 343 |
| 344 virtual void AfterTest() OVERRIDE {} | 344 virtual void AfterTest() OVERRIDE {} |
| 345 | 345 |
| 346 private: | 346 private: |
| 347 bool has_background_ticked_; | 347 bool has_background_ticked_; |
| 348 int num_foreground_animates_; | 348 int num_foreground_animates_; |
| 349 base::TimeTicks last_tick_time_; | 349 base::TimeTicks last_tick_time_; |
| 350 }; | 350 }; |
| 351 | 351 |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 } | 1058 } |
| 1059 | 1059 |
| 1060 virtual void BeginTest() OVERRIDE { | 1060 virtual void BeginTest() OVERRIDE { |
| 1061 prevented_draw_ = 0; | 1061 prevented_draw_ = 0; |
| 1062 added_animations_ = 0; | 1062 added_animations_ = 0; |
| 1063 started_times_ = 0; | 1063 started_times_ = 0; |
| 1064 | 1064 |
| 1065 PostSetNeedsCommitToMainThread(); | 1065 PostSetNeedsCommitToMainThread(); |
| 1066 } | 1066 } |
| 1067 | 1067 |
| 1068 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread( | 1068 virtual DrawResult PrepareToDrawOnThread( |
| 1069 LayerTreeHostImpl* host_impl, | 1069 LayerTreeHostImpl* host_impl, |
| 1070 LayerTreeHostImpl::FrameData* frame_data, | 1070 LayerTreeHostImpl::FrameData* frame_data, |
| 1071 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE { | 1071 DrawResult draw_result) OVERRIDE { |
| 1072 if (added_animations_ < 2) | 1072 if (added_animations_ < 2) |
| 1073 return draw_result; | 1073 return draw_result; |
| 1074 if (TestEnded()) | 1074 if (TestEnded()) |
| 1075 return draw_result; | 1075 return draw_result; |
| 1076 // Act like there is checkerboard when the second animation wants to draw. | 1076 // Act like there is checkerboard when the second animation wants to draw. |
| 1077 ++prevented_draw_; | 1077 ++prevented_draw_; |
| 1078 if (prevented_draw_ > 2) | 1078 if (prevented_draw_ > 2) |
| 1079 EndTest(); | 1079 EndTest(); |
| 1080 return DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; | 1080 return DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; |
| 1081 } | 1081 } |
| 1082 | 1082 |
| 1083 virtual void DidCommitAndDrawFrame() OVERRIDE { | 1083 virtual void DidCommitAndDrawFrame() OVERRIDE { |
| 1084 switch (layer_tree_host()->source_frame_number()) { | 1084 switch (layer_tree_host()->source_frame_number()) { |
| 1085 case 1: | 1085 case 1: |
| 1086 // The animation is longer than 1 BeginFrame interval. | 1086 // The animation is longer than 1 BeginFrame interval. |
| 1087 AddOpacityTransitionToLayer(content_.get(), 0.1, 0.2f, 0.8f, false); | 1087 AddOpacityTransitionToLayer(content_.get(), 0.1, 0.2f, 0.8f, false); |
| 1088 added_animations_++; | 1088 added_animations_++; |
| 1089 break; | 1089 break; |
| 1090 case 2: | 1090 case 2: |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1202 if (!started_animating_) { | 1202 if (!started_animating_) { |
| 1203 started_animating_ = true; | 1203 started_animating_ = true; |
| 1204 expected_impl_tick_time_ = monotonic_time; | 1204 expected_impl_tick_time_ = monotonic_time; |
| 1205 } else { | 1205 } else { |
| 1206 EXPECT_EQ(expected_impl_tick_time_, monotonic_time); | 1206 EXPECT_EQ(expected_impl_tick_time_, monotonic_time); |
| 1207 if (num_commits_ > 2) | 1207 if (num_commits_ > 2) |
| 1208 EndTest(); | 1208 EndTest(); |
| 1209 } | 1209 } |
| 1210 } | 1210 } |
| 1211 | 1211 |
| 1212 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread( | 1212 virtual DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 1213 LayerTreeHostImpl* host_impl, | 1213 LayerTreeHostImpl::FrameData* frame, |
| 1214 LayerTreeHostImpl::FrameData* frame, | 1214 DrawResult draw_result) OVERRIDE { |
| 1215 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE { | |
| 1216 if (TestEnded()) | 1215 if (TestEnded()) |
| 1217 return draw_result; | 1216 return draw_result; |
| 1218 num_draw_attempts_++; | 1217 num_draw_attempts_++; |
| 1219 if (num_draw_attempts_ > 2) { | 1218 if (num_draw_attempts_ > 2) { |
| 1220 num_draw_attempts_ = 0; | 1219 num_draw_attempts_ = 0; |
| 1221 PostSetNeedsCommitToMainThread(); | 1220 PostSetNeedsCommitToMainThread(); |
| 1222 } | 1221 } |
| 1223 return DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; | 1222 return DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; |
| 1224 } | 1223 } |
| 1225 | 1224 |
| 1226 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 1225 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 1227 if (!started_animating_) | 1226 if (!started_animating_) |
| 1228 return; | 1227 return; |
| 1229 expected_impl_tick_time_ = | 1228 expected_impl_tick_time_ = |
| 1230 std::max(expected_impl_tick_time_, last_main_thread_tick_time_); | 1229 std::max(expected_impl_tick_time_, last_main_thread_tick_time_); |
| 1231 num_commits_++; | 1230 num_commits_++; |
| 1232 } | 1231 } |
| 1233 | 1232 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1382 private: | 1381 private: |
| 1383 scoped_refptr<Layer> content_; | 1382 scoped_refptr<Layer> content_; |
| 1384 int num_swap_buffers_; | 1383 int num_swap_buffers_; |
| 1385 }; | 1384 }; |
| 1386 | 1385 |
| 1387 SINGLE_AND_MULTI_THREAD_TEST_F( | 1386 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 1388 LayerTreeHostAnimationTestAddAnimationAfterAnimating); | 1387 LayerTreeHostAnimationTestAddAnimationAfterAnimating); |
| 1389 | 1388 |
| 1390 } // namespace | 1389 } // namespace |
| 1391 } // namespace cc | 1390 } // namespace cc |
| OLD | NEW |