Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Side by Side Diff: cc/animation/element_animations.cc

Issue 1988293003: cc : Delete code not used outside tests related to impl-only animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/animation/element_animations.h ('k') | cc/animation/element_animations_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/element_animations.h" 5 #include "cc/animation/element_animations.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // Remove finished impl side animations only after pushing, 138 // Remove finished impl side animations only after pushing,
139 // and only after the animations are deleted on the main thread 139 // and only after the animations are deleted on the main thread
140 // this insures we will never push an animation twice. 140 // this insures we will never push an animation twice.
141 RemoveAnimationsCompletedOnMainThread(element_animations_impl.get()); 141 RemoveAnimationsCompletedOnMainThread(element_animations_impl.get());
142 142
143 PushPropertiesToImplThread(element_animations_impl.get()); 143 PushPropertiesToImplThread(element_animations_impl.get());
144 element_animations_impl->UpdateActivation(NORMAL_ACTIVATION); 144 element_animations_impl->UpdateActivation(NORMAL_ACTIVATION);
145 UpdateActivation(NORMAL_ACTIVATION); 145 UpdateActivation(NORMAL_ACTIVATION);
146 } 146 }
147 147
148 void ElementAnimations::AddAnimation(std::unique_ptr<Animation> animation) { 148 void ElementAnimations::AddAnimation(std::unique_ptr<Animation> animation) {
ajuma 2016/05/19 15:00:57 Please add: DCHECK(!animation->is_impl_only() || a
jaydasika 2016/05/19 20:14:13 Done.
149 bool added_transform_animation = 149 bool added_transform_animation =
150 animation->target_property() == TargetProperty::TRANSFORM; 150 animation->target_property() == TargetProperty::TRANSFORM;
151 bool added_opacity_animation = 151 bool added_opacity_animation =
152 animation->target_property() == TargetProperty::OPACITY; 152 animation->target_property() == TargetProperty::OPACITY;
153 animations_.push_back(std::move(animation)); 153 animations_.push_back(std::move(animation));
154 needs_to_start_animations_ = true; 154 needs_to_start_animations_ = true;
155 UpdateActivation(NORMAL_ACTIVATION); 155 UpdateActivation(NORMAL_ACTIVATION);
156 if (added_transform_animation) 156 if (added_transform_animation)
157 UpdatePotentiallyAnimatingTransform(); 157 UpdatePotentiallyAnimatingTransform();
158 if (added_opacity_animation) 158 if (added_opacity_animation)
159 UpdateAnimatingOpacity(); 159 UpdateAnimatingOpacity();
160 } 160 }
161 161
162 void ElementAnimations::Animate(base::TimeTicks monotonic_time) { 162 void ElementAnimations::Animate(base::TimeTicks monotonic_time) {
163 DCHECK(!monotonic_time.is_null()); 163 DCHECK(!monotonic_time.is_null());
164 if (!has_element_in_active_list() && !has_element_in_pending_list()) 164 if (!has_element_in_active_list() && !has_element_in_pending_list())
165 return; 165 return;
166 166
167 if (needs_to_start_animations_) 167 if (needs_to_start_animations_)
168 StartAnimations(monotonic_time); 168 StartAnimations(monotonic_time);
169 TickAnimations(monotonic_time); 169 TickAnimations(monotonic_time);
170 last_tick_time_ = monotonic_time; 170 last_tick_time_ = monotonic_time;
171 UpdateAnimatingOpacity(); 171 UpdateAnimatingOpacity();
172 } 172 }
173 173
174 void ElementAnimations::AccumulatePropertyUpdates(
175 base::TimeTicks monotonic_time,
176 AnimationEvents* events) {
177 if (!events)
178 return;
179
180 for (size_t i = 0; i < animations_.size(); ++i) {
181 Animation* animation = animations_[i].get();
182 if (!animation->is_impl_only())
183 continue;
184
185 if (!animation->InEffect(monotonic_time))
186 continue;
187
188 base::TimeDelta trimmed =
189 animation->TrimTimeToCurrentIteration(monotonic_time);
190 switch (animation->target_property()) {
191 case TargetProperty::OPACITY: {
192 AnimationEvent event(AnimationEvent::PROPERTY_UPDATE, element_id_,
193 animation->group(), TargetProperty::OPACITY,
194 monotonic_time);
195 const FloatAnimationCurve* float_animation_curve =
196 animation->curve()->ToFloatAnimationCurve();
197 event.opacity = float_animation_curve->GetValue(trimmed);
198 event.is_impl_only = true;
199 events->events_.push_back(event);
200 break;
201 }
202
203 case TargetProperty::TRANSFORM: {
204 AnimationEvent event(AnimationEvent::PROPERTY_UPDATE, element_id_,
205 animation->group(), TargetProperty::TRANSFORM,
206 monotonic_time);
207 const TransformAnimationCurve* transform_animation_curve =
208 animation->curve()->ToTransformAnimationCurve();
209 event.transform = transform_animation_curve->GetValue(trimmed);
210 event.is_impl_only = true;
211 events->events_.push_back(event);
212 break;
213 }
214
215 case TargetProperty::FILTER: {
216 AnimationEvent event(AnimationEvent::PROPERTY_UPDATE, element_id_,
217 animation->group(), TargetProperty::FILTER,
218 monotonic_time);
219 const FilterAnimationCurve* filter_animation_curve =
220 animation->curve()->ToFilterAnimationCurve();
221 event.filters = filter_animation_curve->GetValue(trimmed);
222 event.is_impl_only = true;
223 events->events_.push_back(event);
224 break;
225 }
226
227 case TargetProperty::BACKGROUND_COLOR: {
228 break;
229 }
230
231 case TargetProperty::SCROLL_OFFSET: {
232 // Impl-side changes to scroll offset are already sent back to the
233 // main thread (e.g. for user-driven scrolling), so a PROPERTY_UPDATE
234 // isn't needed.
235 break;
236 }
237 }
238 }
239 }
240
241 void ElementAnimations::UpdateState(bool start_ready_animations, 174 void ElementAnimations::UpdateState(bool start_ready_animations,
242 AnimationEvents* events) { 175 AnimationEvents* events) {
243 if (!has_element_in_active_list()) 176 if (!has_element_in_active_list())
244 return; 177 return;
245 178
246 // Animate hasn't been called, this happens if an element has been added 179 // Animate hasn't been called, this happens if an element has been added
247 // between the Commit and Draw phases. 180 // between the Commit and Draw phases.
248 if (last_tick_time_ == base::TimeTicks()) 181 if (last_tick_time_ == base::TimeTicks())
249 return; 182 return;
250 183
251 if (start_ready_animations) 184 if (start_ready_animations)
252 PromoteStartedAnimations(last_tick_time_, events); 185 PromoteStartedAnimations(last_tick_time_, events);
253 186
254 MarkFinishedAnimations(last_tick_time_); 187 MarkFinishedAnimations(last_tick_time_);
255 MarkAnimationsForDeletion(last_tick_time_, events); 188 MarkAnimationsForDeletion(last_tick_time_, events);
256 189
257 if (needs_to_start_animations_ && start_ready_animations) { 190 if (needs_to_start_animations_ && start_ready_animations) {
258 StartAnimations(last_tick_time_); 191 StartAnimations(last_tick_time_);
259 PromoteStartedAnimations(last_tick_time_, events); 192 PromoteStartedAnimations(last_tick_time_, events);
260 } 193 }
261 194
262 AccumulatePropertyUpdates(last_tick_time_, events);
263
264 UpdateActivation(NORMAL_ACTIVATION); 195 UpdateActivation(NORMAL_ACTIVATION);
265 } 196 }
266 197
267 void ElementAnimations::ActivateAnimations() { 198 void ElementAnimations::ActivateAnimations() {
268 bool changed_transform_animation = false; 199 bool changed_transform_animation = false;
269 bool changed_opacity_animation = false; 200 bool changed_opacity_animation = false;
270 for (size_t i = 0; i < animations_.size(); ++i) { 201 for (size_t i = 0; i < animations_.size(); ++i) {
271 if (animations_[i]->affects_active_elements() != 202 if (animations_[i]->affects_active_elements() !=
272 animations_[i]->affects_pending_elements()) { 203 animations_[i]->affects_pending_elements()) {
273 if (animations_[i]->target_property() == TargetProperty::TRANSFORM) 204 if (animations_[i]->target_property() == TargetProperty::TRANSFORM)
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 if (animation_host()) { 1456 if (animation_host()) {
1526 DCHECK(animation_host()->mutator_host_client()); 1457 DCHECK(animation_host()->mutator_host_client());
1527 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation( 1458 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation(
1528 element_id()); 1459 element_id());
1529 } 1460 }
1530 1461
1531 return gfx::ScrollOffset(); 1462 return gfx::ScrollOffset();
1532 } 1463 }
1533 1464
1534 } // namespace cc 1465 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/element_animations.h ('k') | cc/animation/element_animations_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698