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
3 // found in the LICENSE file.
5 #include "webkit/renderer/compositor_bindings/web_float_animation_curve_impl.h"
7 #include "cc/animation/animation_curve.h"
8 #include "cc/animation/keyframed_animation_curve.h"
9 #include "cc/animation/timing_function.h"
10 #include "webkit/renderer/compositor_bindings/web_animation_curve_common.h"
12 using blink::WebFloatKeyframe
;
16 WebFloatAnimationCurveImpl::WebFloatAnimationCurveImpl()
17 : curve_(cc::KeyframedFloatAnimationCurve::Create()) {}
19 WebFloatAnimationCurveImpl::~WebFloatAnimationCurveImpl() {}
21 blink::WebAnimationCurve::AnimationCurveType
22 WebFloatAnimationCurveImpl::type() const {
23 return blink::WebAnimationCurve::AnimationCurveTypeFloat
;
26 void WebFloatAnimationCurveImpl::add(const WebFloatKeyframe
& keyframe
) {
27 add(keyframe
, TimingFunctionTypeEase
);
30 void WebFloatAnimationCurveImpl::add(const WebFloatKeyframe
& keyframe
,
31 TimingFunctionType type
) {
32 curve_
->AddKeyframe(cc::FloatKeyframe::Create(
33 keyframe
.time
, keyframe
.value
, CreateTimingFunction(type
)));
36 void WebFloatAnimationCurveImpl::add(const WebFloatKeyframe
& keyframe
,
41 curve_
->AddKeyframe(cc::FloatKeyframe::Create(
44 cc::CubicBezierTimingFunction::Create(x1
, y1
, x2
, y2
)
45 .PassAs
<cc::TimingFunction
>()));
48 float WebFloatAnimationCurveImpl::getValue(double time
) const {
49 return curve_
->GetValue(time
);
52 scoped_ptr
<cc::AnimationCurve
>
53 WebFloatAnimationCurveImpl::CloneToAnimationCurve() const {
54 return curve_
->Clone();