| OLD | NEW |
| 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 <limits> | 8 #include <limits> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 template <typename LayerType> | 111 template <typename LayerType> |
| 112 static void CallFunctionForSubtree( | 112 static void CallFunctionForSubtree( |
| 113 LayerType* root_layer, | 113 LayerType* root_layer, |
| 114 const base::Callback<void(LayerType* layer)>& function); | 114 const base::Callback<void(LayerType* layer)>& function); |
| 115 | 115 |
| 116 // Returns a layer with the given id if one exists in the subtree starting | 116 // Returns a layer with the given id if one exists in the subtree starting |
| 117 // from the given root layer (including mask and replica layers). | 117 // from the given root layer (including mask and replica layers). |
| 118 template <typename LayerType> | 118 template <typename LayerType> |
| 119 static LayerType* FindLayerInSubtree(LayerType* root_layer, int layer_id); | 119 static LayerType* FindLayerInSubtree(LayerType* root_layer, int layer_id); |
| 120 | 120 |
| 121 template <typename LayerType> |
| 122 static LayerType* FindFirstScrollableLayer(LayerType* root_layer); |
| 123 |
| 121 static Layer* get_child_as_raw_ptr( | 124 static Layer* get_child_as_raw_ptr( |
| 122 const LayerList& children, | 125 const LayerList& children, |
| 123 size_t index) { | 126 size_t index) { |
| 124 return children[index].get(); | 127 return children[index].get(); |
| 125 } | 128 } |
| 126 | 129 |
| 127 static LayerImpl* get_child_as_raw_ptr( | 130 static LayerImpl* get_child_as_raw_ptr( |
| 128 const OwnedLayerImplList& children, | 131 const OwnedLayerImplList& children, |
| 129 size_t index) { | 132 size_t index) { |
| 130 return children[index]; | 133 return children[index]; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 180 |
| 178 for (size_t i = 0; i < root_layer->children().size(); ++i) { | 181 for (size_t i = 0; i < root_layer->children().size(); ++i) { |
| 179 if (LayerType* found = FindLayerInSubtree( | 182 if (LayerType* found = FindLayerInSubtree( |
| 180 get_child_as_raw_ptr(root_layer->children(), i), layer_id)) | 183 get_child_as_raw_ptr(root_layer->children(), i), layer_id)) |
| 181 return found; | 184 return found; |
| 182 } | 185 } |
| 183 return NULL; | 186 return NULL; |
| 184 } | 187 } |
| 185 | 188 |
| 186 template <typename LayerType> | 189 template <typename LayerType> |
| 190 LayerType* LayerTreeHostCommon::FindFirstScrollableLayer(LayerType* layer) { |
| 191 if (!layer) |
| 192 return NULL; |
| 193 |
| 194 if (layer->scrollable()) |
| 195 return layer; |
| 196 |
| 197 for (size_t i = 0; i < layer->children().size(); ++i) { |
| 198 LayerType* current = get_child_as_raw_ptr(layer->children(), i); |
| 199 LayerType* found = FindFirstScrollableLayer(current); |
| 200 if (found) |
| 201 return found; |
| 202 } |
| 203 |
| 204 return NULL; |
| 205 } |
| 206 |
| 207 template <typename LayerType> |
| 187 void LayerTreeHostCommon::CallFunctionForSubtree( | 208 void LayerTreeHostCommon::CallFunctionForSubtree( |
| 188 LayerType* root_layer, | 209 LayerType* root_layer, |
| 189 const base::Callback<void(LayerType* layer)>& function) { | 210 const base::Callback<void(LayerType* layer)>& function) { |
| 190 function.Run(root_layer); | 211 function.Run(root_layer); |
| 191 | 212 |
| 192 if (LayerType* mask_layer = root_layer->mask_layer()) | 213 if (LayerType* mask_layer = root_layer->mask_layer()) |
| 193 function.Run(mask_layer); | 214 function.Run(mask_layer); |
| 194 if (LayerType* replica_layer = root_layer->replica_layer()) { | 215 if (LayerType* replica_layer = root_layer->replica_layer()) { |
| 195 function.Run(replica_layer); | 216 function.Run(replica_layer); |
| 196 if (LayerType* mask_layer = replica_layer->mask_layer()) | 217 if (LayerType* mask_layer = replica_layer->mask_layer()) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 false, | 265 false, |
| 245 false, | 266 false, |
| 246 render_surface_layer_list) { | 267 render_surface_layer_list) { |
| 247 DCHECK(root_layer); | 268 DCHECK(root_layer); |
| 248 DCHECK(render_surface_layer_list); | 269 DCHECK(render_surface_layer_list); |
| 249 } | 270 } |
| 250 | 271 |
| 251 } // namespace cc | 272 } // namespace cc |
| 252 | 273 |
| 253 #endif // CC_TREES_LAYER_TREE_HOST_COMMON_H_ | 274 #endif // CC_TREES_LAYER_TREE_HOST_COMMON_H_ |
| OLD | NEW |