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/WebFloatAnimationCurve.h" |
| 6 |
| 7 #include "cc/animation/animation_curve.h" |
| 8 #include "cc/animation/keyframed_animation_curve.h" |
| 9 #include "cc/animation/timing_function.h" |
| 10 |
| 11 using blink::WebFloatKeyframe; |
| 12 |
| 13 namespace blink { |
| 14 |
| 15 WebFloatAnimationCurve::WebFloatAnimationCurve() |
| 16 : m_curve(cc::KeyframedFloatAnimationCurve::Create()) |
| 17 { |
| 18 } |
| 19 |
| 20 WebFloatAnimationCurve::~WebFloatAnimationCurve() |
| 21 { |
| 22 } |
| 23 |
| 24 WebCompositorAnimationCurve::AnimationCurveType |
| 25 WebFloatAnimationCurve::type() const |
| 26 { |
| 27 return WebCompositorAnimationCurve::AnimationCurveTypeFloat; |
| 28 } |
| 29 |
| 30 void WebFloatAnimationCurve::add(const WebFloatKeyframe& keyframe) |
| 31 { |
| 32 add(keyframe, TimingFunctionTypeEase); |
| 33 } |
| 34 |
| 35 void WebFloatAnimationCurve::add(const WebFloatKeyframe& keyframe, |
| 36 TimingFunctionType type) |
| 37 { |
| 38 m_curve->AddKeyframe( |
| 39 cc::FloatKeyframe::Create(base::TimeDelta::FromSecondsD(keyframe.time), |
| 40 keyframe.value, CreateTimingFunction(type))); |
| 41 } |
| 42 |
| 43 void WebFloatAnimationCurve::add(const WebFloatKeyframe& keyframe, |
| 44 double x1, |
| 45 double y1, |
| 46 double x2, |
| 47 double y2) |
| 48 { |
| 49 m_curve->AddKeyframe(cc::FloatKeyframe::Create( |
| 50 base::TimeDelta::FromSecondsD(keyframe.time), keyframe.value, |
| 51 cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2))); |
| 52 } |
| 53 |
| 54 void WebFloatAnimationCurve::add(const WebFloatKeyframe& keyframe, |
| 55 int steps, |
| 56 float stepsStartOffset) |
| 57 { |
| 58 m_curve->AddKeyframe(cc::FloatKeyframe::Create( |
| 59 base::TimeDelta::FromSecondsD(keyframe.time), keyframe.value, |
| 60 cc::StepsTimingFunction::Create(steps, stepsStartOffset))); |
| 61 } |
| 62 |
| 63 void WebFloatAnimationCurve::setLinearTimingFunction() |
| 64 { |
| 65 m_curve->SetTimingFunction(nullptr); |
| 66 } |
| 67 |
| 68 void WebFloatAnimationCurve::setCubicBezierTimingFunction( |
| 69 TimingFunctionType type) |
| 70 { |
| 71 m_curve->SetTimingFunction(CreateTimingFunction(type)); |
| 72 } |
| 73 |
| 74 void WebFloatAnimationCurve::setCubicBezierTimingFunction(double x1, |
| 75 double y1, |
| 76 double x2, |
| 77 double y2) |
| 78 { |
| 79 m_curve->SetTimingFunction( |
| 80 cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2)); |
| 81 } |
| 82 |
| 83 void WebFloatAnimationCurve::setStepsTimingFunction( |
| 84 int numberOfSteps, |
| 85 float stepsStartOffset) |
| 86 { |
| 87 m_curve->SetTimingFunction( |
| 88 cc::StepsTimingFunction::Create(numberOfSteps, stepsStartOffset)); |
| 89 } |
| 90 |
| 91 float WebFloatAnimationCurve::getValue(double time) const |
| 92 { |
| 93 return m_curve->GetValue(base::TimeDelta::FromSecondsD(time)); |
| 94 } |
| 95 |
| 96 scoped_ptr<cc::AnimationCurve> |
| 97 WebFloatAnimationCurve::CloneToAnimationCurve() const |
| 98 { |
| 99 return m_curve->Clone(); |
| 100 } |
| 101 |
| 102 } // namespace blink |
OLD | NEW |