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_); | 308 PostAddAnimationToMainThread(content_); |
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) | |
320 return; | |
321 | |
322 const FloatAnimationCurve* curve = | 317 const FloatAnimationCurve* curve = |
323 animation->curve()->ToFloatAnimationCurve(); | 318 animation->curve()->ToFloatAnimationCurve(); |
324 float start_opacity = curve->GetValue(0.0); | 319 float start_opacity = curve->GetValue(0.0); |
325 float end_opacity = curve->GetValue(curve->Duration()); | 320 float end_opacity = curve->GetValue(curve->Duration()); |
326 float linearly_interpolated_opacity = | 321 float linearly_interpolated_opacity = |
327 0.25f * end_opacity + 0.75f * start_opacity; | 322 0.25f * end_opacity + 0.75f * start_opacity; |
328 double time = curve->Duration() * 0.25; | 323 double time = curve->Duration() * 0.25; |
329 // If the linear timing function associated with this animation was not | 324 // If the linear timing function associated with this animation was not |
330 // picked up, then the linearly interpolated opacity would be different | 325 // picked up, then the linearly interpolated opacity would be different |
331 // because of the default ease timing function. | 326 // because of the default ease timing function. |
332 EXPECT_FLOAT_EQ(linearly_interpolated_opacity, curve->GetValue(time)); | 327 EXPECT_FLOAT_EQ(linearly_interpolated_opacity, curve->GetValue(time)); |
333 | 328 |
334 LayerAnimationController* controller_impl = | 329 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 | 330 |
340 controller->RemoveAnimation(animation->id()); | |
341 controller_impl->RemoveAnimation(animation_impl->id()); | |
342 EndTest(); | 331 EndTest(); |
343 } | 332 } |
344 | 333 |
345 virtual void AfterTest() OVERRIDE {} | 334 virtual void AfterTest() OVERRIDE {} |
346 | 335 |
347 FakeContentLayerClient client_; | 336 FakeContentLayerClient client_; |
348 scoped_refptr<FakeContentLayer> content_; | 337 scoped_refptr<FakeContentLayer> content_; |
349 }; | 338 }; |
350 | 339 |
351 SINGLE_AND_MULTI_THREAD_TEST_F( | 340 SINGLE_AND_MULTI_THREAD_TEST_F( |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 int finished_times_; | 792 int finished_times_; |
804 FakeContentLayerClient client_; | 793 FakeContentLayerClient client_; |
805 scoped_refptr<FakeContentLayer> content_; | 794 scoped_refptr<FakeContentLayer> content_; |
806 }; | 795 }; |
807 | 796 |
808 MULTI_THREAD_TEST_F( | 797 MULTI_THREAD_TEST_F( |
809 LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations); | 798 LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations); |
810 | 799 |
811 } // namespace | 800 } // namespace |
812 } // namespace cc | 801 } // namespace cc |
OLD | NEW |