Chromium Code Reviews| Index: cc/trees/layer_tree_impl.cc |
| diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc |
| index 6806d9cdc85c906ad5ef221f367d690b124ecbff..032bd53e1b18c98e7b9b1f4553ed9dde8bb5f9fe 100644 |
| --- a/cc/trees/layer_tree_impl.cc |
| +++ b/cc/trees/layer_tree_impl.cc |
| @@ -34,6 +34,21 @@ |
| #include "ui/gfx/geometry/vector2d_conversions.h" |
| namespace cc { |
| +namespace { |
| + |
| +template <typename Lambda> |
| +void ProcessLayersRecursive(LayerImpl* current, const Lambda& lambda) { |
| + DCHECK(current); |
| + lambda(current); |
| + if (current->mask_layer()) |
| + ProcessLayersRecursive(current->mask_layer(), lambda); |
| + if (current->replica_layer()) |
| + ProcessLayersRecursive(current->replica_layer(), lambda); |
| + for (size_t i = 0; i < current->children().size(); ++i) |
| + ProcessLayersRecursive(current->children()[i], lambda); |
| +} |
| + |
| +} // namespace |
| // This class exists to split the LayerScrollOffsetDelegate between the |
| // InnerViewportScrollLayer and the OuterViewportScrollLayer in a manner |
| @@ -121,13 +136,32 @@ void LayerTreeImpl::Shutdown() { |
| } |
| void LayerTreeImpl::ReleaseResources() { |
| - if (root_layer_) |
| - ProcessLayersRecursive(root_layer_.get(), &LayerImpl::ReleaseResources); |
| + if (!root_layer_) |
| + return; |
| + |
| + ProcessLayersRecursive(root_layer_.get(), |
| + [](LayerImpl* layer) { layer->ReleaseResources(); }); |
| } |
| void LayerTreeImpl::RecreateResources() { |
| - if (root_layer_) |
| - ProcessLayersRecursive(root_layer_.get(), &LayerImpl::RecreateResources); |
| + if (!root_layer_) |
| + return; |
| + |
| + ProcessLayersRecursive(root_layer_.get(), |
| + [](LayerImpl* layer) { layer->RecreateResources(); }); |
| +} |
| + |
| +void LayerTreeImpl::GatherFrameTimingRequestIds( |
| + std::vector<int64_t>* request_ids) { |
| + if (!root_layer_) |
| + return; |
| + |
| + // TODO(vmpstr): Early out if there are no requests on any of the layers. For |
| + // that, we need to inform LayerTreeImpl whenever there are requests when we |
| + // get them. |
|
vmpstr
2015/02/11 22:42:49
Alternatively, I can store requests ids on layer_t
|
| + ProcessLayersRecursive(root_layer_.get(), [&request_ids](LayerImpl* layer) { |
| + layer->GatherFrameTimingRequestIds(request_ids); |
| + }); |
| } |
| void LayerTreeImpl::SetRootLayer(scoped_ptr<LayerImpl> layer) { |
| @@ -1206,18 +1240,6 @@ const std::vector<LayerImpl*>& LayerTreeImpl::LayersWithCopyOutputRequest() |
| return layers_with_copy_output_request_; |
| } |
| -void LayerTreeImpl::ProcessLayersRecursive(LayerImpl* current, |
| - void (LayerImpl::*function)()) { |
| - DCHECK(current); |
| - (current->*function)(); |
| - if (current->mask_layer()) |
| - ProcessLayersRecursive(current->mask_layer(), function); |
| - if (current->replica_layer()) |
| - ProcessLayersRecursive(current->replica_layer(), function); |
| - for (size_t i = 0; i < current->children().size(); ++i) |
| - ProcessLayersRecursive(current->children()[i], function); |
| -} |
| - |
| template <typename LayerType> |
| static inline bool LayerClipsSubtree(LayerType* layer) { |
| return layer->masks_to_bounds() || layer->mask_layer(); |