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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 | 245 |
246 virtual void AfterTest() OVERRIDE {} | 246 virtual void AfterTest() OVERRIDE {} |
247 | 247 |
248 private: | 248 private: |
249 int num_animates_; | 249 int num_animates_; |
250 }; | 250 }; |
251 | 251 |
252 SINGLE_AND_MULTI_THREAD_TEST_F( | 252 SINGLE_AND_MULTI_THREAD_TEST_F( |
253 LayerTreeHostAnimationTestTickAnimationWhileBackgrounded); | 253 LayerTreeHostAnimationTestTickAnimationWhileBackgrounded); |
254 | 254 |
255 // Ensures that animations continue to be ticked when we are backgrounded. | |
256 class LayerTreeHostAnimationTestAddAnimationWithTimingFunction | 255 class LayerTreeHostAnimationTestAddAnimationWithTimingFunction |
257 : public LayerTreeHostAnimationTest { | 256 : public LayerTreeHostAnimationTest { |
258 public: | 257 public: |
259 LayerTreeHostAnimationTestAddAnimationWithTimingFunction() {} | 258 LayerTreeHostAnimationTestAddAnimationWithTimingFunction() {} |
260 | 259 |
261 virtual void SetupTree() OVERRIDE { | 260 virtual void SetupTree() OVERRIDE { |
262 LayerTreeHostAnimationTest::SetupTree(); | 261 LayerTreeHostAnimationTest::SetupTree(); |
263 content_ = FakeContentLayer::Create(&client_); | 262 content_ = FakeContentLayer::Create(&client_); |
264 content_->SetBounds(gfx::Size(4, 4)); | 263 content_->SetBounds(gfx::Size(4, 4)); |
| 264 content_->set_layer_animation_delegate(this); |
265 layer_tree_host()->root_layer()->AddChild(content_); | 265 layer_tree_host()->root_layer()->AddChild(content_); |
266 } | 266 } |
267 | 267 |
268 virtual void BeginTest() OVERRIDE { | 268 virtual void BeginTest() OVERRIDE { |
269 PostAddAnimationToMainThread(content_); | 269 PostAddAnimationToMainThread(content_); |
270 } | 270 } |
271 | 271 |
272 virtual void AnimateLayers( | 272 virtual void notifyAnimationStarted(double wallClockTime) OVERRIDE { |
273 LayerTreeHostImpl* host_impl, | |
274 base::TimeTicks monotonic_time) OVERRIDE { | |
275 LayerAnimationController* controller = | 273 LayerAnimationController* controller = |
276 layer_tree_host()->root_layer()->children()[0]-> | 274 layer_tree_host()->root_layer()->children()[0]-> |
277 layer_animation_controller(); | 275 layer_animation_controller(); |
278 Animation* animation = | 276 Animation* animation = |
279 controller->GetAnimation(Animation::Opacity); | 277 controller->GetAnimation(Animation::Opacity); |
280 if (!animation) | |
281 return; | |
282 | |
283 const FloatAnimationCurve* curve = | 278 const FloatAnimationCurve* curve = |
284 animation->curve()->ToFloatAnimationCurve(); | 279 animation->curve()->ToFloatAnimationCurve(); |
285 float start_opacity = curve->GetValue(0.0); | 280 float start_opacity = curve->GetValue(0.0); |
286 float end_opacity = curve->GetValue(curve->Duration()); | 281 float end_opacity = curve->GetValue(curve->Duration()); |
287 float linearly_interpolated_opacity = | 282 float linearly_interpolated_opacity = |
288 0.25f * end_opacity + 0.75f * start_opacity; | 283 0.25f * end_opacity + 0.75f * start_opacity; |
289 double time = curve->Duration() * 0.25; | 284 double time = curve->Duration() * 0.25; |
290 // If the linear timing function associated with this animation was not | 285 // If the linear timing function associated with this animation was not |
291 // picked up, then the linearly interpolated opacity would be different | 286 // picked up, then the linearly interpolated opacity would be different |
292 // because of the default ease timing function. | 287 // because of the default ease timing function. |
293 EXPECT_FLOAT_EQ(linearly_interpolated_opacity, curve->GetValue(time)); | 288 EXPECT_FLOAT_EQ(linearly_interpolated_opacity, curve->GetValue(time)); |
294 | 289 |
295 LayerAnimationController* controller_impl = | 290 controller->RemoveAnimation(animation->id()); |
296 host_impl->active_tree()->root_layer()->children()[0]-> | |
297 layer_animation_controller(); | |
298 Animation* animation_impl = | |
299 controller_impl->GetAnimation(Animation::Opacity); | |
300 | 291 |
301 controller->RemoveAnimation(animation->id()); | |
302 controller_impl->RemoveAnimation(animation_impl->id()); | |
303 EndTest(); | 292 EndTest(); |
304 } | 293 } |
305 | 294 |
306 virtual void AfterTest() OVERRIDE {} | 295 virtual void AfterTest() OVERRIDE {} |
307 | 296 |
308 FakeContentLayerClient client_; | 297 FakeContentLayerClient client_; |
309 scoped_refptr<FakeContentLayer> content_; | 298 scoped_refptr<FakeContentLayer> content_; |
310 }; | 299 }; |
311 | 300 |
312 SINGLE_AND_MULTI_THREAD_TEST_F( | 301 SINGLE_AND_MULTI_THREAD_TEST_F( |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 FakeContentLayerClient client_; | 809 FakeContentLayerClient client_; |
821 scoped_refptr<FakeContentLayer> root_layer_; | 810 scoped_refptr<FakeContentLayer> root_layer_; |
822 int started_times_; | 811 int started_times_; |
823 int num_commit_complete_; | 812 int num_commit_complete_; |
824 }; | 813 }; |
825 | 814 |
826 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestPinchZoomScrollbars); | 815 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestPinchZoomScrollbars); |
827 | 816 |
828 } // namespace | 817 } // namespace |
829 } // namespace cc | 818 } // namespace cc |
OLD | NEW |