1 // Copyright (c) 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 "ui/compositor/float_animation_curve_adapter.h"
9 FloatAnimationCurveAdapter::FloatAnimationCurveAdapter(
10 gfx::Tween::Type tween_type
,
13 base::TimeDelta duration
)
14 : tween_type_(tween_type
),
15 initial_value_(initial_value
),
16 target_value_(target_value
),
20 double FloatAnimationCurveAdapter::Duration() const {
21 return duration_
.InSecondsF();
24 scoped_ptr
<cc::AnimationCurve
> FloatAnimationCurveAdapter::Clone() const {
25 scoped_ptr
<FloatAnimationCurveAdapter
> to_return(
26 new FloatAnimationCurveAdapter(tween_type_
,
30 return to_return
.PassAs
<cc::AnimationCurve
>();
33 float FloatAnimationCurveAdapter::GetValue(double t
) const {
34 if (t
>= duration_
.InSecondsF())
37 return initial_value_
;
38 double progress
= t
/ duration_
.InSecondsF();
39 return gfx::Tween::FloatValueBetween(
40 gfx::Tween::CalculateValue(tween_type_
, progress
),