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

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

Issue 73343002: De-activate LayerAnimationControllers when all animations are WaitingForDeletion (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix TickAnimationWhileBackgrounded flake Created 7 years, 1 month 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_delegate.h" 10 #include "cc/animation/animation_delegate.h"
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 case Animation::TargetPropertyEnumSize: 713 case Animation::TargetPropertyEnumSize:
714 NOTREACHED(); 714 NOTREACHED();
715 } 715 }
716 } 716 }
717 } 717 }
718 } 718 }
719 719
720 void LayerAnimationController::UpdateActivation(UpdateActivationType type) { 720 void LayerAnimationController::UpdateActivation(UpdateActivationType type) {
721 bool force = type == ForceActivation; 721 bool force = type == ForceActivation;
722 if (registrar_) { 722 if (registrar_) {
723 if (!active_animations_.empty() && (!is_active_ || force)) 723 bool was_active = is_active_;
724 is_active_ = false;
725 for (size_t i = 0; i < active_animations_.size(); ++i) {
726 if (active_animations_[i]->run_state() != Animation::WaitingForDeletion) {
727 is_active_ = true;
728 break;
729 }
730 }
731
732 if (is_active_ && (!was_active || force))
724 registrar_->DidActivateAnimationController(this); 733 registrar_->DidActivateAnimationController(this);
725 else if (active_animations_.empty() && (is_active_ || force)) 734 else if (!is_active_ && (was_active || force))
726 registrar_->DidDeactivateAnimationController(this); 735 registrar_->DidDeactivateAnimationController(this);
727 is_active_ = !active_animations_.empty();
728 } 736 }
729 } 737 }
730 738
731 void LayerAnimationController::NotifyObserversOpacityAnimated(float opacity) { 739 void LayerAnimationController::NotifyObserversOpacityAnimated(float opacity) {
732 FOR_EACH_OBSERVER(LayerAnimationValueObserver, 740 FOR_EACH_OBSERVER(LayerAnimationValueObserver,
733 value_observers_, 741 value_observers_,
734 OnOpacityAnimated(opacity)); 742 OnOpacityAnimated(opacity));
735 } 743 }
736 744
737 void LayerAnimationController::NotifyObserversTransformAnimated( 745 void LayerAnimationController::NotifyObserversTransformAnimated(
(...skipping 25 matching lines...) Expand all
763 value_observers_); 771 value_observers_);
764 LayerAnimationValueObserver* obs; 772 LayerAnimationValueObserver* obs;
765 while ((obs = it.GetNext()) != NULL) 773 while ((obs = it.GetNext()) != NULL)
766 if (obs->IsActive()) 774 if (obs->IsActive())
767 return true; 775 return true;
768 } 776 }
769 return false; 777 return false;
770 } 778 }
771 779
772 } // namespace cc 780 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/animation/layer_animation_controller_unittest.cc » ('j') | cc/trees/layer_tree_host_unittest_animation.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698