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

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

Issue 2049063002: Revert of Use element id's for animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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.cc ('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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 cc::AnimationTimeline* timeline = compositor->GetAnimationTimeline(); 150 cc::AnimationTimeline* timeline = compositor->GetAnimationTimeline();
151 DCHECK(timeline); 151 DCHECK(timeline);
152 152
153 DCHECK(delegate_->GetCcLayer()); 153 DCHECK(delegate_->GetCcLayer());
154 154
155 // Register ElementAnimations so it will be picked up by 155 // Register ElementAnimations so it will be picked up by
156 // AnimationHost::RegisterPlayerForLayer via 156 // AnimationHost::RegisterPlayerForLayer via
157 // AnimationHost::GetElementAnimationsForLayerId. 157 // AnimationHost::GetElementAnimationsForLayerId.
158 if (element_animations_state_) { 158 if (element_animations_state_) {
159 DCHECK_EQ(element_animations_state_->element_id().primaryId, 159 DCHECK_EQ(element_animations_state_->element_id(),
160 delegate_->GetCcLayer()->id()); 160 delegate_->GetCcLayer()->id());
161 timeline->animation_host()->RegisterElementAnimations( 161 timeline->animation_host()->RegisterElementAnimations(
162 element_animations_state_.get()); 162 element_animations_state_.get());
163 } 163 }
164 164
165 timeline->AttachPlayer(animation_player_); 165 timeline->AttachPlayer(animation_player_);
166 166
167 AttachLayerToAnimationPlayer(delegate_->GetCcLayer()->id()); 167 AttachLayerToAnimationPlayer(delegate_->GetCcLayer()->id());
168 168
169 // Release ElementAnimations state. 169 // Release ElementAnimations state.
170 element_animations_state_ = nullptr; 170 element_animations_state_ = nullptr;
171 } 171 }
172 172
173 void LayerAnimator::ResetCompositor(Compositor* compositor) { 173 void LayerAnimator::ResetCompositor(Compositor* compositor) {
174 DCHECK(compositor); 174 DCHECK(compositor);
175 175
176 cc::AnimationTimeline* timeline = compositor->GetAnimationTimeline(); 176 cc::AnimationTimeline* timeline = compositor->GetAnimationTimeline();
177 DCHECK(timeline); 177 DCHECK(timeline);
178 178
179 cc::ElementId element_id(animation_player_->element_id()); 179 const int layer_id = animation_player_->element_id();
180 180
181 // Store a reference to ElementAnimations (if any) 181 // Store a reference to ElementAnimations (if any)
182 // so it may be picked up in LayerAnimator::SetCompositor. 182 // so it may be picked up in LayerAnimator::SetCompositor.
183 if (element_id) { 183 if (layer_id) {
184 element_animations_state_ = 184 element_animations_state_ =
185 timeline->animation_host()->GetElementAnimationsForElementId( 185 timeline->animation_host()->GetElementAnimationsForElementId(layer_id);
186 element_id);
187 } 186 }
188 187
189 DetachLayerFromAnimationPlayer(); 188 DetachLayerFromAnimationPlayer();
190 189
191 timeline->DetachPlayer(animation_player_); 190 timeline->DetachPlayer(animation_player_);
192 } 191 }
193 192
194 void LayerAnimator::AttachLayerToAnimationPlayer(int layer_id) { 193 void LayerAnimator::AttachLayerToAnimationPlayer(int layer_id) {
195 // For ui, layer and element ids are equivalent.
196 cc::ElementId element_id(layer_id, 0);
197 if (!animation_player_->element_id()) 194 if (!animation_player_->element_id())
198 animation_player_->AttachElement(element_id); 195 animation_player_->AttachElement(layer_id);
199 else 196 else
200 DCHECK_EQ(animation_player_->element_id(), element_id); 197 DCHECK_EQ(animation_player_->element_id(), layer_id);
201 198
202 animation_player_->set_animation_delegate(this); 199 animation_player_->set_animation_delegate(this);
203 } 200 }
204 201
205 void LayerAnimator::DetachLayerFromAnimationPlayer() { 202 void LayerAnimator::DetachLayerFromAnimationPlayer() {
206 animation_player_->set_animation_delegate(nullptr); 203 animation_player_->set_animation_delegate(nullptr);
207 204
208 if (animation_player_->element_id()) 205 if (animation_player_->element_id())
209 animation_player_->DetachElement(); 206 animation_player_->DetachElement();
210 } 207 }
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 const base::WeakPtr<LayerAnimationSequence>& sequence) 964 const base::WeakPtr<LayerAnimationSequence>& sequence)
968 : sequence_(sequence) { 965 : sequence_(sequence) {
969 } 966 }
970 967
971 LayerAnimator::RunningAnimation::RunningAnimation( 968 LayerAnimator::RunningAnimation::RunningAnimation(
972 const RunningAnimation& other) = default; 969 const RunningAnimation& other) = default;
973 970
974 LayerAnimator::RunningAnimation::~RunningAnimation() { } 971 LayerAnimator::RunningAnimation::~RunningAnimation() { }
975 972
976 } // namespace ui 973 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698