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

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

Issue 1437413002: cc: Remove ScopedPtrVector and cc::remove_if. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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/keyframed_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 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 animation_host_->UnregisterPlayerForLayer(layer_id_, this); 98 animation_host_->UnregisterPlayerForLayer(layer_id_, this);
99 } 99 }
100 100
101 void AnimationPlayer::BindElementAnimations() { 101 void AnimationPlayer::BindElementAnimations() {
102 DCHECK(!element_animations_); 102 DCHECK(!element_animations_);
103 element_animations_ = 103 element_animations_ =
104 animation_host_->GetElementAnimationsForLayerId(layer_id_); 104 animation_host_->GetElementAnimationsForLayerId(layer_id_);
105 DCHECK(element_animations_); 105 DCHECK(element_animations_);
106 106
107 // Pass all accumulated animations to LAC. 107 // Pass all accumulated animations to LAC.
108 for (auto it = animations_.begin(); it != animations_.end(); ++it) 108 for (auto& animation : animations_) {
109 element_animations_->layer_animation_controller()->AddAnimation( 109 element_animations_->layer_animation_controller()->AddAnimation(
110 animations_.take(it)); 110 std::move(animation));
111 }
111 if (!animations_.empty()) 112 if (!animations_.empty())
112 SetNeedsCommit(); 113 SetNeedsCommit();
113 animations_.clear(); 114 animations_.clear();
114 } 115 }
115 116
116 void AnimationPlayer::UnbindElementAnimations() { 117 void AnimationPlayer::UnbindElementAnimations() {
117 element_animations_ = nullptr; 118 element_animations_ = nullptr;
118 DCHECK(animations_.empty()); 119 DCHECK(animations_.empty());
119 } 120 }
120 121
(...skipping 16 matching lines...) Expand all
137 animation_id, base::TimeDelta::FromSecondsD(time_offset)); 138 animation_id, base::TimeDelta::FromSecondsD(time_offset));
138 SetNeedsCommit(); 139 SetNeedsCommit();
139 } 140 }
140 141
141 void AnimationPlayer::RemoveAnimation(int animation_id) { 142 void AnimationPlayer::RemoveAnimation(int animation_id) {
142 if (element_animations_) { 143 if (element_animations_) {
143 element_animations_->layer_animation_controller()->RemoveAnimation( 144 element_animations_->layer_animation_controller()->RemoveAnimation(
144 animation_id); 145 animation_id);
145 SetNeedsCommit(); 146 SetNeedsCommit();
146 } else { 147 } else {
147 auto animations_to_remove = animations_.remove_if([animation_id]( 148 auto animations_to_remove =
148 Animation* animation) { return animation->id() == animation_id; }); 149 std::remove_if(animations_.begin(), animations_.end(),
150 [animation_id](const scoped_ptr<Animation>& animation) {
151 return animation->id() == animation_id;
152 });
149 animations_.erase(animations_to_remove, animations_.end()); 153 animations_.erase(animations_to_remove, animations_.end());
150 } 154 }
151 } 155 }
152 156
153 void AnimationPlayer::PushPropertiesTo(AnimationPlayer* player_impl) { 157 void AnimationPlayer::PushPropertiesTo(AnimationPlayer* player_impl) {
154 if (!element_animations_) { 158 if (!element_animations_) {
155 if (player_impl->element_animations()) 159 if (player_impl->element_animations())
156 player_impl->DetachLayer(); 160 player_impl->DetachLayer();
157 return; 161 return;
158 } 162 }
(...skipping 21 matching lines...) Expand all
180 target_property, group); 184 target_property, group);
181 } 185 }
182 186
183 void AnimationPlayer::SetNeedsCommit() { 187 void AnimationPlayer::SetNeedsCommit() {
184 DCHECK(animation_host_); 188 DCHECK(animation_host_);
185 animation_host_->SetNeedsCommit(); 189 animation_host_->SetNeedsCommit();
186 animation_host_->SetNeedsRebuildPropertyTrees(); 190 animation_host_->SetNeedsRebuildPropertyTrees();
187 } 191 }
188 192
189 } // namespace cc 193 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/animation_player.h ('k') | cc/animation/keyframed_animation_curve.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698