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

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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // and only after the animations are deleted on the main thread 135 // and only after the animations are deleted on the main thread
136 // this insures we will never push an animation twice. 136 // this insures we will never push an animation twice.
137 RemoveAnimationsCompletedOnMainThread(element_animations_impl.get()); 137 RemoveAnimationsCompletedOnMainThread(element_animations_impl.get());
138 138
139 PushPropertiesToImplThread(element_animations_impl.get()); 139 PushPropertiesToImplThread(element_animations_impl.get());
140 element_animations_impl->UpdateActivation(NORMAL_ACTIVATION); 140 element_animations_impl->UpdateActivation(NORMAL_ACTIVATION);
141 UpdateActivation(NORMAL_ACTIVATION); 141 UpdateActivation(NORMAL_ACTIVATION);
142 } 142 }
143 143
144 void ElementAnimations::AddAnimation(std::unique_ptr<Animation> animation) { 144 void ElementAnimations::AddAnimation(std::unique_ptr<Animation> animation) {
145 DCHECK(!animation->is_impl_only() ||
146 animation->target_property() == TargetProperty::SCROLL_OFFSET);
145 bool added_transform_animation = 147 bool added_transform_animation =
146 animation->target_property() == TargetProperty::TRANSFORM; 148 animation->target_property() == TargetProperty::TRANSFORM;
147 bool added_opacity_animation = 149 bool added_opacity_animation =
148 animation->target_property() == TargetProperty::OPACITY; 150 animation->target_property() == TargetProperty::OPACITY;
149 animations_.push_back(std::move(animation)); 151 animations_.push_back(std::move(animation));
150 needs_to_start_animations_ = true; 152 needs_to_start_animations_ = true;
151 UpdateActivation(NORMAL_ACTIVATION); 153 UpdateActivation(NORMAL_ACTIVATION);
152 if (added_transform_animation) 154 if (added_transform_animation)
153 UpdateClientAnimationState(TargetProperty::TRANSFORM); 155 UpdateClientAnimationState(TargetProperty::TRANSFORM);
154 if (added_opacity_animation) 156 if (added_opacity_animation)
155 UpdateClientAnimationState(TargetProperty::OPACITY); 157 UpdateClientAnimationState(TargetProperty::OPACITY);
156 } 158 }
157 159
158 void ElementAnimations::Animate(base::TimeTicks monotonic_time) { 160 void ElementAnimations::Animate(base::TimeTicks monotonic_time) {
159 DCHECK(!monotonic_time.is_null()); 161 DCHECK(!monotonic_time.is_null());
160 if (!has_element_in_active_list() && !has_element_in_pending_list()) 162 if (!has_element_in_active_list() && !has_element_in_pending_list())
161 return; 163 return;
162 164
163 if (needs_to_start_animations_) 165 if (needs_to_start_animations_)
164 StartAnimations(monotonic_time); 166 StartAnimations(monotonic_time);
165 TickAnimations(monotonic_time); 167 TickAnimations(monotonic_time);
166 last_tick_time_ = monotonic_time; 168 last_tick_time_ = monotonic_time;
167 UpdateClientAnimationState(TargetProperty::OPACITY); 169 UpdateClientAnimationState(TargetProperty::OPACITY);
168 UpdateClientAnimationState(TargetProperty::TRANSFORM); 170 UpdateClientAnimationState(TargetProperty::TRANSFORM);
169 } 171 }
170 172
171 void ElementAnimations::AccumulatePropertyUpdates(
172 base::TimeTicks monotonic_time,
173 AnimationEvents* events) {
174 if (!events)
175 return;
176
177 for (size_t i = 0; i < animations_.size(); ++i) {
178 Animation* animation = animations_[i].get();
179 if (!animation->is_impl_only())
180 continue;
181
182 if (!animation->InEffect(monotonic_time))
183 continue;
184
185 base::TimeDelta trimmed =
186 animation->TrimTimeToCurrentIteration(monotonic_time);
187 switch (animation->target_property()) {
188 case TargetProperty::OPACITY: {
189 AnimationEvent event(AnimationEvent::PROPERTY_UPDATE, element_id_,
190 animation->group(), TargetProperty::OPACITY,
191 monotonic_time);
192 const FloatAnimationCurve* float_animation_curve =
193 animation->curve()->ToFloatAnimationCurve();
194 event.opacity = float_animation_curve->GetValue(trimmed);
195 event.is_impl_only = true;
196 events->events_.push_back(event);
197 break;
198 }
199
200 case TargetProperty::TRANSFORM: {
201 AnimationEvent event(AnimationEvent::PROPERTY_UPDATE, element_id_,
202 animation->group(), TargetProperty::TRANSFORM,
203 monotonic_time);
204 const TransformAnimationCurve* transform_animation_curve =
205 animation->curve()->ToTransformAnimationCurve();
206 event.transform = transform_animation_curve->GetValue(trimmed);
207 event.is_impl_only = true;
208 events->events_.push_back(event);
209 break;
210 }
211
212 case TargetProperty::FILTER: {
213 AnimationEvent event(AnimationEvent::PROPERTY_UPDATE, element_id_,
214 animation->group(), TargetProperty::FILTER,
215 monotonic_time);
216 const FilterAnimationCurve* filter_animation_curve =
217 animation->curve()->ToFilterAnimationCurve();
218 event.filters = filter_animation_curve->GetValue(trimmed);
219 event.is_impl_only = true;
220 events->events_.push_back(event);
221 break;
222 }
223
224 case TargetProperty::BACKGROUND_COLOR: {
225 break;
226 }
227
228 case TargetProperty::SCROLL_OFFSET: {
229 // Impl-side changes to scroll offset are already sent back to the
230 // main thread (e.g. for user-driven scrolling), so a PROPERTY_UPDATE
231 // isn't needed.
232 break;
233 }
234 }
235 }
236 }
237
238 void ElementAnimations::UpdateState(bool start_ready_animations, 173 void ElementAnimations::UpdateState(bool start_ready_animations,
239 AnimationEvents* events) { 174 AnimationEvents* events) {
240 if (!has_element_in_active_list()) 175 if (!has_element_in_active_list())
241 return; 176 return;
242 177
243 // Animate hasn't been called, this happens if an element has been added 178 // Animate hasn't been called, this happens if an element has been added
244 // between the Commit and Draw phases. 179 // between the Commit and Draw phases.
245 if (last_tick_time_ == base::TimeTicks()) 180 if (last_tick_time_ == base::TimeTicks())
246 return; 181 return;
247 182
248 if (start_ready_animations) 183 if (start_ready_animations)
249 PromoteStartedAnimations(last_tick_time_, events); 184 PromoteStartedAnimations(last_tick_time_, events);
250 185
251 MarkFinishedAnimations(last_tick_time_); 186 MarkFinishedAnimations(last_tick_time_);
252 MarkAnimationsForDeletion(last_tick_time_, events); 187 MarkAnimationsForDeletion(last_tick_time_, events);
253 188
254 if (needs_to_start_animations_ && start_ready_animations) { 189 if (needs_to_start_animations_ && start_ready_animations) {
255 StartAnimations(last_tick_time_); 190 StartAnimations(last_tick_time_);
256 PromoteStartedAnimations(last_tick_time_, events); 191 PromoteStartedAnimations(last_tick_time_, events);
257 } 192 }
258 193
259 AccumulatePropertyUpdates(last_tick_time_, events);
260
261 UpdateActivation(NORMAL_ACTIVATION); 194 UpdateActivation(NORMAL_ACTIVATION);
262 } 195 }
263 196
264 void ElementAnimations::ActivateAnimations() { 197 void ElementAnimations::ActivateAnimations() {
265 bool changed_transform_animation = false; 198 bool changed_transform_animation = false;
266 bool changed_opacity_animation = false; 199 bool changed_opacity_animation = false;
267 for (size_t i = 0; i < animations_.size(); ++i) { 200 for (size_t i = 0; i < animations_.size(); ++i) {
268 if (animations_[i]->affects_active_elements() != 201 if (animations_[i]->affects_active_elements() !=
269 animations_[i]->affects_pending_elements()) { 202 animations_[i]->affects_pending_elements()) {
270 if (animations_[i]->target_property() == TargetProperty::TRANSFORM) 203 if (animations_[i]->target_property() == TargetProperty::TRANSFORM)
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 if (animation_host()) { 1430 if (animation_host()) {
1498 DCHECK(animation_host()->mutator_host_client()); 1431 DCHECK(animation_host()->mutator_host_client());
1499 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation( 1432 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation(
1500 element_id()); 1433 element_id());
1501 } 1434 }
1502 1435
1503 return gfx::ScrollOffset(); 1436 return gfx::ScrollOffset();
1504 } 1437 }
1505 1438
1506 } // namespace cc 1439 } // 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