Index: cc/layer_tree_host.cc |
diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc |
index a6e2a76179913ae4edee0ed72f7d5a19e2aae2b5..e70dec205d83e244f801f13f2c4d52d99eda5d2f 100644 |
--- a/cc/layer_tree_host.cc |
+++ b/cc/layer_tree_host.cc |
@@ -90,8 +90,9 @@ LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSetting |
, m_backgroundColor(SK_ColorWHITE) |
, m_hasTransparentBackground(false) |
, m_partialTextureUpdateRequests(0) |
- , m_animationRegistrar(AnimationRegistrar::create()) |
{ |
+ if (m_settings.acceleratedAnimationEnabled) |
+ m_animationRegistrar = AnimationRegistrar::create(); |
numLayerTreeInstances++; |
} |
@@ -219,11 +220,11 @@ void LayerTreeHost::didBeginFrame() |
m_client->didBeginFrame(); |
} |
-void LayerTreeHost::updateAnimations(base::TimeTicks frameBeginTime) |
+void LayerTreeHost::updateAnimations(base::TimeTicks monotonicFrameBeginTime, base::Time wallClockFrameBeginTime) |
{ |
m_animating = true; |
- m_client->animate((frameBeginTime - base::TimeTicks()).InSecondsF()); |
- animateLayers(frameBeginTime); |
+ m_client->animate((monotonicFrameBeginTime - base::TimeTicks()).InSecondsF()); |
+ animateLayers(monotonicFrameBeginTime, wallClockFrameBeginTime); |
m_animating = false; |
m_renderingStats.numAnimationFrames++; |
@@ -835,18 +836,35 @@ bool LayerTreeHost::blocksPendingCommit() const |
return m_rootLayer->blocksPendingCommitRecursive(); |
} |
-void LayerTreeHost::animateLayers(base::TimeTicks time) |
+void LayerTreeHost::didUpdateLayout() |
+{ |
+ AnimationRegistrar::AnimationControllerMap copy = m_animationRegistrar->active_animation_controllers(); |
+ for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); iter != copy.end(); ++iter) { |
+ if ((*iter).second->orphanWaitStatus() == LayerAnimationController::WaitingForLayout) |
+ (*iter).second->setOrphanWaitStatus(LayerAnimationController::WaitedForLayout); |
+ } |
+} |
+ |
+void LayerTreeHost::animateLayers(base::TimeTicks monotonicTime, base::Time wallClockTime) |
{ |
if (!m_settings.acceleratedAnimationEnabled || m_animationRegistrar->active_animation_controllers().empty()) |
return; |
TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); |
- double monotonicTime = (time - base::TimeTicks()).InSecondsF(); |
+ double monotonicTimeInSeconds = (monotonicTime - base::TimeTicks()).InSecondsF(); |
+ scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEventsVector)); |
AnimationRegistrar::AnimationControllerMap copy = m_animationRegistrar->active_animation_controllers(); |
- for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); iter != copy.end(); ++iter) |
- (*iter).second->animate(monotonicTime, 0); |
+ for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); iter != copy.end(); ++iter) { |
+ if ((*iter).second->hasNonOrphanedObserver()) |
+ (*iter).second->animate(monotonicTimeInSeconds, 0); |
+ else if ((*iter).second->orphanWaitStatus() == LayerAnimationController::WaitedForLayout) |
+ (*iter).second->animate(monotonicTimeInSeconds, events.get()); |
+ } |
+ |
+ if (!events->empty()) |
+ setAnimationEvents(events.Pass(), wallClockTime); |
} |
void LayerTreeHost::setAnimationEventsRecursive(const AnimationEventsVector& events, Layer* layer, base::Time wallClockTime) |