| 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_; |
| 289 }; | 289 }; |
| 290 | 290 |
| 291 SINGLE_AND_MULTI_THREAD_TEST_F( | 291 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 292 LayerTreeHostAnimationTestTickAnimationWhileBackgrounded); | 292 LayerTreeHostAnimationTestTickAnimationWhileBackgrounded); |
| 293 | 293 |
| 294 // Ensures that animations continue to be ticked when we are backgrounded. |
| 294 class LayerTreeHostAnimationTestAddAnimationWithTimingFunction | 295 class LayerTreeHostAnimationTestAddAnimationWithTimingFunction |
| 295 : public LayerTreeHostAnimationTest { | 296 : public LayerTreeHostAnimationTest { |
| 296 public: | 297 public: |
| 297 LayerTreeHostAnimationTestAddAnimationWithTimingFunction() {} | 298 LayerTreeHostAnimationTestAddAnimationWithTimingFunction() {} |
| 298 | 299 |
| 299 virtual void SetupTree() OVERRIDE { | 300 virtual void SetupTree() OVERRIDE { |
| 300 LayerTreeHostAnimationTest::SetupTree(); | 301 LayerTreeHostAnimationTest::SetupTree(); |
| 301 content_ = FakeContentLayer::Create(&client_); | 302 content_ = FakeContentLayer::Create(&client_); |
| 302 content_->SetBounds(gfx::Size(4, 4)); | 303 content_->SetBounds(gfx::Size(4, 4)); |
| 303 content_->set_layer_animation_delegate(this); | |
| 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_); | 308 PostAddAnimationToMainThread(content_); |
| 309 } | 309 } |
| 310 | 310 |
| 311 virtual void notifyAnimationStarted(double wallClockTime) OVERRIDE { | 311 virtual void AnimateLayers( |
| 312 LayerTreeHostImpl* host_impl, |
| 313 base::TimeTicks monotonic_time) OVERRIDE { |
| 312 LayerAnimationController* controller = | 314 LayerAnimationController* controller = |
| 313 layer_tree_host()->root_layer()->children()[0]-> | 315 layer_tree_host()->root_layer()->children()[0]-> |
| 314 layer_animation_controller(); | 316 layer_animation_controller(); |
| 315 Animation* animation = | 317 Animation* animation = |
| 316 controller->GetAnimation(Animation::Opacity); | 318 controller->GetAnimation(Animation::Opacity); |
| 319 if (!animation) |
| 320 return; |
| 321 |
| 317 const FloatAnimationCurve* curve = | 322 const FloatAnimationCurve* curve = |
| 318 animation->curve()->ToFloatAnimationCurve(); | 323 animation->curve()->ToFloatAnimationCurve(); |
| 319 float start_opacity = curve->GetValue(0.0); | 324 float start_opacity = curve->GetValue(0.0); |
| 320 float end_opacity = curve->GetValue(curve->Duration()); | 325 float end_opacity = curve->GetValue(curve->Duration()); |
| 321 float linearly_interpolated_opacity = | 326 float linearly_interpolated_opacity = |
| 322 0.25f * end_opacity + 0.75f * start_opacity; | 327 0.25f * end_opacity + 0.75f * start_opacity; |
| 323 double time = curve->Duration() * 0.25; | 328 double time = curve->Duration() * 0.25; |
| 324 // If the linear timing function associated with this animation was not | 329 // If the linear timing function associated with this animation was not |
| 325 // picked up, then the linearly interpolated opacity would be different | 330 // picked up, then the linearly interpolated opacity would be different |
| 326 // because of the default ease timing function. | 331 // because of the default ease timing function. |
| 327 EXPECT_FLOAT_EQ(linearly_interpolated_opacity, curve->GetValue(time)); | 332 EXPECT_FLOAT_EQ(linearly_interpolated_opacity, curve->GetValue(time)); |
| 328 | 333 |
| 334 LayerAnimationController* controller_impl = |
| 335 host_impl->active_tree()->root_layer()->children()[0]-> |
| 336 layer_animation_controller(); |
| 337 Animation* animation_impl = |
| 338 controller_impl->GetAnimation(Animation::Opacity); |
| 339 |
| 329 controller->RemoveAnimation(animation->id()); | 340 controller->RemoveAnimation(animation->id()); |
| 330 | 341 controller_impl->RemoveAnimation(animation_impl->id()); |
| 331 EndTest(); | 342 EndTest(); |
| 332 } | 343 } |
| 333 | 344 |
| 334 virtual void AfterTest() OVERRIDE {} | 345 virtual void AfterTest() OVERRIDE {} |
| 335 | 346 |
| 336 FakeContentLayerClient client_; | 347 FakeContentLayerClient client_; |
| 337 scoped_refptr<FakeContentLayer> content_; | 348 scoped_refptr<FakeContentLayer> content_; |
| 338 }; | 349 }; |
| 339 | 350 |
| 340 SINGLE_AND_MULTI_THREAD_TEST_F( | 351 SINGLE_AND_MULTI_THREAD_TEST_F( |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 int finished_times_; | 803 int finished_times_; |
| 793 FakeContentLayerClient client_; | 804 FakeContentLayerClient client_; |
| 794 scoped_refptr<FakeContentLayer> content_; | 805 scoped_refptr<FakeContentLayer> content_; |
| 795 }; | 806 }; |
| 796 | 807 |
| 797 MULTI_THREAD_TEST_F( | 808 MULTI_THREAD_TEST_F( |
| 798 LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations); | 809 LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations); |
| 799 | 810 |
| 800 } // namespace | 811 } // namespace |
| 801 } // namespace cc | 812 } // namespace cc |
| OLD | NEW |