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" |
11 #include "cc/keyframed_animation_curve.h" | 11 #include "cc/keyframed_animation_curve.h" |
12 #include "cc/layer_animation_value_observer.h" | 12 #include "cc/layer_animation_value_observer.h" |
13 #include "cc/scoped_ptr_algorithm.h" | 13 #include "cc/scoped_ptr_algorithm.h" |
14 #include "ui/gfx/transform.h" | 14 #include "ui/gfx/transform.h" |
15 | 15 |
16 namespace cc { | 16 namespace cc { |
17 | 17 |
18 LayerAnimationController::LayerAnimationController(int id) | 18 LayerAnimationController::LayerAnimationController(int id) |
19 : m_forceSync(false) | 19 : m_forceSync(false) |
20 , m_id(id) | 20 , m_id(id) |
21 , m_registrar(0) | 21 , m_registrar(0) |
22 , m_isActive(false) | 22 , m_isActive(false) |
| 23 , m_orphanWaitStatus(NeverWaitedForLayout) |
23 { | 24 { |
24 } | 25 } |
25 | 26 |
26 LayerAnimationController::~LayerAnimationController() | 27 LayerAnimationController::~LayerAnimationController() |
27 { | 28 { |
28 if (m_registrar) | 29 if (m_registrar) |
29 m_registrar->UnregisterAnimationController(this); | 30 m_registrar->UnregisterAnimationController(this); |
30 } | 31 } |
31 | 32 |
32 scoped_refptr<LayerAnimationController> LayerAnimationController::create(int id) | 33 scoped_refptr<LayerAnimationController> LayerAnimationController::create(int id) |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 tickAnimations(monotonicTime); | 124 tickAnimations(monotonicTime); |
124 markAnimationsForDeletion(monotonicTime, events); | 125 markAnimationsForDeletion(monotonicTime, events); |
125 startAnimationsWaitingForTargetAvailability(monotonicTime, events); | 126 startAnimationsWaitingForTargetAvailability(monotonicTime, events); |
126 | 127 |
127 updateActivation(); | 128 updateActivation(); |
128 } | 129 } |
129 | 130 |
130 void LayerAnimationController::addAnimation(scoped_ptr<Animation> animation) | 131 void LayerAnimationController::addAnimation(scoped_ptr<Animation> animation) |
131 { | 132 { |
132 m_activeAnimations.push_back(animation.Pass()); | 133 m_activeAnimations.push_back(animation.Pass()); |
| 134 if ((m_orphanWaitStatus == NeverWaitedForLayout) && !hasNonOrphanedObserver(
)) |
| 135 m_orphanWaitStatus = WaitingForLayout; |
133 updateActivation(); | 136 updateActivation(); |
134 } | 137 } |
135 | 138 |
136 Animation* LayerAnimationController::getAnimation(int groupId, Animation::Target
Property targetProperty) const | 139 Animation* LayerAnimationController::getAnimation(int groupId, Animation::Target
Property targetProperty) const |
137 { | 140 { |
138 for (size_t i = 0; i < m_activeAnimations.size(); ++i) | 141 for (size_t i = 0; i < m_activeAnimations.size(); ++i) |
139 if (m_activeAnimations[i]->group() == groupId && m_activeAnimations[i]->
targetProperty() == targetProperty) | 142 if (m_activeAnimations[i]->group() == groupId && m_activeAnimations[i]->
targetProperty() == targetProperty) |
140 return m_activeAnimations[i]; | 143 return m_activeAnimations[i]; |
141 return 0; | 144 return 0; |
142 } | 145 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 { | 203 { |
201 if (!m_observers.HasObserver(observer)) | 204 if (!m_observers.HasObserver(observer)) |
202 m_observers.AddObserver(observer); | 205 m_observers.AddObserver(observer); |
203 } | 206 } |
204 | 207 |
205 void LayerAnimationController::removeObserver(LayerAnimationValueObserver* obser
ver) | 208 void LayerAnimationController::removeObserver(LayerAnimationValueObserver* obser
ver) |
206 { | 209 { |
207 m_observers.RemoveObserver(observer); | 210 m_observers.RemoveObserver(observer); |
208 } | 211 } |
209 | 212 |
| 213 bool LayerAnimationController::hasNonOrphanedObserver() |
| 214 { |
| 215 if (m_observers.might_have_observers()) { |
| 216 ObserverListBase<LayerAnimationValueObserver>::Iterator it(m_observers); |
| 217 LayerAnimationValueObserver* obs; |
| 218 while ((obs = it.GetNext()) != NULL) { |
| 219 if (!obs->IsOrphaned()) |
| 220 return true; |
| 221 } |
| 222 } |
| 223 return false; |
| 224 } |
| 225 |
210 void LayerAnimationController::pushNewAnimationsToImplThread(LayerAnimationContr
oller* controllerImpl) const | 226 void LayerAnimationController::pushNewAnimationsToImplThread(LayerAnimationContr
oller* controllerImpl) const |
211 { | 227 { |
212 // Any new animations owned by the main thread's controller are cloned and a
dde to the impl thread's controller. | 228 // Any new animations owned by the main thread's controller are cloned and a
dde to the impl thread's controller. |
213 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { | 229 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { |
214 // If the animation is already running on the impl thread, there is no n
eed to copy it over. | 230 // If the animation is already running on the impl thread, there is no n
eed to copy it over. |
215 if (controllerImpl->getAnimation(m_activeAnimations[i]->group(), m_activ
eAnimations[i]->targetProperty())) | 231 if (controllerImpl->getAnimation(m_activeAnimations[i]->group(), m_activ
eAnimations[i]->targetProperty())) |
216 continue; | 232 continue; |
217 | 233 |
218 // If the animation is not running on the impl thread, it does not neces
sarily mean that it needs | 234 // If the animation is not running on the impl thread, it does not neces
sarily mean that it needs |
219 // to be copied over and started; it may have already finished. In this
case, the impl thread animation | 235 // to be copied over and started; it may have already finished. In this
case, the impl thread animation |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 ObserverListBase<LayerAnimationValueObserver>::Iterator it(m_observers); | 492 ObserverListBase<LayerAnimationValueObserver>::Iterator it(m_observers); |
477 LayerAnimationValueObserver* obs; | 493 LayerAnimationValueObserver* obs; |
478 while ((obs = it.GetNext()) != NULL) | 494 while ((obs = it.GetNext()) != NULL) |
479 if (obs->IsActive()) | 495 if (obs->IsActive()) |
480 return true; | 496 return true; |
481 } | 497 } |
482 return false; | 498 return false; |
483 } | 499 } |
484 | 500 |
485 } // namespace cc | 501 } // namespace cc |
OLD | NEW |