Chromium Code Reviews| 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 AnimationMap waitingfor_target_animations_; | |
|
vivekg
2014/07/21 12:39:32
nit: waitingfor_target_animations_ => animations_w
shreyas.g
2014/07/21 13:00:37
Done.
| |
| 605 for (size_t i = 0; i < animations_.size(); ++i) { | 606 for (size_t i = 0; i < animations_.size(); ++i) { |
| 606 if (animations_[i]->run_state() == Animation::Starting || | 607 if (animations_[i]->run_state() == Animation::Starting || |
| 607 animations_[i]->run_state() == Animation::Running) { | 608 animations_[i]->run_state() == Animation::Running) { |
| 608 if (animations_[i]->affects_active_observers()) { | 609 if (animations_[i]->affects_active_observers()) { |
| 609 blocked_properties_for_active_observers.insert( | 610 blocked_properties_for_active_observers.insert( |
| 610 animations_[i]->target_property()); | 611 animations_[i]->target_property()); |
| 611 } | 612 } |
| 612 if (animations_[i]->affects_pending_observers()) { | 613 if (animations_[i]->affects_pending_observers()) { |
| 613 blocked_properties_for_pending_observers.insert( | 614 blocked_properties_for_pending_observers.insert( |
| 614 animations_[i]->target_property()); | 615 animations_[i]->target_property()); |
| 615 } | 616 } |
| 617 } else if (animations_[i]->run_state() == | |
| 618 Animation::WaitingForTargetAvailability) { | |
| 619 waitingfor_target_animations_[i] = animations_[i]; | |
| 616 } | 620 } |
| 617 } | 621 } |
| 618 | 622 |
| 619 for (size_t i = 0; i < animations_.size(); ++i) { | 623 for (AnimationMap::const_iterator iter = |
| 620 if (animations_[i]->run_state() == | 624 waitingfor_target_animations_.begin(); |
| 621 Animation::WaitingForTargetAvailability) { | 625 iter != waitingfor_target_animations_.end(); |
| 626 ++iter) { | |
| 622 // Collect all properties for animations with the same group id (they | 627 // Collect all properties for animations with the same group id (they |
| 623 // should all also be in the list of animations). | 628 // should all also be in the list of animations). |
| 624 TargetProperties enqueued_properties; | 629 TargetProperties enqueued_properties; |
| 625 bool affects_active_observers = | 630 bool affects_active_observers = iter->second->affects_active_observers(); |
| 626 animations_[i]->affects_active_observers(); | |
| 627 bool affects_pending_observers = | 631 bool affects_pending_observers = |
| 628 animations_[i]->affects_pending_observers(); | 632 iter->second->affects_pending_observers(); |
| 629 enqueued_properties.insert(animations_[i]->target_property()); | 633 enqueued_properties.insert(iter->second->target_property()); |
| 630 for (size_t j = i + 1; j < animations_.size(); ++j) { | 634 for (size_t j = iter->first + 1; j < animations_.size(); ++j) { |
| 631 if (animations_[i]->group() == animations_[j]->group()) { | 635 if (iter->second->group() == animations_[j]->group()) { |
| 632 enqueued_properties.insert(animations_[j]->target_property()); | 636 enqueued_properties.insert(animations_[j]->target_property()); |
| 633 affects_active_observers |= | 637 affects_active_observers |= |
| 634 animations_[j]->affects_active_observers(); | 638 animations_[j]->affects_active_observers(); |
| 635 affects_pending_observers |= | 639 affects_pending_observers |= |
| 636 animations_[j]->affects_pending_observers(); | 640 animations_[j]->affects_pending_observers(); |
| 637 } | 641 } |
| 638 } | 642 } |
| 639 | 643 |
| 640 // Check to see if intersection of the list of properties affected by | 644 // 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 | 645 // 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 | 646 // 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 | 647 // case, the group's target properties need to be added to the lists of |
| 644 // blocked properties. | 648 // blocked properties. |
| 645 bool null_intersection = true; | 649 bool null_intersection = true; |
| 646 for (TargetProperties::iterator p_iter = enqueued_properties.begin(); | 650 for (TargetProperties::iterator p_iter = enqueued_properties.begin(); |
| 647 p_iter != enqueued_properties.end(); | 651 p_iter != enqueued_properties.end(); |
| 648 ++p_iter) { | 652 ++p_iter) { |
| 649 if (affects_active_observers && | 653 if (affects_active_observers && |
| 650 !blocked_properties_for_active_observers.insert(*p_iter).second) | 654 !blocked_properties_for_active_observers.insert(*p_iter).second) |
| 651 null_intersection = false; | 655 null_intersection = false; |
| 652 if (affects_pending_observers && | 656 if (affects_pending_observers && |
| 653 !blocked_properties_for_pending_observers.insert(*p_iter).second) | 657 !blocked_properties_for_pending_observers.insert(*p_iter).second) |
| 654 null_intersection = false; | 658 null_intersection = false; |
| 655 } | 659 } |
| 656 | 660 |
| 657 // If the intersection is null, then we are free to start the animations | 661 // If the intersection is null, then we are free to start the animations |
| 658 // in the group. | 662 // in the group. |
| 659 if (null_intersection) { | 663 if (null_intersection) { |
| 660 animations_[i]->SetRunState(Animation::Starting, monotonic_time); | 664 iter->second->SetRunState(Animation::Starting, monotonic_time); |
| 661 for (size_t j = i + 1; j < animations_.size(); ++j) { | 665 for (size_t j = iter->first + 1; j < animations_.size(); ++j) { |
| 662 if (animations_[i]->group() == animations_[j]->group()) { | 666 if (iter->second->group() == animations_[j]->group()) { |
| 663 animations_[j]->SetRunState(Animation::Starting, monotonic_time); | 667 animations_[j]->SetRunState(Animation::Starting, monotonic_time); |
| 664 } | 668 } |
| 665 } | 669 } |
| 666 } else { | 670 } else { |
| 667 needs_to_start_animations_ = true; | 671 needs_to_start_animations_ = true; |
| 668 } | 672 } |
| 669 } | |
| 670 } | 673 } |
| 671 } | 674 } |
| 672 | 675 |
| 673 void LayerAnimationController::PromoteStartedAnimations( | 676 void LayerAnimationController::PromoteStartedAnimations( |
| 674 base::TimeTicks monotonic_time, | 677 base::TimeTicks monotonic_time, |
| 675 AnimationEventsVector* events) { | 678 AnimationEventsVector* events) { |
| 676 for (size_t i = 0; i < animations_.size(); ++i) { | 679 for (size_t i = 0; i < animations_.size(); ++i) { |
| 677 if (animations_[i]->run_state() == Animation::Starting && | 680 if (animations_[i]->run_state() == Animation::Starting && |
| 678 animations_[i]->affects_active_observers()) { | 681 animations_[i]->affects_active_observers()) { |
| 679 animations_[i]->SetRunState(Animation::Running, monotonic_time); | 682 animations_[i]->SetRunState(Animation::Running, monotonic_time); |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 971 value_observers_); | 974 value_observers_); |
| 972 LayerAnimationValueObserver* obs; | 975 LayerAnimationValueObserver* obs; |
| 973 while ((obs = it.GetNext()) != NULL) | 976 while ((obs = it.GetNext()) != NULL) |
| 974 if (obs->IsActive()) | 977 if (obs->IsActive()) |
| 975 return true; | 978 return true; |
| 976 } | 979 } |
| 977 return false; | 980 return false; |
| 978 } | 981 } |
| 979 | 982 |
| 980 } // namespace cc | 983 } // namespace cc |
| OLD | NEW |