Implements RLZTrackerDelegate on iOS.
[chromium-blink-merge.git] / cc / animation / keyframed_animation_curve.h
blobb5dfb14628fabe044de8a155161655fe0a050743
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 "base/time/time.h"
9 #include "cc/animation/animation_curve.h"
10 #include "cc/animation/timing_function.h"
11 #include "cc/animation/transform_operations.h"
12 #include "cc/base/cc_export.h"
13 #include "cc/base/scoped_ptr_vector.h"
15 namespace cc {
17 class CC_EXPORT Keyframe {
18 public:
19 base::TimeDelta Time() const;
20 const TimingFunction* timing_function() const {
21 return timing_function_.get();
24 protected:
25 Keyframe(base::TimeDelta time, scoped_ptr<TimingFunction> timing_function);
26 virtual ~Keyframe();
28 private:
29 base::TimeDelta time_;
30 scoped_ptr<TimingFunction> timing_function_;
32 DISALLOW_COPY_AND_ASSIGN(Keyframe);
35 class CC_EXPORT ColorKeyframe : public Keyframe {
36 public:
37 static scoped_ptr<ColorKeyframe> Create(
38 base::TimeDelta time,
39 SkColor value,
40 scoped_ptr<TimingFunction> timing_function);
41 ~ColorKeyframe() override;
43 SkColor Value() const;
45 scoped_ptr<ColorKeyframe> Clone() const;
47 private:
48 ColorKeyframe(base::TimeDelta time,
49 SkColor value,
50 scoped_ptr<TimingFunction> timing_function);
52 SkColor value_;
55 class CC_EXPORT FloatKeyframe : public Keyframe {
56 public:
57 static scoped_ptr<FloatKeyframe> Create(
58 base::TimeDelta time,
59 float value,
60 scoped_ptr<TimingFunction> timing_function);
61 ~FloatKeyframe() override;
63 float Value() const;
65 scoped_ptr<FloatKeyframe> Clone() const;
67 private:
68 FloatKeyframe(base::TimeDelta time,
69 float value,
70 scoped_ptr<TimingFunction> timing_function);
72 float value_;
75 class CC_EXPORT TransformKeyframe : public Keyframe {
76 public:
77 static scoped_ptr<TransformKeyframe> Create(
78 base::TimeDelta time,
79 const TransformOperations& value,
80 scoped_ptr<TimingFunction> timing_function);
81 ~TransformKeyframe() override;
83 const TransformOperations& Value() const;
85 scoped_ptr<TransformKeyframe> Clone() const;
87 private:
88 TransformKeyframe(base::TimeDelta time,
89 const TransformOperations& value,
90 scoped_ptr<TimingFunction> timing_function);
92 TransformOperations value_;
95 class CC_EXPORT FilterKeyframe : public Keyframe {
96 public:
97 static scoped_ptr<FilterKeyframe> Create(
98 base::TimeDelta time,
99 const FilterOperations& value,
100 scoped_ptr<TimingFunction> timing_function);
101 ~FilterKeyframe() override;
103 const FilterOperations& Value() const;
105 scoped_ptr<FilterKeyframe> Clone() const;
107 private:
108 FilterKeyframe(base::TimeDelta time,
109 const FilterOperations& value,
110 scoped_ptr<TimingFunction> timing_function);
112 FilterOperations value_;
115 class CC_EXPORT KeyframedColorAnimationCurve : public ColorAnimationCurve {
116 public:
117 // It is required that the keyframes be sorted by time.
118 static scoped_ptr<KeyframedColorAnimationCurve> Create();
120 ~KeyframedColorAnimationCurve() override;
122 void AddKeyframe(scoped_ptr<ColorKeyframe> keyframe);
123 void SetTimingFunction(scoped_ptr<TimingFunction> timing_function) {
124 timing_function_ = timing_function.Pass();
127 // AnimationCurve implementation
128 base::TimeDelta Duration() const override;
129 scoped_ptr<AnimationCurve> Clone() const override;
131 // BackgrounColorAnimationCurve implementation
132 SkColor GetValue(base::TimeDelta t) const override;
134 private:
135 KeyframedColorAnimationCurve();
137 // Always sorted in order of increasing time. No two keyframes have the
138 // same time.
139 ScopedPtrVector<ColorKeyframe> keyframes_;
140 scoped_ptr<TimingFunction> timing_function_;
142 DISALLOW_COPY_AND_ASSIGN(KeyframedColorAnimationCurve);
145 class CC_EXPORT KeyframedFloatAnimationCurve : public FloatAnimationCurve {
146 public:
147 // It is required that the keyframes be sorted by time.
148 static scoped_ptr<KeyframedFloatAnimationCurve> Create();
150 ~KeyframedFloatAnimationCurve() override;
152 void AddKeyframe(scoped_ptr<FloatKeyframe> keyframe);
153 void SetTimingFunction(scoped_ptr<TimingFunction> timing_function) {
154 timing_function_ = timing_function.Pass();
157 // AnimationCurve implementation
158 base::TimeDelta Duration() const override;
159 scoped_ptr<AnimationCurve> Clone() const override;
161 // FloatAnimationCurve implementation
162 float GetValue(base::TimeDelta t) const override;
164 private:
165 KeyframedFloatAnimationCurve();
167 // Always sorted in order of increasing time. No two keyframes have the
168 // same time.
169 ScopedPtrVector<FloatKeyframe> keyframes_;
170 scoped_ptr<TimingFunction> timing_function_;
172 DISALLOW_COPY_AND_ASSIGN(KeyframedFloatAnimationCurve);
175 class CC_EXPORT KeyframedTransformAnimationCurve
176 : public TransformAnimationCurve {
177 public:
178 // It is required that the keyframes be sorted by time.
179 static scoped_ptr<KeyframedTransformAnimationCurve> Create();
181 ~KeyframedTransformAnimationCurve() override;
183 void AddKeyframe(scoped_ptr<TransformKeyframe> keyframe);
184 void SetTimingFunction(scoped_ptr<TimingFunction> timing_function) {
185 timing_function_ = timing_function.Pass();
188 // AnimationCurve implementation
189 base::TimeDelta Duration() const override;
190 scoped_ptr<AnimationCurve> Clone() const override;
192 // TransformAnimationCurve implementation
193 gfx::Transform GetValue(base::TimeDelta t) const override;
194 bool AnimatedBoundsForBox(const gfx::BoxF& box,
195 gfx::BoxF* bounds) const override;
196 bool AffectsScale() const override;
197 bool PreservesAxisAlignment() const override;
198 bool IsTranslation() const override;
199 bool AnimationStartScale(bool forward_direction,
200 float* start_scale) const override;
201 bool MaximumTargetScale(bool forward_direction,
202 float* max_scale) const override;
204 private:
205 KeyframedTransformAnimationCurve();
207 // Always sorted in order of increasing time. No two keyframes have the
208 // same time.
209 ScopedPtrVector<TransformKeyframe> keyframes_;
210 scoped_ptr<TimingFunction> timing_function_;
212 DISALLOW_COPY_AND_ASSIGN(KeyframedTransformAnimationCurve);
215 class CC_EXPORT KeyframedFilterAnimationCurve
216 : public FilterAnimationCurve {
217 public:
218 // It is required that the keyframes be sorted by time.
219 static scoped_ptr<KeyframedFilterAnimationCurve> Create();
221 ~KeyframedFilterAnimationCurve() override;
223 void AddKeyframe(scoped_ptr<FilterKeyframe> keyframe);
224 void SetTimingFunction(scoped_ptr<TimingFunction> timing_function) {
225 timing_function_ = timing_function.Pass();
228 // AnimationCurve implementation
229 base::TimeDelta Duration() const override;
230 scoped_ptr<AnimationCurve> Clone() const override;
232 // FilterAnimationCurve implementation
233 FilterOperations GetValue(base::TimeDelta t) const override;
234 bool HasFilterThatMovesPixels() const override;
236 private:
237 KeyframedFilterAnimationCurve();
239 // Always sorted in order of increasing time. No two keyframes have the
240 // same time.
241 ScopedPtrVector<FilterKeyframe> keyframes_;
242 scoped_ptr<TimingFunction> timing_function_;
244 DISALLOW_COPY_AND_ASSIGN(KeyframedFilterAnimationCurve);
247 } // namespace cc
249 #endif // CC_ANIMATION_KEYFRAMED_ANIMATION_CURVE_H_