| 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_delegate.h" | 10 #include "cc/animation/animation_delegate.h" |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 animations_[i]->PushPropertiesTo(current_impl); | 595 animations_[i]->PushPropertiesTo(current_impl); |
| 596 } | 596 } |
| 597 } | 597 } |
| 598 | 598 |
| 599 void LayerAnimationController::StartAnimations(base::TimeTicks monotonic_time) { | 599 void LayerAnimationController::StartAnimations(base::TimeTicks monotonic_time) { |
| 600 DCHECK(needs_to_start_animations_); | 600 DCHECK(needs_to_start_animations_); |
| 601 needs_to_start_animations_ = false; | 601 needs_to_start_animations_ = false; |
| 602 // First collect running properties affecting each type of observer. | 602 // First collect running properties affecting each type of observer. |
| 603 TargetProperties blocked_properties_for_active_observers; | 603 TargetProperties blocked_properties_for_active_observers; |
| 604 TargetProperties blocked_properties_for_pending_observers; | 604 TargetProperties blocked_properties_for_pending_observers; |
| 605 std::vector<size_t> animations_waiting_for_target; |
| 606 |
| 607 animations_waiting_for_target.reserve(animations_.size()); |
| 605 for (size_t i = 0; i < animations_.size(); ++i) { | 608 for (size_t i = 0; i < animations_.size(); ++i) { |
| 606 if (animations_[i]->run_state() == Animation::Starting || | 609 if (animations_[i]->run_state() == Animation::Starting || |
| 607 animations_[i]->run_state() == Animation::Running) { | 610 animations_[i]->run_state() == Animation::Running) { |
| 608 if (animations_[i]->affects_active_observers()) { | 611 if (animations_[i]->affects_active_observers()) { |
| 609 blocked_properties_for_active_observers.insert( | 612 blocked_properties_for_active_observers.insert( |
| 610 animations_[i]->target_property()); | 613 animations_[i]->target_property()); |
| 611 } | 614 } |
| 612 if (animations_[i]->affects_pending_observers()) { | 615 if (animations_[i]->affects_pending_observers()) { |
| 613 blocked_properties_for_pending_observers.insert( | 616 blocked_properties_for_pending_observers.insert( |
| 614 animations_[i]->target_property()); | 617 animations_[i]->target_property()); |
| 615 } | 618 } |
| 619 } else if (animations_[i]->run_state() == |
| 620 Animation::WaitingForTargetAvailability) { |
| 621 animations_waiting_for_target.push_back(i); |
| 616 } | 622 } |
| 617 } | 623 } |
| 618 | 624 |
| 619 for (size_t i = 0; i < animations_.size(); ++i) { | 625 for (size_t i = 0; i < animations_waiting_for_target.size(); ++i) { |
| 620 if (animations_[i]->run_state() == | |
| 621 Animation::WaitingForTargetAvailability) { | |
| 622 // Collect all properties for animations with the same group id (they | 626 // Collect all properties for animations with the same group id (they |
| 623 // should all also be in the list of animations). | 627 // should all also be in the list of animations). |
| 628 size_t animation_index = animations_waiting_for_target[i]; |
| 629 Animation* animation_waiting_for_target = animations_[animation_index]; |
| 630 // Check for the run state again even though the animation was waiting |
| 631 // for target because it might have changed the run state while handling |
| 632 // previous animation in this loop (if they belong to same group). |
| 633 if (animation_waiting_for_target->run_state() == |
| 634 Animation::WaitingForTargetAvailability) { |
| 624 TargetProperties enqueued_properties; | 635 TargetProperties enqueued_properties; |
| 625 bool affects_active_observers = | 636 bool affects_active_observers = |
| 626 animations_[i]->affects_active_observers(); | 637 animation_waiting_for_target->affects_active_observers(); |
| 627 bool affects_pending_observers = | 638 bool affects_pending_observers = |
| 628 animations_[i]->affects_pending_observers(); | 639 animation_waiting_for_target->affects_pending_observers(); |
| 629 enqueued_properties.insert(animations_[i]->target_property()); | 640 enqueued_properties.insert( |
| 630 for (size_t j = i + 1; j < animations_.size(); ++j) { | 641 animation_waiting_for_target->target_property()); |
| 631 if (animations_[i]->group() == animations_[j]->group()) { | 642 for (size_t j = animation_index + 1; j < animations_.size(); ++j) { |
| 643 if (animation_waiting_for_target->group() == animations_[j]->group()) { |
| 632 enqueued_properties.insert(animations_[j]->target_property()); | 644 enqueued_properties.insert(animations_[j]->target_property()); |
| 633 affects_active_observers |= | 645 affects_active_observers |= |
| 634 animations_[j]->affects_active_observers(); | 646 animations_[j]->affects_active_observers(); |
| 635 affects_pending_observers |= | 647 affects_pending_observers |= |
| 636 animations_[j]->affects_pending_observers(); | 648 animations_[j]->affects_pending_observers(); |
| 637 } | 649 } |
| 638 } | 650 } |
| 639 | 651 |
| 640 // Check to see if intersection of the list of properties affected by | 652 // Check to see if intersection of the list of properties affected by |
| 641 // the group and the list of currently blocked properties is null, taking | 653 // the group and the list of currently blocked properties is null, taking |
| 642 // into account the type(s) of observers affected by the group. In any | 654 // into account the type(s) of observers affected by the group. In any |
| 643 // case, the group's target properties need to be added to the lists of | 655 // case, the group's target properties need to be added to the lists of |
| 644 // blocked properties. | 656 // blocked properties. |
| 645 bool null_intersection = true; | 657 bool null_intersection = true; |
| 646 for (TargetProperties::iterator p_iter = enqueued_properties.begin(); | 658 for (TargetProperties::iterator p_iter = enqueued_properties.begin(); |
| 647 p_iter != enqueued_properties.end(); | 659 p_iter != enqueued_properties.end(); |
| 648 ++p_iter) { | 660 ++p_iter) { |
| 649 if (affects_active_observers && | 661 if (affects_active_observers && |
| 650 !blocked_properties_for_active_observers.insert(*p_iter).second) | 662 !blocked_properties_for_active_observers.insert(*p_iter).second) |
| 651 null_intersection = false; | 663 null_intersection = false; |
| 652 if (affects_pending_observers && | 664 if (affects_pending_observers && |
| 653 !blocked_properties_for_pending_observers.insert(*p_iter).second) | 665 !blocked_properties_for_pending_observers.insert(*p_iter).second) |
| 654 null_intersection = false; | 666 null_intersection = false; |
| 655 } | 667 } |
| 656 | 668 |
| 657 // If the intersection is null, then we are free to start the animations | 669 // If the intersection is null, then we are free to start the animations |
| 658 // in the group. | 670 // in the group. |
| 659 if (null_intersection) { | 671 if (null_intersection) { |
| 660 animations_[i]->SetRunState(Animation::Starting, monotonic_time); | 672 animation_waiting_for_target->SetRunState(Animation::Starting, |
| 661 for (size_t j = i + 1; j < animations_.size(); ++j) { | 673 monotonic_time); |
| 662 if (animations_[i]->group() == animations_[j]->group()) { | 674 for (size_t j = animation_index + 1; j < animations_.size(); ++j) { |
| 675 if (animation_waiting_for_target->group() == |
| 676 animations_[j]->group()) { |
| 663 animations_[j]->SetRunState(Animation::Starting, monotonic_time); | 677 animations_[j]->SetRunState(Animation::Starting, monotonic_time); |
| 664 } | 678 } |
| 665 } | 679 } |
| 666 } else { | 680 } else { |
| 667 needs_to_start_animations_ = true; | 681 needs_to_start_animations_ = true; |
| 668 } | 682 } |
| 669 } | 683 } |
| 670 } | 684 } |
| 671 } | 685 } |
| 672 | 686 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 value_observers_); | 985 value_observers_); |
| 972 LayerAnimationValueObserver* obs; | 986 LayerAnimationValueObserver* obs; |
| 973 while ((obs = it.GetNext()) != NULL) | 987 while ((obs = it.GetNext()) != NULL) |
| 974 if (obs->IsActive()) | 988 if (obs->IsActive()) |
| 975 return true; | 989 return true; |
| 976 } | 990 } |
| 977 return false; | 991 return false; |
| 978 } | 992 } |
| 979 | 993 |
| 980 } // namespace cc | 994 } // namespace cc |
| OLD | NEW |