OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/layer_animation_controller.h" | 5 #include "cc/layer_animation_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "cc/animation.h" | 9 #include "cc/animation.h" |
10 #include "cc/animation_registrar.h" | 10 #include "cc/animation_registrar.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 return; | 118 return; |
119 | 119 |
120 startAnimationsWaitingForNextTick(monotonicTime); | 120 startAnimationsWaitingForNextTick(monotonicTime); |
121 startAnimationsWaitingForStartTime(monotonicTime); | 121 startAnimationsWaitingForStartTime(monotonicTime); |
122 startAnimationsWaitingForTargetAvailability(monotonicTime); | 122 startAnimationsWaitingForTargetAvailability(monotonicTime); |
123 resolveConflicts(monotonicTime); | 123 resolveConflicts(monotonicTime); |
124 tickAnimations(monotonicTime); | 124 tickAnimations(monotonicTime); |
125 m_lastTickTime = monotonicTime; | 125 m_lastTickTime = monotonicTime; |
126 } | 126 } |
127 | 127 |
128 void LayerAnimationController::accumulatePropertyUpdates(double monotonicTime, | |
129 AnimationEventsVector* events) | |
130 { | |
131 if (!events) | |
132 return; | |
133 | |
134 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { | |
135 Animation* animation = m_activeAnimations[i]; | |
136 if (!animation->isImplOnly()) | |
137 continue; | |
138 | |
139 if (animation->targetProperty() == Animation::Opacity) { | |
140 float opacity = animation->curve()->toFloatAnimationCurve()->getValu e(monotonicTime); | |
141 AnimationEvent event(AnimationEvent::PropertyUpdate, | |
142 m_id, animation->group(), | |
143 Animation::Opacity, monotonicTime); | |
144 event.value = opacity; | |
Ian Vollick
2013/03/06 23:29:45
aesthetic nit: Please avoid the temporary as you d
wjmaclean
2013/03/07 13:49:29
Done.
| |
145 events->push_back(event); | |
146 } | |
147 else if (animation->targetProperty() == Animation::Transform) { | |
148 AnimationEvent event(AnimationEvent::PropertyUpdate, | |
149 m_id, animation->group(), | |
150 Animation::Transform, monotonicTime); | |
151 event.transform = animation->curve()->toTransformAnimationCurve()->g etValue(monotonicTime); | |
152 events->push_back(event); | |
153 } | |
154 } | |
155 } | |
156 | |
128 void LayerAnimationController::updateState(AnimationEventsVector* events) | 157 void LayerAnimationController::updateState(AnimationEventsVector* events) |
129 { | 158 { |
130 if (!hasActiveObserver()) | 159 if (!hasActiveObserver()) |
131 return; | 160 return; |
132 | 161 |
133 promoteStartedAnimations(m_lastTickTime, events); | 162 promoteStartedAnimations(m_lastTickTime, events); |
134 markFinishedAnimations(m_lastTickTime); | 163 markFinishedAnimations(m_lastTickTime); |
135 markAnimationsForDeletion(m_lastTickTime, events); | 164 markAnimationsForDeletion(m_lastTickTime, events); |
136 startAnimationsWaitingForTargetAvailability(m_lastTickTime); | 165 startAnimationsWaitingForTargetAvailability(m_lastTickTime); |
137 promoteStartedAnimations(m_lastTickTime, events); | 166 promoteStartedAnimations(m_lastTickTime, events); |
138 | 167 |
168 accumulatePropertyUpdates(m_lastTickTime, events); | |
169 | |
139 updateActivation(); | 170 updateActivation(); |
140 } | 171 } |
141 | 172 |
142 void LayerAnimationController::addAnimation(scoped_ptr<Animation> animation) | 173 void LayerAnimationController::addAnimation(scoped_ptr<Animation> animation) |
143 { | 174 { |
144 m_activeAnimations.push_back(animation.Pass()); | 175 m_activeAnimations.push_back(animation.Pass()); |
145 updateActivation(); | 176 updateActivation(); |
146 } | 177 } |
147 | 178 |
148 Animation* LayerAnimationController::getAnimation(int groupId, Animation::Target Property targetProperty) const | 179 Animation* LayerAnimationController::getAnimation(int groupId, Animation::Target Property targetProperty) const |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 Animation::RunState initialRunState = Animation::WaitingForTargetAvailab ility; | 269 Animation::RunState initialRunState = Animation::WaitingForTargetAvailab ility; |
239 double startTime = 0; | 270 double startTime = 0; |
240 scoped_ptr<Animation> toAdd(m_activeAnimations[i]->cloneAndInitialize(An imation::ControllingInstance, initialRunState, startTime)); | 271 scoped_ptr<Animation> toAdd(m_activeAnimations[i]->cloneAndInitialize(An imation::ControllingInstance, initialRunState, startTime)); |
241 DCHECK(!toAdd->needsSynchronizedStartTime()); | 272 DCHECK(!toAdd->needsSynchronizedStartTime()); |
242 controllerImpl->addAnimation(toAdd.Pass()); | 273 controllerImpl->addAnimation(toAdd.Pass()); |
243 } | 274 } |
244 } | 275 } |
245 | 276 |
246 struct IsCompleted { | 277 struct IsCompleted { |
247 IsCompleted(const LayerAnimationController& mainThreadController) : m_mainTh readController(mainThreadController) { } | 278 IsCompleted(const LayerAnimationController& mainThreadController) : m_mainTh readController(mainThreadController) { } |
248 bool operator()(Animation* animation) const { return !m_mainThreadController .getAnimation(animation->group(), animation->targetProperty()); } | 279 bool operator()(Animation* animation) const { |
280 if (animation->isImplOnly()) | |
281 return false; | |
282 return !m_mainThreadController.getAnimation(animation->group(), animatio n->targetProperty()); } | |
249 private: | 283 private: |
250 const LayerAnimationController& m_mainThreadController; | 284 const LayerAnimationController& m_mainThreadController; |
251 }; | 285 }; |
252 | 286 |
253 void LayerAnimationController::removeAnimationsCompletedOnMainThread(LayerAnimat ionController* controllerImpl) const | 287 void LayerAnimationController::removeAnimationsCompletedOnMainThread(LayerAnimat ionController* controllerImpl) const |
254 { | 288 { |
255 // Delete all impl thread animations for which there is no corresponding mai n thread animation. | 289 // Delete all impl thread animations for which there is no corresponding mai n thread animation. |
256 // Each iteration, controller->m_activeAnimations.size() is decremented or i is incremented | 290 // Each iteration, controller->m_activeAnimations.size() is decremented or i is incremented |
257 // guaranteeing progress towards loop termination. | 291 // guaranteeing progress towards loop termination. |
258 ScopedPtrVector<Animation>& animations = controllerImpl->m_activeAnimations; | 292 ScopedPtrVector<Animation>& animations = controllerImpl->m_activeAnimations; |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 ObserverListBase<LayerAnimationValueObserver>::Iterator it(m_observers); | 530 ObserverListBase<LayerAnimationValueObserver>::Iterator it(m_observers); |
497 LayerAnimationValueObserver* obs; | 531 LayerAnimationValueObserver* obs; |
498 while ((obs = it.GetNext()) != NULL) | 532 while ((obs = it.GetNext()) != NULL) |
499 if (obs->IsActive()) | 533 if (obs->IsActive()) |
500 return true; | 534 return true; |
501 } | 535 } |
502 return false; | 536 return false; |
503 } | 537 } |
504 | 538 |
505 } // namespace cc | 539 } // namespace cc |
OLD | NEW |