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

Side by Side Diff: cc/animation/animation.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
« no previous file with comments | « cc/animation/animation.h ('k') | cc/animation/animation_curve.h » ('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 #include "cc/animation/animation.h" 5 #include "cc/animation/animation.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/memory/ptr_util.h"
9 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
10 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
11 #include "cc/animation/animation_curve.h" 12 #include "cc/animation/animation_curve.h"
12 #include "cc/base/time_util.h" 13 #include "cc/base/time_util.h"
13 14
14 namespace { 15 namespace {
15 16
16 // This should match the RunState enum. 17 // This should match the RunState enum.
17 static const char* const s_runStateNames[] = {"WAITING_FOR_TARGET_AVAILABILITY", 18 static const char* const s_runStateNames[] = {"WAITING_FOR_TARGET_AVAILABILITY",
18 "WAITING_FOR_DELETION", 19 "WAITING_FOR_DELETION",
19 "STARTING", 20 "STARTING",
20 "RUNNING", 21 "RUNNING",
21 "PAUSED", 22 "PAUSED",
22 "FINISHED", 23 "FINISHED",
23 "ABORTED", 24 "ABORTED",
24 "ABORTED_BUT_NEEDS_COMPLETION"}; 25 "ABORTED_BUT_NEEDS_COMPLETION"};
25 26
26 static_assert(static_cast<int>(cc::Animation::LAST_RUN_STATE) + 1 == 27 static_assert(static_cast<int>(cc::Animation::LAST_RUN_STATE) + 1 ==
27 arraysize(s_runStateNames), 28 arraysize(s_runStateNames),
28 "RunStateEnumSize should equal the number of elements in " 29 "RunStateEnumSize should equal the number of elements in "
29 "s_runStateNames"); 30 "s_runStateNames");
30 31
31 } // namespace 32 } // namespace
32 33
33 namespace cc { 34 namespace cc {
34 35
35 scoped_ptr<Animation> Animation::Create(scoped_ptr<AnimationCurve> curve, 36 std::unique_ptr<Animation> Animation::Create(
36 int animation_id, 37 std::unique_ptr<AnimationCurve> curve,
37 int group_id, 38 int animation_id,
38 TargetProperty::Type target_property) { 39 int group_id,
39 return make_scoped_ptr( 40 TargetProperty::Type target_property) {
41 return base::WrapUnique(
40 new Animation(std::move(curve), animation_id, group_id, target_property)); 42 new Animation(std::move(curve), animation_id, group_id, target_property));
41 } 43 }
42 44
43 Animation::Animation(scoped_ptr<AnimationCurve> curve, 45 Animation::Animation(std::unique_ptr<AnimationCurve> curve,
44 int animation_id, 46 int animation_id,
45 int group_id, 47 int group_id,
46 TargetProperty::Type target_property) 48 TargetProperty::Type target_property)
47 : curve_(std::move(curve)), 49 : curve_(std::move(curve)),
48 id_(animation_id), 50 id_(animation_id),
49 group_(group_id), 51 group_(group_id),
50 target_property_(target_property), 52 target_property_(target_property),
51 run_state_(WAITING_FOR_TARGET_AVAILABILITY), 53 run_state_(WAITING_FOR_TARGET_AVAILABILITY),
52 iterations_(1), 54 iterations_(1),
53 iteration_start_(0), 55 iteration_start_(0),
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 (direction_ == DIRECTION_ALTERNATE && iteration % 2 == 1) || 233 (direction_ == DIRECTION_ALTERNATE && iteration % 2 == 1) ||
232 (direction_ == DIRECTION_ALTERNATE_REVERSE && iteration % 2 == 0); 234 (direction_ == DIRECTION_ALTERNATE_REVERSE && iteration % 2 == 0);
233 235
234 // If we are running the animation in reverse direction, reverse the result 236 // If we are running the animation in reverse direction, reverse the result
235 if (reverse) 237 if (reverse)
236 iteration_time = curve_->Duration() - iteration_time; 238 iteration_time = curve_->Duration() - iteration_time;
237 239
238 return iteration_time; 240 return iteration_time;
239 } 241 }
240 242
241 scoped_ptr<Animation> Animation::CloneAndInitialize( 243 std::unique_ptr<Animation> Animation::CloneAndInitialize(
242 RunState initial_run_state) const { 244 RunState initial_run_state) const {
243 scoped_ptr<Animation> to_return( 245 std::unique_ptr<Animation> to_return(
244 new Animation(curve_->Clone(), id_, group_, target_property_)); 246 new Animation(curve_->Clone(), id_, group_, target_property_));
245 to_return->run_state_ = initial_run_state; 247 to_return->run_state_ = initial_run_state;
246 to_return->iterations_ = iterations_; 248 to_return->iterations_ = iterations_;
247 to_return->iteration_start_ = iteration_start_; 249 to_return->iteration_start_ = iteration_start_;
248 to_return->start_time_ = start_time_; 250 to_return->start_time_ = start_time_;
249 to_return->pause_time_ = pause_time_; 251 to_return->pause_time_ = pause_time_;
250 to_return->total_paused_time_ = total_paused_time_; 252 to_return->total_paused_time_ = total_paused_time_;
251 to_return->time_offset_ = time_offset_; 253 to_return->time_offset_ = time_offset_;
252 to_return->direction_ = direction_; 254 to_return->direction_ = direction_;
253 to_return->playback_rate_ = playback_rate_; 255 to_return->playback_rate_ = playback_rate_;
254 to_return->fill_mode_ = fill_mode_; 256 to_return->fill_mode_ = fill_mode_;
255 DCHECK(!to_return->is_controlling_instance_); 257 DCHECK(!to_return->is_controlling_instance_);
256 to_return->is_controlling_instance_ = true; 258 to_return->is_controlling_instance_ = true;
257 return to_return; 259 return to_return;
258 } 260 }
259 261
260 void Animation::PushPropertiesTo(Animation* other) const { 262 void Animation::PushPropertiesTo(Animation* other) const {
261 // Currently, we only push changes due to pausing and resuming animations on 263 // Currently, we only push changes due to pausing and resuming animations on
262 // the main thread. 264 // the main thread.
263 if (run_state_ == Animation::PAUSED || 265 if (run_state_ == Animation::PAUSED ||
264 other->run_state_ == Animation::PAUSED) { 266 other->run_state_ == Animation::PAUSED) {
265 other->run_state_ = run_state_; 267 other->run_state_ = run_state_;
266 other->pause_time_ = pause_time_; 268 other->pause_time_ = pause_time_;
267 other->total_paused_time_ = total_paused_time_; 269 other->total_paused_time_ = total_paused_time_;
268 } 270 }
269 } 271 }
270 272
271 } // namespace cc 273 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/animation.h ('k') | cc/animation/animation_curve.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698