| OLD | NEW |
| 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 "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "cc/animation/animation_delegate.h" | 10 #include "cc/animation/animation_delegate.h" |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 if (player_impl->element_id()) | 246 if (player_impl->element_id()) |
| 247 player_impl->DetachElement(); | 247 player_impl->DetachElement(); |
| 248 if (element_id_) | 248 if (element_id_) |
| 249 player_impl->AttachElement(element_id_); | 249 player_impl->AttachElement(element_id_); |
| 250 } | 250 } |
| 251 | 251 |
| 252 if (!has_any_animation() && !player_impl->has_any_animation()) | 252 if (!has_any_animation() && !player_impl->has_any_animation()) |
| 253 return; | 253 return; |
| 254 | 254 |
| 255 MarkAbortedAnimationsForDeletion(player_impl); | 255 MarkAbortedAnimationsForDeletion(player_impl); |
| 256 PurgeAnimationsMarkedForDeletion(); | 256 PurgeAnimationsMarkedForDeletion(/* impl_only */ false); |
| 257 PushNewAnimationsToImplThread(player_impl); | 257 PushNewAnimationsToImplThread(player_impl); |
| 258 | 258 |
| 259 // Remove finished impl side animations only after pushing, | 259 // Remove finished impl side animations only after pushing, |
| 260 // and only after the animations are deleted on the main thread | 260 // and only after the animations are deleted on the main thread |
| 261 // this insures we will never push an animation twice. | 261 // this insures we will never push an animation twice. |
| 262 RemoveAnimationsCompletedOnMainThread(player_impl); | 262 RemoveAnimationsCompletedOnMainThread(player_impl); |
| 263 | 263 |
| 264 PushPropertiesToImplThread(player_impl); | 264 PushPropertiesToImplThread(player_impl); |
| 265 | 265 |
| 266 player_impl->UpdateTickingState(UpdateTickingType::NORMAL); | 266 player_impl->UpdateTickingState(UpdateTickingType::NORMAL); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 291 // Animate hasn't been called, this happens if an element has been added | 291 // Animate hasn't been called, this happens if an element has been added |
| 292 // between the Commit and Draw phases. | 292 // between the Commit and Draw phases. |
| 293 if (last_tick_time_ == base::TimeTicks()) | 293 if (last_tick_time_ == base::TimeTicks()) |
| 294 return; | 294 return; |
| 295 | 295 |
| 296 if (start_ready_animations) | 296 if (start_ready_animations) |
| 297 PromoteStartedAnimations(last_tick_time_, events); | 297 PromoteStartedAnimations(last_tick_time_, events); |
| 298 | 298 |
| 299 MarkFinishedAnimations(last_tick_time_); | 299 MarkFinishedAnimations(last_tick_time_); |
| 300 MarkAnimationsForDeletion(last_tick_time_, events); | 300 MarkAnimationsForDeletion(last_tick_time_, events); |
| 301 PurgeAnimationsMarkedForDeletion(/* impl_only */ true); |
| 301 | 302 |
| 302 if (start_ready_animations) { | 303 if (start_ready_animations) { |
| 303 if (needs_to_start_animations()) { | 304 if (needs_to_start_animations()) { |
| 304 StartAnimations(last_tick_time_); | 305 StartAnimations(last_tick_time_); |
| 305 PromoteStartedAnimations(last_tick_time_, events); | 306 PromoteStartedAnimations(last_tick_time_, events); |
| 306 } | 307 } |
| 307 } | 308 } |
| 308 | 309 |
| 309 UpdateTickingState(UpdateTickingType::NORMAL); | 310 UpdateTickingState(UpdateTickingType::NORMAL); |
| 310 } | 311 } |
| (...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 last_tick_time_); | 1091 last_tick_time_); |
| 1091 animation_aborted = true; | 1092 animation_aborted = true; |
| 1092 } | 1093 } |
| 1093 } | 1094 } |
| 1094 } | 1095 } |
| 1095 | 1096 |
| 1096 if (element_animations_ && animation_aborted) | 1097 if (element_animations_ && animation_aborted) |
| 1097 element_animations_->SetNeedsUpdateImplClientState(); | 1098 element_animations_->SetNeedsUpdateImplClientState(); |
| 1098 } | 1099 } |
| 1099 | 1100 |
| 1100 void AnimationPlayer::PurgeAnimationsMarkedForDeletion() { | 1101 void AnimationPlayer::PurgeAnimationsMarkedForDeletion(bool impl_only) { |
| 1101 base::EraseIf(animations_, [](const std::unique_ptr<Animation>& animation) { | 1102 base::EraseIf( |
| 1102 return animation->run_state() == Animation::WAITING_FOR_DELETION; | 1103 animations_, [impl_only](const std::unique_ptr<Animation>& animation) { |
| 1103 }); | 1104 return animation->run_state() == Animation::WAITING_FOR_DELETION && |
| 1105 (!impl_only || animation->is_impl_only()); |
| 1106 }); |
| 1104 } | 1107 } |
| 1105 | 1108 |
| 1106 void AnimationPlayer::PushNewAnimationsToImplThread( | 1109 void AnimationPlayer::PushNewAnimationsToImplThread( |
| 1107 AnimationPlayer* animation_player_impl) const { | 1110 AnimationPlayer* animation_player_impl) const { |
| 1108 // Any new animations owned by the main thread's AnimationPlayer are cloned | 1111 // Any new animations owned by the main thread's AnimationPlayer are cloned |
| 1109 // and added to the impl thread's AnimationPlayer. | 1112 // and added to the impl thread's AnimationPlayer. |
| 1110 for (size_t i = 0; i < animations_.size(); ++i) { | 1113 for (size_t i = 0; i < animations_.size(); ++i) { |
| 1111 // If the animation is already running on the impl thread, there is no | 1114 // If the animation is already running on the impl thread, there is no |
| 1112 // need to copy it over. | 1115 // need to copy it over. |
| 1113 if (animation_player_impl->GetAnimationById(animations_[i]->id())) | 1116 if (animation_player_impl->GetAnimationById(animations_[i]->id())) |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1185 if (current_impl) | 1188 if (current_impl) |
| 1186 animations_[i]->PushPropertiesTo(current_impl); | 1189 animations_[i]->PushPropertiesTo(current_impl); |
| 1187 } | 1190 } |
| 1188 | 1191 |
| 1189 animation_player_impl->scroll_offset_animation_was_interrupted_ = | 1192 animation_player_impl->scroll_offset_animation_was_interrupted_ = |
| 1190 scroll_offset_animation_was_interrupted_; | 1193 scroll_offset_animation_was_interrupted_; |
| 1191 scroll_offset_animation_was_interrupted_ = false; | 1194 scroll_offset_animation_was_interrupted_ = false; |
| 1192 } | 1195 } |
| 1193 | 1196 |
| 1194 } // namespace cc | 1197 } // namespace cc |
| OLD | NEW |