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