| OLD | NEW |
| 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 Loading... |
| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_ |
| OLD | NEW |