| 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( | 44 scoped_ptr<Animation> animation(Animation::Create( |
| 45 Animation::Create(curve.Pass(), | 45 curve.PassAs<AnimationCurve>(), |
| 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( | 73 scoped_ptr<Animation> animation(Animation::Create( |
| 74 Animation::Create(curve.Pass(), | 74 curve.PassAs<AnimationCurve>(), |
| 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.Pass(), id, AnimationIdProvider::NextGroupId(), Animation::Filter)); | 123 curve.PassAs<AnimationCurve>(), |
| 124 id, |
| 125 AnimationIdProvider::NextGroupId(), |
| 126 Animation::Filter)); |
| 124 animation->set_needs_synchronized_start_time(true); | 127 animation->set_needs_synchronized_start_time(true); |
| 125 | 128 |
| 126 target->AddAnimation(animation.Pass()); | 129 target->AddAnimation(animation.Pass()); |
| 127 return id; | 130 return id; |
| 128 } | 131 } |
| 129 | 132 |
| 130 FakeFloatAnimationCurve::FakeFloatAnimationCurve() | 133 FakeFloatAnimationCurve::FakeFloatAnimationCurve() |
| 131 : duration_(1.0) {} | 134 : duration_(1.0) {} |
| 132 | 135 |
| 133 FakeFloatAnimationCurve::FakeFloatAnimationCurve(double duration) | 136 FakeFloatAnimationCurve::FakeFloatAnimationCurve(double duration) |
| 134 : duration_(duration) {} | 137 : duration_(duration) {} |
| 135 | 138 |
| 136 FakeFloatAnimationCurve::~FakeFloatAnimationCurve() {} | 139 FakeFloatAnimationCurve::~FakeFloatAnimationCurve() {} |
| 137 | 140 |
| 138 double FakeFloatAnimationCurve::Duration() const { | 141 double FakeFloatAnimationCurve::Duration() const { |
| 139 return duration_; | 142 return duration_; |
| 140 } | 143 } |
| 141 | 144 |
| 142 float FakeFloatAnimationCurve::GetValue(double now) const { | 145 float FakeFloatAnimationCurve::GetValue(double now) const { |
| 143 return 0.0f; | 146 return 0.0f; |
| 144 } | 147 } |
| 145 | 148 |
| 146 scoped_ptr<AnimationCurve> FakeFloatAnimationCurve::Clone() const { | 149 scoped_ptr<AnimationCurve> FakeFloatAnimationCurve::Clone() const { |
| 147 return make_scoped_ptr(new FakeFloatAnimationCurve); | 150 return make_scoped_ptr(new FakeFloatAnimationCurve).PassAs<AnimationCurve>(); |
| 148 } | 151 } |
| 149 | 152 |
| 150 FakeTransformTransition::FakeTransformTransition(double duration) | 153 FakeTransformTransition::FakeTransformTransition(double duration) |
| 151 : duration_(duration) {} | 154 : duration_(duration) {} |
| 152 | 155 |
| 153 FakeTransformTransition::~FakeTransformTransition() {} | 156 FakeTransformTransition::~FakeTransformTransition() {} |
| 154 | 157 |
| 155 double FakeTransformTransition::Duration() const { | 158 double FakeTransformTransition::Duration() const { |
| 156 return duration_; | 159 return duration_; |
| 157 } | 160 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 168 bool FakeTransformTransition::AffectsScale() const { return false; } | 171 bool FakeTransformTransition::AffectsScale() const { return false; } |
| 169 | 172 |
| 170 bool FakeTransformTransition::IsTranslation() const { return true; } | 173 bool FakeTransformTransition::IsTranslation() const { return true; } |
| 171 | 174 |
| 172 bool FakeTransformTransition::MaximumScale(float* max_scale) const { | 175 bool FakeTransformTransition::MaximumScale(float* max_scale) const { |
| 173 *max_scale = 1.f; | 176 *max_scale = 1.f; |
| 174 return true; | 177 return true; |
| 175 } | 178 } |
| 176 | 179 |
| 177 scoped_ptr<AnimationCurve> FakeTransformTransition::Clone() const { | 180 scoped_ptr<AnimationCurve> FakeTransformTransition::Clone() const { |
| 178 return make_scoped_ptr(new FakeTransformTransition(*this)); | 181 return make_scoped_ptr(new FakeTransformTransition(*this)) |
| 182 .PassAs<AnimationCurve>(); |
| 179 } | 183 } |
| 180 | 184 |
| 181 | 185 |
| 182 FakeFloatTransition::FakeFloatTransition(double duration, float from, float to) | 186 FakeFloatTransition::FakeFloatTransition(double duration, float from, float to) |
| 183 : duration_(duration), from_(from), to_(to) {} | 187 : duration_(duration), from_(from), to_(to) {} |
| 184 | 188 |
| 185 FakeFloatTransition::~FakeFloatTransition() {} | 189 FakeFloatTransition::~FakeFloatTransition() {} |
| 186 | 190 |
| 187 double FakeFloatTransition::Duration() const { | 191 double FakeFloatTransition::Duration() const { |
| 188 return duration_; | 192 return duration_; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 bool FakeInactiveLayerAnimationValueObserver::IsActive() const { | 235 bool FakeInactiveLayerAnimationValueObserver::IsActive() const { |
| 232 return false; | 236 return false; |
| 233 } | 237 } |
| 234 | 238 |
| 235 gfx::Vector2dF FakeLayerAnimationValueProvider::ScrollOffsetForAnimation() | 239 gfx::Vector2dF FakeLayerAnimationValueProvider::ScrollOffsetForAnimation() |
| 236 const { | 240 const { |
| 237 return scroll_offset_; | 241 return scroll_offset_; |
| 238 } | 242 } |
| 239 | 243 |
| 240 scoped_ptr<AnimationCurve> FakeFloatTransition::Clone() const { | 244 scoped_ptr<AnimationCurve> FakeFloatTransition::Clone() const { |
| 241 return make_scoped_ptr(new FakeFloatTransition(*this)); | 245 return make_scoped_ptr(new FakeFloatTransition(*this)) |
| 246 .PassAs<AnimationCurve>(); |
| 242 } | 247 } |
| 243 | 248 |
| 244 int AddOpacityTransitionToController(LayerAnimationController* controller, | 249 int AddOpacityTransitionToController(LayerAnimationController* controller, |
| 245 double duration, | 250 double duration, |
| 246 float start_opacity, | 251 float start_opacity, |
| 247 float end_opacity, | 252 float end_opacity, |
| 248 bool use_timing_function) { | 253 bool use_timing_function) { |
| 249 return AddOpacityTransition(controller, | 254 return AddOpacityTransition(controller, |
| 250 duration, | 255 duration, |
| 251 start_opacity, | 256 start_opacity, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 double duration, | 345 double duration, |
| 341 float start_brightness, | 346 float start_brightness, |
| 342 float end_brightness) { | 347 float end_brightness) { |
| 343 return AddAnimatedFilter(layer->layer_animation_controller(), | 348 return AddAnimatedFilter(layer->layer_animation_controller(), |
| 344 duration, | 349 duration, |
| 345 start_brightness, | 350 start_brightness, |
| 346 end_brightness); | 351 end_brightness); |
| 347 } | 352 } |
| 348 | 353 |
| 349 } // namespace cc | 354 } // namespace cc |
| OLD | NEW |