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

Side by Side Diff: cc/layer_animation_controller.cc

Issue 12453010: Allow impl-only animations, and return opacity values via AnimationEvents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
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
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 if (m_activeAnimations[i]->targetProperty() == Animation::Opacity) {
Ian Vollick 2013/03/06 01:00:57 Need to check that the animation is impl only here
wjmaclean 2013/03/06 17:03:13 Done.
136 Animation* animation = m_activeAnimations[i];
137 float opacity = animation->curve()->toFloatAnimationCurve()->getValu e(monotonicTime);
138 AnimationEvent event(AnimationEvent::PropertyUpdate,
139 m_id, animation->group(),
140 Animation::Opacity, monotonicTime,
141 opacity);
142 events->push_back(event);
143 }
144 }
145 }
146
128 void LayerAnimationController::updateState(AnimationEventsVector* events) 147 void LayerAnimationController::updateState(AnimationEventsVector* events)
129 { 148 {
130 if (!hasActiveObserver()) 149 if (!hasActiveObserver())
131 return; 150 return;
132 151
133 promoteStartedAnimations(m_lastTickTime, events); 152 promoteStartedAnimations(m_lastTickTime, events);
134 markFinishedAnimations(m_lastTickTime); 153 markFinishedAnimations(m_lastTickTime);
135 markAnimationsForDeletion(m_lastTickTime, events); 154 markAnimationsForDeletion(m_lastTickTime, events);
136 startAnimationsWaitingForTargetAvailability(m_lastTickTime); 155 startAnimationsWaitingForTargetAvailability(m_lastTickTime);
137 promoteStartedAnimations(m_lastTickTime, events); 156 promoteStartedAnimations(m_lastTickTime, events);
138 157
158 accumulatePropertyUpdates(m_lastTickTime, events);
159
139 updateActivation(); 160 updateActivation();
140 } 161 }
141 162
142 void LayerAnimationController::addAnimation(scoped_ptr<Animation> animation) 163 void LayerAnimationController::addAnimation(scoped_ptr<Animation> animation)
143 { 164 {
144 m_activeAnimations.push_back(animation.Pass()); 165 m_activeAnimations.push_back(animation.Pass());
145 updateActivation(); 166 updateActivation();
146 } 167 }
147 168
148 Animation* LayerAnimationController::getAnimation(int groupId, Animation::Target Property targetProperty) const 169 Animation* LayerAnimationController::getAnimation(int groupId, Animation::Target Property targetProperty) const
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 Animation::RunState initialRunState = Animation::WaitingForTargetAvailab ility; 259 Animation::RunState initialRunState = Animation::WaitingForTargetAvailab ility;
239 double startTime = 0; 260 double startTime = 0;
240 scoped_ptr<Animation> toAdd(m_activeAnimations[i]->cloneAndInitialize(An imation::ControllingInstance, initialRunState, startTime)); 261 scoped_ptr<Animation> toAdd(m_activeAnimations[i]->cloneAndInitialize(An imation::ControllingInstance, initialRunState, startTime));
241 DCHECK(!toAdd->needsSynchronizedStartTime()); 262 DCHECK(!toAdd->needsSynchronizedStartTime());
242 controllerImpl->addAnimation(toAdd.Pass()); 263 controllerImpl->addAnimation(toAdd.Pass());
243 } 264 }
244 } 265 }
245 266
246 struct IsCompleted { 267 struct IsCompleted {
247 IsCompleted(const LayerAnimationController& mainThreadController) : m_mainTh readController(mainThreadController) { } 268 IsCompleted(const LayerAnimationController& mainThreadController) : m_mainTh readController(mainThreadController) { }
248 bool operator()(Animation* animation) const { return !m_mainThreadController .getAnimation(animation->group(), animation->targetProperty()); } 269 bool operator()(Animation* animation) const {
270 if (animation->isImplAnimationOnly())
271 return false;
272 return !m_mainThreadController.getAnimation(animation->group(), animatio n->targetProperty()); }
249 private: 273 private:
250 const LayerAnimationController& m_mainThreadController; 274 const LayerAnimationController& m_mainThreadController;
251 }; 275 };
252 276
253 void LayerAnimationController::removeAnimationsCompletedOnMainThread(LayerAnimat ionController* controllerImpl) const 277 void LayerAnimationController::removeAnimationsCompletedOnMainThread(LayerAnimat ionController* controllerImpl) const
254 { 278 {
255 // Delete all impl thread animations for which there is no corresponding mai n thread animation. 279 // 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 280 // Each iteration, controller->m_activeAnimations.size() is decremented or i is incremented
257 // guaranteeing progress towards loop termination. 281 // guaranteeing progress towards loop termination.
258 ScopedPtrVector<Animation>& animations = controllerImpl->m_activeAnimations; 282 ScopedPtrVector<Animation>& animations = controllerImpl->m_activeAnimations;
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 ObserverListBase<LayerAnimationValueObserver>::Iterator it(m_observers); 520 ObserverListBase<LayerAnimationValueObserver>::Iterator it(m_observers);
497 LayerAnimationValueObserver* obs; 521 LayerAnimationValueObserver* obs;
498 while ((obs = it.GetNext()) != NULL) 522 while ((obs = it.GetNext()) != NULL)
499 if (obs->IsActive()) 523 if (obs->IsActive())
500 return true; 524 return true;
501 } 525 }
502 return false; 526 return false;
503 } 527 }
504 528
505 } // namespace cc 529 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698