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 "cc/animation/animation_id_provider.h" | 7 #include "cc/animation/animation_id_provider.h" |
8 #include "cc/animation/keyframed_animation_curve.h" | 8 #include "cc/animation/keyframed_animation_curve.h" |
9 #include "cc/animation/layer_animation_controller.h" | 9 #include "cc/animation/layer_animation_controller.h" |
10 #include "cc/animation/transform_operations.h" | 10 #include "cc/animation/transform_operations.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 float end_opacity, | 29 float end_opacity, |
30 bool use_timing_function) { | 30 bool use_timing_function) { |
31 scoped_ptr<KeyframedFloatAnimationCurve> | 31 scoped_ptr<KeyframedFloatAnimationCurve> |
32 curve(KeyframedFloatAnimationCurve::Create()); | 32 curve(KeyframedFloatAnimationCurve::Create()); |
33 | 33 |
34 scoped_ptr<TimingFunction> func; | 34 scoped_ptr<TimingFunction> func; |
35 if (!use_timing_function) | 35 if (!use_timing_function) |
36 func = EaseTimingFunction::Create(); | 36 func = EaseTimingFunction::Create(); |
37 if (duration > 0.0) | 37 if (duration > 0.0) |
38 curve->AddKeyframe(FloatKeyframe::Create(0.0, start_opacity, func.Pass())); | 38 curve->AddKeyframe(FloatKeyframe::Create(0.0, start_opacity, func.Pass())); |
39 curve->AddKeyframe(FloatKeyframe::Create( | 39 curve->AddKeyframe(FloatKeyframe::Create(duration, end_opacity, nullptr)); |
40 duration, end_opacity, scoped_ptr<TimingFunction>())); | |
41 | 40 |
42 int id = AnimationIdProvider::NextAnimationId(); | 41 int id = AnimationIdProvider::NextAnimationId(); |
43 | 42 |
44 scoped_ptr<Animation> animation( | 43 scoped_ptr<Animation> animation( |
45 Animation::Create(curve.Pass(), | 44 Animation::Create(curve.Pass(), |
46 id, | 45 id, |
47 AnimationIdProvider::NextGroupId(), | 46 AnimationIdProvider::NextGroupId(), |
48 Animation::Opacity)); | 47 Animation::Opacity)); |
49 animation->set_needs_synchronized_start_time(true); | 48 animation->set_needs_synchronized_start_time(true); |
50 | 49 |
51 target->AddAnimation(animation.Pass()); | 50 target->AddAnimation(animation.Pass()); |
52 return id; | 51 return id; |
53 } | 52 } |
54 | 53 |
55 template <class Target> | 54 template <class Target> |
56 int AddAnimatedTransform(Target* target, | 55 int AddAnimatedTransform(Target* target, |
57 double duration, | 56 double duration, |
58 TransformOperations start_operations, | 57 TransformOperations start_operations, |
59 TransformOperations operations) { | 58 TransformOperations operations) { |
60 scoped_ptr<KeyframedTransformAnimationCurve> | 59 scoped_ptr<KeyframedTransformAnimationCurve> |
61 curve(KeyframedTransformAnimationCurve::Create()); | 60 curve(KeyframedTransformAnimationCurve::Create()); |
62 | 61 |
63 if (duration > 0.0) { | 62 if (duration > 0.0) { |
64 curve->AddKeyframe(TransformKeyframe::Create( | 63 curve->AddKeyframe( |
65 0.0, start_operations, scoped_ptr<TimingFunction>())); | 64 TransformKeyframe::Create(0.0, start_operations, nullptr)); |
66 } | 65 } |
67 | 66 |
68 curve->AddKeyframe(TransformKeyframe::Create( | 67 curve->AddKeyframe(TransformKeyframe::Create(duration, operations, nullptr)); |
69 duration, operations, scoped_ptr<TimingFunction>())); | |
70 | 68 |
71 int id = AnimationIdProvider::NextAnimationId(); | 69 int id = AnimationIdProvider::NextAnimationId(); |
72 | 70 |
73 scoped_ptr<Animation> animation( | 71 scoped_ptr<Animation> animation( |
74 Animation::Create(curve.Pass(), | 72 Animation::Create(curve.Pass(), |
75 id, | 73 id, |
76 AnimationIdProvider::NextGroupId(), | 74 AnimationIdProvider::NextGroupId(), |
77 Animation::Transform)); | 75 Animation::Transform)); |
78 animation->set_needs_synchronized_start_time(true); | 76 animation->set_needs_synchronized_start_time(true); |
79 | 77 |
(...skipping 21 matching lines...) Expand all Loading... |
101 double duration, | 99 double duration, |
102 float start_brightness, | 100 float start_brightness, |
103 float end_brightness) { | 101 float end_brightness) { |
104 scoped_ptr<KeyframedFilterAnimationCurve> | 102 scoped_ptr<KeyframedFilterAnimationCurve> |
105 curve(KeyframedFilterAnimationCurve::Create()); | 103 curve(KeyframedFilterAnimationCurve::Create()); |
106 | 104 |
107 if (duration > 0.0) { | 105 if (duration > 0.0) { |
108 FilterOperations start_filters; | 106 FilterOperations start_filters; |
109 start_filters.Append( | 107 start_filters.Append( |
110 FilterOperation::CreateBrightnessFilter(start_brightness)); | 108 FilterOperation::CreateBrightnessFilter(start_brightness)); |
111 curve->AddKeyframe(FilterKeyframe::Create( | 109 curve->AddKeyframe(FilterKeyframe::Create(0.0, start_filters, nullptr)); |
112 0.0, start_filters, scoped_ptr<TimingFunction>())); | |
113 } | 110 } |
114 | 111 |
115 FilterOperations filters; | 112 FilterOperations filters; |
116 filters.Append(FilterOperation::CreateBrightnessFilter(end_brightness)); | 113 filters.Append(FilterOperation::CreateBrightnessFilter(end_brightness)); |
117 curve->AddKeyframe( | 114 curve->AddKeyframe(FilterKeyframe::Create(duration, filters, nullptr)); |
118 FilterKeyframe::Create(duration, filters, scoped_ptr<TimingFunction>())); | |
119 | 115 |
120 int id = AnimationIdProvider::NextAnimationId(); | 116 int id = AnimationIdProvider::NextAnimationId(); |
121 | 117 |
122 scoped_ptr<Animation> animation(Animation::Create( | 118 scoped_ptr<Animation> animation(Animation::Create( |
123 curve.Pass(), id, AnimationIdProvider::NextGroupId(), Animation::Filter)); | 119 curve.Pass(), id, AnimationIdProvider::NextGroupId(), Animation::Filter)); |
124 animation->set_needs_synchronized_start_time(true); | 120 animation->set_needs_synchronized_start_time(true); |
125 | 121 |
126 target->AddAnimation(animation.Pass()); | 122 target->AddAnimation(animation.Pass()); |
127 return id; | 123 return id; |
128 } | 124 } |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 double duration, | 337 double duration, |
342 float start_brightness, | 338 float start_brightness, |
343 float end_brightness) { | 339 float end_brightness) { |
344 return AddAnimatedFilter(layer->layer_animation_controller(), | 340 return AddAnimatedFilter(layer->layer_animation_controller(), |
345 duration, | 341 duration, |
346 start_brightness, | 342 start_brightness, |
347 end_brightness); | 343 end_brightness); |
348 } | 344 } |
349 | 345 |
350 } // namespace cc | 346 } // namespace cc |
OLD | NEW |