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 #ifndef CC_ANIMATION_KEYFRAMED_ANIMATION_CURVE_H_
6 #define CC_ANIMATION_KEYFRAMED_ANIMATION_CURVE_H_
8 #include "cc/animation/animation_curve.h"
9 #include "cc/animation/timing_function.h"
10 #include "cc/animation/transform_operations.h"
11 #include "cc/base/cc_export.h"
12 #include "cc/base/scoped_ptr_vector.h"
16 class CC_EXPORT Keyframe
{
19 const TimingFunction
* timing_function() const {
20 return timing_function_
.get();
24 Keyframe(double time
, scoped_ptr
<TimingFunction
> timing_function
);
29 scoped_ptr
<TimingFunction
> timing_function_
;
31 DISALLOW_COPY_AND_ASSIGN(Keyframe
);
34 class CC_EXPORT FloatKeyframe
: public Keyframe
{
36 static scoped_ptr
<FloatKeyframe
> Create(
39 scoped_ptr
<TimingFunction
> timing_function
);
40 virtual ~FloatKeyframe();
44 scoped_ptr
<FloatKeyframe
> Clone() const;
47 FloatKeyframe(double time
,
49 scoped_ptr
<TimingFunction
> timing_function
);
54 class CC_EXPORT TransformKeyframe
: public Keyframe
{
56 static scoped_ptr
<TransformKeyframe
> Create(
58 const TransformOperations
& value
,
59 scoped_ptr
<TimingFunction
> timing_function
);
60 virtual ~TransformKeyframe();
62 const TransformOperations
& Value() const;
64 scoped_ptr
<TransformKeyframe
> Clone() const;
69 const TransformOperations
& value
,
70 scoped_ptr
<TimingFunction
> timing_function
);
72 TransformOperations value_
;
75 class CC_EXPORT KeyframedFloatAnimationCurve
: public FloatAnimationCurve
{
77 // It is required that the keyframes be sorted by time.
78 static scoped_ptr
<KeyframedFloatAnimationCurve
> Create();
80 virtual ~KeyframedFloatAnimationCurve();
82 void AddKeyframe(scoped_ptr
<FloatKeyframe
> keyframe
);
84 // AnimationCurve implementation
85 virtual double Duration() const OVERRIDE
;
86 virtual scoped_ptr
<AnimationCurve
> Clone() const OVERRIDE
;
88 // FloatAnimationCurve implementation
89 virtual float GetValue(double t
) const OVERRIDE
;
92 KeyframedFloatAnimationCurve();
94 // Always sorted in order of increasing time. No two keyframes have the
96 ScopedPtrVector
<FloatKeyframe
> keyframes_
;
98 DISALLOW_COPY_AND_ASSIGN(KeyframedFloatAnimationCurve
);
101 class CC_EXPORT KeyframedTransformAnimationCurve
102 : public TransformAnimationCurve
{
104 // It is required that the keyframes be sorted by time.
105 static scoped_ptr
<KeyframedTransformAnimationCurve
> Create();
107 virtual ~KeyframedTransformAnimationCurve();
109 void AddKeyframe(scoped_ptr
<TransformKeyframe
> keyframe
);
111 // AnimationCurve implementation
112 virtual double Duration() const OVERRIDE
;
113 virtual scoped_ptr
<AnimationCurve
> Clone() const OVERRIDE
;
115 // TransformAnimationCurve implementation
116 virtual gfx::Transform
GetValue(double t
) const OVERRIDE
;
119 KeyframedTransformAnimationCurve();
121 // Always sorted in order of increasing time. No two keyframes have the
123 ScopedPtrVector
<TransformKeyframe
> keyframes_
;
125 DISALLOW_COPY_AND_ASSIGN(KeyframedTransformAnimationCurve
);
130 #endif // CC_ANIMATION_KEYFRAMED_ANIMATION_CURVE_H_