| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 template <typename LayerType> | 120 template <typename LayerType> |
| 121 static void CallFunctionForSubtree( | 121 static void CallFunctionForSubtree( |
| 122 LayerType* root_layer, | 122 LayerType* root_layer, |
| 123 const base::Callback<void(LayerType* layer)>& function); | 123 const base::Callback<void(LayerType* layer)>& function); |
| 124 | 124 |
| 125 // Returns a layer with the given id if one exists in the subtree starting | 125 // Returns a layer with the given id if one exists in the subtree starting |
| 126 // from the given root layer (including mask and replica layers). | 126 // from the given root layer (including mask and replica layers). |
| 127 template <typename LayerType> | 127 template <typename LayerType> |
| 128 static LayerType* FindLayerInSubtree(LayerType* root_layer, int layer_id); | 128 static LayerType* FindLayerInSubtree(LayerType* root_layer, int layer_id); |
| 129 | 129 |
| 130 static Layer* get_child_as_raw_ptr( | 130 static Layer* get_layer_as_raw_ptr(const LayerList& layers, size_t index) { |
| 131 const LayerList& children, | 131 return layers[index].get(); |
| 132 size_t index) { | |
| 133 return children[index].get(); | |
| 134 } | 132 } |
| 135 | 133 |
| 136 static LayerImpl* get_child_as_raw_ptr( | 134 static LayerImpl* get_layer_as_raw_ptr(const OwnedLayerImplList& layers, |
| 137 const OwnedLayerImplList& children, | 135 size_t index) { |
| 138 size_t index) { | 136 return layers[index]; |
| 139 return children[index]; | |
| 140 } | 137 } |
| 141 | 138 |
| 142 static LayerImpl* get_child_as_raw_ptr(const LayerImplList& children, | 139 static LayerImpl* get_layer_as_raw_ptr(const LayerImplList& layers, |
| 143 size_t index) { | 140 size_t index) { |
| 144 return children[index]; | 141 return layers[index]; |
| 145 } | 142 } |
| 146 | 143 |
| 147 struct ScrollUpdateInfo { | 144 struct ScrollUpdateInfo { |
| 148 int layer_id; | 145 int layer_id; |
| 149 gfx::Vector2d scroll_delta; | 146 gfx::Vector2d scroll_delta; |
| 150 }; | 147 }; |
| 151 }; | 148 }; |
| 152 | 149 |
| 153 struct CC_EXPORT ScrollAndScaleSet { | 150 struct CC_EXPORT ScrollAndScaleSet { |
| 154 ScrollAndScaleSet(); | 151 ScrollAndScaleSet(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 184 | 181 |
| 185 if (root_layer->mask_layer() && root_layer->mask_layer()->id() == layer_id) | 182 if (root_layer->mask_layer() && root_layer->mask_layer()->id() == layer_id) |
| 186 return root_layer->mask_layer(); | 183 return root_layer->mask_layer(); |
| 187 | 184 |
| 188 if (root_layer->replica_layer() && | 185 if (root_layer->replica_layer() && |
| 189 root_layer->replica_layer()->id() == layer_id) | 186 root_layer->replica_layer()->id() == layer_id) |
| 190 return root_layer->replica_layer(); | 187 return root_layer->replica_layer(); |
| 191 | 188 |
| 192 for (size_t i = 0; i < root_layer->children().size(); ++i) { | 189 for (size_t i = 0; i < root_layer->children().size(); ++i) { |
| 193 if (LayerType* found = FindLayerInSubtree( | 190 if (LayerType* found = FindLayerInSubtree( |
| 194 get_child_as_raw_ptr(root_layer->children(), i), layer_id)) | 191 get_layer_as_raw_ptr(root_layer->children(), i), layer_id)) |
| 195 return found; | 192 return found; |
| 196 } | 193 } |
| 197 return NULL; | 194 return NULL; |
| 198 } | 195 } |
| 199 | 196 |
| 200 template <typename LayerType> | 197 template <typename LayerType> |
| 201 void LayerTreeHostCommon::CallFunctionForSubtree( | 198 void LayerTreeHostCommon::CallFunctionForSubtree( |
| 202 LayerType* root_layer, | 199 LayerType* root_layer, |
| 203 const base::Callback<void(LayerType* layer)>& function) { | 200 const base::Callback<void(LayerType* layer)>& function) { |
| 204 function.Run(root_layer); | 201 function.Run(root_layer); |
| 205 | 202 |
| 206 if (LayerType* mask_layer = root_layer->mask_layer()) | 203 if (LayerType* mask_layer = root_layer->mask_layer()) |
| 207 function.Run(mask_layer); | 204 function.Run(mask_layer); |
| 208 if (LayerType* replica_layer = root_layer->replica_layer()) { | 205 if (LayerType* replica_layer = root_layer->replica_layer()) { |
| 209 function.Run(replica_layer); | 206 function.Run(replica_layer); |
| 210 if (LayerType* mask_layer = replica_layer->mask_layer()) | 207 if (LayerType* mask_layer = replica_layer->mask_layer()) |
| 211 function.Run(mask_layer); | 208 function.Run(mask_layer); |
| 212 } | 209 } |
| 213 | 210 |
| 214 for (size_t i = 0; i < root_layer->children().size(); ++i) { | 211 for (size_t i = 0; i < root_layer->children().size(); ++i) { |
| 215 CallFunctionForSubtree(get_child_as_raw_ptr(root_layer->children(), i), | 212 CallFunctionForSubtree(get_layer_as_raw_ptr(root_layer->children(), i), |
| 216 function); | 213 function); |
| 217 } | 214 } |
| 218 } | 215 } |
| 219 | 216 |
| 220 template <typename LayerType, typename RenderSurfaceLayerListType> | 217 template <typename LayerType, typename RenderSurfaceLayerListType> |
| 221 LayerTreeHostCommon::CalcDrawPropsInputsForTesting<LayerType, | 218 LayerTreeHostCommon::CalcDrawPropsInputsForTesting<LayerType, |
| 222 RenderSurfaceLayerListType>:: | 219 RenderSurfaceLayerListType>:: |
| 223 CalcDrawPropsInputsForTesting( | 220 CalcDrawPropsInputsForTesting( |
| 224 LayerType* root_layer, | 221 LayerType* root_layer, |
| 225 const gfx::Size& device_viewport_size, | 222 const gfx::Size& device_viewport_size, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 true, | 257 true, |
| 261 false, | 258 false, |
| 262 render_surface_layer_list) { | 259 render_surface_layer_list) { |
| 263 DCHECK(root_layer); | 260 DCHECK(root_layer); |
| 264 DCHECK(render_surface_layer_list); | 261 DCHECK(render_surface_layer_list); |
| 265 } | 262 } |
| 266 | 263 |
| 267 } // namespace cc | 264 } // namespace cc |
| 268 | 265 |
| 269 #endif // CC_TREES_LAYER_TREE_HOST_COMMON_H_ | 266 #endif // CC_TREES_LAYER_TREE_HOST_COMMON_H_ |
| OLD | NEW |