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 it = animations_.begin(); it != animations_.end(); ++it) |
danakj
2015/11/17 01:12:16
This could be
for (auto& animation : animations_)
vmpstr
2015/11/17 23:26:23
Done.
| |
109 element_animations_->layer_animation_controller()->AddAnimation( | 109 element_animations_->layer_animation_controller()->AddAnimation(it->Pass()); |
110 animations_.take(it)); | |
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 |
(...skipping 16 matching lines...) Expand all Loading... | |
137 animation_id, base::TimeDelta::FromSecondsD(time_offset)); | 136 animation_id, base::TimeDelta::FromSecondsD(time_offset)); |
138 SetNeedsCommit(); | 137 SetNeedsCommit(); |
139 } | 138 } |
140 | 139 |
141 void AnimationPlayer::RemoveAnimation(int animation_id) { | 140 void AnimationPlayer::RemoveAnimation(int animation_id) { |
142 if (element_animations_) { | 141 if (element_animations_) { |
143 element_animations_->layer_animation_controller()->RemoveAnimation( | 142 element_animations_->layer_animation_controller()->RemoveAnimation( |
144 animation_id); | 143 animation_id); |
145 SetNeedsCommit(); | 144 SetNeedsCommit(); |
146 } else { | 145 } else { |
147 auto animations_to_remove = animations_.remove_if([animation_id]( | 146 auto animations_to_remove = |
148 Animation* animation) { return animation->id() == animation_id; }); | 147 std::remove_if(animations_.begin(), animations_.end(), |
148 [animation_id](const scoped_ptr<Animation>& animation) { | |
149 return animation->id() == animation_id; | |
150 }); | |
149 animations_.erase(animations_to_remove, animations_.end()); | 151 animations_.erase(animations_to_remove, animations_.end()); |
150 } | 152 } |
151 } | 153 } |
152 | 154 |
153 void AnimationPlayer::PushPropertiesTo(AnimationPlayer* player_impl) { | 155 void AnimationPlayer::PushPropertiesTo(AnimationPlayer* player_impl) { |
154 if (!element_animations_) { | 156 if (!element_animations_) { |
155 if (player_impl->element_animations()) | 157 if (player_impl->element_animations()) |
156 player_impl->DetachLayer(); | 158 player_impl->DetachLayer(); |
157 return; | 159 return; |
158 } | 160 } |
(...skipping 21 matching lines...) Expand all Loading... | |
180 target_property, group); | 182 target_property, group); |
181 } | 183 } |
182 | 184 |
183 void AnimationPlayer::SetNeedsCommit() { | 185 void AnimationPlayer::SetNeedsCommit() { |
184 DCHECK(animation_host_); | 186 DCHECK(animation_host_); |
185 animation_host_->SetNeedsCommit(); | 187 animation_host_->SetNeedsCommit(); |
186 animation_host_->SetNeedsRebuildPropertyTrees(); | 188 animation_host_->SetNeedsRebuildPropertyTrees(); |
187 } | 189 } |
188 | 190 |
189 } // namespace cc | 191 } // namespace cc |
OLD | NEW |