| Index: cc/layer_tree_host_impl.cc
|
| diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc
|
| index 236a63a4cfbde6f6f5a1a009c757ed3fee383c5b..3050ec2217a20235b1a2403a9bfbc6a4907281ba 100644
|
| --- a/cc/layer_tree_host_impl.cc
|
| +++ b/cc/layer_tree_host_impl.cc
|
| @@ -9,7 +9,6 @@
|
| #include "base/basictypes.h"
|
| #include "base/debug/trace_event.h"
|
| #include "base/json/json_writer.h"
|
| -#include "base/stl_util.h"
|
| #include "cc/append_quads_data.h"
|
| #include "cc/damage_tracker.h"
|
| #include "cc/debug_rect_history.h"
|
| @@ -219,6 +218,7 @@ 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())
|
| @@ -243,13 +243,8 @@ LayerTreeHostImpl::~LayerTreeHostImpl()
|
| DCHECK(m_proxy->isImplThread());
|
| TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()");
|
|
|
| - if (rootLayer()) {
|
| + if (rootLayer())
|
| clearRenderSurfaces();
|
| - // The layer trees must be destroyed before the layer tree host. We've
|
| - // made a contract with our animation controllers that the registrar
|
| - // will outlive them, and we must make good.
|
| - m_activeTree.reset();
|
| - }
|
| }
|
|
|
| void LayerTreeHostImpl::beginCommit()
|
| @@ -597,6 +592,35 @@ 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.
|
| @@ -953,7 +977,7 @@ void LayerTreeHostImpl::setVisible(bool visible)
|
|
|
| m_renderer->setVisible(visible);
|
|
|
| - setBackgroundTickingEnabled(!m_visible && !m_activeAnimationControllers.empty());
|
| + setBackgroundTickingEnabled(!m_visible && m_needsAnimateLayers);
|
| }
|
|
|
| bool LayerTreeHostImpl::initializeRenderer(scoped_ptr<OutputSurface> outputSurface)
|
| @@ -1508,23 +1532,23 @@ void LayerTreeHostImpl::animatePageScale(base::TimeTicks time)
|
|
|
| void LayerTreeHostImpl::animateLayers(base::TimeTicks monotonicTime, base::Time wallClockTime)
|
| {
|
| - if (!m_settings.acceleratedAnimationEnabled || m_activeAnimationControllers.empty() || !rootLayer())
|
| + if (!m_settings.acceleratedAnimationEnabled || !m_needsAnimateLayers || !rootLayer())
|
| return;
|
|
|
| TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers");
|
|
|
| - double monotonicSeconds = (monotonicTime - base::TimeTicks()).InSecondsF();
|
| -
|
| scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEventsVector));
|
| - AnimationControllerSet copy = m_activeAnimationControllers;
|
| - for (AnimationControllerSet::iterator iter = copy.begin(); iter != copy.end(); ++iter)
|
| - (*iter)->animate(monotonicSeconds, events.get());
|
| +
|
| + bool didAnimate = false;
|
| + animateLayersRecursive(rootLayer(), monotonicTime, wallClockTime, events.get(), didAnimate, m_needsAnimateLayers);
|
|
|
| if (!events->empty())
|
| m_client->postAnimationEventsToMainThreadOnImplThread(events.Pass(), wallClockTime);
|
|
|
| - m_client->setNeedsRedrawOnImplThread();
|
| - setBackgroundTickingEnabled(!m_visible && !m_activeAnimationControllers.empty());
|
| + if (didAnimate)
|
| + m_client->setNeedsRedrawOnImplThread();
|
| +
|
| + setBackgroundTickingEnabled(!m_visible && m_needsAnimateLayers);
|
| }
|
|
|
| base::TimeDelta LayerTreeHostImpl::lowFrequencyAnimationInterval() const
|
| @@ -1654,27 +1678,4 @@ void LayerTreeHostImpl::animateScrollbarsRecursive(LayerImpl* layer, base::TimeT
|
| animateScrollbarsRecursive(layer->children()[i], time);
|
| }
|
|
|
| -void LayerTreeHostImpl::DidActivateAnimationController(LayerAnimationController* controller) {
|
| - m_activeAnimationControllers.insert(controller);
|
| -}
|
| -
|
| -void LayerTreeHostImpl::DidDeactivateAnimationController(LayerAnimationController* controller) {
|
| - if (ContainsKey(m_activeAnimationControllers, controller))
|
| - m_activeAnimationControllers.erase(controller);
|
| -}
|
| -
|
| -void LayerTreeHostImpl::RegisterAnimationController(LayerAnimationController* controller) {
|
| -#if !defined(NDEBUG)
|
| - m_allAnimationControllers.insert(controller);
|
| -#endif
|
| -}
|
| -
|
| -void LayerTreeHostImpl::UnregisterAnimationController(LayerAnimationController* controller) {
|
| -#if !defined(NDEBUG)
|
| - if (ContainsKey(m_allAnimationControllers, controller))
|
| - m_allAnimationControllers.erase(controller);
|
| -#endif
|
| - DidDeactivateAnimationController(controller);
|
| -}
|
| -
|
| } // namespace cc
|
|
|