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

Side by Side Diff: cc/animation/animation_player.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_player.h ('k') | cc/animation/animation_registrar.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_player.h" 5 #include "cc/animation/animation_player.h"
6 6
7 #include "cc/animation/animation_delegate.h" 7 #include "cc/animation/animation_delegate.h"
8 #include "cc/animation/animation_host.h" 8 #include "cc/animation/animation_host.h"
9 #include "cc/animation/animation_timeline.h" 9 #include "cc/animation/animation_timeline.h"
10 #include "cc/animation/element_animations.h" 10 #include "cc/animation/element_animations.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 if (!animations_.empty()) 111 if (!animations_.empty())
112 SetNeedsCommit(); 112 SetNeedsCommit();
113 animations_.clear(); 113 animations_.clear();
114 } 114 }
115 115
116 void AnimationPlayer::UnbindElementAnimations() { 116 void AnimationPlayer::UnbindElementAnimations() {
117 element_animations_ = nullptr; 117 element_animations_ = nullptr;
118 DCHECK(animations_.empty()); 118 DCHECK(animations_.empty());
119 } 119 }
120 120
121 void AnimationPlayer::AddAnimation(scoped_ptr<Animation> animation) { 121 void AnimationPlayer::AddAnimation(std::unique_ptr<Animation> animation) {
122 DCHECK(animation->target_property() != TargetProperty::SCROLL_OFFSET || 122 DCHECK(animation->target_property() != TargetProperty::SCROLL_OFFSET ||
123 (animation_host_ && animation_host_->SupportsScrollAnimations())); 123 (animation_host_ && animation_host_->SupportsScrollAnimations()));
124 124
125 if (element_animations_) { 125 if (element_animations_) {
126 element_animations_->layer_animation_controller()->AddAnimation( 126 element_animations_->layer_animation_controller()->AddAnimation(
127 std::move(animation)); 127 std::move(animation));
128 SetNeedsCommit(); 128 SetNeedsCommit();
129 } else { 129 } else {
130 animations_.push_back(std::move(animation)); 130 animations_.push_back(std::move(animation));
131 } 131 }
132 } 132 }
133 133
134 void AnimationPlayer::PauseAnimation(int animation_id, double time_offset) { 134 void AnimationPlayer::PauseAnimation(int animation_id, double time_offset) {
135 DCHECK(element_animations_); 135 DCHECK(element_animations_);
136 element_animations_->layer_animation_controller()->PauseAnimation( 136 element_animations_->layer_animation_controller()->PauseAnimation(
137 animation_id, base::TimeDelta::FromSecondsD(time_offset)); 137 animation_id, base::TimeDelta::FromSecondsD(time_offset));
138 SetNeedsCommit(); 138 SetNeedsCommit();
139 } 139 }
140 140
141 void AnimationPlayer::RemoveAnimation(int animation_id) { 141 void AnimationPlayer::RemoveAnimation(int animation_id) {
142 if (element_animations_) { 142 if (element_animations_) {
143 element_animations_->layer_animation_controller()->RemoveAnimation( 143 element_animations_->layer_animation_controller()->RemoveAnimation(
144 animation_id); 144 animation_id);
145 SetNeedsCommit(); 145 SetNeedsCommit();
146 } else { 146 } else {
147 auto animations_to_remove = 147 auto animations_to_remove = std::remove_if(
148 std::remove_if(animations_.begin(), animations_.end(), 148 animations_.begin(), animations_.end(),
149 [animation_id](const scoped_ptr<Animation>& animation) { 149 [animation_id](const std::unique_ptr<Animation>& animation) {
150 return animation->id() == animation_id; 150 return animation->id() == animation_id;
151 }); 151 });
152 animations_.erase(animations_to_remove, animations_.end()); 152 animations_.erase(animations_to_remove, animations_.end());
153 } 153 }
154 } 154 }
155 155
156 void AnimationPlayer::AbortAnimation(int animation_id) { 156 void AnimationPlayer::AbortAnimation(int animation_id) {
157 DCHECK(element_animations_); 157 DCHECK(element_animations_);
158 element_animations_->layer_animation_controller()->AbortAnimation( 158 element_animations_->layer_animation_controller()->AbortAnimation(
159 animation_id); 159 animation_id);
160 SetNeedsCommit(); 160 SetNeedsCommit();
161 } 161 }
162 162
163 void AnimationPlayer::AbortAnimations(TargetProperty::Type target_property, 163 void AnimationPlayer::AbortAnimations(TargetProperty::Type target_property,
164 bool needs_completion) { 164 bool needs_completion) {
165 if (element_animations_) { 165 if (element_animations_) {
166 element_animations_->layer_animation_controller()->AbortAnimations( 166 element_animations_->layer_animation_controller()->AbortAnimations(
167 target_property, needs_completion); 167 target_property, needs_completion);
168 SetNeedsCommit(); 168 SetNeedsCommit();
169 } else { 169 } else {
170 auto animations_to_remove = std::remove_if( 170 auto animations_to_remove = std::remove_if(
171 animations_.begin(), animations_.end(), 171 animations_.begin(), animations_.end(),
172 [target_property](const scoped_ptr<Animation>& animation) { 172 [target_property](const std::unique_ptr<Animation>& animation) {
173 return animation->target_property() == target_property; 173 return animation->target_property() == target_property;
174 }); 174 });
175 animations_.erase(animations_to_remove, animations_.end()); 175 animations_.erase(animations_to_remove, animations_.end());
176 } 176 }
177 } 177 }
178 178
179 void AnimationPlayer::PushPropertiesTo(AnimationPlayer* player_impl) { 179 void AnimationPlayer::PushPropertiesTo(AnimationPlayer* player_impl) {
180 if (layer_id_ != player_impl->layer_id()) { 180 if (layer_id_ != player_impl->layer_id()) {
181 if (player_impl->layer_id()) 181 if (player_impl->layer_id())
182 player_impl->DetachLayer(); 182 player_impl->DetachLayer();
(...skipping 26 matching lines...) Expand all
209 int group) { 209 int group) {
210 if (layer_animation_delegate_) 210 if (layer_animation_delegate_)
211 layer_animation_delegate_->NotifyAnimationAborted(monotonic_time, 211 layer_animation_delegate_->NotifyAnimationAborted(monotonic_time,
212 target_property, group); 212 target_property, group);
213 } 213 }
214 214
215 void AnimationPlayer::NotifyAnimationTakeover( 215 void AnimationPlayer::NotifyAnimationTakeover(
216 base::TimeTicks monotonic_time, 216 base::TimeTicks monotonic_time,
217 TargetProperty::Type target_property, 217 TargetProperty::Type target_property,
218 double animation_start_time, 218 double animation_start_time,
219 scoped_ptr<AnimationCurve> curve) { 219 std::unique_ptr<AnimationCurve> curve) {
220 if (layer_animation_delegate_) { 220 if (layer_animation_delegate_) {
221 DCHECK(curve); 221 DCHECK(curve);
222 layer_animation_delegate_->NotifyAnimationTakeover( 222 layer_animation_delegate_->NotifyAnimationTakeover(
223 monotonic_time, target_property, animation_start_time, 223 monotonic_time, target_property, animation_start_time,
224 std::move(curve)); 224 std::move(curve));
225 } 225 }
226 } 226 }
227 227
228 void AnimationPlayer::SetNeedsCommit() { 228 void AnimationPlayer::SetNeedsCommit() {
229 DCHECK(animation_host_); 229 DCHECK(animation_host_);
230 animation_host_->SetNeedsCommit(); 230 animation_host_->SetNeedsCommit();
231 animation_host_->SetNeedsRebuildPropertyTrees(); 231 animation_host_->SetNeedsRebuildPropertyTrees();
232 } 232 }
233 233
234 } // namespace cc 234 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/animation_player.h ('k') | cc/animation/animation_registrar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698