| 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" |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 marked_animations_for_deletions = true; | 803 marked_animations_for_deletions = true; |
| 804 continue; | 804 continue; |
| 805 } | 805 } |
| 806 | 806 |
| 807 bool all_anims_with_same_id_are_finished = false; | 807 bool all_anims_with_same_id_are_finished = false; |
| 808 | 808 |
| 809 // Since deleting an animation on the main thread leads to its deletion | 809 // Since deleting an animation on the main thread leads to its deletion |
| 810 // on the impl thread, we only mark a FINISHED main thread animation for | 810 // on the impl thread, we only mark a FINISHED main thread animation for |
| 811 // deletion once it has received a FINISHED event from the impl thread. | 811 // deletion once it has received a FINISHED event from the impl thread. |
| 812 bool animation_i_will_send_or_has_received_finish_event = | 812 bool animation_i_will_send_or_has_received_finish_event = |
| 813 events || animations_[i]->received_finished_event(); | 813 animations_[i]->is_controlling_instance() || |
| 814 animations_[i]->is_impl_only() || |
| 815 animations_[i]->received_finished_event(); |
| 814 // If an animation is finished, and not already marked for deletion, | 816 // If an animation is finished, and not already marked for deletion, |
| 815 // find out if all other animations in the same group are also finished. | 817 // find out if all other animations in the same group are also finished. |
| 816 if (animations_[i]->run_state() == Animation::FINISHED && | 818 if (animations_[i]->run_state() == Animation::FINISHED && |
| 817 animation_i_will_send_or_has_received_finish_event) { | 819 animation_i_will_send_or_has_received_finish_event) { |
| 818 // Clear the animations_with_same_group_id if it was added for | 820 // Clear the animations_with_same_group_id if it was added for |
| 819 // the previous animation's iteration. | 821 // the previous animation's iteration. |
| 820 if (animations_with_same_group_id.size() > 0) | 822 if (animations_with_same_group_id.size() > 0) |
| 821 animations_with_same_group_id.clear(); | 823 animations_with_same_group_id.clear(); |
| 822 all_anims_with_same_id_are_finished = true; | 824 all_anims_with_same_id_are_finished = true; |
| 823 for (size_t j = 0; j < animations_.size(); ++j) { | 825 for (size_t j = 0; j < animations_.size(); ++j) { |
| 824 bool animation_j_will_send_or_has_received_finish_event = | 826 bool animation_j_will_send_or_has_received_finish_event = |
| 825 events || animations_[j]->received_finished_event(); | 827 animations_[j]->is_controlling_instance() || |
| 828 animations_[j]->is_impl_only() || |
| 829 animations_[j]->received_finished_event(); |
| 826 if (group_id == animations_[j]->group()) { | 830 if (group_id == animations_[j]->group()) { |
| 827 if (!animations_[j]->is_finished() || | 831 if (!animations_[j]->is_finished() || |
| 828 (animations_[j]->run_state() == Animation::FINISHED && | 832 (animations_[j]->run_state() == Animation::FINISHED && |
| 829 !animation_j_will_send_or_has_received_finish_event)) { | 833 !animation_j_will_send_or_has_received_finish_event)) { |
| 830 all_anims_with_same_id_are_finished = false; | 834 all_anims_with_same_id_are_finished = false; |
| 831 break; | 835 break; |
| 832 } else if (j >= i && | 836 } else if (j >= i && |
| 833 animations_[j]->run_state() != Animation::ABORTED) { | 837 animations_[j]->run_state() != Animation::ABORTED) { |
| 834 // Mark down the animations which belong to the same group | 838 // Mark down the animations which belong to the same group |
| 835 // and is not yet aborted. If this current iteration finds that all | 839 // and is not yet aborted. If this current iteration finds that all |
| 836 // animations with same ID are finished, then the marked | 840 // animations with same ID are finished, then the marked |
| 837 // animations below will be set to WAITING_FOR_DELETION in next | 841 // animations below will be set to WAITING_FOR_DELETION in next |
| 838 // iteration. | 842 // iteration. |
| 839 animations_with_same_group_id.push_back(j); | 843 animations_with_same_group_id.push_back(j); |
| 840 } | 844 } |
| 841 } | 845 } |
| 842 } | 846 } |
| 843 } | 847 } |
| 844 if (all_anims_with_same_id_are_finished) { | 848 if (all_anims_with_same_id_are_finished) { |
| 845 // We now need to remove all animations with the same group id as | 849 // We now need to remove all animations with the same group id as |
| 846 // group_id (and send along animation finished notifications, if | 850 // group_id (and send along animation finished notifications, if |
| 847 // necessary). | 851 // necessary). |
| 848 for (size_t j = 0; j < animations_with_same_group_id.size(); j++) { | 852 for (size_t j = 0; j < animations_with_same_group_id.size(); j++) { |
| 849 size_t animation_index = animations_with_same_group_id[j]; | 853 size_t animation_index = animations_with_same_group_id[j]; |
| 850 if (events) { | 854 bool impl_animation = |
| 851 AnimationEvent finished_event( | 855 animations_[animation_index]->is_controlling_instance() || |
| 852 AnimationEvent::FINISHED, id_, | 856 animations_[animation_index]->is_impl_only(); |
| 853 animations_[animation_index]->group(), | 857 if (events && impl_animation) { |
| 854 animations_[animation_index]->target_property(), | 858 AnimationEvent finished_event( |
| 855 monotonic_time); | 859 AnimationEvent::FINISHED, id_, |
| 856 finished_event.is_impl_only = | 860 animations_[animation_index]->group(), |
| 857 animations_[animation_index]->is_impl_only(); | 861 animations_[animation_index]->target_property(), monotonic_time); |
| 858 if (finished_event.is_impl_only) | 862 finished_event.is_impl_only = |
| 859 NotifyAnimationFinished(finished_event); | 863 animations_[animation_index]->is_impl_only(); |
| 860 else | 864 if (finished_event.is_impl_only) |
| 861 events->push_back(finished_event); | 865 NotifyAnimationFinished(finished_event); |
| 862 } | 866 else |
| 863 animations_[animation_index]->SetRunState( | 867 events->push_back(finished_event); |
| 864 Animation::WAITING_FOR_DELETION, monotonic_time); | 868 } |
| 869 animations_[animation_index]->SetRunState( |
| 870 Animation::WAITING_FOR_DELETION, monotonic_time); |
| 865 } | 871 } |
| 866 marked_animations_for_deletions = true; | 872 marked_animations_for_deletions = true; |
| 867 } | 873 } |
| 868 } | 874 } |
| 869 if (marked_animations_for_deletions) | 875 if (marked_animations_for_deletions) |
| 870 NotifyObserversAnimationWaitingForDeletion(); | 876 NotifyObserversAnimationWaitingForDeletion(); |
| 871 } | 877 } |
| 872 | 878 |
| 873 static bool IsWaitingForDeletion(Animation* animation) { | 879 static bool IsWaitingForDeletion(Animation* animation) { |
| 874 return animation->run_state() == Animation::WAITING_FOR_DELETION; | 880 return animation->run_state() == Animation::WAITING_FOR_DELETION; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1059 &value_observers_); | 1065 &value_observers_); |
| 1060 LayerAnimationValueObserver* obs; | 1066 LayerAnimationValueObserver* obs; |
| 1061 while ((obs = it.GetNext()) != nullptr) | 1067 while ((obs = it.GetNext()) != nullptr) |
| 1062 if (obs->IsActive()) | 1068 if (obs->IsActive()) |
| 1063 return true; | 1069 return true; |
| 1064 } | 1070 } |
| 1065 return false; | 1071 return false; |
| 1066 } | 1072 } |
| 1067 | 1073 |
| 1068 } // namespace cc | 1074 } // namespace cc |
| OLD | NEW |