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

Side by Side Diff: ui/compositor/layer_animator.cc

Issue 1531913003: CC Animations: Make ui::LayerAnimator a LayerAnimationEventObserver (instead of ui::Layer) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix LayerAnimator::SetDelegate Created 5 years 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 | « ui/compositor/layer_animator.h ('k') | ui/compositor/layer_animator_unittest.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "ui/compositor/layer_animator.h" 5 #include "ui/compositor/layer_animator.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "cc/animation/animation_id_provider.h" 10 #include "cc/animation/animation_id_provider.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 base::TimeDelta LayerAnimator::GetTransitionDuration() const { 108 base::TimeDelta LayerAnimator::GetTransitionDuration() const {
109 return transition_duration_; 109 return transition_duration_;
110 } 110 }
111 111
112 void LayerAnimator::SetDelegate(LayerAnimationDelegate* delegate) { 112 void LayerAnimator::SetDelegate(LayerAnimationDelegate* delegate) {
113 if (delegate_ && is_started_) { 113 if (delegate_ && is_started_) {
114 LayerAnimatorCollection* collection = GetLayerAnimatorCollection(); 114 LayerAnimatorCollection* collection = GetLayerAnimatorCollection();
115 if (collection) 115 if (collection)
116 collection->StopAnimator(this); 116 collection->StopAnimator(this);
117 } 117 }
118 SwitchToLayer(delegate ? delegate->GetCcLayer() : nullptr);
118 delegate_ = delegate; 119 delegate_ = delegate;
119 if (delegate_ && is_started_) { 120 if (delegate_ && is_started_) {
120 LayerAnimatorCollection* collection = GetLayerAnimatorCollection(); 121 LayerAnimatorCollection* collection = GetLayerAnimatorCollection();
121 if (collection) 122 if (collection)
122 collection->StartAnimator(this); 123 collection->StartAnimator(this);
123 } 124 }
124 } 125 }
125 126
127 void LayerAnimator::SwitchToLayer(scoped_refptr<cc::Layer> new_layer) {
128 if (delegate_) {
129 DCHECK(delegate_->GetCcLayer());
130 delegate_->GetCcLayer()->RemoveLayerAnimationEventObserver(this);
131 }
132 if (new_layer)
133 new_layer->AddLayerAnimationEventObserver(this);
134 }
135
126 void LayerAnimator::StartAnimation(LayerAnimationSequence* animation) { 136 void LayerAnimator::StartAnimation(LayerAnimationSequence* animation) {
127 scoped_refptr<LayerAnimator> retain(this); 137 scoped_refptr<LayerAnimator> retain(this);
128 OnScheduled(animation); 138 OnScheduled(animation);
129 if (!StartSequenceImmediately(animation)) { 139 if (!StartSequenceImmediately(animation)) {
130 // Attempt to preempt a running animation. 140 // Attempt to preempt a running animation.
131 switch (preemption_strategy_) { 141 switch (preemption_strategy_) {
132 case IMMEDIATELY_SET_NEW_TARGET: 142 case IMMEDIATELY_SET_NEW_TARGET:
133 ImmediatelySetNewTarget(animation); 143 ImmediatelySetNewTarget(animation);
134 break; 144 break;
135 case IMMEDIATELY_ANIMATE_TO_NEW_TARGET: 145 case IMMEDIATELY_ANIMATE_TO_NEW_TARGET:
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 running_animations_.erase(running_animations_.begin() + i); 853 running_animations_.erase(running_animations_.begin() + i);
844 else 854 else
845 i++; 855 i++;
846 } 856 }
847 } 857 }
848 858
849 LayerAnimatorCollection* LayerAnimator::GetLayerAnimatorCollection() { 859 LayerAnimatorCollection* LayerAnimator::GetLayerAnimatorCollection() {
850 return delegate_ ? delegate_->GetLayerAnimatorCollection() : NULL; 860 return delegate_ ? delegate_->GetLayerAnimatorCollection() : NULL;
851 } 861 }
852 862
863 void LayerAnimator::OnAnimationStarted(const cc::AnimationEvent& event) {
864 OnThreadedAnimationStarted(event);
865 }
866
853 LayerAnimator::RunningAnimation::RunningAnimation( 867 LayerAnimator::RunningAnimation::RunningAnimation(
854 const base::WeakPtr<LayerAnimationSequence>& sequence) 868 const base::WeakPtr<LayerAnimationSequence>& sequence)
855 : sequence_(sequence) { 869 : sequence_(sequence) {
856 } 870 }
857 871
858 LayerAnimator::RunningAnimation::~RunningAnimation() { } 872 LayerAnimator::RunningAnimation::~RunningAnimation() { }
859 873
860 } // namespace ui 874 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer_animator.h ('k') | ui/compositor/layer_animator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698