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