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

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

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase Created 4 years, 8 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
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 #include "cc/animation/keyframed_animation_curve.h"
6
5 #include <stddef.h> 7 #include <stddef.h>
6 8
7 #include <algorithm> 9 #include <algorithm>
8 10
9 #include "cc/animation/keyframed_animation_curve.h" 11 #include "base/memory/ptr_util.h"
10 #include "cc/base/time_util.h" 12 #include "cc/base/time_util.h"
11 #include "ui/gfx/animation/tween.h" 13 #include "ui/gfx/animation/tween.h"
12 #include "ui/gfx/geometry/box_f.h" 14 #include "ui/gfx/geometry/box_f.h"
13 15
14 namespace cc { 16 namespace cc {
15 17
16 namespace { 18 namespace {
17 19
18 template <class KeyframeType> 20 template <class KeyframeType>
19 void InsertKeyframe(scoped_ptr<KeyframeType> keyframe, 21 void InsertKeyframe(std::unique_ptr<KeyframeType> keyframe,
20 std::vector<scoped_ptr<KeyframeType>>* keyframes) { 22 std::vector<std::unique_ptr<KeyframeType>>* keyframes) {
21 // Usually, the keyframes will be added in order, so this loop would be 23 // Usually, the keyframes will be added in order, so this loop would be
22 // unnecessary and we should skip it if possible. 24 // unnecessary and we should skip it if possible.
23 if (!keyframes->empty() && keyframe->Time() < keyframes->back()->Time()) { 25 if (!keyframes->empty() && keyframe->Time() < keyframes->back()->Time()) {
24 for (size_t i = 0; i < keyframes->size(); ++i) { 26 for (size_t i = 0; i < keyframes->size(); ++i) {
25 if (keyframe->Time() < keyframes->at(i)->Time()) { 27 if (keyframe->Time() < keyframes->at(i)->Time()) {
26 keyframes->insert(keyframes->begin() + i, std::move(keyframe)); 28 keyframes->insert(keyframes->begin() + i, std::move(keyframe));
27 return; 29 return;
28 } 30 }
29 } 31 }
30 } 32 }
31 33
32 keyframes->push_back(std::move(keyframe)); 34 keyframes->push_back(std::move(keyframe));
33 } 35 }
34 36
35 template <typename KeyframeType> 37 template <typename KeyframeType>
36 base::TimeDelta TransformedAnimationTime( 38 base::TimeDelta TransformedAnimationTime(
37 const std::vector<scoped_ptr<KeyframeType>>& keyframes, 39 const std::vector<std::unique_ptr<KeyframeType>>& keyframes,
38 const scoped_ptr<TimingFunction>& timing_function, 40 const std::unique_ptr<TimingFunction>& timing_function,
39 base::TimeDelta time) { 41 base::TimeDelta time) {
40 if (timing_function) { 42 if (timing_function) {
41 base::TimeDelta start_time = keyframes.front()->Time(); 43 base::TimeDelta start_time = keyframes.front()->Time();
42 base::TimeDelta duration = 44 base::TimeDelta duration =
43 keyframes.back()->Time() - keyframes.front()->Time(); 45 keyframes.back()->Time() - keyframes.front()->Time();
44 double progress = TimeUtil::Divide(time - start_time, duration); 46 double progress = TimeUtil::Divide(time - start_time, duration);
45 47
46 time = TimeUtil::Scale(duration, timing_function->GetValue(progress)) + 48 time = TimeUtil::Scale(duration, timing_function->GetValue(progress)) +
47 start_time; 49 start_time;
48 } 50 }
49 51
50 return time; 52 return time;
51 } 53 }
52 54
53 template <typename KeyframeType> 55 template <typename KeyframeType>
54 size_t GetActiveKeyframe(const std::vector<scoped_ptr<KeyframeType>>& keyframes, 56 size_t GetActiveKeyframe(
55 base::TimeDelta time) { 57 const std::vector<std::unique_ptr<KeyframeType>>& keyframes,
58 base::TimeDelta time) {
56 DCHECK_GE(keyframes.size(), 2ul); 59 DCHECK_GE(keyframes.size(), 2ul);
57 size_t i = 0; 60 size_t i = 0;
58 for (; i < keyframes.size() - 2; ++i) { // Last keyframe is never active. 61 for (; i < keyframes.size() - 2; ++i) { // Last keyframe is never active.
59 if (time < keyframes[i + 1]->Time()) 62 if (time < keyframes[i + 1]->Time())
60 break; 63 break;
61 } 64 }
62 65
63 return i; 66 return i;
64 } 67 }
65 68
66 template <typename KeyframeType> 69 template <typename KeyframeType>
67 double TransformedKeyframeProgress( 70 double TransformedKeyframeProgress(
68 const std::vector<scoped_ptr<KeyframeType>>& keyframes, 71 const std::vector<std::unique_ptr<KeyframeType>>& keyframes,
69 base::TimeDelta time, 72 base::TimeDelta time,
70 size_t i) { 73 size_t i) {
71 double progress = 74 double progress =
72 TimeUtil::Divide(time - keyframes[i]->Time(), 75 TimeUtil::Divide(time - keyframes[i]->Time(),
73 keyframes[i + 1]->Time() - keyframes[i]->Time()); 76 keyframes[i + 1]->Time() - keyframes[i]->Time());
74 77
75 if (keyframes[i]->timing_function()) { 78 if (keyframes[i]->timing_function()) {
76 progress = keyframes[i]->timing_function()->GetValue(progress); 79 progress = keyframes[i]->timing_function()->GetValue(progress);
77 } 80 }
78 81
79 return progress; 82 return progress;
80 } 83 }
81 84
82 } // namespace 85 } // namespace
83 86
84 Keyframe::Keyframe(base::TimeDelta time, 87 Keyframe::Keyframe(base::TimeDelta time,
85 scoped_ptr<TimingFunction> timing_function) 88 std::unique_ptr<TimingFunction> timing_function)
86 : time_(time), timing_function_(std::move(timing_function)) {} 89 : time_(time), timing_function_(std::move(timing_function)) {}
87 90
88 Keyframe::~Keyframe() {} 91 Keyframe::~Keyframe() {}
89 92
90 base::TimeDelta Keyframe::Time() const { 93 base::TimeDelta Keyframe::Time() const {
91 return time_; 94 return time_;
92 } 95 }
93 96
94 scoped_ptr<ColorKeyframe> ColorKeyframe::Create( 97 std::unique_ptr<ColorKeyframe> ColorKeyframe::Create(
95 base::TimeDelta time, 98 base::TimeDelta time,
96 SkColor value, 99 SkColor value,
97 scoped_ptr<TimingFunction> timing_function) { 100 std::unique_ptr<TimingFunction> timing_function) {
98 return make_scoped_ptr( 101 return base::WrapUnique(
99 new ColorKeyframe(time, value, std::move(timing_function))); 102 new ColorKeyframe(time, value, std::move(timing_function)));
100 } 103 }
101 104
102 ColorKeyframe::ColorKeyframe(base::TimeDelta time, 105 ColorKeyframe::ColorKeyframe(base::TimeDelta time,
103 SkColor value, 106 SkColor value,
104 scoped_ptr<TimingFunction> timing_function) 107 std::unique_ptr<TimingFunction> timing_function)
105 : Keyframe(time, std::move(timing_function)), value_(value) {} 108 : Keyframe(time, std::move(timing_function)), value_(value) {}
106 109
107 ColorKeyframe::~ColorKeyframe() {} 110 ColorKeyframe::~ColorKeyframe() {}
108 111
109 SkColor ColorKeyframe::Value() const { return value_; } 112 SkColor ColorKeyframe::Value() const { return value_; }
110 113
111 scoped_ptr<ColorKeyframe> ColorKeyframe::Clone() const { 114 std::unique_ptr<ColorKeyframe> ColorKeyframe::Clone() const {
112 scoped_ptr<TimingFunction> func; 115 std::unique_ptr<TimingFunction> func;
113 if (timing_function()) 116 if (timing_function())
114 func = timing_function()->Clone(); 117 func = timing_function()->Clone();
115 return ColorKeyframe::Create(Time(), Value(), std::move(func)); 118 return ColorKeyframe::Create(Time(), Value(), std::move(func));
116 } 119 }
117 120
118 scoped_ptr<FloatKeyframe> FloatKeyframe::Create( 121 std::unique_ptr<FloatKeyframe> FloatKeyframe::Create(
119 base::TimeDelta time, 122 base::TimeDelta time,
120 float value, 123 float value,
121 scoped_ptr<TimingFunction> timing_function) { 124 std::unique_ptr<TimingFunction> timing_function) {
122 return make_scoped_ptr( 125 return base::WrapUnique(
123 new FloatKeyframe(time, value, std::move(timing_function))); 126 new FloatKeyframe(time, value, std::move(timing_function)));
124 } 127 }
125 128
126 FloatKeyframe::FloatKeyframe(base::TimeDelta time, 129 FloatKeyframe::FloatKeyframe(base::TimeDelta time,
127 float value, 130 float value,
128 scoped_ptr<TimingFunction> timing_function) 131 std::unique_ptr<TimingFunction> timing_function)
129 : Keyframe(time, std::move(timing_function)), value_(value) {} 132 : Keyframe(time, std::move(timing_function)), value_(value) {}
130 133
131 FloatKeyframe::~FloatKeyframe() {} 134 FloatKeyframe::~FloatKeyframe() {}
132 135
133 float FloatKeyframe::Value() const { 136 float FloatKeyframe::Value() const {
134 return value_; 137 return value_;
135 } 138 }
136 139
137 scoped_ptr<FloatKeyframe> FloatKeyframe::Clone() const { 140 std::unique_ptr<FloatKeyframe> FloatKeyframe::Clone() const {
138 scoped_ptr<TimingFunction> func; 141 std::unique_ptr<TimingFunction> func;
139 if (timing_function()) 142 if (timing_function())
140 func = timing_function()->Clone(); 143 func = timing_function()->Clone();
141 return FloatKeyframe::Create(Time(), Value(), std::move(func)); 144 return FloatKeyframe::Create(Time(), Value(), std::move(func));
142 } 145 }
143 146
144 scoped_ptr<TransformKeyframe> TransformKeyframe::Create( 147 std::unique_ptr<TransformKeyframe> TransformKeyframe::Create(
145 base::TimeDelta time, 148 base::TimeDelta time,
146 const TransformOperations& value, 149 const TransformOperations& value,
147 scoped_ptr<TimingFunction> timing_function) { 150 std::unique_ptr<TimingFunction> timing_function) {
148 return make_scoped_ptr( 151 return base::WrapUnique(
149 new TransformKeyframe(time, value, std::move(timing_function))); 152 new TransformKeyframe(time, value, std::move(timing_function)));
150 } 153 }
151 154
152 TransformKeyframe::TransformKeyframe(base::TimeDelta time, 155 TransformKeyframe::TransformKeyframe(
153 const TransformOperations& value, 156 base::TimeDelta time,
154 scoped_ptr<TimingFunction> timing_function) 157 const TransformOperations& value,
158 std::unique_ptr<TimingFunction> timing_function)
155 : Keyframe(time, std::move(timing_function)), value_(value) {} 159 : Keyframe(time, std::move(timing_function)), value_(value) {}
156 160
157 TransformKeyframe::~TransformKeyframe() {} 161 TransformKeyframe::~TransformKeyframe() {}
158 162
159 const TransformOperations& TransformKeyframe::Value() const { 163 const TransformOperations& TransformKeyframe::Value() const {
160 return value_; 164 return value_;
161 } 165 }
162 166
163 scoped_ptr<TransformKeyframe> TransformKeyframe::Clone() const { 167 std::unique_ptr<TransformKeyframe> TransformKeyframe::Clone() const {
164 scoped_ptr<TimingFunction> func; 168 std::unique_ptr<TimingFunction> func;
165 if (timing_function()) 169 if (timing_function())
166 func = timing_function()->Clone(); 170 func = timing_function()->Clone();
167 return TransformKeyframe::Create(Time(), Value(), std::move(func)); 171 return TransformKeyframe::Create(Time(), Value(), std::move(func));
168 } 172 }
169 173
170 scoped_ptr<FilterKeyframe> FilterKeyframe::Create( 174 std::unique_ptr<FilterKeyframe> FilterKeyframe::Create(
171 base::TimeDelta time, 175 base::TimeDelta time,
172 const FilterOperations& value, 176 const FilterOperations& value,
173 scoped_ptr<TimingFunction> timing_function) { 177 std::unique_ptr<TimingFunction> timing_function) {
174 return make_scoped_ptr( 178 return base::WrapUnique(
175 new FilterKeyframe(time, value, std::move(timing_function))); 179 new FilterKeyframe(time, value, std::move(timing_function)));
176 } 180 }
177 181
178 FilterKeyframe::FilterKeyframe(base::TimeDelta time, 182 FilterKeyframe::FilterKeyframe(base::TimeDelta time,
179 const FilterOperations& value, 183 const FilterOperations& value,
180 scoped_ptr<TimingFunction> timing_function) 184 std::unique_ptr<TimingFunction> timing_function)
181 : Keyframe(time, std::move(timing_function)), value_(value) {} 185 : Keyframe(time, std::move(timing_function)), value_(value) {}
182 186
183 FilterKeyframe::~FilterKeyframe() {} 187 FilterKeyframe::~FilterKeyframe() {}
184 188
185 const FilterOperations& FilterKeyframe::Value() const { 189 const FilterOperations& FilterKeyframe::Value() const {
186 return value_; 190 return value_;
187 } 191 }
188 192
189 scoped_ptr<FilterKeyframe> FilterKeyframe::Clone() const { 193 std::unique_ptr<FilterKeyframe> FilterKeyframe::Clone() const {
190 scoped_ptr<TimingFunction> func; 194 std::unique_ptr<TimingFunction> func;
191 if (timing_function()) 195 if (timing_function())
192 func = timing_function()->Clone(); 196 func = timing_function()->Clone();
193 return FilterKeyframe::Create(Time(), Value(), std::move(func)); 197 return FilterKeyframe::Create(Time(), Value(), std::move(func));
194 } 198 }
195 199
196 scoped_ptr<KeyframedColorAnimationCurve> KeyframedColorAnimationCurve:: 200 std::unique_ptr<KeyframedColorAnimationCurve>
197 Create() { 201 KeyframedColorAnimationCurve::Create() {
198 return make_scoped_ptr(new KeyframedColorAnimationCurve); 202 return base::WrapUnique(new KeyframedColorAnimationCurve);
199 } 203 }
200 204
201 KeyframedColorAnimationCurve::KeyframedColorAnimationCurve() {} 205 KeyframedColorAnimationCurve::KeyframedColorAnimationCurve() {}
202 206
203 KeyframedColorAnimationCurve::~KeyframedColorAnimationCurve() {} 207 KeyframedColorAnimationCurve::~KeyframedColorAnimationCurve() {}
204 208
205 void KeyframedColorAnimationCurve::AddKeyframe( 209 void KeyframedColorAnimationCurve::AddKeyframe(
206 scoped_ptr<ColorKeyframe> keyframe) { 210 std::unique_ptr<ColorKeyframe> keyframe) {
207 InsertKeyframe(std::move(keyframe), &keyframes_); 211 InsertKeyframe(std::move(keyframe), &keyframes_);
208 } 212 }
209 213
210 base::TimeDelta KeyframedColorAnimationCurve::Duration() const { 214 base::TimeDelta KeyframedColorAnimationCurve::Duration() const {
211 return keyframes_.back()->Time() - keyframes_.front()->Time(); 215 return keyframes_.back()->Time() - keyframes_.front()->Time();
212 } 216 }
213 217
214 scoped_ptr<AnimationCurve> KeyframedColorAnimationCurve::Clone() const { 218 std::unique_ptr<AnimationCurve> KeyframedColorAnimationCurve::Clone() const {
215 scoped_ptr<KeyframedColorAnimationCurve> to_return = 219 std::unique_ptr<KeyframedColorAnimationCurve> to_return =
216 KeyframedColorAnimationCurve::Create(); 220 KeyframedColorAnimationCurve::Create();
217 for (size_t i = 0; i < keyframes_.size(); ++i) 221 for (size_t i = 0; i < keyframes_.size(); ++i)
218 to_return->AddKeyframe(keyframes_[i]->Clone()); 222 to_return->AddKeyframe(keyframes_[i]->Clone());
219 223
220 if (timing_function_) 224 if (timing_function_)
221 to_return->SetTimingFunction(timing_function_->Clone()); 225 to_return->SetTimingFunction(timing_function_->Clone());
222 226
223 return std::move(to_return); 227 return std::move(to_return);
224 } 228 }
225 229
226 SkColor KeyframedColorAnimationCurve::GetValue(base::TimeDelta t) const { 230 SkColor KeyframedColorAnimationCurve::GetValue(base::TimeDelta t) const {
227 if (t <= keyframes_.front()->Time()) 231 if (t <= keyframes_.front()->Time())
228 return keyframes_.front()->Value(); 232 return keyframes_.front()->Value();
229 233
230 if (t >= keyframes_.back()->Time()) 234 if (t >= keyframes_.back()->Time())
231 return keyframes_.back()->Value(); 235 return keyframes_.back()->Value();
232 236
233 t = TransformedAnimationTime(keyframes_, timing_function_, t); 237 t = TransformedAnimationTime(keyframes_, timing_function_, t);
234 size_t i = GetActiveKeyframe(keyframes_, t); 238 size_t i = GetActiveKeyframe(keyframes_, t);
235 double progress = TransformedKeyframeProgress(keyframes_, t, i); 239 double progress = TransformedKeyframeProgress(keyframes_, t, i);
236 240
237 return gfx::Tween::ColorValueBetween( 241 return gfx::Tween::ColorValueBetween(
238 progress, keyframes_[i]->Value(), keyframes_[i + 1]->Value()); 242 progress, keyframes_[i]->Value(), keyframes_[i + 1]->Value());
239 } 243 }
240 244
241 // KeyframedFloatAnimationCurve 245 // KeyframedFloatAnimationCurve
242 246
243 scoped_ptr<KeyframedFloatAnimationCurve> KeyframedFloatAnimationCurve:: 247 std::unique_ptr<KeyframedFloatAnimationCurve>
244 Create() { 248 KeyframedFloatAnimationCurve::Create() {
245 return make_scoped_ptr(new KeyframedFloatAnimationCurve); 249 return base::WrapUnique(new KeyframedFloatAnimationCurve);
246 } 250 }
247 251
248 KeyframedFloatAnimationCurve::KeyframedFloatAnimationCurve() {} 252 KeyframedFloatAnimationCurve::KeyframedFloatAnimationCurve() {}
249 253
250 KeyframedFloatAnimationCurve::~KeyframedFloatAnimationCurve() {} 254 KeyframedFloatAnimationCurve::~KeyframedFloatAnimationCurve() {}
251 255
252 void KeyframedFloatAnimationCurve::AddKeyframe( 256 void KeyframedFloatAnimationCurve::AddKeyframe(
253 scoped_ptr<FloatKeyframe> keyframe) { 257 std::unique_ptr<FloatKeyframe> keyframe) {
254 InsertKeyframe(std::move(keyframe), &keyframes_); 258 InsertKeyframe(std::move(keyframe), &keyframes_);
255 } 259 }
256 260
257 base::TimeDelta KeyframedFloatAnimationCurve::Duration() const { 261 base::TimeDelta KeyframedFloatAnimationCurve::Duration() const {
258 return keyframes_.back()->Time() - keyframes_.front()->Time(); 262 return keyframes_.back()->Time() - keyframes_.front()->Time();
259 } 263 }
260 264
261 scoped_ptr<AnimationCurve> KeyframedFloatAnimationCurve::Clone() const { 265 std::unique_ptr<AnimationCurve> KeyframedFloatAnimationCurve::Clone() const {
262 scoped_ptr<KeyframedFloatAnimationCurve> to_return = 266 std::unique_ptr<KeyframedFloatAnimationCurve> to_return =
263 KeyframedFloatAnimationCurve::Create(); 267 KeyframedFloatAnimationCurve::Create();
264 for (size_t i = 0; i < keyframes_.size(); ++i) 268 for (size_t i = 0; i < keyframes_.size(); ++i)
265 to_return->AddKeyframe(keyframes_[i]->Clone()); 269 to_return->AddKeyframe(keyframes_[i]->Clone());
266 270
267 if (timing_function_) 271 if (timing_function_)
268 to_return->SetTimingFunction(timing_function_->Clone()); 272 to_return->SetTimingFunction(timing_function_->Clone());
269 273
270 return std::move(to_return); 274 return std::move(to_return);
271 } 275 }
272 276
273 float KeyframedFloatAnimationCurve::GetValue(base::TimeDelta t) const { 277 float KeyframedFloatAnimationCurve::GetValue(base::TimeDelta t) const {
274 if (t <= keyframes_.front()->Time()) 278 if (t <= keyframes_.front()->Time())
275 return keyframes_.front()->Value(); 279 return keyframes_.front()->Value();
276 280
277 if (t >= keyframes_.back()->Time()) 281 if (t >= keyframes_.back()->Time())
278 return keyframes_.back()->Value(); 282 return keyframes_.back()->Value();
279 283
280 t = TransformedAnimationTime(keyframes_, timing_function_, t); 284 t = TransformedAnimationTime(keyframes_, timing_function_, t);
281 size_t i = GetActiveKeyframe(keyframes_, t); 285 size_t i = GetActiveKeyframe(keyframes_, t);
282 double progress = TransformedKeyframeProgress(keyframes_, t, i); 286 double progress = TransformedKeyframeProgress(keyframes_, t, i);
283 287
284 return keyframes_[i]->Value() + 288 return keyframes_[i]->Value() +
285 (keyframes_[i+1]->Value() - keyframes_[i]->Value()) * progress; 289 (keyframes_[i+1]->Value() - keyframes_[i]->Value()) * progress;
286 } 290 }
287 291
288 scoped_ptr<KeyframedTransformAnimationCurve> KeyframedTransformAnimationCurve:: 292 std::unique_ptr<KeyframedTransformAnimationCurve>
289 Create() { 293 KeyframedTransformAnimationCurve::Create() {
290 return make_scoped_ptr(new KeyframedTransformAnimationCurve); 294 return base::WrapUnique(new KeyframedTransformAnimationCurve);
291 } 295 }
292 296
293 KeyframedTransformAnimationCurve::KeyframedTransformAnimationCurve() {} 297 KeyframedTransformAnimationCurve::KeyframedTransformAnimationCurve() {}
294 298
295 KeyframedTransformAnimationCurve::~KeyframedTransformAnimationCurve() {} 299 KeyframedTransformAnimationCurve::~KeyframedTransformAnimationCurve() {}
296 300
297 void KeyframedTransformAnimationCurve::AddKeyframe( 301 void KeyframedTransformAnimationCurve::AddKeyframe(
298 scoped_ptr<TransformKeyframe> keyframe) { 302 std::unique_ptr<TransformKeyframe> keyframe) {
299 InsertKeyframe(std::move(keyframe), &keyframes_); 303 InsertKeyframe(std::move(keyframe), &keyframes_);
300 } 304 }
301 305
302 base::TimeDelta KeyframedTransformAnimationCurve::Duration() const { 306 base::TimeDelta KeyframedTransformAnimationCurve::Duration() const {
303 return keyframes_.back()->Time() - keyframes_.front()->Time(); 307 return keyframes_.back()->Time() - keyframes_.front()->Time();
304 } 308 }
305 309
306 scoped_ptr<AnimationCurve> KeyframedTransformAnimationCurve::Clone() const { 310 std::unique_ptr<AnimationCurve> KeyframedTransformAnimationCurve::Clone()
307 scoped_ptr<KeyframedTransformAnimationCurve> to_return = 311 const {
312 std::unique_ptr<KeyframedTransformAnimationCurve> to_return =
308 KeyframedTransformAnimationCurve::Create(); 313 KeyframedTransformAnimationCurve::Create();
309 for (size_t i = 0; i < keyframes_.size(); ++i) 314 for (size_t i = 0; i < keyframes_.size(); ++i)
310 to_return->AddKeyframe(keyframes_[i]->Clone()); 315 to_return->AddKeyframe(keyframes_[i]->Clone());
311 316
312 if (timing_function_) 317 if (timing_function_)
313 to_return->SetTimingFunction(timing_function_->Clone()); 318 to_return->SetTimingFunction(timing_function_->Clone());
314 319
315 return std::move(to_return); 320 return std::move(to_return);
316 } 321 }
317 322
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 return false; 423 return false;
419 float max_scale_for_segment = 424 float max_scale_for_segment =
420 fmax(std::abs(target_scale_for_segment.x()), 425 fmax(std::abs(target_scale_for_segment.x()),
421 fmax(std::abs(target_scale_for_segment.y()), 426 fmax(std::abs(target_scale_for_segment.y()),
422 std::abs(target_scale_for_segment.z()))); 427 std::abs(target_scale_for_segment.z())));
423 *max_scale = fmax(*max_scale, max_scale_for_segment); 428 *max_scale = fmax(*max_scale, max_scale_for_segment);
424 } 429 }
425 return true; 430 return true;
426 } 431 }
427 432
428 scoped_ptr<KeyframedFilterAnimationCurve> KeyframedFilterAnimationCurve:: 433 std::unique_ptr<KeyframedFilterAnimationCurve>
429 Create() { 434 KeyframedFilterAnimationCurve::Create() {
430 return make_scoped_ptr(new KeyframedFilterAnimationCurve); 435 return base::WrapUnique(new KeyframedFilterAnimationCurve);
431 } 436 }
432 437
433 KeyframedFilterAnimationCurve::KeyframedFilterAnimationCurve() {} 438 KeyframedFilterAnimationCurve::KeyframedFilterAnimationCurve() {}
434 439
435 KeyframedFilterAnimationCurve::~KeyframedFilterAnimationCurve() {} 440 KeyframedFilterAnimationCurve::~KeyframedFilterAnimationCurve() {}
436 441
437 void KeyframedFilterAnimationCurve::AddKeyframe( 442 void KeyframedFilterAnimationCurve::AddKeyframe(
438 scoped_ptr<FilterKeyframe> keyframe) { 443 std::unique_ptr<FilterKeyframe> keyframe) {
439 InsertKeyframe(std::move(keyframe), &keyframes_); 444 InsertKeyframe(std::move(keyframe), &keyframes_);
440 } 445 }
441 446
442 base::TimeDelta KeyframedFilterAnimationCurve::Duration() const { 447 base::TimeDelta KeyframedFilterAnimationCurve::Duration() const {
443 return keyframes_.back()->Time() - keyframes_.front()->Time(); 448 return keyframes_.back()->Time() - keyframes_.front()->Time();
444 } 449 }
445 450
446 scoped_ptr<AnimationCurve> KeyframedFilterAnimationCurve::Clone() const { 451 std::unique_ptr<AnimationCurve> KeyframedFilterAnimationCurve::Clone() const {
447 scoped_ptr<KeyframedFilterAnimationCurve> to_return = 452 std::unique_ptr<KeyframedFilterAnimationCurve> to_return =
448 KeyframedFilterAnimationCurve::Create(); 453 KeyframedFilterAnimationCurve::Create();
449 for (size_t i = 0; i < keyframes_.size(); ++i) 454 for (size_t i = 0; i < keyframes_.size(); ++i)
450 to_return->AddKeyframe(keyframes_[i]->Clone()); 455 to_return->AddKeyframe(keyframes_[i]->Clone());
451 456
452 if (timing_function_) 457 if (timing_function_)
453 to_return->SetTimingFunction(timing_function_->Clone()); 458 to_return->SetTimingFunction(timing_function_->Clone());
454 459
455 return std::move(to_return); 460 return std::move(to_return);
456 } 461 }
457 462
(...skipping 15 matching lines...) Expand all
473 bool KeyframedFilterAnimationCurve::HasFilterThatMovesPixels() const { 478 bool KeyframedFilterAnimationCurve::HasFilterThatMovesPixels() const {
474 for (size_t i = 0; i < keyframes_.size(); ++i) { 479 for (size_t i = 0; i < keyframes_.size(); ++i) {
475 if (keyframes_[i]->Value().HasFilterThatMovesPixels()) { 480 if (keyframes_[i]->Value().HasFilterThatMovesPixels()) {
476 return true; 481 return true;
477 } 482 }
478 } 483 }
479 return false; 484 return false;
480 } 485 }
481 486
482 } // namespace cc 487 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/keyframed_animation_curve.h ('k') | cc/animation/keyframed_animation_curve_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698