OLD | NEW |
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 SetNeedsCommit(); | 112 SetNeedsCommit(); |
113 animations_.clear(); | 113 animations_.clear(); |
114 } | 114 } |
115 | 115 |
116 void AnimationPlayer::UnbindElementAnimations() { | 116 void AnimationPlayer::UnbindElementAnimations() { |
117 element_animations_ = nullptr; | 117 element_animations_ = nullptr; |
118 DCHECK(animations_.empty()); | 118 DCHECK(animations_.empty()); |
119 } | 119 } |
120 | 120 |
121 void AnimationPlayer::AddAnimation(scoped_ptr<Animation> animation) { | 121 void AnimationPlayer::AddAnimation(scoped_ptr<Animation> animation) { |
122 DCHECK(animation->target_property() != Animation::SCROLL_OFFSET || | 122 DCHECK(animation->target_property() != TargetProperty::SCROLL_OFFSET || |
123 (animation_host_ && animation_host_->SupportsScrollAnimations())); | 123 (animation_host_ && animation_host_->SupportsScrollAnimations())); |
124 | 124 |
125 if (element_animations_) { | 125 if (element_animations_) { |
126 element_animations_->layer_animation_controller()->AddAnimation( | 126 element_animations_->layer_animation_controller()->AddAnimation( |
127 std::move(animation)); | 127 std::move(animation)); |
128 SetNeedsCommit(); | 128 SetNeedsCommit(); |
129 } else { | 129 } else { |
130 animations_.push_back(std::move(animation)); | 130 animations_.push_back(std::move(animation)); |
131 } | 131 } |
132 } | 132 } |
(...skipping 20 matching lines...) Expand all Loading... |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
156 void AnimationPlayer::AbortAnimation(int animation_id) { | 156 void AnimationPlayer::AbortAnimation(int animation_id) { |
157 DCHECK(element_animations_); | 157 DCHECK(element_animations_); |
158 element_animations_->layer_animation_controller()->AbortAnimation( | 158 element_animations_->layer_animation_controller()->AbortAnimation( |
159 animation_id); | 159 animation_id); |
160 SetNeedsCommit(); | 160 SetNeedsCommit(); |
161 } | 161 } |
162 | 162 |
163 void AnimationPlayer::AbortAnimations( | 163 void AnimationPlayer::AbortAnimations(TargetProperty::Type target_property) { |
164 Animation::TargetProperty target_property) { | |
165 if (element_animations_) { | 164 if (element_animations_) { |
166 element_animations_->layer_animation_controller()->AbortAnimations( | 165 element_animations_->layer_animation_controller()->AbortAnimations( |
167 target_property); | 166 target_property); |
168 SetNeedsCommit(); | 167 SetNeedsCommit(); |
169 } else { | 168 } else { |
170 auto animations_to_remove = std::remove_if( | 169 auto animations_to_remove = std::remove_if( |
171 animations_.begin(), animations_.end(), | 170 animations_.begin(), animations_.end(), |
172 [target_property](const scoped_ptr<Animation>& animation) { | 171 [target_property](const scoped_ptr<Animation>& animation) { |
173 return animation->target_property() == target_property; | 172 return animation->target_property() == target_property; |
174 }); | 173 }); |
175 animations_.erase(animations_to_remove, animations_.end()); | 174 animations_.erase(animations_to_remove, animations_.end()); |
176 } | 175 } |
177 } | 176 } |
178 | 177 |
179 void AnimationPlayer::PushPropertiesTo(AnimationPlayer* player_impl) { | 178 void AnimationPlayer::PushPropertiesTo(AnimationPlayer* player_impl) { |
180 if (layer_id_ != player_impl->layer_id()) { | 179 if (layer_id_ != player_impl->layer_id()) { |
181 if (player_impl->layer_id()) | 180 if (player_impl->layer_id()) |
182 player_impl->DetachLayer(); | 181 player_impl->DetachLayer(); |
183 if (layer_id_) | 182 if (layer_id_) |
184 player_impl->AttachLayer(layer_id_); | 183 player_impl->AttachLayer(layer_id_); |
185 } | 184 } |
186 } | 185 } |
187 | 186 |
188 void AnimationPlayer::NotifyAnimationStarted( | 187 void AnimationPlayer::NotifyAnimationStarted( |
189 base::TimeTicks monotonic_time, | 188 base::TimeTicks monotonic_time, |
190 Animation::TargetProperty target_property, | 189 TargetProperty::Type target_property, |
191 int group) { | 190 int group) { |
192 if (layer_animation_delegate_) | 191 if (layer_animation_delegate_) |
193 layer_animation_delegate_->NotifyAnimationStarted(monotonic_time, | 192 layer_animation_delegate_->NotifyAnimationStarted(monotonic_time, |
194 target_property, group); | 193 target_property, group); |
195 } | 194 } |
196 | 195 |
197 void AnimationPlayer::NotifyAnimationFinished( | 196 void AnimationPlayer::NotifyAnimationFinished( |
198 base::TimeTicks monotonic_time, | 197 base::TimeTicks monotonic_time, |
199 Animation::TargetProperty target_property, | 198 TargetProperty::Type target_property, |
200 int group) { | 199 int group) { |
201 if (layer_animation_delegate_) | 200 if (layer_animation_delegate_) |
202 layer_animation_delegate_->NotifyAnimationFinished(monotonic_time, | 201 layer_animation_delegate_->NotifyAnimationFinished(monotonic_time, |
203 target_property, group); | 202 target_property, group); |
204 } | 203 } |
205 | 204 |
206 void AnimationPlayer::NotifyAnimationAborted( | 205 void AnimationPlayer::NotifyAnimationAborted( |
207 base::TimeTicks monotonic_time, | 206 base::TimeTicks monotonic_time, |
208 Animation::TargetProperty target_property, | 207 TargetProperty::Type target_property, |
209 int group) { | 208 int group) { |
210 if (layer_animation_delegate_) | 209 if (layer_animation_delegate_) |
211 layer_animation_delegate_->NotifyAnimationAborted(monotonic_time, | 210 layer_animation_delegate_->NotifyAnimationAborted(monotonic_time, |
212 target_property, group); | 211 target_property, group); |
213 } | 212 } |
214 | 213 |
215 void AnimationPlayer::SetNeedsCommit() { | 214 void AnimationPlayer::SetNeedsCommit() { |
216 DCHECK(animation_host_); | 215 DCHECK(animation_host_); |
217 animation_host_->SetNeedsCommit(); | 216 animation_host_->SetNeedsCommit(); |
218 animation_host_->SetNeedsRebuildPropertyTrees(); | 217 animation_host_->SetNeedsRebuildPropertyTrees(); |
219 } | 218 } |
220 | 219 |
221 } // namespace cc | 220 } // namespace cc |
OLD | NEW |