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

Unified Diff: ui/compositor/layer_animator.cc

Issue 1778213003: UI Compositor: Fix threaded animation survival if layer removed and added. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/layer_animator.cc
diff --git a/ui/compositor/layer_animator.cc b/ui/compositor/layer_animator.cc
index aee68120456c472ca1692f88998a0f3d0850a71b..5f16d35fef1483d6b91823eda9944dbb6dce5a92 100644
--- a/ui/compositor/layer_animator.cc
+++ b/ui/compositor/layer_animator.cc
@@ -10,10 +10,13 @@
#include "base/memory/scoped_ptr.h"
#include "base/trace_event/trace_event.h"
#include "cc/animation/animation_events.h"
+#include "cc/animation/animation_host.h"
#include "cc/animation/animation_id_provider.h"
#include "cc/animation/animation_player.h"
+#include "cc/animation/animation_registrar.h"
#include "cc/animation/animation_timeline.h"
#include "cc/animation/element_animations.h"
+#include "cc/animation/layer_animation_controller.h"
#include "cc/layers/layer_settings.h"
#include "cc/output/begin_frame_args.h"
#include "ui/compositor/compositor.h"
@@ -137,6 +140,9 @@ void LayerAnimator::SetDelegate(LayerAnimationDelegate* delegate) {
}
void LayerAnimator::SwitchToLayer(scoped_refptr<cc::Layer> new_layer) {
+ // Release LAC state for old layer.
+ animation_controller_state_ = nullptr;
+
if (delegate_) {
if (animation_player_)
DetachLayerFromAnimationPlayer();
@@ -156,16 +162,37 @@ void LayerAnimator::SetCompositor(Compositor* compositor) {
if (animation_player_) {
cc::AnimationTimeline* timeline = compositor->GetAnimationTimeline();
DCHECK(timeline);
- timeline->AttachPlayer(animation_player_);
DCHECK(delegate_->GetCcLayer());
+
+ // Register LAC so ElementAnimations picks it up via
+ // AnimationRegistrar::GetAnimationControllerForId.
+ if (animation_controller_state_) {
+ DCHECK_EQ(animation_controller_state_->id(),
+ delegate_->GetCcLayer()->id());
+ timeline->animation_host()
+ ->animation_registrar()
+ ->RegisterAnimationController(animation_controller_state_.get());
+ }
+
+ timeline->AttachPlayer(animation_player_);
+
AttachLayerToAnimationPlayer(delegate_->GetCcLayer()->id());
+
+ // Release LAC (it is referenced in ElementAnimations).
+ animation_controller_state_ = nullptr;
}
}
void LayerAnimator::ResetCompositor(Compositor* compositor) {
DCHECK(compositor);
if (animation_player_) {
+ // Store a reference to LAC if any so it may be picked up in SetCompositor.
+ if (animation_player_->element_animations()) {
+ animation_controller_state_ =
+ animation_player_->element_animations()->layer_animation_controller();
+ }
+
DetachLayerFromAnimationPlayer();
cc::AnimationTimeline* timeline = compositor->GetAnimationTimeline();
« 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