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

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

Issue 1776513002: UI Compositor: Fix threaded animation survival if layer removed and added. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix. Add more checks for moving between compositors test. Created 4 years, 9 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') | 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
12 #include "cc/animation/animation_events.h" 12 #include "cc/animation/animation_events.h"
13 #include "cc/animation/animation_host.h"
13 #include "cc/animation/animation_id_provider.h" 14 #include "cc/animation/animation_id_provider.h"
14 #include "cc/animation/animation_player.h" 15 #include "cc/animation/animation_player.h"
16 #include "cc/animation/animation_registrar.h"
15 #include "cc/animation/animation_timeline.h" 17 #include "cc/animation/animation_timeline.h"
16 #include "cc/animation/element_animations.h" 18 #include "cc/animation/element_animations.h"
19 #include "cc/animation/layer_animation_controller.h"
17 #include "cc/layers/layer_settings.h" 20 #include "cc/layers/layer_settings.h"
18 #include "cc/output/begin_frame_args.h" 21 #include "cc/output/begin_frame_args.h"
19 #include "ui/compositor/compositor.h" 22 #include "ui/compositor/compositor.h"
20 #include "ui/compositor/layer.h" 23 #include "ui/compositor/layer.h"
21 #include "ui/compositor/layer_animation_delegate.h" 24 #include "ui/compositor/layer_animation_delegate.h"
22 #include "ui/compositor/layer_animation_observer.h" 25 #include "ui/compositor/layer_animation_observer.h"
23 #include "ui/compositor/layer_animation_sequence.h" 26 #include "ui/compositor/layer_animation_sequence.h"
24 #include "ui/compositor/layer_animator_collection.h" 27 #include "ui/compositor/layer_animator_collection.h"
25 28
26 #define SAFE_INVOKE_VOID(function, running_anim, ...) \ 29 #define SAFE_INVOKE_VOID(function, running_anim, ...) \
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 else 150 else
148 new_layer->AddLayerAnimationEventObserver(this); 151 new_layer->AddLayerAnimationEventObserver(this);
149 } 152 }
150 } 153 }
151 154
152 void LayerAnimator::SetCompositor(Compositor* compositor) { 155 void LayerAnimator::SetCompositor(Compositor* compositor) {
153 DCHECK(compositor); 156 DCHECK(compositor);
154 if (animation_player_) { 157 if (animation_player_) {
155 cc::AnimationTimeline* timeline = compositor->GetAnimationTimeline(); 158 cc::AnimationTimeline* timeline = compositor->GetAnimationTimeline();
156 DCHECK(timeline); 159 DCHECK(timeline);
160
161 DCHECK(delegate_->GetCcLayer());
162
163 // Register LAC so ElementAnimations picks it up via
164 // AnimationRegistrar::GetAnimationControllerForId.
165 if (animation_controller_state_ &&
166 animation_controller_state_->id() == delegate_->GetCcLayer()->id()) {
ajuma 2016/03/08 23:51:00 To turn this back into a DCHECK, clear the animati
167 timeline->animation_host()
168 ->animation_registrar()
169 ->RegisterAnimationController(animation_controller_state_.get());
170 }
171
157 timeline->AttachPlayer(animation_player_); 172 timeline->AttachPlayer(animation_player_);
158 173
159 DCHECK(delegate_->GetCcLayer());
160 AttachLayerToAnimationPlayer(delegate_->GetCcLayer()->id()); 174 AttachLayerToAnimationPlayer(delegate_->GetCcLayer()->id());
175
176 // Release LAC (it is referenced in ElementAnimations).
177 animation_controller_state_ = nullptr;
161 } 178 }
162 } 179 }
163 180
164 void LayerAnimator::ResetCompositor(Compositor* compositor) { 181 void LayerAnimator::ResetCompositor(Compositor* compositor) {
165 DCHECK(compositor); 182 DCHECK(compositor);
166 if (animation_player_) { 183 if (animation_player_) {
184 // Store a reference to LAC if any so it may be picked up in SetCompositor.
185 if (animation_player_->element_animations()) {
186 animation_controller_state_ =
187 animation_player_->element_animations()->layer_animation_controller();
188 }
189
167 DetachLayerFromAnimationPlayer(); 190 DetachLayerFromAnimationPlayer();
168 191
169 cc::AnimationTimeline* timeline = compositor->GetAnimationTimeline(); 192 cc::AnimationTimeline* timeline = compositor->GetAnimationTimeline();
170 DCHECK(timeline); 193 DCHECK(timeline);
171 timeline->DetachPlayer(animation_player_); 194 timeline->DetachPlayer(animation_player_);
172 } 195 }
173 } 196 }
174 197
175 void LayerAnimator::AttachLayerToAnimationPlayer(int layer_id) { 198 void LayerAnimator::AttachLayerToAnimationPlayer(int layer_id) {
176 DCHECK(animation_player_); 199 DCHECK(animation_player_);
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 const base::WeakPtr<LayerAnimationSequence>& sequence) 977 const base::WeakPtr<LayerAnimationSequence>& sequence)
955 : sequence_(sequence) { 978 : sequence_(sequence) {
956 } 979 }
957 980
958 LayerAnimator::RunningAnimation::RunningAnimation( 981 LayerAnimator::RunningAnimation::RunningAnimation(
959 const RunningAnimation& other) = default; 982 const RunningAnimation& other) = default;
960 983
961 LayerAnimator::RunningAnimation::~RunningAnimation() { } 984 LayerAnimator::RunningAnimation::~RunningAnimation() { }
962 985
963 } // namespace ui 986 } // 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