Chromium Code Reviews| 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_impl.h" | |
| 18 #include "cc/trees/property_tree.h" | 21 #include "cc/trees/property_tree.h" |
| 19 #include "ui/gfx/geometry/rect.h" | 22 #include "ui/gfx/geometry/rect.h" |
| 20 #include "ui/gfx/geometry/vector2d.h" | 23 #include "ui/gfx/geometry/vector2d.h" |
| 21 #include "ui/gfx/transform.h" | 24 #include "ui/gfx/transform.h" |
| 22 | 25 |
| 23 namespace cc { | 26 namespace cc { |
| 24 | 27 |
| 25 namespace proto { | 28 namespace proto { |
| 26 class ScrollUpdateInfo; | 29 class ScrollUpdateInfo; |
| 27 class ScrollAndScaleSet; | 30 class ScrollAndScaleSet; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 static void PreCalculateMetaInformationForTesting(Layer* root_layer); | 128 static void PreCalculateMetaInformationForTesting(Layer* root_layer); |
| 126 | 129 |
| 127 static void CalculateDrawProperties(CalcDrawPropsImplInputs* inputs); | 130 static void CalculateDrawProperties(CalcDrawPropsImplInputs* inputs); |
| 128 static void CalculateDrawProperties( | 131 static void CalculateDrawProperties( |
| 129 CalcDrawPropsImplInputsForTesting* inputs); | 132 CalcDrawPropsImplInputsForTesting* inputs); |
| 130 | 133 |
| 131 template <typename LayerType> | 134 template <typename LayerType> |
| 132 static bool RenderSurfaceContributesToTarget(LayerType*, | 135 static bool RenderSurfaceContributesToTarget(LayerType*, |
| 133 int target_surface_layer_id); | 136 int target_surface_layer_id); |
| 134 | 137 |
| 135 template <typename LayerType, typename Function> | 138 template <typename Function> |
| 136 static void CallFunctionForSubtree(LayerType* layer, | 139 static void CallFunctionForEveryLayer(Layer* layer, const Function& function); |
|
ajuma
2016/03/31 23:11:06
Can this take a LayerTreeHost instead? Since this
jaydasika
2016/04/01 01:29:58
Done.
| |
| 137 const Function& function); | 140 |
| 141 template <typename Function> | |
| 142 static void CallFunctionForEveryLayer(LayerImpl* layer, | |
|
ajuma
2016/03/31 23:11:06
This should take a LayerTreeImpl instead of a Laye
jaydasika
2016/04/01 01:29:58
Done.
| |
| 143 const Function& function); | |
| 138 | 144 |
| 139 static Layer* get_layer_as_raw_ptr(const LayerList& layers, size_t index) { | 145 static Layer* get_layer_as_raw_ptr(const LayerList& layers, size_t index) { |
| 140 return layers[index].get(); | 146 return layers[index].get(); |
| 141 } | 147 } |
| 142 | 148 |
| 143 static LayerImpl* get_layer_as_raw_ptr(const LayerImplList& layers, | 149 static LayerImpl* get_layer_as_raw_ptr(const LayerImplList& layers, |
| 144 size_t index) { | 150 size_t index) { |
| 145 return layers[index]; | 151 return layers[index]; |
| 146 } | 152 } |
| 147 | 153 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 // surface, and | 193 // surface, and |
| 188 // (2) The layer's render surface is not the same as the target surface. | 194 // (2) The layer's render surface is not the same as the target surface. |
| 189 // | 195 // |
| 190 // Otherwise, the layer just contributes itself to the target surface. | 196 // Otherwise, the layer just contributes itself to the target surface. |
| 191 | 197 |
| 192 return layer->render_target() == layer && | 198 return layer->render_target() == layer && |
| 193 layer->id() != target_surface_layer_id; | 199 layer->id() != target_surface_layer_id; |
| 194 } | 200 } |
| 195 | 201 |
| 196 template <typename LayerType, typename Function> | 202 template <typename LayerType, typename Function> |
| 197 void LayerTreeHostCommon::CallFunctionForSubtree(LayerType* layer, | 203 static void CallFunctionForLayer(LayerType* layer, const Function& function) { |
| 198 const Function& function) { | |
| 199 function(layer); | 204 function(layer); |
| 200 | 205 |
| 201 if (LayerType* mask_layer = layer->mask_layer()) | 206 if (LayerType* mask_layer = layer->mask_layer()) |
| 202 function(mask_layer); | 207 function(mask_layer); |
| 203 if (LayerType* replica_layer = layer->replica_layer()) { | 208 if (LayerType* replica_layer = layer->replica_layer()) { |
| 204 function(replica_layer); | 209 function(replica_layer); |
| 205 if (LayerType* mask_layer = replica_layer->mask_layer()) | 210 if (LayerType* mask_layer = replica_layer->mask_layer()) |
| 206 function(mask_layer); | 211 function(mask_layer); |
| 207 } | 212 } |
| 213 } | |
| 214 | |
| 215 template <typename Function> | |
| 216 void LayerTreeHostCommon::CallFunctionForEveryLayer(Layer* layer, | |
| 217 const Function& function) { | |
| 218 CallFunctionForLayer(layer, function); | |
| 208 | 219 |
| 209 for (size_t i = 0; i < layer->children().size(); ++i) { | 220 for (size_t i = 0; i < layer->children().size(); ++i) { |
| 210 CallFunctionForSubtree(get_layer_as_raw_ptr(layer->children(), i), | 221 CallFunctionForEveryLayer(get_layer_as_raw_ptr(layer->children(), i), |
| 211 function); | 222 function); |
| 212 } | 223 } |
| 213 } | 224 } |
| 214 | 225 |
| 226 template <typename Function> | |
| 227 void LayerTreeHostCommon::CallFunctionForEveryLayer(LayerImpl* root_layer, | |
| 228 const Function& function) { | |
| 229 for (auto* layer : *root_layer->layer_tree_impl()) | |
| 230 CallFunctionForLayer(layer, function); | |
| 231 } | |
| 232 | |
| 215 CC_EXPORT PropertyTrees* GetPropertyTrees(Layer* layer); | 233 CC_EXPORT PropertyTrees* GetPropertyTrees(Layer* layer); |
| 216 CC_EXPORT PropertyTrees* GetPropertyTrees(LayerImpl* layer); | 234 CC_EXPORT PropertyTrees* GetPropertyTrees(LayerImpl* layer); |
| 217 | 235 |
| 218 } // namespace cc | 236 } // namespace cc |
| 219 | 237 |
| 220 #endif // CC_TREES_LAYER_TREE_HOST_COMMON_H_ | 238 #endif // CC_TREES_LAYER_TREE_HOST_COMMON_H_ |
| OLD | NEW |