| OLD | NEW |
| 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/layer_animation_controller.h" | 5 #include "cc/animation/layer_animation_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "cc/animation/animation.h" | 10 #include "cc/animation/animation.h" |
| 11 #include "cc/animation/animation_delegate.h" | 11 #include "cc/animation/animation_delegate.h" |
| 12 #include "cc/animation/animation_registrar.h" | 12 #include "cc/animation/animation_registrar.h" |
| 13 #include "cc/animation/keyframed_animation_curve.h" | 13 #include "cc/animation/keyframed_animation_curve.h" |
| 14 #include "cc/animation/layer_animation_value_observer.h" | 14 #include "cc/animation/layer_animation_value_observer.h" |
| 15 #include "cc/animation/layer_animation_value_provider.h" | 15 #include "cc/animation/layer_animation_value_provider.h" |
| 16 #include "cc/animation/scroll_offset_animation_curve.h" | 16 #include "cc/animation/scroll_offset_animation_curve.h" |
| 17 #include "cc/base/scoped_ptr_algorithm.h" | |
| 18 #include "cc/output/filter_operations.h" | 17 #include "cc/output/filter_operations.h" |
| 19 #include "ui/gfx/geometry/box_f.h" | 18 #include "ui/gfx/geometry/box_f.h" |
| 20 #include "ui/gfx/transform.h" | 19 #include "ui/gfx/transform.h" |
| 21 | 20 |
| 22 namespace cc { | 21 namespace cc { |
| 23 | 22 |
| 24 LayerAnimationController::LayerAnimationController(int id) | 23 LayerAnimationController::LayerAnimationController(int id) |
| 25 : registrar_(0), | 24 : registrar_(0), |
| 26 id_(id), | 25 id_(id), |
| 27 is_active_(false), | 26 is_active_(false), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 46 base::TimeDelta time_offset) { | 45 base::TimeDelta time_offset) { |
| 47 for (size_t i = 0; i < animations_.size(); ++i) { | 46 for (size_t i = 0; i < animations_.size(); ++i) { |
| 48 if (animations_[i]->id() == animation_id) { | 47 if (animations_[i]->id() == animation_id) { |
| 49 animations_[i]->SetRunState(Animation::PAUSED, | 48 animations_[i]->SetRunState(Animation::PAUSED, |
| 50 time_offset + animations_[i]->start_time() + | 49 time_offset + animations_[i]->start_time() + |
| 51 animations_[i]->time_offset()); | 50 animations_[i]->time_offset()); |
| 52 } | 51 } |
| 53 } | 52 } |
| 54 } | 53 } |
| 55 | 54 |
| 56 struct HasAnimationId { | |
| 57 explicit HasAnimationId(int id) : id_(id) {} | |
| 58 bool operator()(Animation* animation) const { | |
| 59 return animation->id() == id_; | |
| 60 } | |
| 61 | |
| 62 private: | |
| 63 int id_; | |
| 64 }; | |
| 65 | |
| 66 void LayerAnimationController::UpdatePotentiallyAnimatingTransform() { | 55 void LayerAnimationController::UpdatePotentiallyAnimatingTransform() { |
| 67 bool was_potentially_animating_transform_for_active_observers = | 56 bool was_potentially_animating_transform_for_active_observers = |
| 68 potentially_animating_transform_for_active_observers_; | 57 potentially_animating_transform_for_active_observers_; |
| 69 bool was_potentially_animating_transform_for_pending_observers = | 58 bool was_potentially_animating_transform_for_pending_observers = |
| 70 potentially_animating_transform_for_pending_observers_; | 59 potentially_animating_transform_for_pending_observers_; |
| 71 | 60 |
| 72 potentially_animating_transform_for_active_observers_ = false; | 61 potentially_animating_transform_for_active_observers_ = false; |
| 73 potentially_animating_transform_for_pending_observers_ = false; | 62 potentially_animating_transform_for_pending_observers_ = false; |
| 74 | 63 |
| 75 for (Animation* animation : animations_) { | 64 for (const auto& animation : animations_) { |
| 76 if (!animation->is_finished() && | 65 if (!animation->is_finished() && |
| 77 animation->target_property() == Animation::TRANSFORM) { | 66 animation->target_property() == Animation::TRANSFORM) { |
| 78 potentially_animating_transform_for_active_observers_ |= | 67 potentially_animating_transform_for_active_observers_ |= |
| 79 animation->affects_active_observers(); | 68 animation->affects_active_observers(); |
| 80 potentially_animating_transform_for_pending_observers_ |= | 69 potentially_animating_transform_for_pending_observers_ |= |
| 81 animation->affects_pending_observers(); | 70 animation->affects_pending_observers(); |
| 82 } | 71 } |
| 83 } | 72 } |
| 84 | 73 |
| 85 bool changed_for_active_observers = | 74 bool changed_for_active_observers = |
| 86 was_potentially_animating_transform_for_active_observers != | 75 was_potentially_animating_transform_for_active_observers != |
| 87 potentially_animating_transform_for_active_observers_; | 76 potentially_animating_transform_for_active_observers_; |
| 88 bool changed_for_pending_observers = | 77 bool changed_for_pending_observers = |
| 89 was_potentially_animating_transform_for_pending_observers != | 78 was_potentially_animating_transform_for_pending_observers != |
| 90 potentially_animating_transform_for_pending_observers_; | 79 potentially_animating_transform_for_pending_observers_; |
| 91 | 80 |
| 92 if (!changed_for_active_observers && !changed_for_pending_observers) | 81 if (!changed_for_active_observers && !changed_for_pending_observers) |
| 93 return; | 82 return; |
| 94 | 83 |
| 95 NotifyObserversTransformIsPotentiallyAnimatingChanged( | 84 NotifyObserversTransformIsPotentiallyAnimatingChanged( |
| 96 changed_for_active_observers, changed_for_pending_observers); | 85 changed_for_active_observers, changed_for_pending_observers); |
| 97 } | 86 } |
| 98 | 87 |
| 99 void LayerAnimationController::RemoveAnimation(int animation_id) { | 88 void LayerAnimationController::RemoveAnimation(int animation_id) { |
| 100 bool removed_transform_animation = false; | 89 bool removed_transform_animation = false; |
| 101 auto animations_to_remove = | 90 // Since we want to use the animations that we're going to remove, we need to |
| 102 animations_.remove_if(HasAnimationId(animation_id)); | 91 // use a stable_parition here instead of remove_if. Remove_if leaves the |
| 92 // removed items in an unspecified state. |
| 93 auto animations_to_remove = std::stable_partition( |
| 94 animations_.begin(), animations_.end(), |
| 95 [animation_id](const scoped_ptr<Animation>& animation) { |
| 96 return animation->id() != animation_id; |
| 97 }); |
| 103 for (auto it = animations_to_remove; it != animations_.end(); ++it) { | 98 for (auto it = animations_to_remove; it != animations_.end(); ++it) { |
| 104 if ((*it)->target_property() == Animation::SCROLL_OFFSET) { | 99 if ((*it)->target_property() == Animation::SCROLL_OFFSET) { |
| 105 scroll_offset_animation_was_interrupted_ = true; | 100 scroll_offset_animation_was_interrupted_ = true; |
| 106 } else if ((*it)->target_property() == Animation::TRANSFORM && | 101 } else if ((*it)->target_property() == Animation::TRANSFORM && |
| 107 !(*it)->is_finished()) { | 102 !(*it)->is_finished()) { |
| 108 removed_transform_animation = true; | 103 removed_transform_animation = true; |
| 109 } | 104 } |
| 110 } | 105 } |
| 111 | 106 |
| 112 animations_.erase(animations_to_remove, animations_.end()); | 107 animations_.erase(animations_to_remove, animations_.end()); |
| 113 UpdateActivation(NORMAL_ACTIVATION); | 108 UpdateActivation(NORMAL_ACTIVATION); |
| 114 if (removed_transform_animation) | 109 if (removed_transform_animation) |
| 115 UpdatePotentiallyAnimatingTransform(); | 110 UpdatePotentiallyAnimatingTransform(); |
| 116 } | 111 } |
| 117 | 112 |
| 118 struct HasAnimationIdAndProperty { | |
| 119 HasAnimationIdAndProperty(int id, Animation::TargetProperty target_property) | |
| 120 : id_(id), target_property_(target_property) {} | |
| 121 bool operator()(Animation* animation) const { | |
| 122 return animation->id() == id_ && | |
| 123 animation->target_property() == target_property_; | |
| 124 } | |
| 125 | |
| 126 private: | |
| 127 int id_; | |
| 128 Animation::TargetProperty target_property_; | |
| 129 }; | |
| 130 | |
| 131 void LayerAnimationController::RemoveAnimation( | 113 void LayerAnimationController::RemoveAnimation( |
| 132 int animation_id, | 114 int animation_id, |
| 133 Animation::TargetProperty target_property) { | 115 Animation::TargetProperty target_property) { |
| 134 bool removed_transform_animation = false; | 116 bool removed_transform_animation = false; |
| 135 auto animations_to_remove = animations_.remove_if( | 117 auto does_not_have_id_or_property = [animation_id, target_property]( |
| 136 HasAnimationIdAndProperty(animation_id, target_property)); | 118 const scoped_ptr<Animation>& animation) { |
| 119 return animation->id() != animation_id || |
| 120 animation->target_property() != target_property; |
| 121 }; |
| 122 // Since we want to use the animations that we're going to remove, we need to |
| 123 // use a stable_parition here instead of remove_if. Remove_if leaves the |
| 124 // removed items in an unspecified state. |
| 125 auto animations_to_remove = std::stable_partition( |
| 126 animations_.begin(), animations_.end(), does_not_have_id_or_property); |
| 137 if (animations_to_remove == animations_.end()) | 127 if (animations_to_remove == animations_.end()) |
| 138 return; | 128 return; |
| 139 | 129 |
| 140 if (target_property == Animation::SCROLL_OFFSET) | 130 if (target_property == Animation::SCROLL_OFFSET) |
| 141 scroll_offset_animation_was_interrupted_ = true; | 131 scroll_offset_animation_was_interrupted_ = true; |
| 142 else if (target_property == Animation::TRANSFORM && | 132 else if (target_property == Animation::TRANSFORM && |
| 143 !(*animations_to_remove)->is_finished()) | 133 !(*animations_to_remove)->is_finished()) |
| 144 removed_transform_animation = true; | 134 removed_transform_animation = true; |
| 145 | 135 |
| 146 animations_.erase(animations_to_remove, animations_.end()); | 136 animations_.erase(animations_to_remove, animations_.end()); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 last_tick_time_ = monotonic_time; | 185 last_tick_time_ = monotonic_time; |
| 196 } | 186 } |
| 197 | 187 |
| 198 void LayerAnimationController::AccumulatePropertyUpdates( | 188 void LayerAnimationController::AccumulatePropertyUpdates( |
| 199 base::TimeTicks monotonic_time, | 189 base::TimeTicks monotonic_time, |
| 200 AnimationEventsVector* events) { | 190 AnimationEventsVector* events) { |
| 201 if (!events) | 191 if (!events) |
| 202 return; | 192 return; |
| 203 | 193 |
| 204 for (size_t i = 0; i < animations_.size(); ++i) { | 194 for (size_t i = 0; i < animations_.size(); ++i) { |
| 205 Animation* animation = animations_[i]; | 195 Animation* animation = animations_[i].get(); |
| 206 if (!animation->is_impl_only()) | 196 if (!animation->is_impl_only()) |
| 207 continue; | 197 continue; |
| 208 | 198 |
| 209 if (!animation->InEffect(monotonic_time)) | 199 if (!animation->InEffect(monotonic_time)) |
| 210 continue; | 200 continue; |
| 211 | 201 |
| 212 base::TimeDelta trimmed = | 202 base::TimeDelta trimmed = |
| 213 animation->TrimTimeToCurrentIteration(monotonic_time); | 203 animation->TrimTimeToCurrentIteration(monotonic_time); |
| 214 switch (animation->target_property()) { | 204 switch (animation->target_property()) { |
| 215 case Animation::OPACITY: { | 205 case Animation::OPACITY: { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 if (needs_to_start_animations_ && start_ready_animations) { | 271 if (needs_to_start_animations_ && start_ready_animations) { |
| 282 StartAnimations(last_tick_time_); | 272 StartAnimations(last_tick_time_); |
| 283 PromoteStartedAnimations(last_tick_time_, events); | 273 PromoteStartedAnimations(last_tick_time_, events); |
| 284 } | 274 } |
| 285 | 275 |
| 286 AccumulatePropertyUpdates(last_tick_time_, events); | 276 AccumulatePropertyUpdates(last_tick_time_, events); |
| 287 | 277 |
| 288 UpdateActivation(NORMAL_ACTIVATION); | 278 UpdateActivation(NORMAL_ACTIVATION); |
| 289 } | 279 } |
| 290 | 280 |
| 291 struct AffectsNoObservers { | |
| 292 bool operator()(Animation* animation) const { | |
| 293 return !animation->affects_active_observers() && | |
| 294 !animation->affects_pending_observers(); | |
| 295 } | |
| 296 }; | |
| 297 | |
| 298 void LayerAnimationController::ActivateAnimations() { | 281 void LayerAnimationController::ActivateAnimations() { |
| 299 bool changed_transform_animation = false; | 282 bool changed_transform_animation = false; |
| 300 for (size_t i = 0; i < animations_.size(); ++i) { | 283 for (size_t i = 0; i < animations_.size(); ++i) { |
| 301 if (animations_[i]->affects_active_observers() != | 284 if (animations_[i]->affects_active_observers() != |
| 302 animations_[i]->affects_pending_observers() && | 285 animations_[i]->affects_pending_observers() && |
| 303 animations_[i]->target_property() == Animation::TRANSFORM) | 286 animations_[i]->target_property() == Animation::TRANSFORM) |
| 304 changed_transform_animation = true; | 287 changed_transform_animation = true; |
| 305 animations_[i]->set_affects_active_observers( | 288 animations_[i]->set_affects_active_observers( |
| 306 animations_[i]->affects_pending_observers()); | 289 animations_[i]->affects_pending_observers()); |
| 307 } | 290 } |
| 308 animations_.erase(cc::remove_if(&animations_, | 291 auto affects_no_observers = [](const scoped_ptr<Animation>& animation) { |
| 309 animations_.begin(), | 292 return !animation->affects_active_observers() && |
| 310 animations_.end(), | 293 !animation->affects_pending_observers(); |
| 311 AffectsNoObservers()), | 294 }; |
| 295 animations_.erase(std::remove_if(animations_.begin(), animations_.end(), |
| 296 affects_no_observers), |
| 312 animations_.end()); | 297 animations_.end()); |
| 313 scroll_offset_animation_was_interrupted_ = false; | 298 scroll_offset_animation_was_interrupted_ = false; |
| 314 UpdateActivation(NORMAL_ACTIVATION); | 299 UpdateActivation(NORMAL_ACTIVATION); |
| 315 if (changed_transform_animation) | 300 if (changed_transform_animation) |
| 316 UpdatePotentiallyAnimatingTransform(); | 301 UpdatePotentiallyAnimatingTransform(); |
| 317 } | 302 } |
| 318 | 303 |
| 319 void LayerAnimationController::AddAnimation(scoped_ptr<Animation> animation) { | 304 void LayerAnimationController::AddAnimation(scoped_ptr<Animation> animation) { |
| 320 bool added_transform_animation = | 305 bool added_transform_animation = |
| 321 animation->target_property() == Animation::TRANSFORM; | 306 animation->target_property() == Animation::TRANSFORM; |
| 322 animations_.push_back(animation.Pass()); | 307 animations_.push_back(animation.Pass()); |
| 323 needs_to_start_animations_ = true; | 308 needs_to_start_animations_ = true; |
| 324 UpdateActivation(NORMAL_ACTIVATION); | 309 UpdateActivation(NORMAL_ACTIVATION); |
| 325 if (added_transform_animation) | 310 if (added_transform_animation) |
| 326 UpdatePotentiallyAnimatingTransform(); | 311 UpdatePotentiallyAnimatingTransform(); |
| 327 } | 312 } |
| 328 | 313 |
| 329 Animation* LayerAnimationController::GetAnimation( | 314 Animation* LayerAnimationController::GetAnimation( |
| 330 Animation::TargetProperty target_property) const { | 315 Animation::TargetProperty target_property) const { |
| 331 for (size_t i = 0; i < animations_.size(); ++i) { | 316 for (size_t i = 0; i < animations_.size(); ++i) { |
| 332 size_t index = animations_.size() - i - 1; | 317 size_t index = animations_.size() - i - 1; |
| 333 if (animations_[index]->target_property() == target_property) | 318 if (animations_[index]->target_property() == target_property) |
| 334 return animations_[index]; | 319 return animations_[index].get(); |
| 335 } | 320 } |
| 336 return 0; | 321 return nullptr; |
| 337 } | 322 } |
| 338 | 323 |
| 339 Animation* LayerAnimationController::GetAnimationById(int animation_id) const { | 324 Animation* LayerAnimationController::GetAnimationById(int animation_id) const { |
| 340 for (size_t i = 0; i < animations_.size(); ++i) | 325 for (size_t i = 0; i < animations_.size(); ++i) |
| 341 if (animations_[i]->id() == animation_id) | 326 if (animations_[i]->id() == animation_id) |
| 342 return animations_[i]; | 327 return animations_[i].get(); |
| 343 return nullptr; | 328 return nullptr; |
| 344 } | 329 } |
| 345 | 330 |
| 346 bool LayerAnimationController::HasActiveAnimation() const { | 331 bool LayerAnimationController::HasActiveAnimation() const { |
| 347 for (size_t i = 0; i < animations_.size(); ++i) { | 332 for (size_t i = 0; i < animations_.size(); ++i) { |
| 348 if (!animations_[i]->is_finished()) | 333 if (!animations_[i]->is_finished()) |
| 349 return true; | 334 return true; |
| 350 } | 335 } |
| 351 return false; | 336 return false; |
| 352 } | 337 } |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 static bool IsCompleted( | 715 static bool IsCompleted( |
| 731 Animation* animation, | 716 Animation* animation, |
| 732 const LayerAnimationController* main_thread_controller) { | 717 const LayerAnimationController* main_thread_controller) { |
| 733 if (animation->is_impl_only()) { | 718 if (animation->is_impl_only()) { |
| 734 return (animation->run_state() == Animation::WAITING_FOR_DELETION); | 719 return (animation->run_state() == Animation::WAITING_FOR_DELETION); |
| 735 } else { | 720 } else { |
| 736 return !main_thread_controller->GetAnimationById(animation->id()); | 721 return !main_thread_controller->GetAnimationById(animation->id()); |
| 737 } | 722 } |
| 738 } | 723 } |
| 739 | 724 |
| 740 static bool AffectsActiveOnlyAndIsWaitingForDeletion(Animation* animation) { | |
| 741 return animation->run_state() == Animation::WAITING_FOR_DELETION && | |
| 742 !animation->affects_pending_observers(); | |
| 743 } | |
| 744 | |
| 745 void LayerAnimationController::RemoveAnimationsCompletedOnMainThread( | 725 void LayerAnimationController::RemoveAnimationsCompletedOnMainThread( |
| 746 LayerAnimationController* controller_impl) const { | 726 LayerAnimationController* controller_impl) const { |
| 747 bool removed_transform_animation = false; | 727 bool removed_transform_animation = false; |
| 748 // Animations removed on the main thread should no longer affect pending | 728 // Animations removed on the main thread should no longer affect pending |
| 749 // observers, and should stop affecting active observers after the next call | 729 // observers, and should stop affecting active observers after the next call |
| 750 // to ActivateAnimations. If already WAITING_FOR_DELETION, they can be removed | 730 // to ActivateAnimations. If already WAITING_FOR_DELETION, they can be removed |
| 751 // immediately. | 731 // immediately. |
| 752 ScopedPtrVector<Animation>& animations = controller_impl->animations_; | 732 auto& animations = controller_impl->animations_; |
| 753 for (size_t i = 0; i < animations.size(); ++i) { | 733 for (const auto& animation : animations) { |
| 754 if (IsCompleted(animations[i], this)) { | 734 if (IsCompleted(animation.get(), this)) { |
| 755 animations[i]->set_affects_pending_observers(false); | 735 animation->set_affects_pending_observers(false); |
| 756 if (animations[i]->target_property() == Animation::TRANSFORM) | 736 if (animation->target_property() == Animation::TRANSFORM) |
| 757 removed_transform_animation = true; | 737 removed_transform_animation = true; |
| 758 } | 738 } |
| 759 } | 739 } |
| 760 animations.erase(cc::remove_if(&animations, | 740 auto affects_active_only_and_is_waiting_for_deletion = []( |
| 761 animations.begin(), | 741 const scoped_ptr<Animation>& animation) { |
| 762 animations.end(), | 742 return animation->run_state() == Animation::WAITING_FOR_DELETION && |
| 763 AffectsActiveOnlyAndIsWaitingForDeletion), | 743 !animation->affects_pending_observers(); |
| 764 animations.end()); | 744 }; |
| 745 animations.erase( |
| 746 std::remove_if(animations.begin(), animations.end(), |
| 747 affects_active_only_and_is_waiting_for_deletion), |
| 748 animations.end()); |
| 765 | 749 |
| 766 if (removed_transform_animation) | 750 if (removed_transform_animation) |
| 767 controller_impl->UpdatePotentiallyAnimatingTransform(); | 751 controller_impl->UpdatePotentiallyAnimatingTransform(); |
| 768 } | 752 } |
| 769 | 753 |
| 770 void LayerAnimationController::PushPropertiesToImplThread( | 754 void LayerAnimationController::PushPropertiesToImplThread( |
| 771 LayerAnimationController* controller_impl) { | 755 LayerAnimationController* controller_impl) { |
| 772 for (size_t i = 0; i < animations_.size(); ++i) { | 756 for (size_t i = 0; i < animations_.size(); ++i) { |
| 773 Animation* current_impl = | 757 Animation* current_impl = |
| 774 controller_impl->GetAnimationById(animations_[i]->id()); | 758 controller_impl->GetAnimationById(animations_[i]->id()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 803 } else if (animations_[i]->run_state() == | 787 } else if (animations_[i]->run_state() == |
| 804 Animation::WAITING_FOR_TARGET_AVAILABILITY) { | 788 Animation::WAITING_FOR_TARGET_AVAILABILITY) { |
| 805 animations_waiting_for_target.push_back(i); | 789 animations_waiting_for_target.push_back(i); |
| 806 } | 790 } |
| 807 } | 791 } |
| 808 | 792 |
| 809 for (size_t i = 0; i < animations_waiting_for_target.size(); ++i) { | 793 for (size_t i = 0; i < animations_waiting_for_target.size(); ++i) { |
| 810 // Collect all properties for animations with the same group id (they | 794 // Collect all properties for animations with the same group id (they |
| 811 // should all also be in the list of animations). | 795 // should all also be in the list of animations). |
| 812 size_t animation_index = animations_waiting_for_target[i]; | 796 size_t animation_index = animations_waiting_for_target[i]; |
| 813 Animation* animation_waiting_for_target = animations_[animation_index]; | 797 Animation* animation_waiting_for_target = |
| 798 animations_[animation_index].get(); |
| 814 // Check for the run state again even though the animation was waiting | 799 // Check for the run state again even though the animation was waiting |
| 815 // for target because it might have changed the run state while handling | 800 // for target because it might have changed the run state while handling |
| 816 // previous animation in this loop (if they belong to same group). | 801 // previous animation in this loop (if they belong to same group). |
| 817 if (animation_waiting_for_target->run_state() == | 802 if (animation_waiting_for_target->run_state() == |
| 818 Animation::WAITING_FOR_TARGET_AVAILABILITY) { | 803 Animation::WAITING_FOR_TARGET_AVAILABILITY) { |
| 819 TargetProperties enqueued_properties; | 804 TargetProperties enqueued_properties; |
| 820 bool affects_active_observers = | 805 bool affects_active_observers = |
| 821 animation_waiting_for_target->affects_active_observers(); | 806 animation_waiting_for_target->affects_active_observers(); |
| 822 bool affects_pending_observers = | 807 bool affects_pending_observers = |
| 823 animation_waiting_for_target->affects_pending_observers(); | 808 animation_waiting_for_target->affects_pending_observers(); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 animations_[animation_index]->SetRunState( | 987 animations_[animation_index]->SetRunState( |
| 1003 Animation::WAITING_FOR_DELETION, monotonic_time); | 988 Animation::WAITING_FOR_DELETION, monotonic_time); |
| 1004 } | 989 } |
| 1005 marked_animations_for_deletions = true; | 990 marked_animations_for_deletions = true; |
| 1006 } | 991 } |
| 1007 } | 992 } |
| 1008 if (marked_animations_for_deletions) | 993 if (marked_animations_for_deletions) |
| 1009 NotifyObserversAnimationWaitingForDeletion(); | 994 NotifyObserversAnimationWaitingForDeletion(); |
| 1010 } | 995 } |
| 1011 | 996 |
| 1012 static bool IsWaitingForDeletion(Animation* animation) { | |
| 1013 return animation->run_state() == Animation::WAITING_FOR_DELETION; | |
| 1014 } | |
| 1015 | |
| 1016 void LayerAnimationController::PurgeAnimationsMarkedForDeletion() { | 997 void LayerAnimationController::PurgeAnimationsMarkedForDeletion() { |
| 1017 animations_.erase(cc::remove_if(&animations_, | 998 animations_.erase(std::remove_if(animations_.begin(), animations_.end(), |
| 1018 animations_.begin(), | 999 [](const scoped_ptr<Animation>& animation) { |
| 1019 animations_.end(), | 1000 return animation->run_state() == |
| 1020 IsWaitingForDeletion), | 1001 Animation::WAITING_FOR_DELETION; |
| 1002 }), |
| 1021 animations_.end()); | 1003 animations_.end()); |
| 1022 } | 1004 } |
| 1023 | 1005 |
| 1024 void LayerAnimationController::TickAnimations(base::TimeTicks monotonic_time) { | 1006 void LayerAnimationController::TickAnimations(base::TimeTicks monotonic_time) { |
| 1025 for (size_t i = 0; i < animations_.size(); ++i) { | 1007 for (size_t i = 0; i < animations_.size(); ++i) { |
| 1026 if (animations_[i]->run_state() == Animation::STARTING || | 1008 if (animations_[i]->run_state() == Animation::STARTING || |
| 1027 animations_[i]->run_state() == Animation::RUNNING || | 1009 animations_[i]->run_state() == Animation::RUNNING || |
| 1028 animations_[i]->run_state() == Animation::PAUSED) { | 1010 animations_[i]->run_state() == Animation::PAUSED) { |
| 1029 if (!animations_[i]->InEffect(monotonic_time)) | 1011 if (!animations_[i]->InEffect(monotonic_time)) |
| 1030 continue; | 1012 continue; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 &value_observers_); | 1199 &value_observers_); |
| 1218 LayerAnimationValueObserver* obs; | 1200 LayerAnimationValueObserver* obs; |
| 1219 while ((obs = it.GetNext()) != nullptr) | 1201 while ((obs = it.GetNext()) != nullptr) |
| 1220 if (obs->IsActive()) | 1202 if (obs->IsActive()) |
| 1221 return true; | 1203 return true; |
| 1222 } | 1204 } |
| 1223 return false; | 1205 return false; |
| 1224 } | 1206 } |
| 1225 | 1207 |
| 1226 } // namespace cc | 1208 } // namespace cc |
| OLD | NEW |