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

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

Issue 2756963002: Purge impl-only animations awaiting deletion in AnimationPlayer::UpdateState. (Closed)
Patch Set: Created 3 years, 9 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/element_animations_unittest.cc » ('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 <algorithm> 7 #include <algorithm>
8 8
9 #include "cc/animation/animation_delegate.h" 9 #include "cc/animation/animation_delegate.h"
10 #include "cc/animation/animation_events.h" 10 #include "cc/animation/animation_events.h"
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 if (player_impl->element_id()) 245 if (player_impl->element_id())
246 player_impl->DetachElement(); 246 player_impl->DetachElement();
247 if (element_id_) 247 if (element_id_)
248 player_impl->AttachElement(element_id_); 248 player_impl->AttachElement(element_id_);
249 } 249 }
250 250
251 if (!has_any_animation() && !player_impl->has_any_animation()) 251 if (!has_any_animation() && !player_impl->has_any_animation())
252 return; 252 return;
253 253
254 MarkAbortedAnimationsForDeletion(player_impl); 254 MarkAbortedAnimationsForDeletion(player_impl);
255 PurgeAnimationsMarkedForDeletion(); 255 PurgeAnimationsMarkedForDeletion(/* impl_only */ false);
256 PushNewAnimationsToImplThread(player_impl); 256 PushNewAnimationsToImplThread(player_impl);
257 257
258 // Remove finished impl side animations only after pushing, 258 // Remove finished impl side animations only after pushing,
259 // and only after the animations are deleted on the main thread 259 // and only after the animations are deleted on the main thread
260 // this insures we will never push an animation twice. 260 // this insures we will never push an animation twice.
261 RemoveAnimationsCompletedOnMainThread(player_impl); 261 RemoveAnimationsCompletedOnMainThread(player_impl);
262 262
263 PushPropertiesToImplThread(player_impl); 263 PushPropertiesToImplThread(player_impl);
264 264
265 player_impl->UpdateTickingState(UpdateTickingType::NORMAL); 265 player_impl->UpdateTickingState(UpdateTickingType::NORMAL);
(...skipping 24 matching lines...) Expand all
290 // Animate hasn't been called, this happens if an element has been added 290 // Animate hasn't been called, this happens if an element has been added
291 // between the Commit and Draw phases. 291 // between the Commit and Draw phases.
292 if (last_tick_time_ == base::TimeTicks()) 292 if (last_tick_time_ == base::TimeTicks())
293 return; 293 return;
294 294
295 if (start_ready_animations) 295 if (start_ready_animations)
296 PromoteStartedAnimations(last_tick_time_, events); 296 PromoteStartedAnimations(last_tick_time_, events);
297 297
298 MarkFinishedAnimations(last_tick_time_); 298 MarkFinishedAnimations(last_tick_time_);
299 MarkAnimationsForDeletion(last_tick_time_, events); 299 MarkAnimationsForDeletion(last_tick_time_, events);
300 PurgeAnimationsMarkedForDeletion(/* impl_only */ true);
300 301
301 if (start_ready_animations) { 302 if (start_ready_animations) {
302 if (needs_to_start_animations()) { 303 if (needs_to_start_animations()) {
303 StartAnimations(last_tick_time_); 304 StartAnimations(last_tick_time_);
304 PromoteStartedAnimations(last_tick_time_, events); 305 PromoteStartedAnimations(last_tick_time_, events);
305 } 306 }
306 } 307 }
307 308
308 UpdateTickingState(UpdateTickingType::NORMAL); 309 UpdateTickingState(UpdateTickingType::NORMAL);
309 } 310 }
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 last_tick_time_); 1092 last_tick_time_);
1092 animation_aborted = true; 1093 animation_aborted = true;
1093 } 1094 }
1094 } 1095 }
1095 } 1096 }
1096 1097
1097 if (element_animations_ && animation_aborted) 1098 if (element_animations_ && animation_aborted)
1098 element_animations_->SetNeedsUpdateImplClientState(); 1099 element_animations_->SetNeedsUpdateImplClientState();
1099 } 1100 }
1100 1101
1101 void AnimationPlayer::PurgeAnimationsMarkedForDeletion() { 1102 void AnimationPlayer::PurgeAnimationsMarkedForDeletion(bool impl_only) {
1102 animations_.erase( 1103 animations_.erase(
1103 std::remove_if(animations_.begin(), animations_.end(), 1104 std::remove_if(animations_.begin(), animations_.end(),
1104 [](const std::unique_ptr<Animation>& animation) { 1105 [impl_only](const std::unique_ptr<Animation>& animation) {
1105 return animation->run_state() == 1106 return animation->run_state() ==
1106 Animation::WAITING_FOR_DELETION; 1107 Animation::WAITING_FOR_DELETION &&
1108 (!impl_only || animation->is_impl_only());
1107 }), 1109 }),
1108 animations_.end()); 1110 animations_.end());
1109 } 1111 }
1110 1112
1111 void AnimationPlayer::PushNewAnimationsToImplThread( 1113 void AnimationPlayer::PushNewAnimationsToImplThread(
1112 AnimationPlayer* animation_player_impl) const { 1114 AnimationPlayer* animation_player_impl) const {
1113 // Any new animations owned by the main thread's AnimationPlayer are cloned 1115 // Any new animations owned by the main thread's AnimationPlayer are cloned
1114 // and added to the impl thread's AnimationPlayer. 1116 // and added to the impl thread's AnimationPlayer.
1115 for (size_t i = 0; i < animations_.size(); ++i) { 1117 for (size_t i = 0; i < animations_.size(); ++i) {
1116 // If the animation is already running on the impl thread, there is no 1118 // If the animation is already running on the impl thread, there is no
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 if (current_impl) 1195 if (current_impl)
1194 animations_[i]->PushPropertiesTo(current_impl); 1196 animations_[i]->PushPropertiesTo(current_impl);
1195 } 1197 }
1196 1198
1197 animation_player_impl->scroll_offset_animation_was_interrupted_ = 1199 animation_player_impl->scroll_offset_animation_was_interrupted_ =
1198 scroll_offset_animation_was_interrupted_; 1200 scroll_offset_animation_was_interrupted_;
1199 scroll_offset_animation_was_interrupted_ = false; 1201 scroll_offset_animation_was_interrupted_ = false;
1200 } 1202 }
1201 1203
1202 } // namespace cc 1204 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/animation_player.h ('k') | cc/animation/element_animations_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698