Index: cc/layer_tree_host_impl.cc |
diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc |
index 2426e01cfdc335e0f63345611f9a2d1923f1c985..c3d6252b6ef1940fe4a574677e49f6a9d2daba54 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 "base/stl_util.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. |
@@ -981,7 +954,7 @@ void LayerTreeHostImpl::setVisible(bool visible) |
m_renderer->setVisible(visible); |
- setBackgroundTickingEnabled(!m_visible && m_needsAnimateLayers); |
+ setBackgroundTickingEnabled(!m_visible && !m_activeAnimationControllers.empty()); |
} |
bool LayerTreeHostImpl::initializeRenderer(scoped_ptr<GraphicsContext> context) |
@@ -1532,23 +1505,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 || m_activeAnimationControllers.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 = m_activeAnimationControllers; |
+ 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 && !m_activeAnimationControllers.empty()); |
} |
base::TimeDelta LayerTreeHostImpl::lowFrequencyAnimationInterval() const |
@@ -1635,4 +1608,14 @@ void LayerTreeHostImpl::animateScrollbarsRecursive(LayerImpl* layer, base::TimeT |
animateScrollbarsRecursive(layer->children()[i], time); |
} |
+ |
+void LayerTreeHostImpl::Register(LayerAnimationController* controller) { |
+ m_activeAnimationControllers.insert(controller); |
+} |
+ |
+void LayerTreeHostImpl::Unregister(LayerAnimationController* controller) { |
+ if (ContainsKey(m_activeAnimationControllers, controller)) |
+ m_activeAnimationControllers.erase(controller); |
+} |
+ |
} // namespace cc |