Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3575)

Unified Diff: cc/trees/layer_tree_host_common.h

Issue 1846043002: cc : Make CallFunctionForSubtree on impl use layer iterator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4799a2ad5c81166e26e5b315ac0ab0644634e2c3 100644
--- a/cc/trees/layer_tree_host_common.h
+++ b/cc/trees/layer_tree_host_common.h
@@ -14,7 +14,11 @@
#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_host.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 +136,13 @@ 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(LayerTreeHost* layer,
+ const Function& function);
+
+ template <typename Function>
+ static void CallFunctionForEveryLayer(LayerTreeImpl* layer,
+ const Function& function);
static Layer* get_layer_as_raw_ptr(const LayerList& layers, size_t index) {
return layers[index].get();
@@ -194,8 +202,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 +212,31 @@ void LayerTreeHostCommon::CallFunctionForSubtree(LayerType* layer,
if (LayerType* mask_layer = replica_layer->mask_layer())
function(mask_layer);
}
+}
+
+template <typename Function>
+static void CallFunctionForEveryLayerInternal(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);
+ CallFunctionForEveryLayerInternal(layer->children()[i].get(), function);
}
}
+template <typename Function>
+void LayerTreeHostCommon::CallFunctionForEveryLayer(LayerTreeHost* host,
+ const Function& function) {
+ CallFunctionForEveryLayerInternal(host->root_layer(), function);
+}
+
+template <typename Function>
+void LayerTreeHostCommon::CallFunctionForEveryLayer(LayerTreeImpl* host_impl,
+ const Function& function) {
+ for (auto* layer : *host_impl)
+ CallFunctionForLayer(layer, function);
+}
+
CC_EXPORT PropertyTrees* GetPropertyTrees(Layer* layer);
CC_EXPORT PropertyTrees* GetPropertyTrees(LayerImpl* layer);
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698