OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "platform/animation/CompositorTransformAnimationCurve.h" |
| 6 |
| 7 #include "cc/animation/keyframed_animation_curve.h" |
| 8 #include "cc/animation/timing_function.h" |
| 9 #include "cc/animation/transform_operations.h" |
| 10 #include "platform/animation/CompositorTransformOperations.h" |
| 11 |
| 12 using blink::CompositorTransformKeyframe; |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 CompositorTransformAnimationCurve::CompositorTransformAnimationCurve() |
| 17 : m_curve(cc::KeyframedTransformAnimationCurve::Create()) |
| 18 { |
| 19 } |
| 20 |
| 21 CompositorTransformAnimationCurve::~CompositorTransformAnimationCurve() |
| 22 { |
| 23 } |
| 24 |
| 25 CompositorAnimationCurve::AnimationCurveType CompositorTransformAnimationCurve::
type() const |
| 26 { |
| 27 return CompositorAnimationCurve::AnimationCurveTypeTransform; |
| 28 } |
| 29 |
| 30 void CompositorTransformAnimationCurve::add(const CompositorTransformKeyframe& k
eyframe) |
| 31 { |
| 32 add(keyframe, TimingFunctionTypeEase); |
| 33 } |
| 34 |
| 35 void CompositorTransformAnimationCurve::add(const CompositorTransformKeyframe& k
eyframe, TimingFunctionType type) |
| 36 { |
| 37 const cc::TransformOperations& transformOperations = keyframe.value().asTran
sformOperations(); |
| 38 m_curve->AddKeyframe(cc::TransformKeyframe::Create( |
| 39 base::TimeDelta::FromSecondsD(keyframe.time()), transformOperations, |
| 40 createTimingFunction(type))); |
| 41 } |
| 42 |
| 43 void CompositorTransformAnimationCurve::add(const CompositorTransformKeyframe& k
eyframe, double x1, double y1, double x2, double y2) |
| 44 { |
| 45 const cc::TransformOperations& transformOperations = keyframe.value().asTran
sformOperations(); |
| 46 m_curve->AddKeyframe(cc::TransformKeyframe::Create( |
| 47 base::TimeDelta::FromSecondsD(keyframe.time()), transformOperations, |
| 48 cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2))); |
| 49 } |
| 50 |
| 51 void CompositorTransformAnimationCurve::add(const CompositorTransformKeyframe& k
eyframe, int steps, float stepsStartOffset) |
| 52 { |
| 53 const cc::TransformOperations& transformOperations = keyframe.value().asTran
sformOperations(); |
| 54 m_curve->AddKeyframe(cc::TransformKeyframe::Create( |
| 55 base::TimeDelta::FromSecondsD(keyframe.time()), transformOperations, |
| 56 cc::StepsTimingFunction::Create(steps, stepsStartOffset))); |
| 57 } |
| 58 |
| 59 void CompositorTransformAnimationCurve::setLinearTimingFunction() |
| 60 { |
| 61 m_curve->SetTimingFunction(nullptr); |
| 62 } |
| 63 |
| 64 void CompositorTransformAnimationCurve::setCubicBezierTimingFunction(TimingFunct
ionType type) |
| 65 { |
| 66 m_curve->SetTimingFunction(createTimingFunction(type)); |
| 67 } |
| 68 |
| 69 void CompositorTransformAnimationCurve::setCubicBezierTimingFunction(double x1,
double y1, double x2, double y2) |
| 70 { |
| 71 m_curve->SetTimingFunction( |
| 72 cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2)); |
| 73 } |
| 74 |
| 75 void CompositorTransformAnimationCurve::setStepsTimingFunction(int numberOfSteps
, float stepsStartOffset) |
| 76 { |
| 77 m_curve->SetTimingFunction(cc::StepsTimingFunction::Create(numberOfSteps, st
epsStartOffset)); |
| 78 } |
| 79 |
| 80 scoped_ptr<cc::AnimationCurve> CompositorTransformAnimationCurve::cloneToAnimati
onCurve() const |
| 81 { |
| 82 return m_curve->Clone(); |
| 83 } |
| 84 |
| 85 } // namespace blink |
OLD | NEW |