summaryrefslogtreecommitdiffstats
path: root/cc/trees/layer_tree_host_impl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'cc/trees/layer_tree_host_impl.cc')
-rw-r--r--cc/trees/layer_tree_host_impl.cc55
1 files changed, 30 insertions, 25 deletions
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 5d84fcd..2b8d453 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -1109,9 +1109,12 @@ bool LayerTreeHostImpl::AllowPartialSwap() const {
return !debug_state_.ShowHudRects();
}
-void DidBeginTracing(LayerImpl* layer) {
- layer->DidBeginTracing();
-}
+class DidBeginTracingFunctor {
+ public:
+ void operator()(LayerImpl* layer) {
+ layer->DidBeginTracing();
+ }
+};
void LayerTreeHostImpl::DrawLayers(FrameData* frame,
base::TimeTicks frame_begin_time) {
@@ -1153,12 +1156,13 @@ void LayerTreeHostImpl::DrawLayers(FrameData* frame,
bool is_new_trace;
TRACE_EVENT_IS_NEW_TRACE(&is_new_trace);
if (is_new_trace) {
- if (pending_tree_) {
- LayerTreeHostCommon::CallFunctionForSubtree(DidBeginTracing,
- pending_tree_->root_layer());
- }
- LayerTreeHostCommon::CallFunctionForSubtree(DidBeginTracing,
- active_tree_->root_layer());
+ if (pending_tree_)
+ LayerTreeHostCommon::CallFunctionForSubtree<
+ DidBeginTracingFunctor, LayerImpl>(
+ pending_tree_->root_layer());
+ LayerTreeHostCommon::CallFunctionForSubtree<
+ DidBeginTracingFunctor, LayerImpl>(
+ active_tree_->root_layer());
}
TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
@@ -1425,10 +1429,6 @@ ManagedMemoryPolicy LayerTreeHostImpl::ActualManagedMemoryPolicy() const {
return actual;
}
-static void LostOutputSurface(LayerImpl* layer) {
- layer->DidLoseOutputSurface();
-}
-
bool LayerTreeHostImpl::InitializeRenderer(
scoped_ptr<OutputSurface> output_surface) {
// Since we will create a new resource provider, we cannot continue to use
@@ -1436,18 +1436,12 @@ bool LayerTreeHostImpl::InitializeRenderer(
// before we destroy the old resource provider.
if (active_tree_->root_layer())
ClearRenderSurfaces();
- if (active_tree_->root_layer()) {
- LayerTreeHostCommon::CallFunctionForSubtree(LostOutputSurface,
- active_tree_->root_layer());
- }
- if (pending_tree_ && pending_tree_->root_layer()) {
- LayerTreeHostCommon::CallFunctionForSubtree(LostOutputSurface,
- pending_tree_->root_layer());
- }
- if (recycle_tree_ && recycle_tree_->root_layer()) {
- LayerTreeHostCommon::CallFunctionForSubtree(LostOutputSurface,
- recycle_tree_->root_layer());
- }
+ if (active_tree_->root_layer())
+ SendDidLoseOutputSurfaceRecursive(active_tree_->root_layer());
+ if (pending_tree_ && pending_tree_->root_layer())
+ SendDidLoseOutputSurfaceRecursive(pending_tree_->root_layer());
+ if (recycle_tree_ && recycle_tree_->root_layer())
+ SendDidLoseOutputSurfaceRecursive(recycle_tree_->root_layer());
if (resource_provider_)
resource_provider_->DidLoseOutputSurface();
@@ -2077,6 +2071,17 @@ base::TimeDelta LayerTreeHostImpl::LowFrequencyAnimationInterval() const {
return base::TimeDelta::FromSeconds(1);
}
+void LayerTreeHostImpl::SendDidLoseOutputSurfaceRecursive(LayerImpl* current) {
+ DCHECK(current);
+ current->DidLoseOutputSurface();
+ if (current->mask_layer())
+ SendDidLoseOutputSurfaceRecursive(current->mask_layer());
+ if (current->replica_layer())
+ SendDidLoseOutputSurfaceRecursive(current->replica_layer());
+ for (size_t i = 0; i < current->children().size(); ++i)
+ SendDidLoseOutputSurfaceRecursive(current->children()[i]);
+}
+
void LayerTreeHostImpl::ClearRenderSurfaces() {
active_tree_->ClearRenderSurfaces();
if (pending_tree_)