| 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 "cc/active_animation.h" | 7 #include "cc/active_animation.h" |
| 8 #include "cc/animation_registrar.h" |
| 8 #include "cc/keyframed_animation_curve.h" | 9 #include "cc/keyframed_animation_curve.h" |
| 9 #include "ui/gfx/transform.h" | 10 #include "ui/gfx/transform.h" |
| 10 | 11 |
| 11 namespace cc { | 12 namespace cc { |
| 12 | 13 |
| 13 LayerAnimationController::LayerAnimationController(LayerAnimationControllerClien
t* client) | 14 LayerAnimationController::LayerAnimationController() |
| 14 : m_forceSync(false) | 15 : m_forceSync(false) |
| 15 , m_client(client) | 16 , m_id(-1) |
| 17 , m_opacity(1.0) |
| 18 , m_registrar(0) |
| 16 { | 19 { |
| 17 } | 20 } |
| 18 | 21 |
| 19 LayerAnimationController::~LayerAnimationController() | 22 LayerAnimationController::~LayerAnimationController() |
| 20 { | 23 { |
| 24 if (m_registrar) |
| 25 m_registrar->DidDeactivateAnimationController(this); |
| 21 } | 26 } |
| 22 | 27 |
| 23 scoped_ptr<LayerAnimationController> LayerAnimationController::create(LayerAnima
tionControllerClient* client) | 28 scoped_refptr<LayerAnimationController> LayerAnimationController::create() |
| 24 { | 29 { |
| 25 return make_scoped_ptr(new LayerAnimationController(client)); | 30 return make_scoped_refptr(new LayerAnimationController()); |
| 26 } | 31 } |
| 27 | 32 |
| 28 void LayerAnimationController::pauseAnimation(int animationId, double timeOffset
) | 33 void LayerAnimationController::pauseAnimation(int animationId, double timeOffset
) |
| 29 { | 34 { |
| 30 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { | 35 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { |
| 31 if (m_activeAnimations[i]->id() == animationId) | 36 if (m_activeAnimations[i]->id() == animationId) |
| 32 m_activeAnimations[i]->setRunState(ActiveAnimation::Paused, timeOffs
et + m_activeAnimations[i]->startTime()); | 37 m_activeAnimations[i]->setRunState(ActiveAnimation::Paused, timeOffs
et + m_activeAnimations[i]->startTime()); |
| 33 } | 38 } |
| 34 } | 39 } |
| 35 | 40 |
| 36 void LayerAnimationController::removeAnimation(int animationId) | 41 void LayerAnimationController::removeAnimation(int animationId) |
| 37 { | 42 { |
| 38 for (size_t i = 0; i < m_activeAnimations.size();) { | 43 for (size_t i = 0; i < m_activeAnimations.size();) { |
| 39 if (m_activeAnimations[i]->id() == animationId) | 44 if (m_activeAnimations[i]->id() == animationId) |
| 40 m_activeAnimations.remove(i); | 45 m_activeAnimations.remove(i); |
| 41 else | 46 else |
| 42 i++; | 47 i++; |
| 43 } | 48 } |
| 49 updateRegistration(); |
| 44 } | 50 } |
| 45 | 51 |
| 46 void LayerAnimationController::removeAnimation(int animationId, ActiveAnimation:
:TargetProperty targetProperty) | 52 void LayerAnimationController::removeAnimation(int animationId, ActiveAnimation:
:TargetProperty targetProperty) |
| 47 { | 53 { |
| 48 for (size_t i = 0; i < m_activeAnimations.size();) { | 54 for (size_t i = 0; i < m_activeAnimations.size();) { |
| 49 if (m_activeAnimations[i]->id() == animationId && m_activeAnimations[i]-
>targetProperty() == targetProperty) | 55 if (m_activeAnimations[i]->id() == animationId && m_activeAnimations[i]-
>targetProperty() == targetProperty) |
| 50 m_activeAnimations.remove(i); | 56 m_activeAnimations.remove(i); |
| 51 else | 57 else |
| 52 i++; | 58 i++; |
| 53 } | 59 } |
| 60 updateRegistration(); |
| 54 } | 61 } |
| 55 | 62 |
| 56 // According to render layer backing, these are for testing only. | 63 // According to render layer backing, these are for testing only. |
| 57 void LayerAnimationController::suspendAnimations(double monotonicTime) | 64 void LayerAnimationController::suspendAnimations(double monotonicTime) |
| 58 { | 65 { |
| 59 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { | 66 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { |
| 60 if (!m_activeAnimations[i]->isFinished()) | 67 if (!m_activeAnimations[i]->isFinished()) |
| 61 m_activeAnimations[i]->setRunState(ActiveAnimation::Paused, monotoni
cTime); | 68 m_activeAnimations[i]->setRunState(ActiveAnimation::Paused, monotoni
cTime); |
| 62 } | 69 } |
| 63 } | 70 } |
| 64 | 71 |
| 65 // Looking at GraphicsLayerCA, this appears to be the analog to suspendAnimation
s, which is for testing. | 72 // Looking at GraphicsLayerCA, this appears to be the analog to suspendAnimation
s, which is for testing. |
| 66 void LayerAnimationController::resumeAnimations(double monotonicTime) | 73 void LayerAnimationController::resumeAnimations(double monotonicTime) |
| 67 { | 74 { |
| 68 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { | 75 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { |
| 69 if (m_activeAnimations[i]->runState() == ActiveAnimation::Paused) | 76 if (m_activeAnimations[i]->runState() == ActiveAnimation::Paused) |
| 70 m_activeAnimations[i]->setRunState(ActiveAnimation::Running, monoton
icTime); | 77 m_activeAnimations[i]->setRunState(ActiveAnimation::Running, monoton
icTime); |
| 71 } | 78 } |
| 72 } | 79 } |
| 73 | 80 |
| 74 // Ensures that the list of active animations on the main thread and the impl th
read | 81 // Ensures that the list of active animations on the main thread and the impl th
read |
| 75 // are kept in sync. | 82 // are kept in sync. |
| 76 void LayerAnimationController::pushAnimationUpdatesTo(LayerAnimationController*
controllerImpl) | 83 void LayerAnimationController::pushAnimationUpdatesTo(LayerAnimationController*
controllerImpl) |
| 77 { | 84 { |
| 85 if (!isAnimatingProperty(ActiveAnimation::Opacity)) |
| 86 controllerImpl->m_opacity = m_opacity; |
| 87 |
| 88 if (!isAnimatingProperty(ActiveAnimation::Transform)) |
| 89 controllerImpl->m_transform = m_transform; |
| 90 |
| 78 if (m_forceSync) { | 91 if (m_forceSync) { |
| 79 replaceImplThreadAnimations(controllerImpl); | 92 replaceImplThreadAnimations(controllerImpl); |
| 80 m_forceSync = false; | 93 m_forceSync = false; |
| 81 } else { | 94 } else { |
| 82 purgeAnimationsMarkedForDeletion(); | 95 purgeAnimationsMarkedForDeletion(); |
| 83 pushNewAnimationsToImplThread(controllerImpl); | 96 pushNewAnimationsToImplThread(controllerImpl); |
| 84 | 97 |
| 85 // Remove finished impl side animations only after pushing, | 98 // Remove finished impl side animations only after pushing, |
| 86 // and only after the animations are deleted on the main thread | 99 // and only after the animations are deleted on the main thread |
| 87 // this insures we will never push an animation twice. | 100 // this insures we will never push an animation twice. |
| 88 removeAnimationsCompletedOnMainThread(controllerImpl); | 101 removeAnimationsCompletedOnMainThread(controllerImpl); |
| 89 | 102 |
| 90 pushPropertiesToImplThread(controllerImpl); | 103 pushPropertiesToImplThread(controllerImpl); |
| 91 } | 104 } |
| 92 } | 105 } |
| 93 | 106 |
| 94 void LayerAnimationController::animate(double monotonicTime, AnimationEventsVect
or* events) | 107 void LayerAnimationController::animate(double monotonicTime, AnimationEventsVect
or* events) |
| 95 { | 108 { |
| 96 startAnimationsWaitingForNextTick(monotonicTime, events); | 109 startAnimationsWaitingForNextTick(monotonicTime, events); |
| 97 startAnimationsWaitingForStartTime(monotonicTime, events); | 110 startAnimationsWaitingForStartTime(monotonicTime, events); |
| 98 startAnimationsWaitingForTargetAvailability(monotonicTime, events); | 111 startAnimationsWaitingForTargetAvailability(monotonicTime, events); |
| 99 resolveConflicts(monotonicTime); | 112 resolveConflicts(monotonicTime); |
| 100 tickAnimations(monotonicTime); | 113 tickAnimations(monotonicTime); |
| 101 markAnimationsForDeletion(monotonicTime, events); | 114 markAnimationsForDeletion(monotonicTime, events); |
| 102 startAnimationsWaitingForTargetAvailability(monotonicTime, events); | 115 startAnimationsWaitingForTargetAvailability(monotonicTime, events); |
| 116 |
| 117 updateRegistration(); |
| 103 } | 118 } |
| 104 | 119 |
| 105 void LayerAnimationController::addAnimation(scoped_ptr<ActiveAnimation> animatio
n) | 120 void LayerAnimationController::addAnimation(scoped_ptr<ActiveAnimation> animatio
n) |
| 106 { | 121 { |
| 107 m_activeAnimations.append(animation.Pass()); | 122 m_activeAnimations.append(animation.Pass()); |
| 123 updateRegistration(); |
| 108 } | 124 } |
| 109 | 125 |
| 110 ActiveAnimation* LayerAnimationController::getActiveAnimation(int groupId, Activ
eAnimation::TargetProperty targetProperty) const | 126 ActiveAnimation* LayerAnimationController::getActiveAnimation(int groupId, Activ
eAnimation::TargetProperty targetProperty) const |
| 111 { | 127 { |
| 112 for (size_t i = 0; i < m_activeAnimations.size(); ++i) | 128 for (size_t i = 0; i < m_activeAnimations.size(); ++i) |
| 113 if (m_activeAnimations[i]->group() == groupId && m_activeAnimations[i]->
targetProperty() == targetProperty) | 129 if (m_activeAnimations[i]->group() == groupId && m_activeAnimations[i]->
targetProperty() == targetProperty) |
| 114 return m_activeAnimations[i]; | 130 return m_activeAnimations[i]; |
| 115 return 0; | 131 return 0; |
| 116 } | 132 } |
| 117 | 133 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 147 { | 163 { |
| 148 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { | 164 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { |
| 149 if (m_activeAnimations[i]->group() == event.groupId && m_activeAnimation
s[i]->targetProperty() == event.targetProperty && m_activeAnimations[i]->needsSy
nchronizedStartTime()) { | 165 if (m_activeAnimations[i]->group() == event.groupId && m_activeAnimation
s[i]->targetProperty() == event.targetProperty && m_activeAnimations[i]->needsSy
nchronizedStartTime()) { |
| 150 m_activeAnimations[i]->setNeedsSynchronizedStartTime(false); | 166 m_activeAnimations[i]->setNeedsSynchronizedStartTime(false); |
| 151 m_activeAnimations[i]->setStartTime(event.monotonicTime); | 167 m_activeAnimations[i]->setStartTime(event.monotonicTime); |
| 152 return; | 168 return; |
| 153 } | 169 } |
| 154 } | 170 } |
| 155 } | 171 } |
| 156 | 172 |
| 157 void LayerAnimationController::setClient(LayerAnimationControllerClient* client) | 173 void LayerAnimationController::setAnimationRegistrar(AnimationRegistrar* registr
ar) |
| 158 { | 174 { |
| 159 m_client = client; | 175 if (m_registrar == registrar) |
| 176 return; |
| 177 |
| 178 if (m_registrar) |
| 179 m_registrar->UnregisterAnimationController(this); |
| 180 |
| 181 m_registrar = registrar; |
| 182 if (m_registrar) |
| 183 m_registrar->RegisterAnimationController(this); |
| 184 |
| 185 updateRegistration(); |
| 186 } |
| 187 |
| 188 void LayerAnimationController::setId(int id) |
| 189 { |
| 190 m_id = id; |
| 191 } |
| 192 |
| 193 bool LayerAnimationController::setOpacity(float opacity) |
| 194 { |
| 195 if (m_opacity == opacity || isAnimatingProperty(ActiveAnimation::Opacity)) |
| 196 return false; |
| 197 m_opacity = opacity; |
| 198 return true; |
| 199 } |
| 200 |
| 201 bool LayerAnimationController::setTransform(const gfx::Transform& transform) |
| 202 { |
| 203 if (m_transform == transform || isAnimatingProperty(ActiveAnimation::Transfo
rm)) |
| 204 return false; |
| 205 m_transform = transform; |
| 206 return true; |
| 160 } | 207 } |
| 161 | 208 |
| 162 void LayerAnimationController::pushNewAnimationsToImplThread(LayerAnimationContr
oller* controllerImpl) const | 209 void LayerAnimationController::pushNewAnimationsToImplThread(LayerAnimationContr
oller* controllerImpl) const |
| 163 { | 210 { |
| 164 // Any new animations owned by the main thread's controller are cloned and a
dde to the impl thread's controller. | 211 // Any new animations owned by the main thread's controller are cloned and a
dde to the impl thread's controller. |
| 165 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { | 212 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { |
| 166 // If the animation is already running on the impl thread, there is no n
eed to copy it over. | 213 // If the animation is already running on the impl thread, there is no n
eed to copy it over. |
| 167 if (controllerImpl->getActiveAnimation(m_activeAnimations[i]->group(), m
_activeAnimations[i]->targetProperty())) | 214 if (controllerImpl->getActiveAnimation(m_activeAnimations[i]->group(), m
_activeAnimations[i]->targetProperty())) |
| 168 continue; | 215 continue; |
| 169 | 216 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 } | 254 } |
| 208 | 255 |
| 209 void LayerAnimationController::startAnimationsWaitingForNextTick(double monotoni
cTime, AnimationEventsVector* events) | 256 void LayerAnimationController::startAnimationsWaitingForNextTick(double monotoni
cTime, AnimationEventsVector* events) |
| 210 { | 257 { |
| 211 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { | 258 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { |
| 212 if (m_activeAnimations[i]->runState() == ActiveAnimation::WaitingForNext
Tick) { | 259 if (m_activeAnimations[i]->runState() == ActiveAnimation::WaitingForNext
Tick) { |
| 213 m_activeAnimations[i]->setRunState(ActiveAnimation::Running, monoton
icTime); | 260 m_activeAnimations[i]->setRunState(ActiveAnimation::Running, monoton
icTime); |
| 214 if (!m_activeAnimations[i]->hasSetStartTime()) | 261 if (!m_activeAnimations[i]->hasSetStartTime()) |
| 215 m_activeAnimations[i]->setStartTime(monotonicTime); | 262 m_activeAnimations[i]->setStartTime(monotonicTime); |
| 216 if (events) | 263 if (events) |
| 217 events->push_back(AnimationEvent(AnimationEvent::Started, m_clie
nt->id(), m_activeAnimations[i]->group(), m_activeAnimations[i]->targetProperty(
), monotonicTime)); | 264 events->push_back(AnimationEvent(AnimationEvent::Started, m_id,
m_activeAnimations[i]->group(), m_activeAnimations[i]->targetProperty(), monoton
icTime)); |
| 218 } | 265 } |
| 219 } | 266 } |
| 220 } | 267 } |
| 221 | 268 |
| 222 void LayerAnimationController::startAnimationsWaitingForStartTime(double monoton
icTime, AnimationEventsVector* events) | 269 void LayerAnimationController::startAnimationsWaitingForStartTime(double monoton
icTime, AnimationEventsVector* events) |
| 223 { | 270 { |
| 224 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { | 271 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { |
| 225 if (m_activeAnimations[i]->runState() == ActiveAnimation::WaitingForStar
tTime && m_activeAnimations[i]->startTime() <= monotonicTime) { | 272 if (m_activeAnimations[i]->runState() == ActiveAnimation::WaitingForStar
tTime && m_activeAnimations[i]->startTime() <= monotonicTime) { |
| 226 m_activeAnimations[i]->setRunState(ActiveAnimation::Running, monoton
icTime); | 273 m_activeAnimations[i]->setRunState(ActiveAnimation::Running, monoton
icTime); |
| 227 if (events) | 274 if (events) |
| 228 events->push_back(AnimationEvent(AnimationEvent::Started, m_clie
nt->id(), m_activeAnimations[i]->group(), m_activeAnimations[i]->targetProperty(
), monotonicTime)); | 275 events->push_back(AnimationEvent(AnimationEvent::Started, m_id,
m_activeAnimations[i]->group(), m_activeAnimations[i]->targetProperty(), monoton
icTime)); |
| 229 } | 276 } |
| 230 } | 277 } |
| 231 } | 278 } |
| 232 | 279 |
| 233 void LayerAnimationController::startAnimationsWaitingForTargetAvailability(doubl
e monotonicTime, AnimationEventsVector* events) | 280 void LayerAnimationController::startAnimationsWaitingForTargetAvailability(doubl
e monotonicTime, AnimationEventsVector* events) |
| 234 { | 281 { |
| 235 // First collect running properties. | 282 // First collect running properties. |
| 236 TargetProperties blockedProperties; | 283 TargetProperties blockedProperties; |
| 237 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { | 284 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { |
| 238 if (m_activeAnimations[i]->runState() == ActiveAnimation::Running || m_a
ctiveAnimations[i]->runState() == ActiveAnimation::Finished) | 285 if (m_activeAnimations[i]->runState() == ActiveAnimation::Running || m_a
ctiveAnimations[i]->runState() == ActiveAnimation::Finished) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 257 if (!blockedProperties.insert(*pIter).second) | 304 if (!blockedProperties.insert(*pIter).second) |
| 258 nullIntersection = false; | 305 nullIntersection = false; |
| 259 } | 306 } |
| 260 | 307 |
| 261 // If the intersection is null, then we are free to start the animat
ions in the group. | 308 // If the intersection is null, then we are free to start the animat
ions in the group. |
| 262 if (nullIntersection) { | 309 if (nullIntersection) { |
| 263 m_activeAnimations[i]->setRunState(ActiveAnimation::Running, mon
otonicTime); | 310 m_activeAnimations[i]->setRunState(ActiveAnimation::Running, mon
otonicTime); |
| 264 if (!m_activeAnimations[i]->hasSetStartTime()) | 311 if (!m_activeAnimations[i]->hasSetStartTime()) |
| 265 m_activeAnimations[i]->setStartTime(monotonicTime); | 312 m_activeAnimations[i]->setStartTime(monotonicTime); |
| 266 if (events) | 313 if (events) |
| 267 events->push_back(AnimationEvent(AnimationEvent::Started, m_
client->id(), m_activeAnimations[i]->group(), m_activeAnimations[i]->targetPrope
rty(), monotonicTime)); | 314 events->push_back(AnimationEvent(AnimationEvent::Started, m_
id, m_activeAnimations[i]->group(), m_activeAnimations[i]->targetProperty(), mon
otonicTime)); |
| 268 for (size_t j = i + 1; j < m_activeAnimations.size(); ++j) { | 315 for (size_t j = i + 1; j < m_activeAnimations.size(); ++j) { |
| 269 if (m_activeAnimations[i]->group() == m_activeAnimations[j]-
>group()) { | 316 if (m_activeAnimations[i]->group() == m_activeAnimations[j]-
>group()) { |
| 270 m_activeAnimations[j]->setRunState(ActiveAnimation::Runn
ing, monotonicTime); | 317 m_activeAnimations[j]->setRunState(ActiveAnimation::Runn
ing, monotonicTime); |
| 271 if (!m_activeAnimations[j]->hasSetStartTime()) | 318 if (!m_activeAnimations[j]->hasSetStartTime()) |
| 272 m_activeAnimations[j]->setStartTime(monotonicTime); | 319 m_activeAnimations[j]->setStartTime(monotonicTime); |
| 273 } | 320 } |
| 274 } | 321 } |
| 275 } | 322 } |
| 276 } | 323 } |
| 277 } | 324 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 break; | 360 break; |
| 314 } | 361 } |
| 315 } | 362 } |
| 316 } | 363 } |
| 317 if (allAnimsWithSameIdAreFinished) { | 364 if (allAnimsWithSameIdAreFinished) { |
| 318 // We now need to remove all animations with the same group id as gr
oupId | 365 // We now need to remove all animations with the same group id as gr
oupId |
| 319 // (and send along animation finished notifications, if necessary). | 366 // (and send along animation finished notifications, if necessary). |
| 320 for (size_t j = i; j < m_activeAnimations.size(); j++) { | 367 for (size_t j = i; j < m_activeAnimations.size(); j++) { |
| 321 if (groupId == m_activeAnimations[j]->group()) { | 368 if (groupId == m_activeAnimations[j]->group()) { |
| 322 if (events) | 369 if (events) |
| 323 events->push_back(AnimationEvent(AnimationEvent::Finishe
d, m_client->id(), m_activeAnimations[j]->group(), m_activeAnimations[j]->target
Property(), monotonicTime)); | 370 events->push_back(AnimationEvent(AnimationEvent::Finishe
d, m_id, m_activeAnimations[j]->group(), m_activeAnimations[j]->targetProperty()
, monotonicTime)); |
| 324 m_activeAnimations[j]->setRunState(ActiveAnimation::WaitingF
orDeletion, monotonicTime); | 371 m_activeAnimations[j]->setRunState(ActiveAnimation::WaitingF
orDeletion, monotonicTime); |
| 325 } | 372 } |
| 326 } | 373 } |
| 327 } | 374 } |
| 328 } | 375 } |
| 329 } | 376 } |
| 330 | 377 |
| 331 void LayerAnimationController::purgeAnimationsMarkedForDeletion() | 378 void LayerAnimationController::purgeAnimationsMarkedForDeletion() |
| 332 { | 379 { |
| 333 for (size_t i = 0; i < m_activeAnimations.size();) { | 380 for (size_t i = 0; i < m_activeAnimations.size();) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 351 toAdd = m_activeAnimations[i]->cloneAndInitialize(ActiveAnimation::C
ontrollingInstance, initialRunState, startTime).Pass(); | 398 toAdd = m_activeAnimations[i]->cloneAndInitialize(ActiveAnimation::C
ontrollingInstance, initialRunState, startTime).Pass(); |
| 352 } else | 399 } else |
| 353 toAdd = m_activeAnimations[i]->clone(ActiveAnimation::ControllingIns
tance).Pass(); | 400 toAdd = m_activeAnimations[i]->clone(ActiveAnimation::ControllingIns
tance).Pass(); |
| 354 | 401 |
| 355 controllerImpl->addAnimation(toAdd.Pass()); | 402 controllerImpl->addAnimation(toAdd.Pass()); |
| 356 } | 403 } |
| 357 } | 404 } |
| 358 | 405 |
| 359 void LayerAnimationController::tickAnimations(double monotonicTime) | 406 void LayerAnimationController::tickAnimations(double monotonicTime) |
| 360 { | 407 { |
| 361 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { | 408 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { |
| 362 if (m_activeAnimations[i]->runState() == ActiveAnimation::Running || m_a
ctiveAnimations[i]->runState() == ActiveAnimation::Paused) { | 409 if (m_activeAnimations[i]->runState() == ActiveAnimation::Running || m_a
ctiveAnimations[i]->runState() == ActiveAnimation::Paused) { |
| 363 double trimmed = m_activeAnimations[i]->trimTimeToCurrentIteration(m
onotonicTime); | 410 double trimmed = m_activeAnimations[i]->trimTimeToCurrentIteration(m
onotonicTime); |
| 364 | 411 |
| 365 // Animation assumes its initial value until it gets the synchronize
d start time | 412 // Animation assumes its initial value until it gets the synchronize
d start time |
| 366 // from the impl thread and can start ticking. | 413 // from the impl thread and can start ticking. |
| 367 if (m_activeAnimations[i]->needsSynchronizedStartTime()) | 414 if (m_activeAnimations[i]->needsSynchronizedStartTime()) |
| 368 trimmed = 0; | 415 trimmed = 0; |
| 369 | 416 |
| 370 switch (m_activeAnimations[i]->targetProperty()) { | 417 switch (m_activeAnimations[i]->targetProperty()) { |
| 371 | 418 |
| 372 case ActiveAnimation::Transform: { | 419 case ActiveAnimation::Transform: { |
| 373 const TransformAnimationCurve* transformAnimationCurve = m_activ
eAnimations[i]->curve()->toTransformAnimationCurve(); | 420 const TransformAnimationCurve* transformAnimationCurve = m_activ
eAnimations[i]->curve()->toTransformAnimationCurve(); |
| 374 const gfx::Transform matrix = transformAnimationCurve->getValue(
trimmed).toTransform(); | 421 m_transform = transformAnimationCurve->getValue(trimmed).toTrans
form(); |
| 375 if (m_activeAnimations[i]->isFinishedAt(monotonicTime)) | 422 if (m_activeAnimations[i]->isFinishedAt(monotonicTime)) |
| 376 m_activeAnimations[i]->setRunState(ActiveAnimation::Finished
, monotonicTime); | 423 m_activeAnimations[i]->setRunState(ActiveAnimation::Finished
, monotonicTime); |
| 377 | |
| 378 m_client->setTransformFromAnimation(matrix); | |
| 379 break; | 424 break; |
| 380 } | 425 } |
| 381 | 426 |
| 382 case ActiveAnimation::Opacity: { | 427 case ActiveAnimation::Opacity: { |
| 383 const FloatAnimationCurve* floatAnimationCurve = m_activeAnimati
ons[i]->curve()->toFloatAnimationCurve(); | 428 const FloatAnimationCurve* floatAnimationCurve = m_activeAnimati
ons[i]->curve()->toFloatAnimationCurve(); |
| 384 const float opacity = floatAnimationCurve->getValue(trimmed); | 429 m_opacity = floatAnimationCurve->getValue(trimmed); |
| 385 if (m_activeAnimations[i]->isFinishedAt(monotonicTime)) | 430 if (m_activeAnimations[i]->isFinishedAt(monotonicTime)) |
| 386 m_activeAnimations[i]->setRunState(ActiveAnimation::Finished
, monotonicTime); | 431 m_activeAnimations[i]->setRunState(ActiveAnimation::Finished
, monotonicTime); |
| 387 | |
| 388 m_client->setOpacityFromAnimation(opacity); | |
| 389 break; | 432 break; |
| 390 } | 433 } |
| 391 | 434 |
| 392 // Do nothing for sentinel value. | 435 // Do nothing for sentinel value. |
| 393 case ActiveAnimation::TargetPropertyEnumSize: | 436 case ActiveAnimation::TargetPropertyEnumSize: |
| 394 NOTREACHED(); | 437 NOTREACHED(); |
| 395 } | 438 } |
| 396 } | 439 } |
| 397 } | 440 } |
| 398 } | 441 } |
| 399 | 442 |
| 443 void LayerAnimationController::updateRegistration() |
| 444 { |
| 445 if (m_registrar) { |
| 446 if (hasActiveAnimation()) |
| 447 m_registrar->DidActivateAnimationController(this); |
| 448 else |
| 449 m_registrar->DidDeactivateAnimationController(this); |
| 450 } |
| 451 } |
| 452 |
| 400 } // namespace cc | 453 } // namespace cc |
| OLD | NEW |