| 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/scroll_offset_animation_curve.h" |
| 13 #include "cc/animation/timing_function.h" | 14 #include "cc/animation/timing_function.h" |
| 14 #include "cc/animation/transform_operations.h" | 15 #include "cc/animation/transform_operations.h" |
| 15 #include "cc/base/time_util.h" | 16 #include "cc/base/time_util.h" |
| 16 #include "cc/layers/layer.h" | 17 #include "cc/layers/layer.h" |
| 17 #include "cc/layers/layer_impl.h" | 18 #include "cc/layers/layer_impl.h" |
| 18 | 19 |
| 19 using cc::Animation; | 20 using cc::Animation; |
| 20 using cc::AnimationCurve; | 21 using cc::AnimationCurve; |
| 21 using cc::FloatKeyframe; | 22 using cc::FloatKeyframe; |
| 22 using cc::KeyframedFloatAnimationCurve; | 23 using cc::KeyframedFloatAnimationCurve; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 double progress = TimeUtil::Divide(time, duration_); | 210 double progress = TimeUtil::Divide(time, duration_); |
| 210 if (progress >= 1.0) | 211 if (progress >= 1.0) |
| 211 progress = 1.0; | 212 progress = 1.0; |
| 212 return (1.0 - progress) * from_ + progress * to_; | 213 return (1.0 - progress) * from_ + progress * to_; |
| 213 } | 214 } |
| 214 | 215 |
| 215 std::unique_ptr<AnimationCurve> FakeFloatTransition::Clone() const { | 216 std::unique_ptr<AnimationCurve> FakeFloatTransition::Clone() const { |
| 216 return base::WrapUnique(new FakeFloatTransition(*this)); | 217 return base::WrapUnique(new FakeFloatTransition(*this)); |
| 217 } | 218 } |
| 218 | 219 |
| 220 int AddScrollOffsetAnimationToElementAnimations(ElementAnimations* target, |
| 221 gfx::ScrollOffset initial_value, |
| 222 gfx::ScrollOffset target_value, |
| 223 bool impl_only) { |
| 224 std::unique_ptr<ScrollOffsetAnimationCurve> curve( |
| 225 ScrollOffsetAnimationCurve::Create( |
| 226 target_value, CubicBezierTimingFunction::CreatePreset( |
| 227 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); |
| 228 curve->SetInitialValue(initial_value); |
| 229 |
| 230 int id = AnimationIdProvider::NextAnimationId(); |
| 231 |
| 232 std::unique_ptr<Animation> animation(Animation::Create( |
| 233 std::move(curve), id, AnimationIdProvider::NextGroupId(), |
| 234 TargetProperty::SCROLL_OFFSET)); |
| 235 animation->set_is_impl_only(impl_only); |
| 236 |
| 237 target->AddAnimation(std::move(animation)); |
| 238 |
| 239 return id; |
| 240 } |
| 241 |
| 219 int AddOpacityTransitionToElementAnimations(ElementAnimations* target, | 242 int AddOpacityTransitionToElementAnimations(ElementAnimations* target, |
| 220 double duration, | 243 double duration, |
| 221 float start_opacity, | 244 float start_opacity, |
| 222 float end_opacity, | 245 float end_opacity, |
| 223 bool use_timing_function) { | 246 bool use_timing_function) { |
| 224 return AddOpacityTransition(target, duration, start_opacity, end_opacity, | 247 return AddOpacityTransition(target, duration, start_opacity, end_opacity, |
| 225 use_timing_function); | 248 use_timing_function); |
| 226 } | 249 } |
| 227 | 250 |
| 228 int AddAnimatedTransformToElementAnimations(ElementAnimations* target, | 251 int AddAnimatedTransformToElementAnimations(ElementAnimations* target, |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 ElementId element_id, | 424 ElementId element_id, |
| 402 scoped_refptr<AnimationTimeline> timeline, | 425 scoped_refptr<AnimationTimeline> timeline, |
| 403 TargetProperty::Type target_property) { | 426 TargetProperty::Type target_property) { |
| 404 scoped_refptr<ElementAnimations> element_animations = | 427 scoped_refptr<ElementAnimations> element_animations = |
| 405 timeline->animation_host()->GetElementAnimationsForElementId(element_id); | 428 timeline->animation_host()->GetElementAnimationsForElementId(element_id); |
| 406 DCHECK(element_animations); | 429 DCHECK(element_animations); |
| 407 element_animations->AbortAnimations(target_property); | 430 element_animations->AbortAnimations(target_property); |
| 408 } | 431 } |
| 409 | 432 |
| 410 } // namespace cc | 433 } // namespace cc |
| OLD | NEW |