| 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 class LayerTreeHostAnimationTestTickAnimationWhileBackgrounded | 257 class LayerTreeHostAnimationTestTickAnimationWhileBackgrounded |
| 258 : public LayerTreeHostAnimationTest { | 258 : public LayerTreeHostAnimationTest { |
| 259 public: | 259 public: |
| 260 LayerTreeHostAnimationTestTickAnimationWhileBackgrounded() | 260 LayerTreeHostAnimationTestTickAnimationWhileBackgrounded() |
| 261 : num_animates_(0) {} | 261 : num_animates_(0) {} |
| 262 | 262 |
| 263 virtual void BeginTest() OVERRIDE { | 263 virtual void BeginTest() OVERRIDE { |
| 264 PostAddAnimationToMainThread(layer_tree_host()->root_layer()); | 264 PostAddAnimationToMainThread(layer_tree_host()->root_layer()); |
| 265 } | 265 } |
| 266 | 266 |
| 267 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 268 if (num_animates_ == 1) |
| 269 PostSetVisibleToMainThread(false); |
| 270 } |
| 271 |
| 267 // Use WillAnimateLayers to set visible false before the animation runs and | 272 // Use WillAnimateLayers to set visible false before the animation runs and |
| 268 // causes a commit, so we block the second visible animate in single-thread | 273 // causes a commit, so we block the second visible animate in single-thread |
| 269 // mode. | 274 // mode. |
| 270 virtual void WillAnimateLayers( | 275 virtual void WillAnimateLayers( |
| 271 LayerTreeHostImpl* host_impl, | 276 LayerTreeHostImpl* host_impl, |
| 272 base::TimeTicks monotonic_time) OVERRIDE { | 277 base::TimeTicks monotonic_time) OVERRIDE { |
| 273 if (num_animates_ < 2) { | 278 if (num_animates_ < 3) { |
| 274 if (!num_animates_) { | |
| 275 // We have a long animation running. It should continue to tick even | |
| 276 // if we are not visible. | |
| 277 PostSetVisibleToMainThread(false); | |
| 278 } | |
| 279 num_animates_++; | 279 num_animates_++; |
| 280 return; | 280 return; |
| 281 } | 281 } |
| 282 EndTest(); | 282 EndTest(); |
| 283 } | 283 } |
| 284 | 284 |
| 285 virtual void AfterTest() OVERRIDE {} | 285 virtual void AfterTest() OVERRIDE {} |
| 286 | 286 |
| 287 private: | 287 private: |
| 288 int num_animates_; | 288 int num_animates_; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 304 layer_tree_host()->root_layer()->AddChild(content_); | 304 layer_tree_host()->root_layer()->AddChild(content_); |
| 305 } | 305 } |
| 306 | 306 |
| 307 virtual void BeginTest() OVERRIDE { | 307 virtual void BeginTest() OVERRIDE { |
| 308 PostAddAnimationToMainThread(content_.get()); | 308 PostAddAnimationToMainThread(content_.get()); |
| 309 } | 309 } |
| 310 | 310 |
| 311 virtual void AnimateLayers( | 311 virtual void AnimateLayers( |
| 312 LayerTreeHostImpl* host_impl, | 312 LayerTreeHostImpl* host_impl, |
| 313 base::TimeTicks monotonic_time) OVERRIDE { | 313 base::TimeTicks monotonic_time) OVERRIDE { |
| 314 if (!host_impl->active_tree()->root_layer()) |
| 315 return; |
| 314 LayerAnimationController* controller_impl = | 316 LayerAnimationController* controller_impl = |
| 315 host_impl->active_tree()->root_layer()->children()[0]-> | 317 host_impl->active_tree()->root_layer()->children()[0]-> |
| 316 layer_animation_controller(); | 318 layer_animation_controller(); |
| 317 Animation* animation = | 319 Animation* animation = |
| 318 controller_impl->GetAnimation(Animation::Opacity); | 320 controller_impl->GetAnimation(Animation::Opacity); |
| 319 if (!animation) | 321 if (!animation) |
| 320 return; | 322 return; |
| 321 | 323 |
| 322 const FloatAnimationCurve* curve = | 324 const FloatAnimationCurve* curve = |
| 323 animation->curve()->ToFloatAnimationCurve(); | 325 animation->curve()->ToFloatAnimationCurve(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 main_start_time_ = animation->start_time(); | 375 main_start_time_ = animation->start_time(); |
| 374 controller->RemoveAnimation(animation->id()); | 376 controller->RemoveAnimation(animation->id()); |
| 375 | 377 |
| 376 if (impl_start_time_ > 0.0) | 378 if (impl_start_time_ > 0.0) |
| 377 EndTest(); | 379 EndTest(); |
| 378 } | 380 } |
| 379 | 381 |
| 380 virtual void UpdateAnimationState( | 382 virtual void UpdateAnimationState( |
| 381 LayerTreeHostImpl* impl_host, | 383 LayerTreeHostImpl* impl_host, |
| 382 bool has_unfinished_animation) OVERRIDE { | 384 bool has_unfinished_animation) OVERRIDE { |
| 385 if (!impl_host->active_tree()->root_layer()) |
| 386 return; |
| 387 |
| 383 LayerAnimationController* controller = | 388 LayerAnimationController* controller = |
| 384 impl_host->active_tree()->root_layer()->children()[0]-> | 389 impl_host->active_tree()->root_layer()->children()[0]-> |
| 385 layer_animation_controller(); | 390 layer_animation_controller(); |
| 386 Animation* animation = | 391 Animation* animation = |
| 387 controller->GetAnimation(Animation::Opacity); | 392 controller->GetAnimation(Animation::Opacity); |
| 388 if (!animation) | 393 if (!animation) |
| 389 return; | 394 return; |
| 390 | 395 |
| 391 impl_start_time_ = animation->start_time(); | 396 impl_start_time_ = animation->start_time(); |
| 392 controller->RemoveAnimation(animation->id()); | 397 controller->RemoveAnimation(animation->id()); |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 int finished_times_; | 800 int finished_times_; |
| 796 FakeContentLayerClient client_; | 801 FakeContentLayerClient client_; |
| 797 scoped_refptr<FakeContentLayer> content_; | 802 scoped_refptr<FakeContentLayer> content_; |
| 798 }; | 803 }; |
| 799 | 804 |
| 800 MULTI_THREAD_TEST_F( | 805 MULTI_THREAD_TEST_F( |
| 801 LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations); | 806 LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations); |
| 802 | 807 |
| 803 } // namespace | 808 } // namespace |
| 804 } // namespace cc | 809 } // namespace cc |
| OLD | NEW |