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