Index: cc/layer_tree_host_impl.cc |
diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc |
index 26e1b3dc40d961978c4b35d5e5ca05b6d6750c94..62410c5fd425f31ba3739b6b0e5ade08a046e36b 100644 |
--- a/cc/layer_tree_host_impl.cc |
+++ b/cc/layer_tree_host_impl.cc |
@@ -8,6 +8,7 @@ |
#include "base/basictypes.h" |
#include "base/debug/trace_event.h" |
+#include "cc/animation_registrar.h" |
#include "cc/append_quads_data.h" |
#include "cc/damage_tracker.h" |
#include "cc/debug_rect_history.h" |
@@ -220,7 +221,6 @@ LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre |
PriorityCalculator::allowNothingCutoff()) |
, m_backgroundColor(0) |
, m_hasTransparentBackground(false) |
- , m_needsAnimateLayers(false) |
, m_pinchGestureActive(false) |
, m_fpsCounter(FrameRateCounter::create(m_proxy->hasImplThread())) |
, m_debugRectHistory(DebugRectHistory::create()) |
@@ -237,8 +237,10 @@ LayerTreeHostImpl::~LayerTreeHostImpl() |
DCHECK(m_proxy->isImplThread()); |
TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); |
- if (m_rootLayerImpl) |
+ if (m_rootLayerImpl) { |
clearRenderSurfaces(); |
+ m_rootLayerImpl.release(); |
+ } |
} |
void LayerTreeHostImpl::beginCommit() |
@@ -585,35 +587,6 @@ bool LayerTreeHostImpl::calculateRenderPasses(FrameData& frame) |
return drawFrame; |
} |
-void LayerTreeHostImpl::animateLayersRecursive(LayerImpl* current, base::TimeTicks monotonicTime, base::Time wallClockTime, AnimationEventsVector* events, bool& didAnimate, bool& needsAnimateLayers) |
-{ |
- bool subtreeNeedsAnimateLayers = false; |
- |
- LayerAnimationController* currentController = current->layerAnimationController(); |
- |
- bool hadActiveAnimation = currentController->hasActiveAnimation(); |
- double monotonicTimeSeconds = (monotonicTime - base::TimeTicks()).InSecondsF(); |
- currentController->animate(monotonicTimeSeconds, events); |
- bool startedAnimation = events->size() > 0; |
- |
- // We animated if we either ticked a running animation, or started a new animation. |
- if (hadActiveAnimation || startedAnimation) |
- didAnimate = true; |
- |
- // If the current controller still has an active animation, we must continue animating layers. |
- if (currentController->hasActiveAnimation()) |
- subtreeNeedsAnimateLayers = true; |
- |
- for (size_t i = 0; i < current->children().size(); ++i) { |
- bool childNeedsAnimateLayers = false; |
- animateLayersRecursive(current->children()[i], monotonicTime, wallClockTime, events, didAnimate, childNeedsAnimateLayers); |
- if (childNeedsAnimateLayers) |
- subtreeNeedsAnimateLayers = true; |
- } |
- |
- needsAnimateLayers = subtreeNeedsAnimateLayers; |
-} |
- |
void LayerTreeHostImpl::setBackgroundTickingEnabled(bool enabled) |
{ |
// Lazily create the timeSource adapter so that we can vary the interval for testing. |
@@ -980,7 +953,7 @@ void LayerTreeHostImpl::setVisible(bool visible) |
m_renderer->setVisible(visible); |
- setBackgroundTickingEnabled(!m_visible && m_needsAnimateLayers); |
+ setBackgroundTickingEnabled(!m_visible && !AnimationRegistrar::GetActiveControllers(AnimationRegistrar::CompositorThread).empty()); |
} |
bool LayerTreeHostImpl::initializeRenderer(scoped_ptr<GraphicsContext> context) |
@@ -1146,6 +1119,11 @@ void LayerTreeHostImpl::updateMaxScrollOffset() |
m_rootScrollLayerImpl->setMaxScrollOffset(gfx::ToFlooredVector2d(maxScroll)); |
} |
+bool LayerTreeHostImpl::needsAnimateLayers() const |
+{ |
+ return !AnimationRegistrar::GetActiveControllers(AnimationRegistrar::CompositorThread).empty(); |
+} |
+ |
void LayerTreeHostImpl::setNeedsRedraw() |
{ |
m_client->setNeedsRedrawOnImplThread(); |
@@ -1531,23 +1509,23 @@ void LayerTreeHostImpl::animatePageScale(base::TimeTicks time) |
void LayerTreeHostImpl::animateLayers(base::TimeTicks monotonicTime, base::Time wallClockTime) |
{ |
- if (!m_settings.acceleratedAnimationEnabled || !m_needsAnimateLayers || !m_rootLayerImpl) |
+ if (!m_settings.acceleratedAnimationEnabled || AnimationRegistrar::GetActiveControllers(AnimationRegistrar::CompositorThread).empty() || !m_rootLayerImpl) |
return; |
TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); |
- scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEventsVector)); |
+ double monotonicSeconds = (monotonicTime - base::TimeTicks()).InSecondsF(); |
- bool didAnimate = false; |
- animateLayersRecursive(m_rootLayerImpl.get(), monotonicTime, wallClockTime, events.get(), didAnimate, m_needsAnimateLayers); |
+ scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEventsVector)); |
+ AnimationControllerSet copy = AnimationRegistrar::GetActiveControllers(AnimationRegistrar::CompositorThread); |
+ for (AnimationControllerSet::iterator iter = copy.begin(); iter != copy.end(); ++iter) |
+ (*iter)->animate(monotonicSeconds, events.get()); |
if (!events->empty()) |
m_client->postAnimationEventsToMainThreadOnImplThread(events.Pass(), wallClockTime); |
- if (didAnimate) |
- m_client->setNeedsRedrawOnImplThread(); |
- |
- setBackgroundTickingEnabled(!m_visible && m_needsAnimateLayers); |
+ m_client->setNeedsRedrawOnImplThread(); |
+ setBackgroundTickingEnabled(!m_visible && !AnimationRegistrar::GetActiveControllers(AnimationRegistrar::CompositorThread).empty()); |
} |
base::TimeDelta LayerTreeHostImpl::lowFrequencyAnimationInterval() const |