OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_LAYERS_LAYER_PROTO_CONVERTER_H_ | 5 #ifndef CC_LAYERS_LAYER_PROTO_CONVERTER_H_ |
6 #define CC_LAYERS_LAYER_PROTO_CONVERTER_H_ | 6 #define CC_LAYERS_LAYER_PROTO_CONVERTER_H_ |
7 | 7 |
8 #include <unordered_map> | 8 #include <unordered_map> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "cc/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
12 #include "cc/layers/layer.h" | 12 #include "cc/layers/layer.h" |
13 | 13 |
14 namespace cc { | 14 namespace cc { |
15 | 15 |
16 namespace proto { | 16 namespace proto { |
17 class LayerNode; | 17 class LayerNode; |
18 class LayerUpdate; | 18 class LayerUpdate; |
19 } | 19 } |
20 | 20 |
21 // A class to faciliate (de)serialization of a Layer tree to protocol buffers. | 21 // A class to faciliate (de)serialization of a Layer tree to protocol buffers. |
22 class CC_EXPORT LayerProtoConverter { | 22 class CC_EXPORT LayerProtoConverter { |
23 public: | 23 public: |
24 // Starting at |root_layer|, serializes the layer hierarchy into the | |
25 // proto::LayerNode. | |
26 static void SerializeLayerHierarchy(const scoped_refptr<Layer> root_layer, | |
27 proto::LayerNode* root_node); | |
28 | |
29 // Recursively iterate over the given LayerNode proto and read the structure | 24 // Recursively iterate over the given LayerNode proto and read the structure |
30 // into a local Layer structure, re-using existing Layers. returns the new | 25 // into a local Layer structure, re-using existing Layers. returns the new |
31 // root Layer after updating the hierarchy (may be the same as | 26 // root Layer after updating the hierarchy (may be the same as |
32 // |existing_root|). |existing_root| may be null, which might happen during | 27 // |existing_root|). |existing_root| may be null, which might happen during |
33 // the first deserialize. | 28 // the first deserialize. |
34 static scoped_refptr<Layer> DeserializeLayerHierarchy( | 29 static scoped_refptr<Layer> DeserializeLayerHierarchy( |
35 const scoped_refptr<Layer> existing_root, | 30 const scoped_refptr<Layer> existing_root, |
36 const proto::LayerNode& root_node, | 31 const proto::LayerNode& root_node, |
37 LayerTreeHost* layer_tree); | 32 LayerTreeHost* layer_tree); |
38 | 33 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 // and special layers to |layer_id_map|. | 67 // and special layers to |layer_id_map|. |
73 // TODO(vmpstr): LayerIdMap ref counts layers, so this function needs to deal | 68 // TODO(vmpstr): LayerIdMap ref counts layers, so this function needs to deal |
74 // with ref counted objects instead of iterating over raw pointers. | 69 // with ref counted objects instead of iterating over raw pointers. |
75 static void RecursivelyFindAllLayers(Layer* root_layer, | 70 static void RecursivelyFindAllLayers(Layer* root_layer, |
76 LayerIdMap* layer_id_map); | 71 LayerIdMap* layer_id_map); |
77 }; | 72 }; |
78 | 73 |
79 } // namespace cc | 74 } // namespace cc |
80 | 75 |
81 #endif // CC_LAYERS_LAYER_PROTO_CONVERTER_H_ | 76 #endif // CC_LAYERS_LAYER_PROTO_CONVERTER_H_ |
OLD | NEW |