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/test/animation_test_common.h" | 5 #include "cc/test/animation_test_common.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "cc/animation/animation_host.h" | 8 #include "cc/animation/animation_host.h" |
9 #include "cc/animation/animation_id_provider.h" | 9 #include "cc/animation/animation_id_provider.h" |
10 #include "cc/animation/animation_player.h" | 10 #include "cc/animation/animation_player.h" |
11 #include "cc/animation/element_animations.h" | 11 #include "cc/animation/element_animations.h" |
12 #include "cc/animation/keyframed_animation_curve.h" | 12 #include "cc/animation/keyframed_animation_curve.h" |
| 13 #include "cc/animation/timing_function.h" |
13 #include "cc/animation/transform_operations.h" | 14 #include "cc/animation/transform_operations.h" |
14 #include "cc/base/time_util.h" | 15 #include "cc/base/time_util.h" |
15 #include "cc/layers/layer.h" | 16 #include "cc/layers/layer.h" |
16 #include "cc/layers/layer_impl.h" | 17 #include "cc/layers/layer_impl.h" |
17 | 18 |
18 using cc::Animation; | 19 using cc::Animation; |
19 using cc::AnimationCurve; | 20 using cc::AnimationCurve; |
20 using cc::EaseTimingFunction; | |
21 using cc::FloatKeyframe; | 21 using cc::FloatKeyframe; |
22 using cc::KeyframedFloatAnimationCurve; | 22 using cc::KeyframedFloatAnimationCurve; |
23 using cc::KeyframedTransformAnimationCurve; | 23 using cc::KeyframedTransformAnimationCurve; |
24 using cc::TimingFunction; | 24 using cc::TimingFunction; |
25 using cc::TransformKeyframe; | 25 using cc::TransformKeyframe; |
26 | 26 |
27 namespace cc { | 27 namespace cc { |
28 | 28 |
29 template <class Target> | 29 template <class Target> |
30 int AddOpacityTransition(Target* target, | 30 int AddOpacityTransition(Target* target, |
31 double duration, | 31 double duration, |
32 float start_opacity, | 32 float start_opacity, |
33 float end_opacity, | 33 float end_opacity, |
34 bool use_timing_function) { | 34 bool use_timing_function) { |
35 std::unique_ptr<KeyframedFloatAnimationCurve> curve( | 35 std::unique_ptr<KeyframedFloatAnimationCurve> curve( |
36 KeyframedFloatAnimationCurve::Create()); | 36 KeyframedFloatAnimationCurve::Create()); |
37 | 37 |
38 std::unique_ptr<TimingFunction> func; | 38 std::unique_ptr<TimingFunction> func; |
39 if (!use_timing_function) | 39 if (!use_timing_function) |
40 func = EaseTimingFunction::Create(); | 40 func = CubicBezierTimingFunction::CreatePreset( |
| 41 CubicBezierTimingFunction::EaseType::EASE); |
41 if (duration > 0.0) | 42 if (duration > 0.0) |
42 curve->AddKeyframe(FloatKeyframe::Create(base::TimeDelta(), start_opacity, | 43 curve->AddKeyframe(FloatKeyframe::Create(base::TimeDelta(), start_opacity, |
43 std::move(func))); | 44 std::move(func))); |
44 curve->AddKeyframe(FloatKeyframe::Create( | 45 curve->AddKeyframe(FloatKeyframe::Create( |
45 base::TimeDelta::FromSecondsD(duration), end_opacity, nullptr)); | 46 base::TimeDelta::FromSecondsD(duration), end_opacity, nullptr)); |
46 | 47 |
47 int id = AnimationIdProvider::NextAnimationId(); | 48 int id = AnimationIdProvider::NextAnimationId(); |
48 | 49 |
49 std::unique_ptr<Animation> animation(Animation::Create( | 50 std::unique_ptr<Animation> animation(Animation::Create( |
50 std::move(curve), id, AnimationIdProvider::NextGroupId(), | 51 std::move(curve), id, AnimationIdProvider::NextGroupId(), |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 void AbortAnimationsOnLayerWithPlayer(int layer_id, | 400 void AbortAnimationsOnLayerWithPlayer(int layer_id, |
400 scoped_refptr<AnimationTimeline> timeline, | 401 scoped_refptr<AnimationTimeline> timeline, |
401 TargetProperty::Type target_property) { | 402 TargetProperty::Type target_property) { |
402 scoped_refptr<ElementAnimations> element_animations = | 403 scoped_refptr<ElementAnimations> element_animations = |
403 timeline->animation_host()->GetElementAnimationsForElementId(layer_id); | 404 timeline->animation_host()->GetElementAnimationsForElementId(layer_id); |
404 DCHECK(element_animations); | 405 DCHECK(element_animations); |
405 element_animations->AbortAnimations(target_property); | 406 element_animations->AbortAnimations(target_property); |
406 } | 407 } |
407 | 408 |
408 } // namespace cc | 409 } // namespace cc |
OLD | NEW |