| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 animation_host_->UnregisterPlayerForLayer(layer_id_, this); | 98 animation_host_->UnregisterPlayerForLayer(layer_id_, this); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void AnimationPlayer::BindElementAnimations() { | 101 void AnimationPlayer::BindElementAnimations() { |
| 102 DCHECK(!element_animations_); | 102 DCHECK(!element_animations_); |
| 103 element_animations_ = | 103 element_animations_ = |
| 104 animation_host_->GetElementAnimationsForLayerId(layer_id_); | 104 animation_host_->GetElementAnimationsForLayerId(layer_id_); |
| 105 DCHECK(element_animations_); | 105 DCHECK(element_animations_); |
| 106 | 106 |
| 107 // Pass all accumulated animations to LAC. | 107 // Pass all accumulated animations to LAC. |
| 108 for (auto it = animations_.begin(); it != animations_.end(); ++it) | 108 for (auto& animation : animations_) { |
| 109 element_animations_->layer_animation_controller()->AddAnimation( | 109 element_animations_->layer_animation_controller()->AddAnimation( |
| 110 animations_.take(it)); | 110 std::move(animation)); |
| 111 } |
| 111 if (!animations_.empty()) | 112 if (!animations_.empty()) |
| 112 SetNeedsCommit(); | 113 SetNeedsCommit(); |
| 113 animations_.clear(); | 114 animations_.clear(); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void AnimationPlayer::UnbindElementAnimations() { | 117 void AnimationPlayer::UnbindElementAnimations() { |
| 117 element_animations_ = nullptr; | 118 element_animations_ = nullptr; |
| 118 DCHECK(animations_.empty()); | 119 DCHECK(animations_.empty()); |
| 119 } | 120 } |
| 120 | 121 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 137 animation_id, base::TimeDelta::FromSecondsD(time_offset)); | 138 animation_id, base::TimeDelta::FromSecondsD(time_offset)); |
| 138 SetNeedsCommit(); | 139 SetNeedsCommit(); |
| 139 } | 140 } |
| 140 | 141 |
| 141 void AnimationPlayer::RemoveAnimation(int animation_id) { | 142 void AnimationPlayer::RemoveAnimation(int animation_id) { |
| 142 if (element_animations_) { | 143 if (element_animations_) { |
| 143 element_animations_->layer_animation_controller()->RemoveAnimation( | 144 element_animations_->layer_animation_controller()->RemoveAnimation( |
| 144 animation_id); | 145 animation_id); |
| 145 SetNeedsCommit(); | 146 SetNeedsCommit(); |
| 146 } else { | 147 } else { |
| 147 auto animations_to_remove = animations_.remove_if([animation_id]( | 148 auto animations_to_remove = |
| 148 Animation* animation) { return animation->id() == animation_id; }); | 149 std::remove_if(animations_.begin(), animations_.end(), |
| 150 [animation_id](const scoped_ptr<Animation>& animation) { |
| 151 return animation->id() == animation_id; |
| 152 }); |
| 149 animations_.erase(animations_to_remove, animations_.end()); | 153 animations_.erase(animations_to_remove, animations_.end()); |
| 150 } | 154 } |
| 151 } | 155 } |
| 152 | 156 |
| 153 void AnimationPlayer::PushPropertiesTo(AnimationPlayer* player_impl) { | 157 void AnimationPlayer::PushPropertiesTo(AnimationPlayer* player_impl) { |
| 154 if (!element_animations_) { | 158 if (!element_animations_) { |
| 155 if (player_impl->element_animations()) | 159 if (player_impl->element_animations()) |
| 156 player_impl->DetachLayer(); | 160 player_impl->DetachLayer(); |
| 157 return; | 161 return; |
| 158 } | 162 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 180 target_property, group); | 184 target_property, group); |
| 181 } | 185 } |
| 182 | 186 |
| 183 void AnimationPlayer::SetNeedsCommit() { | 187 void AnimationPlayer::SetNeedsCommit() { |
| 184 DCHECK(animation_host_); | 188 DCHECK(animation_host_); |
| 185 animation_host_->SetNeedsCommit(); | 189 animation_host_->SetNeedsCommit(); |
| 186 animation_host_->SetNeedsRebuildPropertyTrees(); | 190 animation_host_->SetNeedsRebuildPropertyTrees(); |
| 187 } | 191 } |
| 188 | 192 |
| 189 } // namespace cc | 193 } // namespace cc |
| OLD | NEW |