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_KEYFRAMED_ANIMATION_CURVE_H_
6 #define CC_KEYFRAMED_ANIMATION_CURVE_H_
8 #include "cc/animation_curve.h"
9 #include "cc/cc_export.h"
10 #include "cc/scoped_ptr_vector.h"
11 #include "cc/timing_function.h"
12 #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformOperations.h"
16 class CC_EXPORT Keyframe
{
19 const TimingFunction
* timingFunction() const;
22 Keyframe(double time
, scoped_ptr
<TimingFunction
>);
27 scoped_ptr
<TimingFunction
> m_timingFunction
;
29 DISALLOW_COPY_AND_ASSIGN(Keyframe
);
32 class CC_EXPORT FloatKeyframe
: public Keyframe
{
34 static scoped_ptr
<FloatKeyframe
> create(double time
, float value
, scoped_ptr
<TimingFunction
>);
35 virtual ~FloatKeyframe();
39 scoped_ptr
<FloatKeyframe
> clone() const;
42 FloatKeyframe(double time
, float value
, scoped_ptr
<TimingFunction
>);
47 class CC_EXPORT TransformKeyframe
: public Keyframe
{
49 static scoped_ptr
<TransformKeyframe
> create(double time
, const WebKit::WebTransformOperations
& value
, scoped_ptr
<TimingFunction
>);
50 virtual ~TransformKeyframe();
52 const WebKit::WebTransformOperations
& value() const;
54 scoped_ptr
<TransformKeyframe
> clone() const;
57 TransformKeyframe(double time
, const WebKit::WebTransformOperations
& value
, scoped_ptr
<TimingFunction
>);
59 WebKit::WebTransformOperations m_value
;
62 class CC_EXPORT KeyframedFloatAnimationCurve
: public FloatAnimationCurve
{
64 // It is required that the keyframes be sorted by time.
65 static scoped_ptr
<KeyframedFloatAnimationCurve
> create();
67 virtual ~KeyframedFloatAnimationCurve();
69 void addKeyframe(scoped_ptr
<FloatKeyframe
>);
71 // AnimationCurve implementation
72 virtual double duration() const OVERRIDE
;
73 virtual scoped_ptr
<AnimationCurve
> clone() const OVERRIDE
;
75 // FloatAnimationCurve implementation
76 virtual float getValue(double t
) const OVERRIDE
;
79 KeyframedFloatAnimationCurve();
81 // Always sorted in order of increasing time. No two keyframes have the
83 ScopedPtrVector
<FloatKeyframe
> m_keyframes
;
85 DISALLOW_COPY_AND_ASSIGN(KeyframedFloatAnimationCurve
);
88 class CC_EXPORT KeyframedTransformAnimationCurve
: public TransformAnimationCurve
{
90 // It is required that the keyframes be sorted by time.
91 static scoped_ptr
<KeyframedTransformAnimationCurve
> create();
93 virtual ~KeyframedTransformAnimationCurve();
95 void addKeyframe(scoped_ptr
<TransformKeyframe
>);
97 // AnimationCurve implementation
98 virtual double duration() const OVERRIDE
;
99 virtual scoped_ptr
<AnimationCurve
> clone() const OVERRIDE
;
101 // TransformAnimationCurve implementation
102 virtual WebKit::WebTransformationMatrix
getValue(double t
) const OVERRIDE
;
105 KeyframedTransformAnimationCurve();
107 // Always sorted in order of increasing time. No two keyframes have the
109 ScopedPtrVector
<TransformKeyframe
> m_keyframes
;
111 DISALLOW_COPY_AND_ASSIGN(KeyframedTransformAnimationCurve
);
116 #endif // CC_KEYFRAMED_ANIMATION_CURVE_H_