OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "webkit/compositor_bindings/web_float_animation_curve_impl.h" | 5 #include "webkit/compositor_bindings/web_float_animation_curve_impl.h" |
6 | 6 |
7 #include "cc/animation/animation_curve.h" | 7 #include "cc/animation/animation_curve.h" |
8 #include "cc/animation/keyframed_animation_curve.h" | 8 #include "cc/animation/keyframed_animation_curve.h" |
9 #include "cc/animation/timing_function.h" | 9 #include "cc/animation/timing_function.h" |
10 #include "webkit/compositor_bindings/web_animation_curve_common.h" | 10 #include "webkit/compositor_bindings/web_animation_curve_common.h" |
11 | 11 |
12 namespace WebKit { | 12 using WebKit::WebFloatKeyframe; |
| 13 |
| 14 namespace webkit { |
13 | 15 |
14 WebFloatAnimationCurveImpl::WebFloatAnimationCurveImpl() | 16 WebFloatAnimationCurveImpl::WebFloatAnimationCurveImpl() |
15 : curve_(cc::KeyframedFloatAnimationCurve::Create()) {} | 17 : curve_(cc::KeyframedFloatAnimationCurve::Create()) {} |
16 | 18 |
17 WebFloatAnimationCurveImpl::~WebFloatAnimationCurveImpl() {} | 19 WebFloatAnimationCurveImpl::~WebFloatAnimationCurveImpl() {} |
18 | 20 |
19 WebAnimationCurve::AnimationCurveType WebFloatAnimationCurveImpl::type() const { | 21 WebKit::WebAnimationCurve::AnimationCurveType |
20 return WebAnimationCurve::AnimationCurveTypeFloat; | 22 WebFloatAnimationCurveImpl::type() const { |
| 23 return WebKit::WebAnimationCurve::AnimationCurveTypeFloat; |
21 } | 24 } |
22 | 25 |
23 void WebFloatAnimationCurveImpl::add(const WebFloatKeyframe& keyframe) { | 26 void WebFloatAnimationCurveImpl::add(const WebFloatKeyframe& keyframe) { |
24 add(keyframe, TimingFunctionTypeEase); | 27 add(keyframe, TimingFunctionTypeEase); |
25 } | 28 } |
26 | 29 |
27 void WebFloatAnimationCurveImpl::add(const WebFloatKeyframe& keyframe, | 30 void WebFloatAnimationCurveImpl::add(const WebFloatKeyframe& keyframe, |
28 TimingFunctionType type) { | 31 TimingFunctionType type) { |
29 curve_->AddKeyframe(cc::FloatKeyframe::Create( | 32 curve_->AddKeyframe(cc::FloatKeyframe::Create( |
30 keyframe.time, keyframe.value, createTimingFunction(type))); | 33 keyframe.time, keyframe.value, CreateTimingFunction(type))); |
31 } | 34 } |
32 | 35 |
33 void WebFloatAnimationCurveImpl::add(const WebFloatKeyframe& keyframe, | 36 void WebFloatAnimationCurveImpl::add(const WebFloatKeyframe& keyframe, |
34 double x1, | 37 double x1, |
35 double y1, | 38 double y1, |
36 double x2, | 39 double x2, |
37 double y2) { | 40 double y2) { |
38 curve_->AddKeyframe(cc::FloatKeyframe::Create( | 41 curve_->AddKeyframe(cc::FloatKeyframe::Create( |
39 keyframe.time, | 42 keyframe.time, |
40 keyframe.value, | 43 keyframe.value, |
41 cc::CubicBezierTimingFunction::create(x1, y1, x2, y2) | 44 cc::CubicBezierTimingFunction::create(x1, y1, x2, y2) |
42 .PassAs<cc::TimingFunction>())); | 45 .PassAs<cc::TimingFunction>())); |
43 } | 46 } |
44 | 47 |
45 float WebFloatAnimationCurveImpl::getValue(double time) const { | 48 float WebFloatAnimationCurveImpl::getValue(double time) const { |
46 return curve_->GetValue(time); | 49 return curve_->GetValue(time); |
47 } | 50 } |
48 | 51 |
49 scoped_ptr<cc::AnimationCurve> | 52 scoped_ptr<cc::AnimationCurve> |
50 WebFloatAnimationCurveImpl::cloneToAnimationCurve() const { | 53 WebFloatAnimationCurveImpl::CloneToAnimationCurve() const { |
51 return curve_->Clone(); | 54 return curve_->Clone(); |
52 } | 55 } |
53 | 56 |
54 } // namespace WebKit | 57 } // namespace webkit |
OLD | NEW |