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> |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 namespace proto { | 29 namespace proto { |
| 30 class ScrollUpdateInfo; | 30 class ScrollUpdateInfo; |
| 31 class ScrollAndScaleSet; | 31 class ScrollAndScaleSet; |
| 32 } | 32 } |
| 33 | 33 |
| 34 class LayerImpl; | 34 class LayerImpl; |
| 35 class Layer; | 35 class Layer; |
| 36 class SwapPromise; | 36 class SwapPromise; |
| 37 class PropertyTrees; | 37 class PropertyTrees; |
| 38 | 38 |
| 39 enum CallFunctionLayerType : uint32_t { | |
| 40 BASIC_LAYER = 0, | |
| 41 MASK_LAYER = 1, | |
| 42 REPLICA_LAYER = 2, | |
| 43 ALL_LAYERS = MASK_LAYER | REPLICA_LAYER | |
| 44 }; | |
| 45 | |
| 39 class CC_EXPORT LayerTreeHostCommon { | 46 class CC_EXPORT LayerTreeHostCommon { |
| 40 public: | 47 public: |
| 41 static gfx::Rect CalculateVisibleRect(const gfx::Rect& target_surface_rect, | 48 static gfx::Rect CalculateVisibleRect(const gfx::Rect& target_surface_rect, |
| 42 const gfx::Rect& layer_bound_rect, | 49 const gfx::Rect& layer_bound_rect, |
| 43 const gfx::Transform& transform); | 50 const gfx::Transform& transform); |
| 44 | 51 |
| 45 struct CC_EXPORT CalcDrawPropsMainInputsForTesting { | 52 struct CC_EXPORT CalcDrawPropsMainInputsForTesting { |
| 46 public: | 53 public: |
| 47 CalcDrawPropsMainInputsForTesting(Layer* root_layer, | 54 CalcDrawPropsMainInputsForTesting(Layer* root_layer, |
| 48 const gfx::Size& device_viewport_size, | 55 const gfx::Size& device_viewport_size, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 static void CalculateDrawProperties(CalcDrawPropsImplInputs* inputs); | 139 static void CalculateDrawProperties(CalcDrawPropsImplInputs* inputs); |
| 133 static void CalculateDrawProperties( | 140 static void CalculateDrawProperties( |
| 134 CalcDrawPropsImplInputsForTesting* inputs); | 141 CalcDrawPropsImplInputsForTesting* inputs); |
| 135 | 142 |
| 136 template <typename LayerType> | 143 template <typename LayerType> |
| 137 static bool RenderSurfaceContributesToTarget(LayerType*, | 144 static bool RenderSurfaceContributesToTarget(LayerType*, |
| 138 int target_surface_layer_id); | 145 int target_surface_layer_id); |
| 139 | 146 |
| 140 template <typename Function> | 147 template <typename Function> |
| 141 static void CallFunctionForEveryLayer(LayerTreeHost* layer, | 148 static void CallFunctionForEveryLayer(LayerTreeHost* layer, |
| 142 const Function& function); | 149 const Function& function, |
| 150 const CallFunctionLayerType& type); | |
| 143 | 151 |
| 144 template <typename Function> | 152 template <typename Function> |
| 145 static void CallFunctionForEveryLayer(LayerTreeImpl* layer, | 153 static void CallFunctionForEveryLayer(LayerTreeImpl* layer, |
| 146 const Function& function); | 154 const Function& function, |
| 155 const CallFunctionLayerType& type); | |
| 147 | 156 |
| 148 static Layer* get_layer_as_raw_ptr(const LayerList& layers, size_t index) { | 157 static Layer* get_layer_as_raw_ptr(const LayerList& layers, size_t index) { |
| 149 return layers[index].get(); | 158 return layers[index].get(); |
| 150 } | 159 } |
| 151 | 160 |
| 152 static LayerImpl* get_layer_as_raw_ptr(const LayerImplList& layers, | 161 static LayerImpl* get_layer_as_raw_ptr(const LayerImplList& layers, |
| 153 size_t index) { | 162 size_t index) { |
| 154 return layers[index]; | 163 return layers[index]; |
| 155 } | 164 } |
| 156 | 165 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 // surface, and | 205 // surface, and |
| 197 // (2) The layer's render surface is not the same as the target surface. | 206 // (2) The layer's render surface is not the same as the target surface. |
| 198 // | 207 // |
| 199 // Otherwise, the layer just contributes itself to the target surface. | 208 // Otherwise, the layer just contributes itself to the target surface. |
| 200 | 209 |
| 201 return layer->render_target() == layer && | 210 return layer->render_target() == layer && |
| 202 layer->id() != target_surface_layer_id; | 211 layer->id() != target_surface_layer_id; |
| 203 } | 212 } |
| 204 | 213 |
| 205 template <typename LayerType, typename Function> | 214 template <typename LayerType, typename Function> |
| 206 static void CallFunctionForLayer(LayerType* layer, const Function& function) { | 215 static void CallFunctionForLayer(LayerType* layer, |
| 216 const Function& function, | |
| 217 const CallFunctionLayerType& type) { | |
|
Ian Vollick
2016/04/06 19:42:26
This CallFunctionForLayer stuff seems reasonable (
sunxd
2016/04/07 15:37:13
I think we can, but at some time when layer list i
Ian Vollick
2016/04/07 17:20:25
Well, the iterator is meant to be the wrapper that
| |
| 207 function(layer); | 218 function(layer); |
| 208 | 219 |
| 209 if (LayerType* mask_layer = layer->mask_layer()) | 220 LayerType* mask_layer = layer->mask_layer(); |
| 221 if ((type & CallFunctionLayerType::MASK_LAYER) && mask_layer) | |
| 210 function(mask_layer); | 222 function(mask_layer); |
| 211 if (LayerType* replica_layer = layer->replica_layer()) { | 223 LayerType* replica_layer = layer->replica_layer(); |
| 224 if ((type & CallFunctionLayerType::REPLICA_LAYER) && replica_layer) { | |
| 212 function(replica_layer); | 225 function(replica_layer); |
| 213 if (LayerType* mask_layer = replica_layer->mask_layer()) | 226 mask_layer = replica_layer->mask_layer(); |
| 227 if ((type & CallFunctionLayerType::MASK_LAYER) && mask_layer) | |
| 214 function(mask_layer); | 228 function(mask_layer); |
| 215 } | 229 } |
| 216 } | 230 } |
| 217 | 231 |
| 218 template <typename Function> | 232 template <typename Function> |
| 219 static void CallFunctionForEveryLayerInternal(Layer* layer, | 233 static void CallFunctionForEveryLayerInternal( |
| 220 const Function& function) { | 234 Layer* layer, |
| 221 CallFunctionForLayer(layer, function); | 235 const Function& function, |
| 236 const CallFunctionLayerType& type) { | |
| 237 CallFunctionForLayer(layer, function, type); | |
| 222 | 238 |
| 223 for (size_t i = 0; i < layer->children().size(); ++i) { | 239 for (size_t i = 0; i < layer->children().size(); ++i) { |
| 224 CallFunctionForEveryLayerInternal(layer->children()[i].get(), function); | 240 CallFunctionForEveryLayerInternal(layer->children()[i].get(), function, |
| 241 type); | |
| 225 } | 242 } |
| 226 } | 243 } |
| 227 | 244 |
| 228 template <typename Function> | 245 template <typename Function> |
| 229 void LayerTreeHostCommon::CallFunctionForEveryLayer(LayerTreeHost* host, | 246 void LayerTreeHostCommon::CallFunctionForEveryLayer( |
| 230 const Function& function) { | 247 LayerTreeHost* host, |
| 231 CallFunctionForEveryLayerInternal(host->root_layer(), function); | 248 const Function& function, |
| 249 const CallFunctionLayerType& type) { | |
| 250 CallFunctionForEveryLayerInternal(host->root_layer(), function, type); | |
| 232 } | 251 } |
| 233 | 252 |
| 234 template <typename Function> | 253 template <typename Function> |
| 235 void LayerTreeHostCommon::CallFunctionForEveryLayer(LayerTreeImpl* host_impl, | 254 void LayerTreeHostCommon::CallFunctionForEveryLayer( |
| 236 const Function& function) { | 255 LayerTreeImpl* host_impl, |
| 256 const Function& function, | |
| 257 const CallFunctionLayerType& type) { | |
| 237 for (auto* layer : *host_impl) | 258 for (auto* layer : *host_impl) |
| 238 CallFunctionForLayer(layer, function); | 259 CallFunctionForLayer(layer, function, type); |
| 239 } | 260 } |
| 240 | 261 |
| 241 CC_EXPORT PropertyTrees* GetPropertyTrees(Layer* layer); | 262 CC_EXPORT PropertyTrees* GetPropertyTrees(Layer* layer); |
| 242 CC_EXPORT PropertyTrees* GetPropertyTrees(LayerImpl* layer); | 263 CC_EXPORT PropertyTrees* GetPropertyTrees(LayerImpl* layer); |
| 243 | 264 |
| 244 } // namespace cc | 265 } // namespace cc |
| 245 | 266 |
| 246 #endif // CC_TREES_LAYER_TREE_HOST_COMMON_H_ | 267 #endif // CC_TREES_LAYER_TREE_HOST_COMMON_H_ |
| OLD | NEW |