OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CC_ANIMATION_KEYFRAMED_ANIMATION_CURVE_H_ | |
6 #define CC_ANIMATION_KEYFRAMED_ANIMATION_CURVE_H_ | |
7 | |
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" | |
14 | |
15 namespace cc { | |
16 | |
17 class CC_EXPORT Keyframe { | |
18 public: | |
19 base::TimeDelta Time() const; | |
20 const TimingFunction* timing_function() const { | |
21 return timing_function_.get(); | |
22 } | |
23 | |
24 protected: | |
25 Keyframe(base::TimeDelta time, scoped_ptr<TimingFunction> timing_function); | |
26 virtual ~Keyframe(); | |
27 | |
28 private: | |
29 base::TimeDelta time_; | |
30 scoped_ptr<TimingFunction> timing_function_; | |
31 | |
32 DISALLOW_COPY_AND_ASSIGN(Keyframe); | |
33 }; | |
34 | |
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; | |
42 | |
43 SkColor Value() const; | |
44 | |
45 scoped_ptr<ColorKeyframe> Clone() const; | |
46 | |
47 private: | |
48 ColorKeyframe(base::TimeDelta time, | |
49 SkColor value, | |
50 scoped_ptr<TimingFunction> timing_function); | |
51 | |
52 SkColor value_; | |
53 }; | |
54 | |
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; | |
62 | |
63 float Value() const; | |
64 | |
65 scoped_ptr<FloatKeyframe> Clone() const; | |
66 | |
67 private: | |
68 FloatKeyframe(base::TimeDelta time, | |
69 float value, | |
70 scoped_ptr<TimingFunction> timing_function); | |
71 | |
72 float value_; | |
73 }; | |
74 | |
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; | |
82 | |
83 const TransformOperations& Value() const; | |
84 | |
85 scoped_ptr<TransformKeyframe> Clone() const; | |
86 | |
87 private: | |
88 TransformKeyframe(base::TimeDelta time, | |
89 const TransformOperations& value, | |
90 scoped_ptr<TimingFunction> timing_function); | |
91 | |
92 TransformOperations value_; | |
93 }; | |
94 | |
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; | |
102 | |
103 const FilterOperations& Value() const; | |
104 | |
105 scoped_ptr<FilterKeyframe> Clone() const; | |
106 | |
107 private: | |
108 FilterKeyframe(base::TimeDelta time, | |
109 const FilterOperations& value, | |
110 scoped_ptr<TimingFunction> timing_function); | |
111 | |
112 FilterOperations value_; | |
113 }; | |
114 | |
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(); | |
119 | |
120 ~KeyframedColorAnimationCurve() override; | |
121 | |
122 void AddKeyframe(scoped_ptr<ColorKeyframe> keyframe); | |
123 void SetTimingFunction(scoped_ptr<TimingFunction> timing_function) { | |
124 timing_function_ = timing_function.Pass(); | |
125 } | |
126 | |
127 // AnimationCurve implementation | |
128 base::TimeDelta Duration() const override; | |
129 scoped_ptr<AnimationCurve> Clone() const override; | |
130 | |
131 // BackgrounColorAnimationCurve implementation | |
132 SkColor GetValue(base::TimeDelta t) const override; | |
133 | |
134 private: | |
135 KeyframedColorAnimationCurve(); | |
136 | |
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_; | |
141 | |
142 DISALLOW_COPY_AND_ASSIGN(KeyframedColorAnimationCurve); | |
143 }; | |
144 | |
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(); | |
149 | |
150 ~KeyframedFloatAnimationCurve() override; | |
151 | |
152 void AddKeyframe(scoped_ptr<FloatKeyframe> keyframe); | |
153 void SetTimingFunction(scoped_ptr<TimingFunction> timing_function) { | |
154 timing_function_ = timing_function.Pass(); | |
155 } | |
156 | |
157 // AnimationCurve implementation | |
158 base::TimeDelta Duration() const override; | |
159 scoped_ptr<AnimationCurve> Clone() const override; | |
160 | |
161 // FloatAnimationCurve implementation | |
162 float GetValue(base::TimeDelta t) const override; | |
163 | |
164 private: | |
165 KeyframedFloatAnimationCurve(); | |
166 | |
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_; | |
171 | |
172 DISALLOW_COPY_AND_ASSIGN(KeyframedFloatAnimationCurve); | |
173 }; | |
174 | |
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(); | |
180 | |
181 ~KeyframedTransformAnimationCurve() override; | |
182 | |
183 void AddKeyframe(scoped_ptr<TransformKeyframe> keyframe); | |
184 void SetTimingFunction(scoped_ptr<TimingFunction> timing_function) { | |
185 timing_function_ = timing_function.Pass(); | |
186 } | |
187 | |
188 // AnimationCurve implementation | |
189 base::TimeDelta Duration() const override; | |
190 scoped_ptr<AnimationCurve> Clone() const override; | |
191 | |
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 MaximumTargetScale(bool forward_direction, | |
200 float* max_scale) const override; | |
201 | |
202 private: | |
203 KeyframedTransformAnimationCurve(); | |
204 | |
205 // Always sorted in order of increasing time. No two keyframes have the | |
206 // same time. | |
207 ScopedPtrVector<TransformKeyframe> keyframes_; | |
208 scoped_ptr<TimingFunction> timing_function_; | |
209 | |
210 DISALLOW_COPY_AND_ASSIGN(KeyframedTransformAnimationCurve); | |
211 }; | |
212 | |
213 class CC_EXPORT KeyframedFilterAnimationCurve | |
214 : public FilterAnimationCurve { | |
215 public: | |
216 // It is required that the keyframes be sorted by time. | |
217 static scoped_ptr<KeyframedFilterAnimationCurve> Create(); | |
218 | |
219 ~KeyframedFilterAnimationCurve() override; | |
220 | |
221 void AddKeyframe(scoped_ptr<FilterKeyframe> keyframe); | |
222 void SetTimingFunction(scoped_ptr<TimingFunction> timing_function) { | |
223 timing_function_ = timing_function.Pass(); | |
224 } | |
225 | |
226 // AnimationCurve implementation | |
227 base::TimeDelta Duration() const override; | |
228 scoped_ptr<AnimationCurve> Clone() const override; | |
229 | |
230 // FilterAnimationCurve implementation | |
231 FilterOperations GetValue(base::TimeDelta t) const override; | |
232 bool HasFilterThatMovesPixels() const override; | |
233 | |
234 private: | |
235 KeyframedFilterAnimationCurve(); | |
236 | |
237 // Always sorted in order of increasing time. No two keyframes have the | |
238 // same time. | |
239 ScopedPtrVector<FilterKeyframe> keyframes_; | |
240 scoped_ptr<TimingFunction> timing_function_; | |
241 | |
242 DISALLOW_COPY_AND_ASSIGN(KeyframedFilterAnimationCurve); | |
243 }; | |
244 | |
245 } // namespace cc | |
246 | |
247 #endif // CC_ANIMATION_KEYFRAMED_ANIMATION_CURVE_H_ | |
OLD | NEW |