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 23 matching lines...) Expand all Loading... |
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( |
40 duration, end_opacity, scoped_ptr<TimingFunction>())); | 40 duration, end_opacity, scoped_ptr<TimingFunction>())); |
41 | 41 |
42 int id = AnimationIdProvider::NextAnimationId(); | 42 int id = AnimationIdProvider::NextAnimationId(); |
43 | 43 |
44 scoped_ptr<Animation> animation(Animation::Create( | 44 scoped_ptr<Animation> animation( |
45 curve.PassAs<AnimationCurve>(), | 45 Animation::Create(curve.Pass(), |
46 id, | 46 id, |
47 AnimationIdProvider::NextGroupId(), | 47 AnimationIdProvider::NextGroupId(), |
48 Animation::Opacity)); | 48 Animation::Opacity)); |
49 animation->set_needs_synchronized_start_time(true); | 49 animation->set_needs_synchronized_start_time(true); |
50 | 50 |
51 target->AddAnimation(animation.Pass()); | 51 target->AddAnimation(animation.Pass()); |
52 return id; | 52 return id; |
53 } | 53 } |
54 | 54 |
55 template <class Target> | 55 template <class Target> |
56 int AddAnimatedTransform(Target* target, | 56 int AddAnimatedTransform(Target* target, |
57 double duration, | 57 double duration, |
58 TransformOperations start_operations, | 58 TransformOperations start_operations, |
59 TransformOperations operations) { | 59 TransformOperations operations) { |
60 scoped_ptr<KeyframedTransformAnimationCurve> | 60 scoped_ptr<KeyframedTransformAnimationCurve> |
61 curve(KeyframedTransformAnimationCurve::Create()); | 61 curve(KeyframedTransformAnimationCurve::Create()); |
62 | 62 |
63 if (duration > 0.0) { | 63 if (duration > 0.0) { |
64 curve->AddKeyframe(TransformKeyframe::Create( | 64 curve->AddKeyframe(TransformKeyframe::Create( |
65 0.0, start_operations, scoped_ptr<TimingFunction>())); | 65 0.0, start_operations, scoped_ptr<TimingFunction>())); |
66 } | 66 } |
67 | 67 |
68 curve->AddKeyframe(TransformKeyframe::Create( | 68 curve->AddKeyframe(TransformKeyframe::Create( |
69 duration, operations, scoped_ptr<TimingFunction>())); | 69 duration, operations, scoped_ptr<TimingFunction>())); |
70 | 70 |
71 int id = AnimationIdProvider::NextAnimationId(); | 71 int id = AnimationIdProvider::NextAnimationId(); |
72 | 72 |
73 scoped_ptr<Animation> animation(Animation::Create( | 73 scoped_ptr<Animation> animation( |
74 curve.PassAs<AnimationCurve>(), | 74 Animation::Create(curve.Pass(), |
75 id, | 75 id, |
76 AnimationIdProvider::NextGroupId(), | 76 AnimationIdProvider::NextGroupId(), |
77 Animation::Transform)); | 77 Animation::Transform)); |
78 animation->set_needs_synchronized_start_time(true); | 78 animation->set_needs_synchronized_start_time(true); |
79 | 79 |
80 target->AddAnimation(animation.Pass()); | 80 target->AddAnimation(animation.Pass()); |
81 return id; | 81 return id; |
82 } | 82 } |
83 | 83 |
84 template <class Target> | 84 template <class Target> |
85 int AddAnimatedTransform(Target* target, | 85 int AddAnimatedTransform(Target* target, |
86 double duration, | 86 double duration, |
87 int delta_x, | 87 int delta_x, |
(...skipping 25 matching lines...) Expand all Loading... |
113 } | 113 } |
114 | 114 |
115 FilterOperations filters; | 115 FilterOperations filters; |
116 filters.Append(FilterOperation::CreateBrightnessFilter(end_brightness)); | 116 filters.Append(FilterOperation::CreateBrightnessFilter(end_brightness)); |
117 curve->AddKeyframe( | 117 curve->AddKeyframe( |
118 FilterKeyframe::Create(duration, filters, scoped_ptr<TimingFunction>())); | 118 FilterKeyframe::Create(duration, filters, scoped_ptr<TimingFunction>())); |
119 | 119 |
120 int id = AnimationIdProvider::NextAnimationId(); | 120 int id = AnimationIdProvider::NextAnimationId(); |
121 | 121 |
122 scoped_ptr<Animation> animation(Animation::Create( | 122 scoped_ptr<Animation> animation(Animation::Create( |
123 curve.PassAs<AnimationCurve>(), | 123 curve.Pass(), id, AnimationIdProvider::NextGroupId(), Animation::Filter)); |
124 id, | |
125 AnimationIdProvider::NextGroupId(), | |
126 Animation::Filter)); | |
127 animation->set_needs_synchronized_start_time(true); | 124 animation->set_needs_synchronized_start_time(true); |
128 | 125 |
129 target->AddAnimation(animation.Pass()); | 126 target->AddAnimation(animation.Pass()); |
130 return id; | 127 return id; |
131 } | 128 } |
132 | 129 |
133 FakeFloatAnimationCurve::FakeFloatAnimationCurve() | 130 FakeFloatAnimationCurve::FakeFloatAnimationCurve() |
134 : duration_(1.0) {} | 131 : duration_(1.0) {} |
135 | 132 |
136 FakeFloatAnimationCurve::FakeFloatAnimationCurve(double duration) | 133 FakeFloatAnimationCurve::FakeFloatAnimationCurve(double duration) |
137 : duration_(duration) {} | 134 : duration_(duration) {} |
138 | 135 |
139 FakeFloatAnimationCurve::~FakeFloatAnimationCurve() {} | 136 FakeFloatAnimationCurve::~FakeFloatAnimationCurve() {} |
140 | 137 |
141 double FakeFloatAnimationCurve::Duration() const { | 138 double FakeFloatAnimationCurve::Duration() const { |
142 return duration_; | 139 return duration_; |
143 } | 140 } |
144 | 141 |
145 float FakeFloatAnimationCurve::GetValue(double now) const { | 142 float FakeFloatAnimationCurve::GetValue(double now) const { |
146 return 0.0f; | 143 return 0.0f; |
147 } | 144 } |
148 | 145 |
149 scoped_ptr<AnimationCurve> FakeFloatAnimationCurve::Clone() const { | 146 scoped_ptr<AnimationCurve> FakeFloatAnimationCurve::Clone() const { |
150 return make_scoped_ptr(new FakeFloatAnimationCurve).PassAs<AnimationCurve>(); | 147 return make_scoped_ptr(new FakeFloatAnimationCurve); |
151 } | 148 } |
152 | 149 |
153 FakeTransformTransition::FakeTransformTransition(double duration) | 150 FakeTransformTransition::FakeTransformTransition(double duration) |
154 : duration_(duration) {} | 151 : duration_(duration) {} |
155 | 152 |
156 FakeTransformTransition::~FakeTransformTransition() {} | 153 FakeTransformTransition::~FakeTransformTransition() {} |
157 | 154 |
158 double FakeTransformTransition::Duration() const { | 155 double FakeTransformTransition::Duration() const { |
159 return duration_; | 156 return duration_; |
160 } | 157 } |
(...skipping 10 matching lines...) Expand all Loading... |
171 bool FakeTransformTransition::AffectsScale() const { return false; } | 168 bool FakeTransformTransition::AffectsScale() const { return false; } |
172 | 169 |
173 bool FakeTransformTransition::IsTranslation() const { return true; } | 170 bool FakeTransformTransition::IsTranslation() const { return true; } |
174 | 171 |
175 bool FakeTransformTransition::MaximumScale(float* max_scale) const { | 172 bool FakeTransformTransition::MaximumScale(float* max_scale) const { |
176 *max_scale = 1.f; | 173 *max_scale = 1.f; |
177 return true; | 174 return true; |
178 } | 175 } |
179 | 176 |
180 scoped_ptr<AnimationCurve> FakeTransformTransition::Clone() const { | 177 scoped_ptr<AnimationCurve> FakeTransformTransition::Clone() const { |
181 return make_scoped_ptr(new FakeTransformTransition(*this)) | 178 return make_scoped_ptr(new FakeTransformTransition(*this)); |
182 .PassAs<AnimationCurve>(); | |
183 } | 179 } |
184 | 180 |
185 | 181 |
186 FakeFloatTransition::FakeFloatTransition(double duration, float from, float to) | 182 FakeFloatTransition::FakeFloatTransition(double duration, float from, float to) |
187 : duration_(duration), from_(from), to_(to) {} | 183 : duration_(duration), from_(from), to_(to) {} |
188 | 184 |
189 FakeFloatTransition::~FakeFloatTransition() {} | 185 FakeFloatTransition::~FakeFloatTransition() {} |
190 | 186 |
191 double FakeFloatTransition::Duration() const { | 187 double FakeFloatTransition::Duration() const { |
192 return duration_; | 188 return duration_; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 bool FakeInactiveLayerAnimationValueObserver::IsActive() const { | 231 bool FakeInactiveLayerAnimationValueObserver::IsActive() const { |
236 return false; | 232 return false; |
237 } | 233 } |
238 | 234 |
239 gfx::Vector2dF FakeLayerAnimationValueProvider::ScrollOffsetForAnimation() | 235 gfx::Vector2dF FakeLayerAnimationValueProvider::ScrollOffsetForAnimation() |
240 const { | 236 const { |
241 return scroll_offset_; | 237 return scroll_offset_; |
242 } | 238 } |
243 | 239 |
244 scoped_ptr<AnimationCurve> FakeFloatTransition::Clone() const { | 240 scoped_ptr<AnimationCurve> FakeFloatTransition::Clone() const { |
245 return make_scoped_ptr(new FakeFloatTransition(*this)) | 241 return make_scoped_ptr(new FakeFloatTransition(*this)); |
246 .PassAs<AnimationCurve>(); | |
247 } | 242 } |
248 | 243 |
249 int AddOpacityTransitionToController(LayerAnimationController* controller, | 244 int AddOpacityTransitionToController(LayerAnimationController* controller, |
250 double duration, | 245 double duration, |
251 float start_opacity, | 246 float start_opacity, |
252 float end_opacity, | 247 float end_opacity, |
253 bool use_timing_function) { | 248 bool use_timing_function) { |
254 return AddOpacityTransition(controller, | 249 return AddOpacityTransition(controller, |
255 duration, | 250 duration, |
256 start_opacity, | 251 start_opacity, |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 double duration, | 340 double duration, |
346 float start_brightness, | 341 float start_brightness, |
347 float end_brightness) { | 342 float end_brightness) { |
348 return AddAnimatedFilter(layer->layer_animation_controller(), | 343 return AddAnimatedFilter(layer->layer_animation_controller(), |
349 duration, | 344 duration, |
350 start_brightness, | 345 start_brightness, |
351 end_brightness); | 346 end_brightness); |
352 } | 347 } |
353 | 348 |
354 } // namespace cc | 349 } // namespace cc |
OLD | NEW |