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"
7 #include "cc/base/time_util.h"
11 FloatAnimationCurveAdapter::FloatAnimationCurveAdapter(
12 gfx::Tween::Type tween_type
,
15 base::TimeDelta duration
)
16 : tween_type_(tween_type
),
17 initial_value_(initial_value
),
18 target_value_(target_value
),
22 base::TimeDelta
FloatAnimationCurveAdapter::Duration() const {
26 scoped_ptr
<cc::AnimationCurve
> FloatAnimationCurveAdapter::Clone() const {
27 return make_scoped_ptr(new FloatAnimationCurveAdapter(
28 tween_type_
, initial_value_
, target_value_
, duration_
));
31 float FloatAnimationCurveAdapter::GetValue(base::TimeDelta t
) const {
34 if (t
<= base::TimeDelta())
35 return initial_value_
;
36 double progress
= cc::TimeUtil::Divide(t
, duration_
);
37 return gfx::Tween::FloatValueBetween(
38 gfx::Tween::CalculateValue(tween_type_
, progress
),