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/transform_animation_curve_adapter.h"
9 TransformAnimationCurveAdapter::TransformAnimationCurveAdapter(
10 Tween::Type tween_type
,
11 gfx::Transform initial_value
,
12 gfx::Transform target_value
,
13 base::TimeDelta duration
)
14 : tween_type_(tween_type
),
15 initial_value_(initial_value
),
16 target_value_(target_value
),
18 gfx::DecomposeTransform(&decomposed_initial_value_
, initial_value_
);
19 gfx::DecomposeTransform(&decomposed_target_value_
, target_value_
);
22 TransformAnimationCurveAdapter::~TransformAnimationCurveAdapter() {
25 double TransformAnimationCurveAdapter::Duration() const {
26 return duration_
.InSecondsF();
29 scoped_ptr
<cc::AnimationCurve
> TransformAnimationCurveAdapter::Clone() const {
30 scoped_ptr
<TransformAnimationCurveAdapter
> to_return(
31 new TransformAnimationCurveAdapter(tween_type_
,
35 return to_return
.PassAs
<cc::AnimationCurve
>();
38 gfx::Transform
TransformAnimationCurveAdapter::GetValue(
40 if (t
>= duration_
.InSecondsF())
43 return initial_value_
;
44 double progress
= t
/ duration_
.InSecondsF();
46 gfx::DecomposedTransform to_return
;
47 gfx::BlendDecomposedTransforms(&to_return
,
48 decomposed_target_value_
,
49 decomposed_initial_value_
,
50 Tween::CalculateValue(tween_type_
, progress
));
51 return gfx::ComposeTransform(to_return
);