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 | 8 |
9 #include "cc/animation/animation.h" | 9 #include "cc/animation/animation.h" |
10 #include "cc/animation/animation_registrar.h" | 10 #include "cc/animation/animation_registrar.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 bool operator()(Animation* animation) const { | 47 bool operator()(Animation* animation) const { |
48 return animation->id() == id_; | 48 return animation->id() == id_; |
49 } | 49 } |
50 | 50 |
51 private: | 51 private: |
52 int id_; | 52 int id_; |
53 }; | 53 }; |
54 | 54 |
55 void LayerAnimationController::RemoveAnimation(int animation_id) { | 55 void LayerAnimationController::RemoveAnimation(int animation_id) { |
56 ScopedPtrVector<Animation>& animations = active_animations_; | 56 ScopedPtrVector<Animation>& animations = active_animations_; |
57 animations.erase(cc::remove_if(animations, | 57 animations.erase(cc::remove_if(&animations, |
58 animations.begin(), | 58 animations.begin(), |
59 animations.end(), | 59 animations.end(), |
60 HasAnimationId(animation_id)), | 60 HasAnimationId(animation_id)), |
61 animations.end()); | 61 animations.end()); |
62 UpdateActivation(NormalActivation); | 62 UpdateActivation(NormalActivation); |
63 } | 63 } |
64 | 64 |
65 struct HasAnimationIdAndProperty { | 65 struct HasAnimationIdAndProperty { |
66 HasAnimationIdAndProperty(int id, Animation::TargetProperty target_property) | 66 HasAnimationIdAndProperty(int id, Animation::TargetProperty target_property) |
67 : id_(id), target_property_(target_property) {} | 67 : id_(id), target_property_(target_property) {} |
68 bool operator()(Animation* animation) const { | 68 bool operator()(Animation* animation) const { |
69 return animation->id() == id_ && | 69 return animation->id() == id_ && |
70 animation->target_property() == target_property_; | 70 animation->target_property() == target_property_; |
71 } | 71 } |
72 | 72 |
73 private: | 73 private: |
74 int id_; | 74 int id_; |
75 Animation::TargetProperty target_property_; | 75 Animation::TargetProperty target_property_; |
76 }; | 76 }; |
77 | 77 |
78 void LayerAnimationController::RemoveAnimation( | 78 void LayerAnimationController::RemoveAnimation( |
79 int animation_id, | 79 int animation_id, |
80 Animation::TargetProperty target_property) { | 80 Animation::TargetProperty target_property) { |
81 ScopedPtrVector<Animation>& animations = active_animations_; | 81 ScopedPtrVector<Animation>& animations = active_animations_; |
82 animations.erase(cc::remove_if(animations, | 82 animations.erase(cc::remove_if(&animations, |
83 animations.begin(), | 83 animations.begin(), |
84 animations.end(), | 84 animations.end(), |
85 HasAnimationIdAndProperty(animation_id, | 85 HasAnimationIdAndProperty(animation_id, |
86 target_property)), | 86 target_property)), |
87 animations.end()); | 87 animations.end()); |
88 UpdateActivation(NormalActivation); | 88 UpdateActivation(NormalActivation); |
89 } | 89 } |
90 | 90 |
91 // According to render layer backing, these are for testing only. | 91 // According to render layer backing, these are for testing only. |
92 void LayerAnimationController::SuspendAnimations(double monotonic_time) { | 92 void LayerAnimationController::SuspendAnimations(double monotonic_time) { |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 }; | 318 }; |
319 | 319 |
320 void LayerAnimationController::RemoveAnimationsCompletedOnMainThread( | 320 void LayerAnimationController::RemoveAnimationsCompletedOnMainThread( |
321 LayerAnimationController* controller_impl) const { | 321 LayerAnimationController* controller_impl) const { |
322 // Delete all impl thread animations for which there is no corresponding | 322 // Delete all impl thread animations for which there is no corresponding |
323 // main thread animation. Each iteration, | 323 // main thread animation. Each iteration, |
324 // controller->active_animations_.size() is decremented or i is incremented | 324 // controller->active_animations_.size() is decremented or i is incremented |
325 // guaranteeing progress towards loop termination. | 325 // guaranteeing progress towards loop termination. |
326 ScopedPtrVector<Animation>& animations = | 326 ScopedPtrVector<Animation>& animations = |
327 controller_impl->active_animations_; | 327 controller_impl->active_animations_; |
328 animations.erase(cc::remove_if(animations, | 328 animations.erase(cc::remove_if(&animations, |
329 animations.begin(), | 329 animations.begin(), |
330 animations.end(), | 330 animations.end(), |
331 IsCompleted(*this)), | 331 IsCompleted(*this)), |
332 animations.end()); | 332 animations.end()); |
333 } | 333 } |
334 | 334 |
335 void LayerAnimationController::PushPropertiesToImplThread( | 335 void LayerAnimationController::PushPropertiesToImplThread( |
336 LayerAnimationController* controller_impl) const { | 336 LayerAnimationController* controller_impl) const { |
337 for (size_t i = 0; i < active_animations_.size(); ++i) { | 337 for (size_t i = 0; i < active_animations_.size(); ++i) { |
338 Animation* current_impl = | 338 Animation* current_impl = |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 } | 507 } |
508 } | 508 } |
509 } | 509 } |
510 | 510 |
511 static bool IsWaitingForDeletion(Animation* animation) { | 511 static bool IsWaitingForDeletion(Animation* animation) { |
512 return animation->run_state() == Animation::WaitingForDeletion; | 512 return animation->run_state() == Animation::WaitingForDeletion; |
513 } | 513 } |
514 | 514 |
515 void LayerAnimationController::PurgeAnimationsMarkedForDeletion() { | 515 void LayerAnimationController::PurgeAnimationsMarkedForDeletion() { |
516 ScopedPtrVector<Animation>& animations = active_animations_; | 516 ScopedPtrVector<Animation>& animations = active_animations_; |
517 animations.erase(cc::remove_if(animations, | 517 animations.erase(cc::remove_if(&animations, |
518 animations.begin(), | 518 animations.begin(), |
519 animations.end(), | 519 animations.end(), |
520 IsWaitingForDeletion), | 520 IsWaitingForDeletion), |
521 animations.end()); | 521 animations.end()); |
522 } | 522 } |
523 | 523 |
524 void LayerAnimationController::ReplaceImplThreadAnimations( | 524 void LayerAnimationController::ReplaceImplThreadAnimations( |
525 LayerAnimationController* controller_impl) const { | 525 LayerAnimationController* controller_impl) const { |
526 controller_impl->active_animations_.clear(); | 526 controller_impl->active_animations_.clear(); |
527 for (size_t i = 0; i < active_animations_.size(); ++i) { | 527 for (size_t i = 0; i < active_animations_.size(); ++i) { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 ObserverListBase<LayerAnimationValueObserver>::Iterator it(observers_); | 617 ObserverListBase<LayerAnimationValueObserver>::Iterator it(observers_); |
618 LayerAnimationValueObserver* obs; | 618 LayerAnimationValueObserver* obs; |
619 while ((obs = it.GetNext()) != NULL) | 619 while ((obs = it.GetNext()) != NULL) |
620 if (obs->IsActive()) | 620 if (obs->IsActive()) |
621 return true; | 621 return true; |
622 } | 622 } |
623 return false; | 623 return false; |
624 } | 624 } |
625 | 625 |
626 } // namespace cc | 626 } // namespace cc |
OLD | NEW |