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/scroll_offset_animation_curve.h" | 9 #include "cc/animation/scroll_offset_animation_curve.h" |
10 #include "cc/animation/timing_function.h" | 10 #include "cc/animation/timing_function.h" |
| 11 #include "cc/base/time_util.h" |
11 #include "cc/layers/layer.h" | 12 #include "cc/layers/layer.h" |
12 #include "cc/layers/layer_impl.h" | 13 #include "cc/layers/layer_impl.h" |
13 #include "cc/test/animation_test_common.h" | 14 #include "cc/test/animation_test_common.h" |
14 #include "cc/test/fake_content_layer.h" | 15 #include "cc/test/fake_content_layer.h" |
15 #include "cc/test/fake_content_layer_client.h" | 16 #include "cc/test/fake_content_layer_client.h" |
16 #include "cc/test/layer_tree_test.h" | 17 #include "cc/test/layer_tree_test.h" |
17 #include "cc/trees/layer_tree_impl.h" | 18 #include "cc/trees/layer_tree_impl.h" |
18 | 19 |
19 namespace cc { | 20 namespace cc { |
20 namespace { | 21 namespace { |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 LayerAnimationController* controller_impl = | 497 LayerAnimationController* controller_impl = |
497 host_impl->active_tree()->root_layer()->children()[0]-> | 498 host_impl->active_tree()->root_layer()->children()[0]-> |
498 layer_animation_controller(); | 499 layer_animation_controller(); |
499 Animation* animation = | 500 Animation* animation = |
500 controller_impl->GetAnimation(Animation::Opacity); | 501 controller_impl->GetAnimation(Animation::Opacity); |
501 if (!animation) | 502 if (!animation) |
502 return; | 503 return; |
503 | 504 |
504 const FloatAnimationCurve* curve = | 505 const FloatAnimationCurve* curve = |
505 animation->curve()->ToFloatAnimationCurve(); | 506 animation->curve()->ToFloatAnimationCurve(); |
506 float start_opacity = curve->GetValue(0.0); | 507 float start_opacity = curve->GetValue(base::TimeDelta()); |
507 float end_opacity = curve->GetValue(curve->Duration().InSecondsF()); | 508 float end_opacity = curve->GetValue(curve->Duration()); |
508 float linearly_interpolated_opacity = | 509 float linearly_interpolated_opacity = |
509 0.25f * end_opacity + 0.75f * start_opacity; | 510 0.25f * end_opacity + 0.75f * start_opacity; |
510 double time = curve->Duration().InSecondsF() * 0.25; | 511 base::TimeDelta time = TimeUtil::Scale(curve->Duration(), 0.25f); |
511 // If the linear timing function associated with this animation was not | 512 // If the linear timing function associated with this animation was not |
512 // picked up, then the linearly interpolated opacity would be different | 513 // picked up, then the linearly interpolated opacity would be different |
513 // because of the default ease timing function. | 514 // because of the default ease timing function. |
514 EXPECT_FLOAT_EQ(linearly_interpolated_opacity, curve->GetValue(time)); | 515 EXPECT_FLOAT_EQ(linearly_interpolated_opacity, curve->GetValue(time)); |
515 | 516 |
516 EndTest(); | 517 EndTest(); |
517 } | 518 } |
518 | 519 |
519 void AfterTest() override {} | 520 void AfterTest() override {} |
520 | 521 |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 private: | 1193 private: |
1193 scoped_refptr<Layer> content_; | 1194 scoped_refptr<Layer> content_; |
1194 int num_swap_buffers_; | 1195 int num_swap_buffers_; |
1195 }; | 1196 }; |
1196 | 1197 |
1197 SINGLE_AND_MULTI_THREAD_TEST_F( | 1198 SINGLE_AND_MULTI_THREAD_TEST_F( |
1198 LayerTreeHostAnimationTestAddAnimationAfterAnimating); | 1199 LayerTreeHostAnimationTestAddAnimationAfterAnimating); |
1199 | 1200 |
1200 } // namespace | 1201 } // namespace |
1201 } // namespace cc | 1202 } // namespace cc |
OLD | NEW |