| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 118 |
| 119 typedef CalcDrawPropsInputs<LayerImpl, LayerImplList> CalcDrawPropsImplInputs; | 119 typedef CalcDrawPropsInputs<LayerImpl, LayerImplList> CalcDrawPropsImplInputs; |
| 120 typedef CalcDrawPropsInputsForTesting<LayerImpl, LayerImplList> | 120 typedef CalcDrawPropsInputsForTesting<LayerImpl, LayerImplList> |
| 121 CalcDrawPropsImplInputsForTesting; | 121 CalcDrawPropsImplInputsForTesting; |
| 122 static void CalculateDrawProperties(CalcDrawPropsImplInputs* inputs); | 122 static void CalculateDrawProperties(CalcDrawPropsImplInputs* inputs); |
| 123 | 123 |
| 124 template <typename LayerType> | 124 template <typename LayerType> |
| 125 static bool RenderSurfaceContributesToTarget(LayerType*, | 125 static bool RenderSurfaceContributesToTarget(LayerType*, |
| 126 int target_surface_layer_id); | 126 int target_surface_layer_id); |
| 127 | 127 |
| 128 template <typename LayerType> | 128 template <typename LayerType, typename Function> |
| 129 static void CallFunctionForSubtree( | 129 static void CallFunctionForSubtree(LayerType* layer, |
| 130 LayerType* root_layer, | 130 const Function& function); |
| 131 const base::Callback<void(LayerType* layer)>& function); | |
| 132 | 131 |
| 133 // Returns a layer with the given id if one exists in the subtree starting | 132 // Returns a layer with the given id if one exists in the subtree starting |
| 134 // from the given root layer (including mask and replica layers). | 133 // from the given root layer (including mask and replica layers). |
| 135 template <typename LayerType> | 134 template <typename LayerType> |
| 136 static LayerType* FindLayerInSubtree(LayerType* root_layer, int layer_id); | 135 static LayerType* FindLayerInSubtree(LayerType* root_layer, int layer_id); |
| 137 | 136 |
| 138 static Layer* get_layer_as_raw_ptr(const LayerList& layers, size_t index) { | 137 static Layer* get_layer_as_raw_ptr(const LayerList& layers, size_t index) { |
| 139 return layers[index].get(); | 138 return layers[index].get(); |
| 140 } | 139 } |
| 141 | 140 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 return root_layer->replica_layer(); | 197 return root_layer->replica_layer(); |
| 199 | 198 |
| 200 for (size_t i = 0; i < root_layer->children().size(); ++i) { | 199 for (size_t i = 0; i < root_layer->children().size(); ++i) { |
| 201 if (LayerType* found = FindLayerInSubtree( | 200 if (LayerType* found = FindLayerInSubtree( |
| 202 get_layer_as_raw_ptr(root_layer->children(), i), layer_id)) | 201 get_layer_as_raw_ptr(root_layer->children(), i), layer_id)) |
| 203 return found; | 202 return found; |
| 204 } | 203 } |
| 205 return NULL; | 204 return NULL; |
| 206 } | 205 } |
| 207 | 206 |
| 208 template <typename LayerType> | 207 template <typename LayerType, typename Function> |
| 209 void LayerTreeHostCommon::CallFunctionForSubtree( | 208 void LayerTreeHostCommon::CallFunctionForSubtree(LayerType* layer, |
| 210 LayerType* root_layer, | 209 const Function& function) { |
| 211 const base::Callback<void(LayerType* layer)>& function) { | 210 function(layer); |
| 212 function.Run(root_layer); | |
| 213 | 211 |
| 214 if (LayerType* mask_layer = root_layer->mask_layer()) | 212 if (LayerType* mask_layer = layer->mask_layer()) |
| 215 function.Run(mask_layer); | 213 function(mask_layer); |
| 216 if (LayerType* replica_layer = root_layer->replica_layer()) { | 214 if (LayerType* replica_layer = layer->replica_layer()) { |
| 217 function.Run(replica_layer); | 215 function(replica_layer); |
| 218 if (LayerType* mask_layer = replica_layer->mask_layer()) | 216 if (LayerType* mask_layer = replica_layer->mask_layer()) |
| 219 function.Run(mask_layer); | 217 function(mask_layer); |
| 220 } | 218 } |
| 221 | 219 |
| 222 for (size_t i = 0; i < root_layer->children().size(); ++i) { | 220 for (size_t i = 0; i < layer->children().size(); ++i) { |
| 223 CallFunctionForSubtree(get_layer_as_raw_ptr(root_layer->children(), i), | 221 CallFunctionForSubtree(get_layer_as_raw_ptr(layer->children(), i), |
| 224 function); | 222 function); |
| 225 } | 223 } |
| 226 } | 224 } |
| 227 | 225 |
| 228 template <typename LayerType, typename RenderSurfaceLayerListType> | 226 template <typename LayerType, typename RenderSurfaceLayerListType> |
| 229 LayerTreeHostCommon::CalcDrawPropsInputsForTesting<LayerType, | 227 LayerTreeHostCommon::CalcDrawPropsInputsForTesting<LayerType, |
| 230 RenderSurfaceLayerListType>:: | 228 RenderSurfaceLayerListType>:: |
| 231 CalcDrawPropsInputsForTesting( | 229 CalcDrawPropsInputsForTesting( |
| 232 LayerType* root_layer, | 230 LayerType* root_layer, |
| 233 const gfx::Size& device_viewport_size, | 231 const gfx::Size& device_viewport_size, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 true, | 276 true, |
| 279 render_surface_layer_list, | 277 render_surface_layer_list, |
| 280 0) { | 278 0) { |
| 281 DCHECK(root_layer); | 279 DCHECK(root_layer); |
| 282 DCHECK(render_surface_layer_list); | 280 DCHECK(render_surface_layer_list); |
| 283 } | 281 } |
| 284 | 282 |
| 285 } // namespace cc | 283 } // namespace cc |
| 286 | 284 |
| 287 #endif // CC_TREES_LAYER_TREE_HOST_COMMON_H_ | 285 #endif // CC_TREES_LAYER_TREE_HOST_COMMON_H_ |
| OLD | NEW |