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

Side by Side Diff: cc/trees/layer_tree_host_common.h

Issue 15959012: cc: Make all layer recursion use CallFunctionForSubtree (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DidBeginTracing changes Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_TREES_LAYER_TREE_HOST_COMMON_H_ 5 #ifndef CC_TREES_LAYER_TREE_HOST_COMMON_H_
6 #define CC_TREES_LAYER_TREE_HOST_COMMON_H_ 6 #define CC_TREES_LAYER_TREE_HOST_COMMON_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 const LayerImplList& render_surface_layer_list); 57 const LayerImplList& render_surface_layer_list);
58 58
59 static bool LayerHasTouchEventHandlersAt(gfx::PointF screen_space_point, 59 static bool LayerHasTouchEventHandlersAt(gfx::PointF screen_space_point,
60 LayerImpl* layer_impl); 60 LayerImpl* layer_impl);
61 61
62 template <typename LayerType> 62 template <typename LayerType>
63 static bool RenderSurfaceContributesToTarget(LayerType*, 63 static bool RenderSurfaceContributesToTarget(LayerType*,
64 int target_surface_layer_id); 64 int target_surface_layer_id);
65 65
66 template <class Function, typename LayerType> 66 template <class Function, typename LayerType>
67 static void CallFunctionForSubtree(LayerType* root_layer); 67 static void CallFunctionForSubtree(Function function, LayerType* root_layer);
68 68
69 // Returns a layer with the given id if one exists in the subtree starting 69 // Returns a layer with the given id if one exists in the subtree starting
70 // from the given root layer (including mask and replica layers). 70 // from the given root layer (including mask and replica layers).
71 template <typename LayerType> 71 template <typename LayerType>
72 static LayerType* FindLayerInSubtree(LayerType* root_layer, int layer_id); 72 static LayerType* FindLayerInSubtree(LayerType* root_layer, int layer_id);
73 73
74 static Layer* get_child_as_raw_ptr( 74 static Layer* get_child_as_raw_ptr(
75 const LayerList& children, 75 const LayerList& children,
76 size_t index) { 76 size_t index) {
77 return children[index].get(); 77 return children[index].get();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 return root_layer->replica_layer(); 126 return root_layer->replica_layer();
127 127
128 for (size_t i = 0; i < root_layer->children().size(); ++i) { 128 for (size_t i = 0; i < root_layer->children().size(); ++i) {
129 if (LayerType* found = FindLayerInSubtree( 129 if (LayerType* found = FindLayerInSubtree(
130 get_child_as_raw_ptr(root_layer->children(), i), layer_id)) 130 get_child_as_raw_ptr(root_layer->children(), i), layer_id))
131 return found; 131 return found;
132 } 132 }
133 return NULL; 133 return NULL;
134 } 134 }
135 135
136 template <class Function, typename LayerType> 136 template <typename Function, typename LayerType>
137 void LayerTreeHostCommon::CallFunctionForSubtree(LayerType* root_layer) { 137 void LayerTreeHostCommon::CallFunctionForSubtree(Function function,
138 Function()(root_layer); 138 LayerType* root_layer) {
139 function(root_layer);
139 140
140 if (LayerType* mask_layer = root_layer->mask_layer()) 141 if (LayerType* mask_layer = root_layer->mask_layer())
141 Function()(mask_layer); 142 function(mask_layer);
142 if (LayerType* replica_layer = root_layer->replica_layer()) { 143 if (LayerType* replica_layer = root_layer->replica_layer()) {
143 Function()(replica_layer); 144 function(replica_layer);
144 if (LayerType* mask_layer = replica_layer->mask_layer()) 145 if (LayerType* mask_layer = replica_layer->mask_layer())
145 Function()(mask_layer); 146 function(mask_layer);
146 } 147 }
147 148
148 for (size_t i = 0; i < root_layer->children().size(); ++i) { 149 for (size_t i = 0; i < root_layer->children().size(); ++i) {
149 CallFunctionForSubtree<Function>( 150 CallFunctionForSubtree(function,
150 get_child_as_raw_ptr(root_layer->children(), i)); 151 get_child_as_raw_ptr(root_layer->children(), i));
151 } 152 }
152 } 153 }
153 154
154 } // namespace cc 155 } // namespace cc
155 156
156 #endif // CC_TREES_LAYER_TREE_HOST_COMMON_H_ 157 #endif // CC_TREES_LAYER_TREE_HOST_COMMON_H_
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698