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

Side by Side Diff: cc/animation/animation_player.cc

Issue 1904653002: CC Animation: Merge LayerAnimationController into ElementAnimations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor optimization: Don't init value observations if same host. Created 4 years, 8 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 | « cc/animation/animation_player.h ('k') | cc/animation/animation_player_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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "cc/animation/animation_player.h" 5 #include "cc/animation/animation_player.h"
6 6
7 #include "cc/animation/animation_delegate.h" 7 #include "cc/animation/animation_delegate.h"
8 #include "cc/animation/animation_host.h" 8 #include "cc/animation/animation_host.h"
9 #include "cc/animation/animation_timeline.h" 9 #include "cc/animation/animation_timeline.h"
10 #include "cc/animation/layer_animation_controller.h" 10 #include "cc/animation/element_animations.h"
11 11
12 namespace cc { 12 namespace cc {
13 13
14 scoped_refptr<AnimationPlayer> AnimationPlayer::Create(int id) { 14 scoped_refptr<AnimationPlayer> AnimationPlayer::Create(int id) {
15 return make_scoped_refptr(new AnimationPlayer(id)); 15 return make_scoped_refptr(new AnimationPlayer(id));
16 } 16 }
17 17
18 AnimationPlayer::AnimationPlayer(int id) 18 AnimationPlayer::AnimationPlayer(int id)
19 : animation_host_(), 19 : animation_host_(),
20 animation_timeline_(), 20 animation_timeline_(),
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 UnregisterPlayer(); 73 UnregisterPlayer();
74 74
75 layer_id_ = 0; 75 layer_id_ = 0;
76 } 76 }
77 77
78 void AnimationPlayer::RegisterPlayer() { 78 void AnimationPlayer::RegisterPlayer() {
79 DCHECK(layer_id_); 79 DCHECK(layer_id_);
80 DCHECK(animation_host_); 80 DCHECK(animation_host_);
81 DCHECK(!element_animations_); 81 DCHECK(!element_animations_);
82 82
83 // Create LAC or re-use existing. 83 // Create ElementAnimations or re-use existing.
84 animation_host_->RegisterPlayerForLayer(layer_id_, this); 84 animation_host_->RegisterPlayerForLayer(layer_id_, this);
85 // Get local reference to shared LAC. 85 // Get local reference to shared ElementAnimations.
86 BindElementAnimations(); 86 BindElementAnimations();
87 } 87 }
88 88
89 void AnimationPlayer::UnregisterPlayer() { 89 void AnimationPlayer::UnregisterPlayer() {
90 DCHECK(layer_id_); 90 DCHECK(layer_id_);
91 DCHECK(animation_host_); 91 DCHECK(animation_host_);
92 DCHECK(element_animations_); 92 DCHECK(element_animations_);
93 93
94 UnbindElementAnimations(); 94 UnbindElementAnimations();
95 // Destroy LAC or release it if it's still needed. 95 // Destroy ElementAnimations or release it if it's still needed.
96 animation_host_->UnregisterPlayerForLayer(layer_id_, this); 96 animation_host_->UnregisterPlayerForLayer(layer_id_, this);
97 } 97 }
98 98
99 void AnimationPlayer::BindElementAnimations() { 99 void AnimationPlayer::BindElementAnimations() {
100 DCHECK(!element_animations_); 100 DCHECK(!element_animations_);
101 element_animations_ = 101 element_animations_ =
102 animation_host_->GetElementAnimationsForLayerId(layer_id_); 102 animation_host_->GetElementAnimationsForLayerId(layer_id_);
103 DCHECK(element_animations_); 103 DCHECK(element_animations_);
104 104
105 // Pass all accumulated animations to LAC. 105 // Pass all accumulated animations to ElementAnimations.
106 for (auto& animation : animations_) { 106 for (auto& animation : animations_) {
107 element_animations_->AddAnimation(std::move(animation)); 107 element_animations_->AddAnimation(std::move(animation));
108 } 108 }
109 if (!animations_.empty()) 109 if (!animations_.empty())
110 SetNeedsCommit(); 110 SetNeedsCommit();
111 animations_.clear(); 111 animations_.clear();
112 } 112 }
113 113
114 void AnimationPlayer::UnbindElementAnimations() { 114 void AnimationPlayer::UnbindElementAnimations() {
115 element_animations_ = nullptr; 115 element_animations_ = nullptr;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 } 219 }
220 } 220 }
221 221
222 void AnimationPlayer::SetNeedsCommit() { 222 void AnimationPlayer::SetNeedsCommit() {
223 DCHECK(animation_host_); 223 DCHECK(animation_host_);
224 animation_host_->SetNeedsCommit(); 224 animation_host_->SetNeedsCommit();
225 animation_host_->SetNeedsRebuildPropertyTrees(); 225 animation_host_->SetNeedsRebuildPropertyTrees();
226 } 226 }
227 227
228 } // namespace cc 228 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/animation_player.h ('k') | cc/animation/animation_player_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698