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

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

Issue 13613003: cc: Make animations tick regardless of drawing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
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_registrar.h" 10 #include "cc/animation/animation_registrar.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // thread are kept in sync. 109 // thread are kept in sync.
110 void LayerAnimationController::PushAnimationUpdatesTo( 110 void LayerAnimationController::PushAnimationUpdatesTo(
111 LayerAnimationController* controller_impl) { 111 LayerAnimationController* controller_impl) {
112 if (force_sync_) { 112 if (force_sync_) {
113 ReplaceImplThreadAnimations(controller_impl); 113 ReplaceImplThreadAnimations(controller_impl);
114 force_sync_ = false; 114 force_sync_ = false;
115 } else { 115 } else {
116 PurgeAnimationsMarkedForDeletion(); 116 PurgeAnimationsMarkedForDeletion();
117 PushNewAnimationsToImplThread(controller_impl); 117 PushNewAnimationsToImplThread(controller_impl);
118 118
119 // Remove finished impl side animations only after pushing, 119 FinishAnimationsCompletedOnMainThread(controller_impl);
ajuma 2013/04/04 15:28:47 This will also change the way animations that are
120 // and only after the animations are deleted on the main thread
121 // this insures we will never push an animation twice.
122 RemoveAnimationsCompletedOnMainThread(controller_impl);
123 120
124 PushPropertiesToImplThread(controller_impl); 121 PushPropertiesToImplThread(controller_impl);
125 } 122 }
126 controller_impl->UpdateActivation(NormalActivation); 123 controller_impl->UpdateActivation(NormalActivation);
127 UpdateActivation(NormalActivation); 124 UpdateActivation(NormalActivation);
128 } 125 }
129 126
130 void LayerAnimationController::Animate(double monotonic_time) { 127 void LayerAnimationController::Animate(double monotonic_time) {
131 if (!HasActiveObserver()) 128 if (!HasActiveObserver())
132 return; 129 return;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 return; 176 return;
180 177
181 PromoteStartedAnimations(last_tick_time_, events); 178 PromoteStartedAnimations(last_tick_time_, events);
182 MarkFinishedAnimations(last_tick_time_); 179 MarkFinishedAnimations(last_tick_time_);
183 MarkAnimationsForDeletion(last_tick_time_, events); 180 MarkAnimationsForDeletion(last_tick_time_, events);
184 StartAnimationsWaitingForTargetAvailability(last_tick_time_); 181 StartAnimationsWaitingForTargetAvailability(last_tick_time_);
185 PromoteStartedAnimations(last_tick_time_, events); 182 PromoteStartedAnimations(last_tick_time_, events);
186 183
187 AccumulatePropertyUpdates(last_tick_time_, events); 184 AccumulatePropertyUpdates(last_tick_time_, events);
188 185
186 if (events) {
187 // If we have an |events|, then we have sent a finished event to the main
188 // thread in the |events| list. Then the animation serves no purpose to the
189 // compositor anymore, and should be removed.
190 PurgeAnimationsMarkedForDeletion();
ajuma 2013/04/04 15:28:47 This creates a risk of pushing an animation from t
191 }
192
189 UpdateActivation(NormalActivation); 193 UpdateActivation(NormalActivation);
190 } 194 }
191 195
192 void LayerAnimationController::AddAnimation(scoped_ptr<Animation> animation) { 196 void LayerAnimationController::AddAnimation(scoped_ptr<Animation> animation) {
193 active_animations_.push_back(animation.Pass()); 197 active_animations_.push_back(animation.Pass());
194 UpdateActivation(NormalActivation); 198 UpdateActivation(NormalActivation);
195 } 199 }
196 200
197 Animation* LayerAnimationController::GetAnimation( 201 Animation* LayerAnimationController::GetAnimation(
198 int group_id, 202 int group_id,
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 : main_thread_controller_(main_thread_controller) {} 312 : main_thread_controller_(main_thread_controller) {}
309 bool operator()(Animation* animation) const { 313 bool operator()(Animation* animation) const {
310 if (animation->is_impl_only()) 314 if (animation->is_impl_only())
311 return false; 315 return false;
312 return !main_thread_controller_.GetAnimation(animation->group(), 316 return !main_thread_controller_.GetAnimation(animation->group(),
313 animation->target_property()); 317 animation->target_property());
314 } 318 }
315 319
316 private: 320 private:
317 const LayerAnimationController& main_thread_controller_; 321 const LayerAnimationController& main_thread_controller_;
318 }; 322 };
ajuma 2013/04/04 15:28:47 With the change below, this struct is now unused.
319 323
320 void LayerAnimationController::RemoveAnimationsCompletedOnMainThread( 324 void LayerAnimationController::FinishAnimationsCompletedOnMainThread(
321 LayerAnimationController* controller_impl) const { 325 LayerAnimationController* controller_impl) const {
322 // Delete all impl thread animations for which there is no corresponding 326 for (size_t i = 0; i < active_animations_.size(); ++i) {
323 // main thread animation. Each iteration, 327 if (active_animations_[i]->is_impl_only())
324 // controller->active_animations_.size() is decremented or i is incremented 328 continue;
325 // guaranteeing progress towards loop termination. 329 if (!GetAnimation(active_animations_[i]->group(),
326 ScopedPtrVector<Animation>& animations = 330 active_animations_[i]->target_property()))
327 controller_impl->active_animations_; 331 active_animations_[i]->SetRunState(Animation::Finished, 0);
328 animations.erase(cc::remove_if(&animations, 332 }
329 animations.begin(),
330 animations.end(),
331 IsCompleted(*this)),
332 animations.end());
333 } 333 }
334 334
335 void LayerAnimationController::PushPropertiesToImplThread( 335 void LayerAnimationController::PushPropertiesToImplThread(
336 LayerAnimationController* controller_impl) const { 336 LayerAnimationController* controller_impl) const {
337 for (size_t i = 0; i < active_animations_.size(); ++i) { 337 for (size_t i = 0; i < active_animations_.size(); ++i) {
338 Animation* current_impl = 338 Animation* current_impl =
339 controller_impl->GetAnimation( 339 controller_impl->GetAnimation(
340 active_animations_[i]->group(), 340 active_animations_[i]->group(),
341 active_animations_[i]->target_property()); 341 active_animations_[i]->target_property());
342 if (current_impl) 342 if (current_impl)
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 ObserverListBase<LayerAnimationValueObserver>::Iterator it(observers_); 617 ObserverListBase<LayerAnimationValueObserver>::Iterator it(observers_);
618 LayerAnimationValueObserver* obs; 618 LayerAnimationValueObserver* obs;
619 while ((obs = it.GetNext()) != NULL) 619 while ((obs = it.GetNext()) != NULL)
620 if (obs->IsActive()) 620 if (obs->IsActive())
621 return true; 621 return true;
622 } 622 }
623 return false; 623 return false;
624 } 624 }
625 625
626 } // namespace cc 626 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698