Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: cc/animation/layer_animation_controller.cc

Issue 408833002: StartAnimation: Optimized the search for Animations which is waiting for TargetAvailability (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replaced animation/index pair with just index (without push_back) Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_index_;
ajuma 2014/07/23 16:02:18 Calling this |animations_waiting_for_target| seems
shreyas.g 2014/07/24 10:03:50 Done.
606 size_t index = 0;
607
608 animations_waiting_for_target_index_.resize(animations_.size());
ajuma 2014/07/23 16:02:18 How about using reserve instead of resize, and the
shreyas.g 2014/07/24 10:03:50 Done.
605 for (size_t i = 0; i < animations_.size(); ++i) { 609 for (size_t i = 0; i < animations_.size(); ++i) {
606 if (animations_[i]->run_state() == Animation::Starting || 610 if (animations_[i]->run_state() == Animation::Starting ||
607 animations_[i]->run_state() == Animation::Running) { 611 animations_[i]->run_state() == Animation::Running) {
608 if (animations_[i]->affects_active_observers()) { 612 if (animations_[i]->affects_active_observers()) {
609 blocked_properties_for_active_observers.insert( 613 blocked_properties_for_active_observers.insert(
610 animations_[i]->target_property()); 614 animations_[i]->target_property());
611 } 615 }
612 if (animations_[i]->affects_pending_observers()) { 616 if (animations_[i]->affects_pending_observers()) {
613 blocked_properties_for_pending_observers.insert( 617 blocked_properties_for_pending_observers.insert(
614 animations_[i]->target_property()); 618 animations_[i]->target_property());
615 } 619 }
620 } else if (animations_[i]->run_state() ==
621 Animation::WaitingForTargetAvailability) {
622 animations_waiting_for_target_index_[index++] = i;
616 } 623 }
617 } 624 }
618 625
619 for (size_t i = 0; i < animations_.size(); ++i) { 626 for (size_t i = 0; i < index; ++i) {
ajuma 2014/07/23 16:02:18 With the above suggestion to use |reserve| instead
shreyas.g 2014/07/24 10:03:50 Done.
620 if (animations_[i]->run_state() ==
621 Animation::WaitingForTargetAvailability) {
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).
629 size_t animIndex = animations_waiting_for_target_index_[i];
ajuma 2014/07/23 16:02:18 nit: animation_index
shreyas.g 2014/07/24 10:03:50 Done.
630 Animation* animation_waiting_for_target = animations_[animIndex];
ajuma 2014/07/23 16:02:18 You still need to check if this animation is actua
shreyas.g 2014/07/24 10:03:50 Done.
624 TargetProperties enqueued_properties; 631 TargetProperties enqueued_properties;
ajuma 2014/07/23 16:02:18 Nit: indentation needs to be fixed (just run 'git
shreyas.g 2014/07/24 10:03:50 Done.
625 bool affects_active_observers = 632 bool affects_active_observers =
626 animations_[i]->affects_active_observers(); 633 animation_waiting_for_target->affects_active_observers();
627 bool affects_pending_observers = 634 bool affects_pending_observers =
628 animations_[i]->affects_pending_observers(); 635 animation_waiting_for_target->affects_pending_observers();
629 enqueued_properties.insert(animations_[i]->target_property()); 636 enqueued_properties.insert(
630 for (size_t j = i + 1; j < animations_.size(); ++j) { 637 animation_waiting_for_target->target_property());
631 if (animations_[i]->group() == animations_[j]->group()) { 638 for (size_t j = animIndex + 1; j < animations_.size(); ++j) {
639 if (animation_waiting_for_target->group() == animations_[j]->group()) {
632 enqueued_properties.insert(animations_[j]->target_property()); 640 enqueued_properties.insert(animations_[j]->target_property());
633 affects_active_observers |= 641 affects_active_observers |=
634 animations_[j]->affects_active_observers(); 642 animations_[j]->affects_active_observers();
635 affects_pending_observers |= 643 affects_pending_observers |=
636 animations_[j]->affects_pending_observers(); 644 animations_[j]->affects_pending_observers();
637 } 645 }
638 } 646 }
639 647
640 // Check to see if intersection of the list of properties affected by 648 // 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 649 // 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 650 // 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 651 // case, the group's target properties need to be added to the lists of
644 // blocked properties. 652 // blocked properties.
645 bool null_intersection = true; 653 bool null_intersection = true;
646 for (TargetProperties::iterator p_iter = enqueued_properties.begin(); 654 for (TargetProperties::iterator p_iter = enqueued_properties.begin();
647 p_iter != enqueued_properties.end(); 655 p_iter != enqueued_properties.end();
648 ++p_iter) { 656 ++p_iter) {
649 if (affects_active_observers && 657 if (affects_active_observers &&
650 !blocked_properties_for_active_observers.insert(*p_iter).second) 658 !blocked_properties_for_active_observers.insert(*p_iter).second)
651 null_intersection = false; 659 null_intersection = false;
652 if (affects_pending_observers && 660 if (affects_pending_observers &&
653 !blocked_properties_for_pending_observers.insert(*p_iter).second) 661 !blocked_properties_for_pending_observers.insert(*p_iter).second)
654 null_intersection = false; 662 null_intersection = false;
655 } 663 }
656 664
657 // If the intersection is null, then we are free to start the animations 665 // If the intersection is null, then we are free to start the animations
658 // in the group. 666 // in the group.
659 if (null_intersection) { 667 if (null_intersection) {
660 animations_[i]->SetRunState(Animation::Starting, monotonic_time); 668 animation_waiting_for_target->SetRunState(Animation::Starting,
661 for (size_t j = i + 1; j < animations_.size(); ++j) { 669 monotonic_time);
662 if (animations_[i]->group() == animations_[j]->group()) { 670 for (size_t j = animIndex + 1; j < animations_.size(); ++j) {
671 if (animation_waiting_for_target->group() ==
672 animations_[j]->group()) {
663 animations_[j]->SetRunState(Animation::Starting, monotonic_time); 673 animations_[j]->SetRunState(Animation::Starting, monotonic_time);
664 } 674 }
665 } 675 }
666 } else { 676 } else {
667 needs_to_start_animations_ = true; 677 needs_to_start_animations_ = true;
668 } 678 }
669 }
670 } 679 }
671 } 680 }
672 681
673 void LayerAnimationController::PromoteStartedAnimations( 682 void LayerAnimationController::PromoteStartedAnimations(
674 base::TimeTicks monotonic_time, 683 base::TimeTicks monotonic_time,
675 AnimationEventsVector* events) { 684 AnimationEventsVector* events) {
676 for (size_t i = 0; i < animations_.size(); ++i) { 685 for (size_t i = 0; i < animations_.size(); ++i) {
677 if (animations_[i]->run_state() == Animation::Starting && 686 if (animations_[i]->run_state() == Animation::Starting &&
678 animations_[i]->affects_active_observers()) { 687 animations_[i]->affects_active_observers()) {
679 animations_[i]->SetRunState(Animation::Running, monotonic_time); 688 animations_[i]->SetRunState(Animation::Running, monotonic_time);
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 value_observers_); 980 value_observers_);
972 LayerAnimationValueObserver* obs; 981 LayerAnimationValueObserver* obs;
973 while ((obs = it.GetNext()) != NULL) 982 while ((obs = it.GetNext()) != NULL)
974 if (obs->IsActive()) 983 if (obs->IsActive())
975 return true; 984 return true;
976 } 985 }
977 return false; 986 return false;
978 } 987 }
979 988
980 } // namespace cc 989 } // namespace cc
OLDNEW
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698