Chromium Code Reviews| Index: cc/layers/layer_proto_converter.h |
| diff --git a/cc/layers/layer_proto_converter.h b/cc/layers/layer_proto_converter.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7f8352c7b4039ceb087605b7363dfe1bcccccd28 |
| --- /dev/null |
| +++ b/cc/layers/layer_proto_converter.h |
| @@ -0,0 +1,56 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CC_LAYERS_LAYER_PROTO_CONVERTER_H_ |
| +#define CC_LAYERS_LAYER_PROTO_CONVERTER_H_ |
| + |
| +#include "base/macros.h" |
| +#include "cc/base/cc_export.h" |
| +#include "cc/layers/layer.h" |
| + |
| +namespace cc { |
| + |
| +namespace proto { |
| +class LayerNode; |
| +} |
| + |
| +// A class to faciliate (de)serialization of a Layer tree to protocol buffers. |
| +class CC_EXPORT LayerProtoConverter { |
| + public: |
| + // Starting at |root_layer|, serializes the layer hierarchy into the |
| + // proto::LayerNode. |
| + static void SerializeLayerHierarchy(const scoped_refptr<Layer> root_layer, |
| + proto::LayerNode* root_node); |
| + |
| + // Recursively iterate over the given LayerNode proto and read the structure |
| + // into a local Layer structure, re-using existing Layers. returns the new |
| + // root Layer after updating the hierarchy (may be the same as |
| + // |existing_root|). |
| + static scoped_refptr<Layer> DeserializeLayerHierarchy( |
| + scoped_refptr<Layer> existing_root, |
| + const proto::LayerNode& root_node); |
| + |
| + // Returns the Layer with proto.id() as the Layer id, if it exists in |
| + // |layer_id_map|. Otherwise, a new Layer is constructed of the type given |
| + // from proto.type(). |
| + static scoped_refptr<Layer> FindOrAllocateAndConstruct( |
| + const proto::LayerNode& proto, |
| + const Layer::LayerIdMap& layer_id_map); |
| + |
| + private: |
| + LayerProtoConverter(); |
| + virtual ~LayerProtoConverter(); |
|
vmpstr
2015/10/23 21:26:10
Doesn't need to be virtual.
nyquist
2015/10/26 03:14:29
Done.
|
| + |
| + typedef base::hash_map<int, scoped_refptr<Layer>> LayerIdMap; |
|
vmpstr
2015/10/23 21:26:10
new code should be doing this:
using LayerIdMap =
nyquist
2015/10/26 03:14:29
Done.
|
| + // Start at |layer| and recursively add |layer| and all its children and |
| + // special layers to |layer_id_map|. |
| + static void RecursivelyFindAllLayers(const scoped_refptr<Layer>& layer, |
| + LayerIdMap* layer_id_map); |
| + |
| + DISALLOW_COPY_AND_ASSIGN(LayerProtoConverter); |
|
vmpstr
2015/10/23 21:26:10
I don't think you need this if the constructor is
nyquist
2015/10/26 03:14:29
Done.
|
| +}; |
| + |
| +} // namespace cc |
| + |
| +#endif // CC_LAYERS_LAYER_PROTO_CONVERTER_H_ |