Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: cc/animation/keyframed_animation_curve.h

Issue 2966793002: NOT FOR REVIEW - convert to cc animation
Patch Set: switch to transform operations Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/animation/element_animations.cc ('k') | cc/animation/keyframed_animation_curve.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_ANIMATION_KEYFRAMED_ANIMATION_CURVE_H_ 5 #ifndef CC_ANIMATION_KEYFRAMED_ANIMATION_CURVE_H_
6 #define CC_ANIMATION_KEYFRAMED_ANIMATION_CURVE_H_ 6 #define CC_ANIMATION_KEYFRAMED_ANIMATION_CURVE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "cc/animation/animation_curve.h" 12 #include "cc/animation/animation_curve.h"
13 #include "cc/animation/animation_export.h" 13 #include "cc/animation/animation_export.h"
14 #include "cc/animation/timing_function.h" 14 #include "cc/animation/timing_function.h"
15 #include "cc/animation/transform_operations.h" 15 #include "cc/animation/transform_operations.h"
16 #include "ui/gfx/geometry/size_f.h"
16 17
17 namespace cc { 18 namespace cc {
18 19
19 class CC_ANIMATION_EXPORT Keyframe { 20 class CC_ANIMATION_EXPORT Keyframe {
20 public: 21 public:
21 base::TimeDelta Time() const; 22 base::TimeDelta Time() const;
22 const TimingFunction* timing_function() const { 23 const TimingFunction* timing_function() const {
23 return timing_function_.get(); 24 return timing_function_.get();
24 } 25 }
25 26
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 std::unique_ptr<FilterKeyframe> Clone() const; 109 std::unique_ptr<FilterKeyframe> Clone() const;
109 110
110 private: 111 private:
111 FilterKeyframe(base::TimeDelta time, 112 FilterKeyframe(base::TimeDelta time,
112 const FilterOperations& value, 113 const FilterOperations& value,
113 std::unique_ptr<TimingFunction> timing_function); 114 std::unique_ptr<TimingFunction> timing_function);
114 115
115 FilterOperations value_; 116 FilterOperations value_;
116 }; 117 };
117 118
119 class CC_ANIMATION_EXPORT SizeKeyframe : public Keyframe {
120 public:
121 static std::unique_ptr<SizeKeyframe> Create(
122 base::TimeDelta time,
123 const gfx::SizeF& bounds,
124 std::unique_ptr<TimingFunction> timing_function);
125 ~SizeKeyframe() override;
126
127 const gfx::SizeF& Value() const;
128
129 std::unique_ptr<SizeKeyframe> Clone() const;
130
131 private:
132 SizeKeyframe(base::TimeDelta time,
133 const gfx::SizeF& value,
134 std::unique_ptr<TimingFunction> timing_function);
135
136 gfx::SizeF value_;
137 };
138
118 class CC_ANIMATION_EXPORT KeyframedColorAnimationCurve 139 class CC_ANIMATION_EXPORT KeyframedColorAnimationCurve
119 : public ColorAnimationCurve { 140 : public ColorAnimationCurve {
120 public: 141 public:
121 // It is required that the keyframes be sorted by time. 142 // It is required that the keyframes be sorted by time.
122 static std::unique_ptr<KeyframedColorAnimationCurve> Create(); 143 static std::unique_ptr<KeyframedColorAnimationCurve> Create();
123 144
124 ~KeyframedColorAnimationCurve() override; 145 ~KeyframedColorAnimationCurve() override;
125 146
126 void AddKeyframe(std::unique_ptr<ColorKeyframe> keyframe); 147 void AddKeyframe(std::unique_ptr<ColorKeyframe> keyframe);
127 void SetTimingFunction(std::unique_ptr<TimingFunction> timing_function) { 148 void SetTimingFunction(std::unique_ptr<TimingFunction> timing_function) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 double scaled_duration() const { return scaled_duration_; } 230 double scaled_duration() const { return scaled_duration_; }
210 void set_scaled_duration(double scaled_duration) { 231 void set_scaled_duration(double scaled_duration) {
211 scaled_duration_ = scaled_duration; 232 scaled_duration_ = scaled_duration;
212 } 233 }
213 234
214 // AnimationCurve implementation 235 // AnimationCurve implementation
215 base::TimeDelta Duration() const override; 236 base::TimeDelta Duration() const override;
216 std::unique_ptr<AnimationCurve> Clone() const override; 237 std::unique_ptr<AnimationCurve> Clone() const override;
217 238
218 // TransformAnimationCurve implementation 239 // TransformAnimationCurve implementation
219 gfx::Transform GetValue(base::TimeDelta t) const override; 240 TransformOperations GetValue(base::TimeDelta t) const override;
220 bool AnimatedBoundsForBox(const gfx::BoxF& box, 241 bool AnimatedBoundsForBox(const gfx::BoxF& box,
221 gfx::BoxF* bounds) const override; 242 gfx::BoxF* bounds) const override;
222 bool PreservesAxisAlignment() const override; 243 bool PreservesAxisAlignment() const override;
223 bool IsTranslation() const override; 244 bool IsTranslation() const override;
224 bool AnimationStartScale(bool forward_direction, 245 bool AnimationStartScale(bool forward_direction,
225 float* start_scale) const override; 246 float* start_scale) const override;
226 bool MaximumTargetScale(bool forward_direction, 247 bool MaximumTargetScale(bool forward_direction,
227 float* max_scale) const override; 248 float* max_scale) const override;
228 249
229 private: 250 private:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 289
269 // Always sorted in order of increasing time. No two keyframes have the 290 // Always sorted in order of increasing time. No two keyframes have the
270 // same time. 291 // same time.
271 std::vector<std::unique_ptr<FilterKeyframe>> keyframes_; 292 std::vector<std::unique_ptr<FilterKeyframe>> keyframes_;
272 std::unique_ptr<TimingFunction> timing_function_; 293 std::unique_ptr<TimingFunction> timing_function_;
273 double scaled_duration_; 294 double scaled_duration_;
274 295
275 DISALLOW_COPY_AND_ASSIGN(KeyframedFilterAnimationCurve); 296 DISALLOW_COPY_AND_ASSIGN(KeyframedFilterAnimationCurve);
276 }; 297 };
277 298
299 class CC_ANIMATION_EXPORT KeyframedSizeAnimationCurve
300 : public SizeAnimationCurve {
301 public:
302 // It is required that the keyframes be sorted by time.
303 static std::unique_ptr<KeyframedSizeAnimationCurve> Create();
304
305 ~KeyframedSizeAnimationCurve() override;
306
307 void AddKeyframe(std::unique_ptr<SizeKeyframe> keyframe);
308 void SetTimingFunction(std::unique_ptr<TimingFunction> timing_function) {
309 timing_function_ = std::move(timing_function);
310 }
311 double scaled_duration() const { return scaled_duration_; }
312 void set_scaled_duration(double scaled_duration) {
313 scaled_duration_ = scaled_duration;
314 }
315
316 // AnimationCurve implementation
317 base::TimeDelta Duration() const override;
318 std::unique_ptr<AnimationCurve> Clone() const override;
319
320 // SizeAnimationCurve implementation
321 gfx::SizeF GetValue(base::TimeDelta t) const override;
322
323 private:
324 KeyframedSizeAnimationCurve();
325
326 // Always sorted in order of increasing time. No two keyframes have the
327 // same time.
328 std::vector<std::unique_ptr<SizeKeyframe>> keyframes_;
329 std::unique_ptr<TimingFunction> timing_function_;
330 double scaled_duration_;
331
332 DISALLOW_COPY_AND_ASSIGN(KeyframedSizeAnimationCurve);
333 };
334
278 } // namespace cc 335 } // namespace cc
279 336
280 #endif // CC_ANIMATION_KEYFRAMED_ANIMATION_CURVE_H_ 337 #endif // CC_ANIMATION_KEYFRAMED_ANIMATION_CURVE_H_
OLDNEW
« no previous file with comments | « cc/animation/element_animations.cc ('k') | cc/animation/keyframed_animation_curve.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698