| Index: third_party/WebKit/Source/platform/animation/WebTransformAnimationCurve.cpp
|
| diff --git a/third_party/WebKit/Source/platform/animation/WebTransformAnimationCurve.cpp b/third_party/WebKit/Source/platform/animation/WebTransformAnimationCurve.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..3101c18cc842c366a39c06741804087d933eb8a8
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/platform/animation/WebTransformAnimationCurve.cpp
|
| @@ -0,0 +1,97 @@
|
| +// 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/WebTransformAnimationCurve.h"
|
| +
|
| +#include "cc/animation/keyframed_animation_curve.h"
|
| +#include "cc/animation/timing_function.h"
|
| +#include "cc/animation/transform_operations.h"
|
| +#include "platform/animation/WebTransformOperations.h"
|
| +
|
| +using blink::WebTransformKeyframe;
|
| +
|
| +namespace blink {
|
| +
|
| +WebTransformAnimationCurve::WebTransformAnimationCurve()
|
| + : m_curve(cc::KeyframedTransformAnimationCurve::Create())
|
| +{
|
| +}
|
| +
|
| +WebTransformAnimationCurve::~WebTransformAnimationCurve()
|
| +{
|
| +}
|
| +
|
| +WebCompositorAnimationCurve::AnimationCurveType WebTransformAnimationCurve::type() const
|
| +{
|
| + return WebCompositorAnimationCurve::AnimationCurveTypeTransform;
|
| +}
|
| +
|
| +void WebTransformAnimationCurve::add(const WebTransformKeyframe& keyframe)
|
| +{
|
| + add(keyframe, TimingFunctionTypeEase);
|
| +}
|
| +
|
| +void WebTransformAnimationCurve::add(const WebTransformKeyframe& keyframe, TimingFunctionType type)
|
| +{
|
| + const cc::TransformOperations& transformOperations = keyframe.value().AsTransformOperations();
|
| + m_curve->AddKeyframe(cc::TransformKeyframe::Create(
|
| + base::TimeDelta::FromSecondsD(keyframe.time()), transformOperations,
|
| + CreateTimingFunction(type)));
|
| +}
|
| +
|
| +void WebTransformAnimationCurve::add(const WebTransformKeyframe& keyframe,
|
| + double x1,
|
| + double y1,
|
| + double x2,
|
| + double y2)
|
| +{
|
| + const cc::TransformOperations& transformOperations = keyframe.value().AsTransformOperations();
|
| + m_curve->AddKeyframe(cc::TransformKeyframe::Create(
|
| + base::TimeDelta::FromSecondsD(keyframe.time()), transformOperations,
|
| + cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2)));
|
| +}
|
| +
|
| +void WebTransformAnimationCurve::add(const WebTransformKeyframe& keyframe,
|
| + int steps,
|
| + float stepsStartOffset)
|
| +{
|
| + const cc::TransformOperations& transformOperations = keyframe.value().AsTransformOperations();
|
| + m_curve->AddKeyframe(cc::TransformKeyframe::Create(
|
| + base::TimeDelta::FromSecondsD(keyframe.time()), transformOperations,
|
| + cc::StepsTimingFunction::Create(steps, stepsStartOffset)));
|
| +}
|
| +
|
| +void WebTransformAnimationCurve::setLinearTimingFunction()
|
| +{
|
| + m_curve->SetTimingFunction(nullptr);
|
| +}
|
| +
|
| +void WebTransformAnimationCurve::setCubicBezierTimingFunction(TimingFunctionType type)
|
| +{
|
| + m_curve->SetTimingFunction(CreateTimingFunction(type));
|
| +}
|
| +
|
| +void WebTransformAnimationCurve::setCubicBezierTimingFunction(double x1,
|
| + double y1,
|
| + double x2,
|
| + double y2)
|
| +{
|
| + m_curve->SetTimingFunction(
|
| + cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2));
|
| +}
|
| +
|
| +void WebTransformAnimationCurve::setStepsTimingFunction(
|
| + int numberOfSteps,
|
| + float stepsStartOffset)
|
| +{
|
| + m_curve->SetTimingFunction(
|
| + cc::StepsTimingFunction::Create(numberOfSteps, stepsStartOffset));
|
| +}
|
| +
|
| +scoped_ptr<cc::AnimationCurve> WebTransformAnimationCurve::CloneToAnimationCurve() const
|
| +{
|
| + return m_curve->Clone();
|
| +}
|
| +
|
| +} // namespace blink
|
|
|