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