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 #ifndef UI_COMPOSITOR_TRANSFORM_ANIMATION_CURVE_ADAPTER_H_
6 #define UI_COMPOSITOR_TRANSFORM_ANIMATION_CURVE_ADAPTER_H_
8 #include "base/time/time.h"
9 #include "cc/animation/animation_curve.h"
10 #include "ui/compositor/compositor_export.h"
11 #include "ui/gfx/animation/tween.h"
12 #include "ui/gfx/transform.h"
13 #include "ui/gfx/transform_util.h"
17 class COMPOSITOR_EXPORT TransformAnimationCurveAdapter
18 : public cc::TransformAnimationCurve
{
20 TransformAnimationCurveAdapter(gfx::Tween::Type tween_type
,
21 gfx::Transform intial_value
,
22 gfx::Transform target_value
,
23 base::TimeDelta duration
);
25 ~TransformAnimationCurveAdapter() override
;
27 // TransformAnimationCurve implementation.
28 base::TimeDelta
Duration() const override
;
29 scoped_ptr
<AnimationCurve
> Clone() const override
;
30 gfx::Transform
GetValue(base::TimeDelta t
) const override
;
31 bool AnimatedBoundsForBox(const gfx::BoxF
& box
,
32 gfx::BoxF
* bounds
) const override
;
33 bool AffectsScale() const override
;
34 bool IsTranslation() const override
;
35 bool PreservesAxisAlignment() const override
;
36 bool AnimationStartScale(bool forward_direction
,
37 float* start_scale
) const override
;
38 bool MaximumTargetScale(bool forward_direction
,
39 float* max_scale
) const override
;
42 gfx::Tween::Type tween_type_
;
43 gfx::Transform initial_value_
;
44 gfx::Transform target_value_
;
45 gfx::DecomposedTransform decomposed_initial_value_
;
46 gfx::DecomposedTransform decomposed_target_value_
;
47 base::TimeDelta duration_
;
49 DISALLOW_ASSIGN(TransformAnimationCurveAdapter
);
52 class COMPOSITOR_EXPORT InverseTransformCurveAdapter
53 : public cc::TransformAnimationCurve
{
55 InverseTransformCurveAdapter(TransformAnimationCurveAdapter base_curve
,
56 gfx::Transform initial_value
,
57 base::TimeDelta duration
);
59 ~InverseTransformCurveAdapter() override
;
61 base::TimeDelta
Duration() const override
;
62 scoped_ptr
<AnimationCurve
> Clone() const override
;
63 gfx::Transform
GetValue(base::TimeDelta t
) const override
;
64 bool AnimatedBoundsForBox(const gfx::BoxF
& box
,
65 gfx::BoxF
* bounds
) const override
;
66 bool AffectsScale() const override
;
67 bool IsTranslation() const override
;
68 bool PreservesAxisAlignment() const override
;
69 bool AnimationStartScale(bool forward_direction
,
70 float* start_scale
) const override
;
71 bool MaximumTargetScale(bool forward_direction
,
72 float* max_scale
) const override
;
75 TransformAnimationCurveAdapter base_curve_
;
76 gfx::Transform initial_value_
;
77 gfx::Transform effective_initial_value_
;
78 base::TimeDelta duration_
;
80 DISALLOW_ASSIGN(InverseTransformCurveAdapter
);
85 #endif // UI_COMPOSITOR_TRANSFORM_ANIMATION_CURVE_ADAPTER_H_