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

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

Issue 2363733004: UI Compositor Animation: Remove cc::ElementAnimations state storage. (Closed)
Patch Set: Reparent. Created 4 years, 2 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 | « ui/compositor/layer_animator.h ('k') | no next file » | 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 SwitchToLayer(delegate ? delegate->GetCcLayer() : nullptr); 128 SwitchToLayer(delegate ? delegate->GetCcLayer() : nullptr);
129 delegate_ = delegate; 129 delegate_ = delegate;
130 if (delegate_ && is_started_) { 130 if (delegate_ && is_started_) {
131 LayerAnimatorCollection* collection = GetLayerAnimatorCollection(); 131 LayerAnimatorCollection* collection = GetLayerAnimatorCollection();
132 if (collection) 132 if (collection)
133 collection->StartAnimator(this); 133 collection->StartAnimator(this);
134 } 134 }
135 } 135 }
136 136
137 void LayerAnimator::SwitchToLayer(scoped_refptr<cc::Layer> new_layer) { 137 void LayerAnimator::SwitchToLayer(scoped_refptr<cc::Layer> new_layer) {
138 // Release ElementAnimations state for old layer.
139 element_animations_state_ = nullptr;
140
141 if (delegate_) 138 if (delegate_)
142 DetachLayerFromAnimationPlayer(); 139 DetachLayerFromAnimationPlayer();
143 if (new_layer) 140 if (new_layer)
144 AttachLayerToAnimationPlayer(new_layer->id()); 141 AttachLayerToAnimationPlayer(new_layer->id());
145 } 142 }
146 143
147 void LayerAnimator::SetCompositor(Compositor* compositor) { 144 void LayerAnimator::AttachLayerAndTimeline(Compositor* compositor) {
145 DCHECK(compositor);
146
147 cc::AnimationTimeline* timeline = compositor->GetAnimationTimeline();
148 DCHECK(timeline);
149 timeline->AttachPlayer(animation_player_);
150
151 DCHECK(delegate_->GetCcLayer());
152 AttachLayerToAnimationPlayer(delegate_->GetCcLayer()->id());
153 }
154
155 void LayerAnimator::DetachLayerAndTimeline(Compositor* compositor) {
148 DCHECK(compositor); 156 DCHECK(compositor);
149 157
150 cc::AnimationTimeline* timeline = compositor->GetAnimationTimeline(); 158 cc::AnimationTimeline* timeline = compositor->GetAnimationTimeline();
151 DCHECK(timeline); 159 DCHECK(timeline);
152 160
153 DCHECK(delegate_->GetCcLayer());
154
155 // Register ElementAnimations so it will be picked up by
156 // AnimationHost::RegisterPlayerForLayer via
157 // AnimationHost::GetElementAnimationsForLayerId.
158 if (element_animations_state_) {
159 DCHECK_EQ(element_animations_state_->element_id().primaryId,
160 delegate_->GetCcLayer()->id());
161 timeline->animation_host()->RegisterElementAnimations(
162 element_animations_state_.get());
163 }
164
165 timeline->AttachPlayer(animation_player_);
166
167 AttachLayerToAnimationPlayer(delegate_->GetCcLayer()->id());
168
169 // Release ElementAnimations state.
170 element_animations_state_ = nullptr;
171 }
172
173 void LayerAnimator::ResetCompositor(Compositor* compositor) {
174 DCHECK(compositor);
175
176 cc::AnimationTimeline* timeline = compositor->GetAnimationTimeline();
177 DCHECK(timeline);
178
179 cc::ElementId element_id(animation_player_->element_id());
180
181 // Store a reference to ElementAnimations (if any)
182 // so it may be picked up in LayerAnimator::SetCompositor.
183 if (element_id) {
184 element_animations_state_ =
185 timeline->animation_host()->GetElementAnimationsForElementId(
186 element_id);
187 }
188
189 DetachLayerFromAnimationPlayer(); 161 DetachLayerFromAnimationPlayer();
190
191 timeline->DetachPlayer(animation_player_); 162 timeline->DetachPlayer(animation_player_);
192 } 163 }
193 164
194 void LayerAnimator::AttachLayerToAnimationPlayer(int layer_id) { 165 void LayerAnimator::AttachLayerToAnimationPlayer(int layer_id) {
195 // For ui, layer and element ids are equivalent. 166 // For ui, layer and element ids are equivalent.
196 cc::ElementId element_id(layer_id, 0); 167 cc::ElementId element_id(layer_id, 0);
197 if (!animation_player_->element_id()) 168 if (!animation_player_->element_id())
198 animation_player_->AttachElement(element_id); 169 animation_player_->AttachElement(element_id);
199 else 170 else
200 DCHECK_EQ(animation_player_->element_id(), element_id); 171 DCHECK_EQ(animation_player_->element_id(), element_id);
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 const base::WeakPtr<LayerAnimationSequence>& sequence) 934 const base::WeakPtr<LayerAnimationSequence>& sequence)
964 : sequence_(sequence) { 935 : sequence_(sequence) {
965 } 936 }
966 937
967 LayerAnimator::RunningAnimation::RunningAnimation( 938 LayerAnimator::RunningAnimation::RunningAnimation(
968 const RunningAnimation& other) = default; 939 const RunningAnimation& other) = default;
969 940
970 LayerAnimator::RunningAnimation::~RunningAnimation() { } 941 LayerAnimator::RunningAnimation::~RunningAnimation() { }
971 942
972 } // namespace ui 943 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer_animator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698