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

Unified 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 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 4d063ecd6e94d2afd591b0569ed2bdf6aa90a509..b4afd2e0dfc30d31bbfaf65ac10880ba0deba818 100644
--- a/ui/compositor/layer_animator.cc
+++ b/ui/compositor/layer_animator.cc
@@ -115,6 +115,7 @@ void LayerAnimator::SetDelegate(LayerAnimationDelegate* delegate) {
if (collection)
collection->StopAnimator(this);
}
+ SwitchToLayer(delegate ? delegate->GetCcLayer() : nullptr);
delegate_ = delegate;
if (delegate_ && is_started_) {
LayerAnimatorCollection* collection = GetLayerAnimatorCollection();
@@ -123,6 +124,15 @@ void LayerAnimator::SetDelegate(LayerAnimationDelegate* delegate) {
}
}
+void LayerAnimator::SwitchToLayer(scoped_refptr<cc::Layer> new_layer) {
+ if (delegate_) {
+ DCHECK(delegate_->GetCcLayer());
+ delegate_->GetCcLayer()->RemoveLayerAnimationEventObserver(this);
+ }
+ if (new_layer)
+ new_layer->AddLayerAnimationEventObserver(this);
+}
+
void LayerAnimator::StartAnimation(LayerAnimationSequence* animation) {
scoped_refptr<LayerAnimator> retain(this);
OnScheduled(animation);
@@ -850,6 +860,10 @@ LayerAnimatorCollection* LayerAnimator::GetLayerAnimatorCollection() {
return delegate_ ? delegate_->GetLayerAnimatorCollection() : NULL;
}
+void LayerAnimator::OnAnimationStarted(const cc::AnimationEvent& event) {
+ OnThreadedAnimationStarted(event);
+}
+
LayerAnimator::RunningAnimation::RunningAnimation(
const base::WeakPtr<LayerAnimationSequence>& sequence)
: sequence_(sequence) {
« 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