| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <limits> | 10 #include <limits> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "cc/base/cc_export.h" | 16 #include "cc/base/cc_export.h" |
| 17 #include "cc/layers/layer.h" |
| 17 #include "cc/layers/layer_collections.h" | 18 #include "cc/layers/layer_collections.h" |
| 19 #include "cc/layers/layer_impl.h" |
| 20 #include "cc/trees/layer_tree_host.h" |
| 21 #include "cc/trees/layer_tree_impl.h" |
| 18 #include "cc/trees/property_tree.h" | 22 #include "cc/trees/property_tree.h" |
| 19 #include "ui/gfx/geometry/rect.h" | 23 #include "ui/gfx/geometry/rect.h" |
| 20 #include "ui/gfx/geometry/vector2d.h" | 24 #include "ui/gfx/geometry/vector2d.h" |
| 21 #include "ui/gfx/transform.h" | 25 #include "ui/gfx/transform.h" |
| 22 | 26 |
| 23 namespace cc { | 27 namespace cc { |
| 24 | 28 |
| 25 namespace proto { | 29 namespace proto { |
| 26 class ScrollUpdateInfo; | 30 class ScrollUpdateInfo; |
| 27 class ScrollAndScaleSet; | 31 class ScrollAndScaleSet; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 static void PreCalculateMetaInformationForTesting(Layer* root_layer); | 129 static void PreCalculateMetaInformationForTesting(Layer* root_layer); |
| 126 | 130 |
| 127 static void CalculateDrawProperties(CalcDrawPropsImplInputs* inputs); | 131 static void CalculateDrawProperties(CalcDrawPropsImplInputs* inputs); |
| 128 static void CalculateDrawProperties( | 132 static void CalculateDrawProperties( |
| 129 CalcDrawPropsImplInputsForTesting* inputs); | 133 CalcDrawPropsImplInputsForTesting* inputs); |
| 130 | 134 |
| 131 template <typename LayerType> | 135 template <typename LayerType> |
| 132 static bool RenderSurfaceContributesToTarget(LayerType*, | 136 static bool RenderSurfaceContributesToTarget(LayerType*, |
| 133 int target_surface_layer_id); | 137 int target_surface_layer_id); |
| 134 | 138 |
| 135 template <typename LayerType, typename Function> | 139 template <typename Function> |
| 136 static void CallFunctionForSubtree(LayerType* layer, | 140 static void CallFunctionForEveryLayer(LayerTreeHost* layer, |
| 137 const Function& function); | 141 const Function& function); |
| 142 |
| 143 template <typename Function> |
| 144 static void CallFunctionForEveryLayer(LayerTreeImpl* layer, |
| 145 const Function& function); |
| 138 | 146 |
| 139 static Layer* get_layer_as_raw_ptr(const LayerList& layers, size_t index) { | 147 static Layer* get_layer_as_raw_ptr(const LayerList& layers, size_t index) { |
| 140 return layers[index].get(); | 148 return layers[index].get(); |
| 141 } | 149 } |
| 142 | 150 |
| 143 static LayerImpl* get_layer_as_raw_ptr(const LayerImplList& layers, | 151 static LayerImpl* get_layer_as_raw_ptr(const LayerImplList& layers, |
| 144 size_t index) { | 152 size_t index) { |
| 145 return layers[index]; | 153 return layers[index]; |
| 146 } | 154 } |
| 147 | 155 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 // surface, and | 195 // surface, and |
| 188 // (2) The layer's render surface is not the same as the target surface. | 196 // (2) The layer's render surface is not the same as the target surface. |
| 189 // | 197 // |
| 190 // Otherwise, the layer just contributes itself to the target surface. | 198 // Otherwise, the layer just contributes itself to the target surface. |
| 191 | 199 |
| 192 return layer->render_target() == layer && | 200 return layer->render_target() == layer && |
| 193 layer->id() != target_surface_layer_id; | 201 layer->id() != target_surface_layer_id; |
| 194 } | 202 } |
| 195 | 203 |
| 196 template <typename LayerType, typename Function> | 204 template <typename LayerType, typename Function> |
| 197 void LayerTreeHostCommon::CallFunctionForSubtree(LayerType* layer, | 205 static void CallFunctionForLayer(LayerType* layer, const Function& function) { |
| 198 const Function& function) { | |
| 199 function(layer); | 206 function(layer); |
| 200 | 207 |
| 201 if (LayerType* mask_layer = layer->mask_layer()) | 208 if (LayerType* mask_layer = layer->mask_layer()) |
| 202 function(mask_layer); | 209 function(mask_layer); |
| 203 if (LayerType* replica_layer = layer->replica_layer()) { | 210 if (LayerType* replica_layer = layer->replica_layer()) { |
| 204 function(replica_layer); | 211 function(replica_layer); |
| 205 if (LayerType* mask_layer = replica_layer->mask_layer()) | 212 if (LayerType* mask_layer = replica_layer->mask_layer()) |
| 206 function(mask_layer); | 213 function(mask_layer); |
| 207 } | 214 } |
| 215 } |
| 216 |
| 217 template <typename Function> |
| 218 static void CallFunctionForEveryLayerInternal(Layer* layer, |
| 219 const Function& function) { |
| 220 CallFunctionForLayer(layer, function); |
| 208 | 221 |
| 209 for (size_t i = 0; i < layer->children().size(); ++i) { | 222 for (size_t i = 0; i < layer->children().size(); ++i) { |
| 210 CallFunctionForSubtree(get_layer_as_raw_ptr(layer->children(), i), | 223 CallFunctionForEveryLayerInternal(layer->children()[i].get(), function); |
| 211 function); | |
| 212 } | 224 } |
| 213 } | 225 } |
| 214 | 226 |
| 227 template <typename Function> |
| 228 void LayerTreeHostCommon::CallFunctionForEveryLayer(LayerTreeHost* host, |
| 229 const Function& function) { |
| 230 CallFunctionForEveryLayerInternal(host->root_layer(), function); |
| 231 } |
| 232 |
| 233 template <typename Function> |
| 234 void LayerTreeHostCommon::CallFunctionForEveryLayer(LayerTreeImpl* host_impl, |
| 235 const Function& function) { |
| 236 for (auto* layer : *host_impl) |
| 237 CallFunctionForLayer(layer, function); |
| 238 } |
| 239 |
| 215 CC_EXPORT PropertyTrees* GetPropertyTrees(Layer* layer); | 240 CC_EXPORT PropertyTrees* GetPropertyTrees(Layer* layer); |
| 216 CC_EXPORT PropertyTrees* GetPropertyTrees(LayerImpl* layer); | 241 CC_EXPORT PropertyTrees* GetPropertyTrees(LayerImpl* layer); |
| 217 | 242 |
| 218 } // namespace cc | 243 } // namespace cc |
| 219 | 244 |
| 220 #endif // CC_TREES_LAYER_TREE_HOST_COMMON_H_ | 245 #endif // CC_TREES_LAYER_TREE_HOST_COMMON_H_ |
| OLD | NEW |