Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Side by Side Diff: cc/layers/layer_proto_converter.h

Issue 1398443008: Add support for (de)serializing cc::Layer hierarchy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@review-1394353002
Patch Set: Moved functionality outside of Layer to LayerProtoConverter. Updated test-comments to be multiline. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CC_LAYERS_LAYER_PROTO_CONVERTER_H_
6 #define CC_LAYERS_LAYER_PROTO_CONVERTER_H_
7
8 #include "base/macros.h"
9 #include "cc/base/cc_export.h"
10 #include "cc/layers/layer.h"
11
12 namespace cc {
13
14 namespace proto {
15 class LayerNode;
16 }
17
18 // A class to faciliate (de)serialization of a Layer tree to protocol buffers.
19 class CC_EXPORT LayerProtoConverter {
20 public:
21 // Starting at |root_layer|, serializes the layer hierarchy into the
22 // proto::LayerNode.
23 static void SerializeLayerHierarchy(const scoped_refptr<Layer> root_layer,
24 proto::LayerNode* root_node);
25
26 // Recursively iterate over the given LayerNode proto and read the structure
27 // into a local Layer structure, re-using existing Layers. returns the new
28 // root Layer after updating the hierarchy (may be the same as
29 // |existing_root|).
30 static scoped_refptr<Layer> DeserializeLayerHierarchy(
31 scoped_refptr<Layer> existing_root,
32 const proto::LayerNode& root_node);
33
34 // Returns the Layer with proto.id() as the Layer id, if it exists in
35 // |layer_id_map|. Otherwise, a new Layer is constructed of the type given
36 // from proto.type().
37 static scoped_refptr<Layer> FindOrAllocateAndConstruct(
38 const proto::LayerNode& proto,
39 const Layer::LayerIdMap& layer_id_map);
40
41 private:
42 LayerProtoConverter();
43 virtual ~LayerProtoConverter();
vmpstr 2015/10/23 21:26:10 Doesn't need to be virtual.
nyquist 2015/10/26 03:14:29 Done.
44
45 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.
46 // Start at |layer| and recursively add |layer| and all its children and
47 // special layers to |layer_id_map|.
48 static void RecursivelyFindAllLayers(const scoped_refptr<Layer>& layer,
49 LayerIdMap* layer_id_map);
50
51 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.
52 };
53
54 } // namespace cc
55
56 #endif // CC_LAYERS_LAYER_PROTO_CONVERTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698