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

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

Issue 1806223002: CC Animation: Use bitset instead of unordered_set in LayerAnimationController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use operator[] Created 4 years, 9 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 | « cc/animation/layer_animation_controller.h ('k') | cc/animation/target_property.h » ('j') | 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 // First collect running properties affecting each type of observer. 789 // First collect running properties affecting each type of observer.
790 TargetProperties blocked_properties_for_active_observers; 790 TargetProperties blocked_properties_for_active_observers;
791 TargetProperties blocked_properties_for_pending_observers; 791 TargetProperties blocked_properties_for_pending_observers;
792 std::vector<size_t> animations_waiting_for_target; 792 std::vector<size_t> animations_waiting_for_target;
793 793
794 animations_waiting_for_target.reserve(animations_.size()); 794 animations_waiting_for_target.reserve(animations_.size());
795 for (size_t i = 0; i < animations_.size(); ++i) { 795 for (size_t i = 0; i < animations_.size(); ++i) {
796 if (animations_[i]->run_state() == Animation::STARTING || 796 if (animations_[i]->run_state() == Animation::STARTING ||
797 animations_[i]->run_state() == Animation::RUNNING) { 797 animations_[i]->run_state() == Animation::RUNNING) {
798 if (animations_[i]->affects_active_observers()) { 798 if (animations_[i]->affects_active_observers()) {
799 blocked_properties_for_active_observers.insert( 799 blocked_properties_for_active_observers[animations_[i]
800 animations_[i]->target_property()); 800 ->target_property()] = true;
801 } 801 }
802 if (animations_[i]->affects_pending_observers()) { 802 if (animations_[i]->affects_pending_observers()) {
803 blocked_properties_for_pending_observers.insert( 803 blocked_properties_for_pending_observers[animations_[i]
804 animations_[i]->target_property()); 804 ->target_property()] =
805 true;
805 } 806 }
806 } else if (animations_[i]->run_state() == 807 } else if (animations_[i]->run_state() ==
807 Animation::WAITING_FOR_TARGET_AVAILABILITY) { 808 Animation::WAITING_FOR_TARGET_AVAILABILITY) {
808 animations_waiting_for_target.push_back(i); 809 animations_waiting_for_target.push_back(i);
809 } 810 }
810 } 811 }
811 812
812 for (size_t i = 0; i < animations_waiting_for_target.size(); ++i) { 813 for (size_t i = 0; i < animations_waiting_for_target.size(); ++i) {
813 // Collect all properties for animations with the same group id (they 814 // Collect all properties for animations with the same group id (they
814 // should all also be in the list of animations). 815 // should all also be in the list of animations).
815 size_t animation_index = animations_waiting_for_target[i]; 816 size_t animation_index = animations_waiting_for_target[i];
816 Animation* animation_waiting_for_target = 817 Animation* animation_waiting_for_target =
817 animations_[animation_index].get(); 818 animations_[animation_index].get();
818 // Check for the run state again even though the animation was waiting 819 // Check for the run state again even though the animation was waiting
819 // for target because it might have changed the run state while handling 820 // for target because it might have changed the run state while handling
820 // previous animation in this loop (if they belong to same group). 821 // previous animation in this loop (if they belong to same group).
821 if (animation_waiting_for_target->run_state() == 822 if (animation_waiting_for_target->run_state() ==
822 Animation::WAITING_FOR_TARGET_AVAILABILITY) { 823 Animation::WAITING_FOR_TARGET_AVAILABILITY) {
823 TargetProperties enqueued_properties; 824 TargetProperties enqueued_properties;
824 bool affects_active_observers = 825 bool affects_active_observers =
825 animation_waiting_for_target->affects_active_observers(); 826 animation_waiting_for_target->affects_active_observers();
826 bool affects_pending_observers = 827 bool affects_pending_observers =
827 animation_waiting_for_target->affects_pending_observers(); 828 animation_waiting_for_target->affects_pending_observers();
828 enqueued_properties.insert( 829 enqueued_properties[animation_waiting_for_target->target_property()] =
829 animation_waiting_for_target->target_property()); 830 true;
830 for (size_t j = animation_index + 1; j < animations_.size(); ++j) { 831 for (size_t j = animation_index + 1; j < animations_.size(); ++j) {
831 if (animation_waiting_for_target->group() == animations_[j]->group()) { 832 if (animation_waiting_for_target->group() == animations_[j]->group()) {
832 enqueued_properties.insert(animations_[j]->target_property()); 833 enqueued_properties[animations_[j]->target_property()] = true;
833 affects_active_observers |= 834 affects_active_observers |=
834 animations_[j]->affects_active_observers(); 835 animations_[j]->affects_active_observers();
835 affects_pending_observers |= 836 affects_pending_observers |=
836 animations_[j]->affects_pending_observers(); 837 animations_[j]->affects_pending_observers();
837 } 838 }
838 } 839 }
839 840
840 // Check to see if intersection of the list of properties affected by 841 // Check to see if intersection of the list of properties affected by
841 // the group and the list of currently blocked properties is null, taking 842 // the group and the list of currently blocked properties is null, taking
842 // into account the type(s) of observers affected by the group. In any 843 // into account the type(s) of observers affected by the group. In any
843 // case, the group's target properties need to be added to the lists of 844 // case, the group's target properties need to be added to the lists of
844 // blocked properties. 845 // blocked properties.
845 bool null_intersection = true; 846 bool null_intersection = true;
846 for (TargetProperties::iterator p_iter = enqueued_properties.begin(); 847 static_assert(TargetProperty::FIRST_TARGET_PROPERTY == 0,
847 p_iter != enqueued_properties.end(); 848 "TargetProperty must be 0-based enum");
848 ++p_iter) { 849 for (int property = TargetProperty::FIRST_TARGET_PROPERTY;
849 if (affects_active_observers && 850 property <= TargetProperty::LAST_TARGET_PROPERTY; ++property) {
850 !blocked_properties_for_active_observers.insert(*p_iter).second) 851 if (enqueued_properties[property]) {
851 null_intersection = false; 852 if (affects_active_observers) {
852 if (affects_pending_observers && 853 if (blocked_properties_for_active_observers[property])
853 !blocked_properties_for_pending_observers.insert(*p_iter).second) 854 null_intersection = false;
854 null_intersection = false; 855 else
856 blocked_properties_for_active_observers[property] = true;
857 }
858 if (affects_pending_observers) {
859 if (blocked_properties_for_pending_observers[property])
860 null_intersection = false;
861 else
862 blocked_properties_for_pending_observers[property] = true;
863 }
864 }
855 } 865 }
856 866
857 // If the intersection is null, then we are free to start the animations 867 // If the intersection is null, then we are free to start the animations
858 // in the group. 868 // in the group.
859 if (null_intersection) { 869 if (null_intersection) {
860 animation_waiting_for_target->SetRunState(Animation::STARTING, 870 animation_waiting_for_target->SetRunState(Animation::STARTING,
861 monotonic_time); 871 monotonic_time);
862 for (size_t j = animation_index + 1; j < animations_.size(); ++j) { 872 for (size_t j = animation_index + 1; j < animations_.size(); ++j) {
863 if (animation_waiting_for_target->group() == 873 if (animation_waiting_for_target->group() ==
864 animations_[j]->group()) { 874 animations_[j]->group()) {
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 &value_observers_); 1285 &value_observers_);
1276 LayerAnimationValueObserver* obs; 1286 LayerAnimationValueObserver* obs;
1277 while ((obs = it.GetNext()) != nullptr) 1287 while ((obs = it.GetNext()) != nullptr)
1278 if (obs->IsActive()) 1288 if (obs->IsActive())
1279 return true; 1289 return true;
1280 } 1290 }
1281 return false; 1291 return false;
1282 } 1292 }
1283 1293
1284 } // namespace cc 1294 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/layer_animation_controller.h ('k') | cc/animation/target_property.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698