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

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

Issue 1887593003: CC Animation: Make layer_animation_controller a private member of ElementAnimations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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_host.cc ('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/element_animations.h" 10 #include "cc/animation/element_animations.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 98 }
99 99
100 void AnimationPlayer::BindElementAnimations() { 100 void AnimationPlayer::BindElementAnimations() {
101 DCHECK(!element_animations_); 101 DCHECK(!element_animations_);
102 element_animations_ = 102 element_animations_ =
103 animation_host_->GetElementAnimationsForLayerId(layer_id_); 103 animation_host_->GetElementAnimationsForLayerId(layer_id_);
104 DCHECK(element_animations_); 104 DCHECK(element_animations_);
105 105
106 // Pass all accumulated animations to LAC. 106 // Pass all accumulated animations to LAC.
107 for (auto& animation : animations_) { 107 for (auto& animation : animations_) {
108 element_animations_->layer_animation_controller()->AddAnimation( 108 element_animations_->AddAnimation(std::move(animation));
109 std::move(animation));
110 } 109 }
111 if (!animations_.empty()) 110 if (!animations_.empty())
112 SetNeedsCommit(); 111 SetNeedsCommit();
113 animations_.clear(); 112 animations_.clear();
114 } 113 }
115 114
116 void AnimationPlayer::UnbindElementAnimations() { 115 void AnimationPlayer::UnbindElementAnimations() {
117 element_animations_ = nullptr; 116 element_animations_ = nullptr;
118 DCHECK(animations_.empty()); 117 DCHECK(animations_.empty());
119 } 118 }
120 119
121 void AnimationPlayer::AddAnimation(std::unique_ptr<Animation> animation) { 120 void AnimationPlayer::AddAnimation(std::unique_ptr<Animation> animation) {
122 DCHECK(animation->target_property() != TargetProperty::SCROLL_OFFSET || 121 DCHECK(animation->target_property() != TargetProperty::SCROLL_OFFSET ||
123 (animation_host_ && animation_host_->SupportsScrollAnimations())); 122 (animation_host_ && animation_host_->SupportsScrollAnimations()));
124 123
125 if (element_animations_) { 124 if (element_animations_) {
126 element_animations_->layer_animation_controller()->AddAnimation( 125 element_animations_->AddAnimation(std::move(animation));
127 std::move(animation));
128 SetNeedsCommit(); 126 SetNeedsCommit();
129 } else { 127 } else {
130 animations_.push_back(std::move(animation)); 128 animations_.push_back(std::move(animation));
131 } 129 }
132 } 130 }
133 131
134 void AnimationPlayer::PauseAnimation(int animation_id, double time_offset) { 132 void AnimationPlayer::PauseAnimation(int animation_id, double time_offset) {
135 DCHECK(element_animations_); 133 DCHECK(element_animations_);
136 element_animations_->layer_animation_controller()->PauseAnimation( 134 element_animations_->PauseAnimation(
137 animation_id, base::TimeDelta::FromSecondsD(time_offset)); 135 animation_id, base::TimeDelta::FromSecondsD(time_offset));
138 SetNeedsCommit(); 136 SetNeedsCommit();
139 } 137 }
140 138
141 void AnimationPlayer::RemoveAnimation(int animation_id) { 139 void AnimationPlayer::RemoveAnimation(int animation_id) {
142 if (element_animations_) { 140 if (element_animations_) {
143 element_animations_->layer_animation_controller()->RemoveAnimation( 141 element_animations_->RemoveAnimation(animation_id);
144 animation_id);
145 SetNeedsCommit(); 142 SetNeedsCommit();
146 } else { 143 } else {
147 auto animations_to_remove = std::remove_if( 144 auto animations_to_remove = std::remove_if(
148 animations_.begin(), animations_.end(), 145 animations_.begin(), animations_.end(),
149 [animation_id](const std::unique_ptr<Animation>& animation) { 146 [animation_id](const std::unique_ptr<Animation>& animation) {
150 return animation->id() == animation_id; 147 return animation->id() == animation_id;
151 }); 148 });
152 animations_.erase(animations_to_remove, animations_.end()); 149 animations_.erase(animations_to_remove, animations_.end());
153 } 150 }
154 } 151 }
155 152
156 void AnimationPlayer::AbortAnimation(int animation_id) { 153 void AnimationPlayer::AbortAnimation(int animation_id) {
157 DCHECK(element_animations_); 154 DCHECK(element_animations_);
158 element_animations_->layer_animation_controller()->AbortAnimation( 155 element_animations_->AbortAnimation(animation_id);
159 animation_id);
160 SetNeedsCommit(); 156 SetNeedsCommit();
161 } 157 }
162 158
163 void AnimationPlayer::AbortAnimations(TargetProperty::Type target_property, 159 void AnimationPlayer::AbortAnimations(TargetProperty::Type target_property,
164 bool needs_completion) { 160 bool needs_completion) {
165 if (element_animations_) { 161 if (element_animations_) {
166 element_animations_->layer_animation_controller()->AbortAnimations( 162 element_animations_->AbortAnimations(target_property, needs_completion);
167 target_property, needs_completion);
168 SetNeedsCommit(); 163 SetNeedsCommit();
169 } else { 164 } else {
170 auto animations_to_remove = std::remove_if( 165 auto animations_to_remove = std::remove_if(
171 animations_.begin(), animations_.end(), 166 animations_.begin(), animations_.end(),
172 [target_property](const std::unique_ptr<Animation>& animation) { 167 [target_property](const std::unique_ptr<Animation>& animation) {
173 return animation->target_property() == target_property; 168 return animation->target_property() == target_property;
174 }); 169 });
175 animations_.erase(animations_to_remove, animations_.end()); 170 animations_.erase(animations_to_remove, animations_.end());
176 } 171 }
177 } 172 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 220 }
226 } 221 }
227 222
228 void AnimationPlayer::SetNeedsCommit() { 223 void AnimationPlayer::SetNeedsCommit() {
229 DCHECK(animation_host_); 224 DCHECK(animation_host_);
230 animation_host_->SetNeedsCommit(); 225 animation_host_->SetNeedsCommit();
231 animation_host_->SetNeedsRebuildPropertyTrees(); 226 animation_host_->SetNeedsRebuildPropertyTrees();
232 } 227 }
233 228
234 } // namespace cc 229 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/animation_host.cc ('k') | cc/animation/animation_player_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698