Chromium Code Reviews| Index: cc/trees/layer_tree_host_common.h |
| diff --git a/cc/trees/layer_tree_host_common.h b/cc/trees/layer_tree_host_common.h |
| index 427c74f42e581dbd3662283a2625ba6f29944125..8fc5eb02894d887e5bed7f31da386348de81a07b 100644 |
| --- a/cc/trees/layer_tree_host_common.h |
| +++ b/cc/trees/layer_tree_host_common.h |
| @@ -14,7 +14,10 @@ |
| #include "base/macros.h" |
| #include "base/memory/ref_counted.h" |
| #include "cc/base/cc_export.h" |
| +#include "cc/layers/layer.h" |
| #include "cc/layers/layer_collections.h" |
| +#include "cc/layers/layer_impl.h" |
| +#include "cc/trees/layer_tree_impl.h" |
| #include "cc/trees/property_tree.h" |
| #include "ui/gfx/geometry/rect.h" |
| #include "ui/gfx/geometry/vector2d.h" |
| @@ -132,9 +135,12 @@ class CC_EXPORT LayerTreeHostCommon { |
| static bool RenderSurfaceContributesToTarget(LayerType*, |
| int target_surface_layer_id); |
| - template <typename LayerType, typename Function> |
| - static void CallFunctionForSubtree(LayerType* layer, |
| - const Function& function); |
| + template <typename Function> |
| + static void CallFunctionForEveryLayer(Layer* layer, const Function& function); |
|
ajuma
2016/03/31 23:11:06
Can this take a LayerTreeHost instead? Since this
jaydasika
2016/04/01 01:29:58
Done.
|
| + |
| + template <typename Function> |
| + static void CallFunctionForEveryLayer(LayerImpl* layer, |
|
ajuma
2016/03/31 23:11:06
This should take a LayerTreeImpl instead of a Laye
jaydasika
2016/04/01 01:29:58
Done.
|
| + const Function& function); |
| static Layer* get_layer_as_raw_ptr(const LayerList& layers, size_t index) { |
| return layers[index].get(); |
| @@ -194,8 +200,7 @@ bool LayerTreeHostCommon::RenderSurfaceContributesToTarget( |
| } |
| template <typename LayerType, typename Function> |
| -void LayerTreeHostCommon::CallFunctionForSubtree(LayerType* layer, |
| - const Function& function) { |
| +static void CallFunctionForLayer(LayerType* layer, const Function& function) { |
| function(layer); |
| if (LayerType* mask_layer = layer->mask_layer()) |
| @@ -205,13 +210,26 @@ void LayerTreeHostCommon::CallFunctionForSubtree(LayerType* layer, |
| if (LayerType* mask_layer = replica_layer->mask_layer()) |
| function(mask_layer); |
| } |
| +} |
| + |
| +template <typename Function> |
| +void LayerTreeHostCommon::CallFunctionForEveryLayer(Layer* layer, |
| + const Function& function) { |
| + CallFunctionForLayer(layer, function); |
| for (size_t i = 0; i < layer->children().size(); ++i) { |
| - CallFunctionForSubtree(get_layer_as_raw_ptr(layer->children(), i), |
| - function); |
| + CallFunctionForEveryLayer(get_layer_as_raw_ptr(layer->children(), i), |
| + function); |
| } |
| } |
| +template <typename Function> |
| +void LayerTreeHostCommon::CallFunctionForEveryLayer(LayerImpl* root_layer, |
| + const Function& function) { |
| + for (auto* layer : *root_layer->layer_tree_impl()) |
| + CallFunctionForLayer(layer, function); |
| +} |
| + |
| CC_EXPORT PropertyTrees* GetPropertyTrees(Layer* layer); |
| CC_EXPORT PropertyTrees* GetPropertyTrees(LayerImpl* layer); |