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/timing_function.h" | 13 #include "cc/animation/timing_function.h" |
14 #include "cc/animation/transform_operations.h" | 14 #include "cc/animation/transform_operations.h" |
15 #include "cc/base/cc_export.h" | 15 #include "cc/base/cc_export.h" |
16 | 16 |
17 namespace cc { | 17 namespace cc { |
18 | 18 |
19 class CC_EXPORT Keyframe { | 19 class CC_EXPORT Keyframe { |
20 public: | 20 public: |
21 base::TimeDelta Time() const; | 21 base::TimeDelta Time() const; |
22 const TimingFunction* timing_function() const { | 22 const TimingFunction* timing_function() const { |
23 return timing_function_.get(); | 23 return timing_function_.get(); |
24 } | 24 } |
25 | 25 |
26 protected: | 26 protected: |
27 Keyframe(base::TimeDelta time, scoped_ptr<TimingFunction> timing_function); | 27 Keyframe(base::TimeDelta time, |
| 28 std::unique_ptr<TimingFunction> timing_function); |
28 virtual ~Keyframe(); | 29 virtual ~Keyframe(); |
29 | 30 |
30 private: | 31 private: |
31 base::TimeDelta time_; | 32 base::TimeDelta time_; |
32 scoped_ptr<TimingFunction> timing_function_; | 33 std::unique_ptr<TimingFunction> timing_function_; |
33 | 34 |
34 DISALLOW_COPY_AND_ASSIGN(Keyframe); | 35 DISALLOW_COPY_AND_ASSIGN(Keyframe); |
35 }; | 36 }; |
36 | 37 |
37 class CC_EXPORT ColorKeyframe : public Keyframe { | 38 class CC_EXPORT ColorKeyframe : public Keyframe { |
38 public: | 39 public: |
39 static scoped_ptr<ColorKeyframe> Create( | 40 static std::unique_ptr<ColorKeyframe> Create( |
40 base::TimeDelta time, | 41 base::TimeDelta time, |
41 SkColor value, | 42 SkColor value, |
42 scoped_ptr<TimingFunction> timing_function); | 43 std::unique_ptr<TimingFunction> timing_function); |
43 ~ColorKeyframe() override; | 44 ~ColorKeyframe() override; |
44 | 45 |
45 SkColor Value() const; | 46 SkColor Value() const; |
46 | 47 |
47 scoped_ptr<ColorKeyframe> Clone() const; | 48 std::unique_ptr<ColorKeyframe> Clone() const; |
48 | 49 |
49 private: | 50 private: |
50 ColorKeyframe(base::TimeDelta time, | 51 ColorKeyframe(base::TimeDelta time, |
51 SkColor value, | 52 SkColor value, |
52 scoped_ptr<TimingFunction> timing_function); | 53 std::unique_ptr<TimingFunction> timing_function); |
53 | 54 |
54 SkColor value_; | 55 SkColor value_; |
55 }; | 56 }; |
56 | 57 |
57 class CC_EXPORT FloatKeyframe : public Keyframe { | 58 class CC_EXPORT FloatKeyframe : public Keyframe { |
58 public: | 59 public: |
59 static scoped_ptr<FloatKeyframe> Create( | 60 static std::unique_ptr<FloatKeyframe> Create( |
60 base::TimeDelta time, | 61 base::TimeDelta time, |
61 float value, | 62 float value, |
62 scoped_ptr<TimingFunction> timing_function); | 63 std::unique_ptr<TimingFunction> timing_function); |
63 ~FloatKeyframe() override; | 64 ~FloatKeyframe() override; |
64 | 65 |
65 float Value() const; | 66 float Value() const; |
66 | 67 |
67 scoped_ptr<FloatKeyframe> Clone() const; | 68 std::unique_ptr<FloatKeyframe> Clone() const; |
68 | 69 |
69 private: | 70 private: |
70 FloatKeyframe(base::TimeDelta time, | 71 FloatKeyframe(base::TimeDelta time, |
71 float value, | 72 float value, |
72 scoped_ptr<TimingFunction> timing_function); | 73 std::unique_ptr<TimingFunction> timing_function); |
73 | 74 |
74 float value_; | 75 float value_; |
75 }; | 76 }; |
76 | 77 |
77 class CC_EXPORT TransformKeyframe : public Keyframe { | 78 class CC_EXPORT TransformKeyframe : public Keyframe { |
78 public: | 79 public: |
79 static scoped_ptr<TransformKeyframe> Create( | 80 static std::unique_ptr<TransformKeyframe> Create( |
80 base::TimeDelta time, | 81 base::TimeDelta time, |
81 const TransformOperations& value, | 82 const TransformOperations& value, |
82 scoped_ptr<TimingFunction> timing_function); | 83 std::unique_ptr<TimingFunction> timing_function); |
83 ~TransformKeyframe() override; | 84 ~TransformKeyframe() override; |
84 | 85 |
85 const TransformOperations& Value() const; | 86 const TransformOperations& Value() const; |
86 | 87 |
87 scoped_ptr<TransformKeyframe> Clone() const; | 88 std::unique_ptr<TransformKeyframe> Clone() const; |
88 | 89 |
89 private: | 90 private: |
90 TransformKeyframe(base::TimeDelta time, | 91 TransformKeyframe(base::TimeDelta time, |
91 const TransformOperations& value, | 92 const TransformOperations& value, |
92 scoped_ptr<TimingFunction> timing_function); | 93 std::unique_ptr<TimingFunction> timing_function); |
93 | 94 |
94 TransformOperations value_; | 95 TransformOperations value_; |
95 }; | 96 }; |
96 | 97 |
97 class CC_EXPORT FilterKeyframe : public Keyframe { | 98 class CC_EXPORT FilterKeyframe : public Keyframe { |
98 public: | 99 public: |
99 static scoped_ptr<FilterKeyframe> Create( | 100 static std::unique_ptr<FilterKeyframe> Create( |
100 base::TimeDelta time, | 101 base::TimeDelta time, |
101 const FilterOperations& value, | 102 const FilterOperations& value, |
102 scoped_ptr<TimingFunction> timing_function); | 103 std::unique_ptr<TimingFunction> timing_function); |
103 ~FilterKeyframe() override; | 104 ~FilterKeyframe() override; |
104 | 105 |
105 const FilterOperations& Value() const; | 106 const FilterOperations& Value() const; |
106 | 107 |
107 scoped_ptr<FilterKeyframe> Clone() const; | 108 std::unique_ptr<FilterKeyframe> Clone() const; |
108 | 109 |
109 private: | 110 private: |
110 FilterKeyframe(base::TimeDelta time, | 111 FilterKeyframe(base::TimeDelta time, |
111 const FilterOperations& value, | 112 const FilterOperations& value, |
112 scoped_ptr<TimingFunction> timing_function); | 113 std::unique_ptr<TimingFunction> timing_function); |
113 | 114 |
114 FilterOperations value_; | 115 FilterOperations value_; |
115 }; | 116 }; |
116 | 117 |
117 class CC_EXPORT KeyframedColorAnimationCurve : public ColorAnimationCurve { | 118 class CC_EXPORT KeyframedColorAnimationCurve : public ColorAnimationCurve { |
118 public: | 119 public: |
119 // It is required that the keyframes be sorted by time. | 120 // It is required that the keyframes be sorted by time. |
120 static scoped_ptr<KeyframedColorAnimationCurve> Create(); | 121 static std::unique_ptr<KeyframedColorAnimationCurve> Create(); |
121 | 122 |
122 ~KeyframedColorAnimationCurve() override; | 123 ~KeyframedColorAnimationCurve() override; |
123 | 124 |
124 void AddKeyframe(scoped_ptr<ColorKeyframe> keyframe); | 125 void AddKeyframe(std::unique_ptr<ColorKeyframe> keyframe); |
125 void SetTimingFunction(scoped_ptr<TimingFunction> timing_function) { | 126 void SetTimingFunction(std::unique_ptr<TimingFunction> timing_function) { |
126 timing_function_ = std::move(timing_function); | 127 timing_function_ = std::move(timing_function); |
127 } | 128 } |
128 | 129 |
129 // AnimationCurve implementation | 130 // AnimationCurve implementation |
130 base::TimeDelta Duration() const override; | 131 base::TimeDelta Duration() const override; |
131 scoped_ptr<AnimationCurve> Clone() const override; | 132 std::unique_ptr<AnimationCurve> Clone() const override; |
132 | 133 |
133 // BackgrounColorAnimationCurve implementation | 134 // BackgrounColorAnimationCurve implementation |
134 SkColor GetValue(base::TimeDelta t) const override; | 135 SkColor GetValue(base::TimeDelta t) const override; |
135 | 136 |
136 private: | 137 private: |
137 KeyframedColorAnimationCurve(); | 138 KeyframedColorAnimationCurve(); |
138 | 139 |
139 // Always sorted in order of increasing time. No two keyframes have the | 140 // Always sorted in order of increasing time. No two keyframes have the |
140 // same time. | 141 // same time. |
141 std::vector<scoped_ptr<ColorKeyframe>> keyframes_; | 142 std::vector<std::unique_ptr<ColorKeyframe>> keyframes_; |
142 scoped_ptr<TimingFunction> timing_function_; | 143 std::unique_ptr<TimingFunction> timing_function_; |
143 | 144 |
144 DISALLOW_COPY_AND_ASSIGN(KeyframedColorAnimationCurve); | 145 DISALLOW_COPY_AND_ASSIGN(KeyframedColorAnimationCurve); |
145 }; | 146 }; |
146 | 147 |
147 class CC_EXPORT KeyframedFloatAnimationCurve : public FloatAnimationCurve { | 148 class CC_EXPORT KeyframedFloatAnimationCurve : public FloatAnimationCurve { |
148 public: | 149 public: |
149 // It is required that the keyframes be sorted by time. | 150 // It is required that the keyframes be sorted by time. |
150 static scoped_ptr<KeyframedFloatAnimationCurve> Create(); | 151 static std::unique_ptr<KeyframedFloatAnimationCurve> Create(); |
151 | 152 |
152 ~KeyframedFloatAnimationCurve() override; | 153 ~KeyframedFloatAnimationCurve() override; |
153 | 154 |
154 void AddKeyframe(scoped_ptr<FloatKeyframe> keyframe); | 155 void AddKeyframe(std::unique_ptr<FloatKeyframe> keyframe); |
155 void SetTimingFunction(scoped_ptr<TimingFunction> timing_function) { | 156 void SetTimingFunction(std::unique_ptr<TimingFunction> timing_function) { |
156 timing_function_ = std::move(timing_function); | 157 timing_function_ = std::move(timing_function); |
157 } | 158 } |
158 | 159 |
159 // AnimationCurve implementation | 160 // AnimationCurve implementation |
160 base::TimeDelta Duration() const override; | 161 base::TimeDelta Duration() const override; |
161 scoped_ptr<AnimationCurve> Clone() const override; | 162 std::unique_ptr<AnimationCurve> Clone() const override; |
162 | 163 |
163 // FloatAnimationCurve implementation | 164 // FloatAnimationCurve implementation |
164 float GetValue(base::TimeDelta t) const override; | 165 float GetValue(base::TimeDelta t) const override; |
165 | 166 |
166 private: | 167 private: |
167 KeyframedFloatAnimationCurve(); | 168 KeyframedFloatAnimationCurve(); |
168 | 169 |
169 // Always sorted in order of increasing time. No two keyframes have the | 170 // Always sorted in order of increasing time. No two keyframes have the |
170 // same time. | 171 // same time. |
171 std::vector<scoped_ptr<FloatKeyframe>> keyframes_; | 172 std::vector<std::unique_ptr<FloatKeyframe>> keyframes_; |
172 scoped_ptr<TimingFunction> timing_function_; | 173 std::unique_ptr<TimingFunction> timing_function_; |
173 | 174 |
174 DISALLOW_COPY_AND_ASSIGN(KeyframedFloatAnimationCurve); | 175 DISALLOW_COPY_AND_ASSIGN(KeyframedFloatAnimationCurve); |
175 }; | 176 }; |
176 | 177 |
177 class CC_EXPORT KeyframedTransformAnimationCurve | 178 class CC_EXPORT KeyframedTransformAnimationCurve |
178 : public TransformAnimationCurve { | 179 : public TransformAnimationCurve { |
179 public: | 180 public: |
180 // It is required that the keyframes be sorted by time. | 181 // It is required that the keyframes be sorted by time. |
181 static scoped_ptr<KeyframedTransformAnimationCurve> Create(); | 182 static std::unique_ptr<KeyframedTransformAnimationCurve> Create(); |
182 | 183 |
183 ~KeyframedTransformAnimationCurve() override; | 184 ~KeyframedTransformAnimationCurve() override; |
184 | 185 |
185 void AddKeyframe(scoped_ptr<TransformKeyframe> keyframe); | 186 void AddKeyframe(std::unique_ptr<TransformKeyframe> keyframe); |
186 void SetTimingFunction(scoped_ptr<TimingFunction> timing_function) { | 187 void SetTimingFunction(std::unique_ptr<TimingFunction> timing_function) { |
187 timing_function_ = std::move(timing_function); | 188 timing_function_ = std::move(timing_function); |
188 } | 189 } |
189 | 190 |
190 // AnimationCurve implementation | 191 // AnimationCurve implementation |
191 base::TimeDelta Duration() const override; | 192 base::TimeDelta Duration() const override; |
192 scoped_ptr<AnimationCurve> Clone() const override; | 193 std::unique_ptr<AnimationCurve> Clone() const override; |
193 | 194 |
194 // TransformAnimationCurve implementation | 195 // TransformAnimationCurve implementation |
195 gfx::Transform GetValue(base::TimeDelta t) const override; | 196 gfx::Transform GetValue(base::TimeDelta t) const override; |
196 bool AnimatedBoundsForBox(const gfx::BoxF& box, | 197 bool AnimatedBoundsForBox(const gfx::BoxF& box, |
197 gfx::BoxF* bounds) const override; | 198 gfx::BoxF* bounds) const override; |
198 bool AffectsScale() const override; | 199 bool AffectsScale() const override; |
199 bool PreservesAxisAlignment() const override; | 200 bool PreservesAxisAlignment() const override; |
200 bool IsTranslation() const override; | 201 bool IsTranslation() const override; |
201 bool AnimationStartScale(bool forward_direction, | 202 bool AnimationStartScale(bool forward_direction, |
202 float* start_scale) const override; | 203 float* start_scale) const override; |
203 bool MaximumTargetScale(bool forward_direction, | 204 bool MaximumTargetScale(bool forward_direction, |
204 float* max_scale) const override; | 205 float* max_scale) const override; |
205 | 206 |
206 private: | 207 private: |
207 KeyframedTransformAnimationCurve(); | 208 KeyframedTransformAnimationCurve(); |
208 | 209 |
209 // Always sorted in order of increasing time. No two keyframes have the | 210 // Always sorted in order of increasing time. No two keyframes have the |
210 // same time. | 211 // same time. |
211 std::vector<scoped_ptr<TransformKeyframe>> keyframes_; | 212 std::vector<std::unique_ptr<TransformKeyframe>> keyframes_; |
212 scoped_ptr<TimingFunction> timing_function_; | 213 std::unique_ptr<TimingFunction> timing_function_; |
213 | 214 |
214 DISALLOW_COPY_AND_ASSIGN(KeyframedTransformAnimationCurve); | 215 DISALLOW_COPY_AND_ASSIGN(KeyframedTransformAnimationCurve); |
215 }; | 216 }; |
216 | 217 |
217 class CC_EXPORT KeyframedFilterAnimationCurve | 218 class CC_EXPORT KeyframedFilterAnimationCurve |
218 : public FilterAnimationCurve { | 219 : public FilterAnimationCurve { |
219 public: | 220 public: |
220 // It is required that the keyframes be sorted by time. | 221 // It is required that the keyframes be sorted by time. |
221 static scoped_ptr<KeyframedFilterAnimationCurve> Create(); | 222 static std::unique_ptr<KeyframedFilterAnimationCurve> Create(); |
222 | 223 |
223 ~KeyframedFilterAnimationCurve() override; | 224 ~KeyframedFilterAnimationCurve() override; |
224 | 225 |
225 void AddKeyframe(scoped_ptr<FilterKeyframe> keyframe); | 226 void AddKeyframe(std::unique_ptr<FilterKeyframe> keyframe); |
226 void SetTimingFunction(scoped_ptr<TimingFunction> timing_function) { | 227 void SetTimingFunction(std::unique_ptr<TimingFunction> timing_function) { |
227 timing_function_ = std::move(timing_function); | 228 timing_function_ = std::move(timing_function); |
228 } | 229 } |
229 | 230 |
230 // AnimationCurve implementation | 231 // AnimationCurve implementation |
231 base::TimeDelta Duration() const override; | 232 base::TimeDelta Duration() const override; |
232 scoped_ptr<AnimationCurve> Clone() const override; | 233 std::unique_ptr<AnimationCurve> Clone() const override; |
233 | 234 |
234 // FilterAnimationCurve implementation | 235 // FilterAnimationCurve implementation |
235 FilterOperations GetValue(base::TimeDelta t) const override; | 236 FilterOperations GetValue(base::TimeDelta t) const override; |
236 bool HasFilterThatMovesPixels() const override; | 237 bool HasFilterThatMovesPixels() const override; |
237 | 238 |
238 private: | 239 private: |
239 KeyframedFilterAnimationCurve(); | 240 KeyframedFilterAnimationCurve(); |
240 | 241 |
241 // Always sorted in order of increasing time. No two keyframes have the | 242 // Always sorted in order of increasing time. No two keyframes have the |
242 // same time. | 243 // same time. |
243 std::vector<scoped_ptr<FilterKeyframe>> keyframes_; | 244 std::vector<std::unique_ptr<FilterKeyframe>> keyframes_; |
244 scoped_ptr<TimingFunction> timing_function_; | 245 std::unique_ptr<TimingFunction> timing_function_; |
245 | 246 |
246 DISALLOW_COPY_AND_ASSIGN(KeyframedFilterAnimationCurve); | 247 DISALLOW_COPY_AND_ASSIGN(KeyframedFilterAnimationCurve); |
247 }; | 248 }; |
248 | 249 |
249 } // namespace cc | 250 } // namespace cc |
250 | 251 |
251 #endif // CC_ANIMATION_KEYFRAMED_ANIMATION_CURVE_H_ | 252 #endif // CC_ANIMATION_KEYFRAMED_ANIMATION_CURVE_H_ |
OLD | NEW |