| 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 21 matching lines...) Expand all Loading... |
| 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( |
| 164 Animation::TargetProperty target_property) { | 165 AnimationTargetProperty::Enum target_property) { |
| 165 if (element_animations_) { | 166 if (element_animations_) { |
| 166 element_animations_->layer_animation_controller()->AbortAnimations( | 167 element_animations_->layer_animation_controller()->AbortAnimations( |
| 167 target_property); | 168 target_property); |
| 168 SetNeedsCommit(); | 169 SetNeedsCommit(); |
| 169 } else { | 170 } else { |
| 170 auto animations_to_remove = std::remove_if( | 171 auto animations_to_remove = std::remove_if( |
| 171 animations_.begin(), animations_.end(), | 172 animations_.begin(), animations_.end(), |
| 172 [target_property](const scoped_ptr<Animation>& animation) { | 173 [target_property](const scoped_ptr<Animation>& animation) { |
| 173 return animation->target_property() == target_property; | 174 return animation->target_property() == target_property; |
| 174 }); | 175 }); |
| 175 animations_.erase(animations_to_remove, animations_.end()); | 176 animations_.erase(animations_to_remove, animations_.end()); |
| 176 } | 177 } |
| 177 } | 178 } |
| 178 | 179 |
| 179 void AnimationPlayer::PushPropertiesTo(AnimationPlayer* player_impl) { | 180 void AnimationPlayer::PushPropertiesTo(AnimationPlayer* player_impl) { |
| 180 if (layer_id_ != player_impl->layer_id()) { | 181 if (layer_id_ != player_impl->layer_id()) { |
| 181 if (player_impl->layer_id()) | 182 if (player_impl->layer_id()) |
| 182 player_impl->DetachLayer(); | 183 player_impl->DetachLayer(); |
| 183 if (layer_id_) | 184 if (layer_id_) |
| 184 player_impl->AttachLayer(layer_id_); | 185 player_impl->AttachLayer(layer_id_); |
| 185 } | 186 } |
| 186 } | 187 } |
| 187 | 188 |
| 188 void AnimationPlayer::NotifyAnimationStarted( | 189 void AnimationPlayer::NotifyAnimationStarted( |
| 189 base::TimeTicks monotonic_time, | 190 base::TimeTicks monotonic_time, |
| 190 Animation::TargetProperty target_property, | 191 AnimationTargetProperty::Enum target_property, |
| 191 int group) { | 192 int group) { |
| 192 if (layer_animation_delegate_) | 193 if (layer_animation_delegate_) |
| 193 layer_animation_delegate_->NotifyAnimationStarted(monotonic_time, | 194 layer_animation_delegate_->NotifyAnimationStarted(monotonic_time, |
| 194 target_property, group); | 195 target_property, group); |
| 195 } | 196 } |
| 196 | 197 |
| 197 void AnimationPlayer::NotifyAnimationFinished( | 198 void AnimationPlayer::NotifyAnimationFinished( |
| 198 base::TimeTicks monotonic_time, | 199 base::TimeTicks monotonic_time, |
| 199 Animation::TargetProperty target_property, | 200 AnimationTargetProperty::Enum target_property, |
| 200 int group) { | 201 int group) { |
| 201 if (layer_animation_delegate_) | 202 if (layer_animation_delegate_) |
| 202 layer_animation_delegate_->NotifyAnimationFinished(monotonic_time, | 203 layer_animation_delegate_->NotifyAnimationFinished(monotonic_time, |
| 203 target_property, group); | 204 target_property, group); |
| 204 } | 205 } |
| 205 | 206 |
| 206 void AnimationPlayer::NotifyAnimationAborted( | 207 void AnimationPlayer::NotifyAnimationAborted( |
| 207 base::TimeTicks monotonic_time, | 208 base::TimeTicks monotonic_time, |
| 208 Animation::TargetProperty target_property, | 209 AnimationTargetProperty::Enum target_property, |
| 209 int group) { | 210 int group) { |
| 210 if (layer_animation_delegate_) | 211 if (layer_animation_delegate_) |
| 211 layer_animation_delegate_->NotifyAnimationAborted(monotonic_time, | 212 layer_animation_delegate_->NotifyAnimationAborted(monotonic_time, |
| 212 target_property, group); | 213 target_property, group); |
| 213 } | 214 } |
| 214 | 215 |
| 215 void AnimationPlayer::SetNeedsCommit() { | 216 void AnimationPlayer::SetNeedsCommit() { |
| 216 DCHECK(animation_host_); | 217 DCHECK(animation_host_); |
| 217 animation_host_->SetNeedsCommit(); | 218 animation_host_->SetNeedsCommit(); |
| 218 animation_host_->SetNeedsRebuildPropertyTrees(); | 219 animation_host_->SetNeedsRebuildPropertyTrees(); |
| 219 } | 220 } |
| 220 | 221 |
| 221 } // namespace cc | 222 } // namespace cc |
| OLD | NEW |