Chromium Code Reviews| Index: third_party/WebKit/Source/platform/animation/WebFloatAnimationCurve.cpp |
| diff --git a/third_party/WebKit/Source/platform/animation/WebFloatAnimationCurve.cpp b/third_party/WebKit/Source/platform/animation/WebFloatAnimationCurve.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..00846fc6d19cdb78a6652f15f61522a23ff79510 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/platform/animation/WebFloatAnimationCurve.cpp |
| @@ -0,0 +1,102 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "platform/animation/WebFloatAnimationCurve.h" |
| + |
| +#include "cc/animation/animation_curve.h" |
| +#include "cc/animation/keyframed_animation_curve.h" |
| +#include "cc/animation/timing_function.h" |
| + |
| +using blink::WebFloatKeyframe; |
| + |
| +namespace blink { |
| + |
| +WebFloatAnimationCurve::WebFloatAnimationCurve() |
| + : m_curve(cc::KeyframedFloatAnimationCurve::Create()) |
| +{ |
| +} |
| + |
| +WebFloatAnimationCurve::~WebFloatAnimationCurve() |
| +{ |
| +} |
| + |
| +WebCompositorAnimationCurve::AnimationCurveType |
| +WebFloatAnimationCurve::type() const |
| +{ |
| + return WebCompositorAnimationCurve::AnimationCurveTypeFloat; |
| +} |
| + |
| +void WebFloatAnimationCurve::add(const WebFloatKeyframe& keyframe) |
| +{ |
| + add(keyframe, TimingFunctionTypeEase); |
| +} |
| + |
| +void WebFloatAnimationCurve::add(const WebFloatKeyframe& keyframe, |
| + TimingFunctionType type) |
| +{ |
| + m_curve->AddKeyframe( |
| + cc::FloatKeyframe::Create(base::TimeDelta::FromSecondsD(keyframe.time), |
| + keyframe.value, CreateTimingFunction(type))); |
| +} |
| + |
| +void WebFloatAnimationCurve::add(const WebFloatKeyframe& keyframe, |
| + double x1, |
| + double y1, |
| + double x2, |
| + double y2) |
| +{ |
| + m_curve->AddKeyframe(cc::FloatKeyframe::Create( |
| + base::TimeDelta::FromSecondsD(keyframe.time), keyframe.value, |
| + cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2))); |
| +} |
| + |
| +void WebFloatAnimationCurve::add(const WebFloatKeyframe& keyframe, |
| + int steps, |
| + float stepsStartOffset) |
| +{ |
| + m_curve->AddKeyframe(cc::FloatKeyframe::Create( |
| + base::TimeDelta::FromSecondsD(keyframe.time), keyframe.value, |
| + cc::StepsTimingFunction::Create(steps, stepsStartOffset))); |
| +} |
| + |
| +void WebFloatAnimationCurve::setLinearTimingFunction() |
| +{ |
| + m_curve->SetTimingFunction(nullptr); |
| +} |
| + |
| +void WebFloatAnimationCurve::setCubicBezierTimingFunction( |
| + TimingFunctionType type) |
| +{ |
| + m_curve->SetTimingFunction(CreateTimingFunction(type)); |
| +} |
| + |
| +void WebFloatAnimationCurve::setCubicBezierTimingFunction(double x1, |
| + double y1, |
| + double x2, |
| + double y2) |
|
esprehn
2016/01/28 03:40:40
I really hate this style, it leaves one arg way fa
loyso (OOO)
2016/01/28 07:10:09
Done.
|
| +{ |
| + m_curve->SetTimingFunction( |
| + cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2)); |
| +} |
| + |
| +void WebFloatAnimationCurve::setStepsTimingFunction( |
| + int numberOfSteps, |
| + float stepsStartOffset) |
| +{ |
| + m_curve->SetTimingFunction( |
| + cc::StepsTimingFunction::Create(numberOfSteps, stepsStartOffset)); |
| +} |
| + |
| +float WebFloatAnimationCurve::getValue(double time) const |
| +{ |
| + return m_curve->GetValue(base::TimeDelta::FromSecondsD(time)); |
| +} |
| + |
| +scoped_ptr<cc::AnimationCurve> |
| +WebFloatAnimationCurve::CloneToAnimationCurve() const |
| +{ |
| + return m_curve->Clone(); |
| +} |
| + |
| +} // namespace blink |