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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/animation/layer_animation_controller.cc
diff --git a/cc/animation/layer_animation_controller.cc b/cc/animation/layer_animation_controller.cc
index 4e85592303ea3007915d1f577edfe667a2f0277d..88595f57d05c8147bf780a1e298b75fd4a8c7446 100644
--- a/cc/animation/layer_animation_controller.cc
+++ b/cc/animation/layer_animation_controller.cc
@@ -602,6 +602,10 @@ void LayerAnimationController::StartAnimations(base::TimeTicks monotonic_time) {
// First collect running properties affecting each type of observer.
TargetProperties blocked_properties_for_active_observers;
TargetProperties blocked_properties_for_pending_observers;
+ 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.
+ size_t index = 0;
+
+ 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.
for (size_t i = 0; i < animations_.size(); ++i) {
if (animations_[i]->run_state() == Animation::Starting ||
animations_[i]->run_state() == Animation::Running) {
@@ -613,22 +617,26 @@ void LayerAnimationController::StartAnimations(base::TimeTicks monotonic_time) {
blocked_properties_for_pending_observers.insert(
animations_[i]->target_property());
}
+ } else if (animations_[i]->run_state() ==
+ Animation::WaitingForTargetAvailability) {
+ animations_waiting_for_target_index_[index++] = i;
}
}
- for (size_t i = 0; i < animations_.size(); ++i) {
- if (animations_[i]->run_state() ==
- Animation::WaitingForTargetAvailability) {
+ 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.
// Collect all properties for animations with the same group id (they
// should all also be in the list of animations).
+ 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.
+ 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.
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.
bool affects_active_observers =
- animations_[i]->affects_active_observers();
+ animation_waiting_for_target->affects_active_observers();
bool affects_pending_observers =
- animations_[i]->affects_pending_observers();
- enqueued_properties.insert(animations_[i]->target_property());
- for (size_t j = i + 1; j < animations_.size(); ++j) {
- if (animations_[i]->group() == animations_[j]->group()) {
+ animation_waiting_for_target->affects_pending_observers();
+ enqueued_properties.insert(
+ animation_waiting_for_target->target_property());
+ for (size_t j = animIndex + 1; j < animations_.size(); ++j) {
+ if (animation_waiting_for_target->group() == animations_[j]->group()) {
enqueued_properties.insert(animations_[j]->target_property());
affects_active_observers |=
animations_[j]->affects_active_observers();
@@ -657,16 +665,17 @@ void LayerAnimationController::StartAnimations(base::TimeTicks monotonic_time) {
// If the intersection is null, then we are free to start the animations
// in the group.
if (null_intersection) {
- animations_[i]->SetRunState(Animation::Starting, monotonic_time);
- for (size_t j = i + 1; j < animations_.size(); ++j) {
- if (animations_[i]->group() == animations_[j]->group()) {
+ animation_waiting_for_target->SetRunState(Animation::Starting,
+ monotonic_time);
+ for (size_t j = animIndex + 1; j < animations_.size(); ++j) {
+ if (animation_waiting_for_target->group() ==
+ animations_[j]->group()) {
animations_[j]->SetRunState(Animation::Starting, monotonic_time);
}
}
} else {
needs_to_start_animations_ = true;
}
- }
}
}
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698