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 #include "cc/layers/layer_proto_converter.h" | 5 #include "cc/layers/layer_proto_converter.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
9 #include "cc/layers/empty_content_layer_client.h" | 9 #include "cc/layers/empty_content_layer_client.h" |
10 #include "cc/layers/heads_up_display_layer.h" | 10 #include "cc/layers/heads_up_display_layer.h" |
11 #include "cc/layers/layer.h" | 11 #include "cc/layers/layer.h" |
12 #include "cc/layers/picture_layer.h" | 12 #include "cc/layers/picture_layer.h" |
13 #include "cc/layers/solid_color_scrollbar_layer.h" | 13 #include "cc/layers/solid_color_scrollbar_layer.h" |
14 #include "cc/proto/layer.pb.h" | 14 #include "cc/proto/layer.pb.h" |
15 #include "cc/trees/layer_tree_host.h" | 15 #include "cc/trees/layer_tree_host.h" |
16 #include "cc/trees/layer_tree_host_common.h" | 16 #include "cc/trees/layer_tree_host_common.h" |
17 #include "cc/trees/layer_tree_settings.h" | 17 #include "cc/trees/layer_tree_settings.h" |
18 | 18 |
19 namespace cc { | 19 namespace cc { |
20 | 20 |
21 LayerProtoConverter::LayerProtoConverter() {} | 21 LayerProtoConverter::LayerProtoConverter() {} |
22 | 22 |
23 LayerProtoConverter::~LayerProtoConverter() {} | 23 LayerProtoConverter::~LayerProtoConverter() {} |
24 | 24 |
25 // static | 25 // static |
26 void LayerProtoConverter::SerializeLayerHierarchy( | |
27 const scoped_refptr<Layer> root_layer, | |
28 proto::LayerNode* root_node) { | |
29 TRACE_EVENT0("cc.remote", "LayerProtoConverter::SerializeLayerHierarchy"); | |
30 root_layer->ToLayerNodeProto(root_node); | |
31 } | |
32 | |
33 // static | |
34 scoped_refptr<Layer> LayerProtoConverter::DeserializeLayerHierarchy( | 26 scoped_refptr<Layer> LayerProtoConverter::DeserializeLayerHierarchy( |
35 scoped_refptr<Layer> existing_root, | 27 scoped_refptr<Layer> existing_root, |
36 const proto::LayerNode& root_node, | 28 const proto::LayerNode& root_node, |
37 LayerTreeHost* layer_tree_host) { | 29 LayerTreeHost* layer_tree_host) { |
38 LayerIdMap layer_id_map; | 30 LayerIdMap layer_id_map; |
39 if (existing_root) { | 31 if (existing_root) { |
40 existing_root->ClearLayerTreePropertiesForDeserializationAndAddToMap( | 32 existing_root->ClearLayerTreePropertiesForDeserializationAndAddToMap( |
41 &layer_id_map); | 33 &layer_id_map); |
42 } | 34 } |
43 | 35 |
44 scoped_refptr<Layer> new_root = existing_root; | 36 scoped_refptr<Layer> new_root = existing_root; |
45 if (!existing_root || | 37 if (!existing_root || |
46 (root_node.has_id() && root_node.id() != existing_root->id())) { | 38 (root_node.has_id() && root_node.id() != existing_root->id())) { |
47 // The root node has changed or there was no root node, | 39 // The root node has changed or there was no root node, |
48 // so find or create the new root. | 40 // so find or create the new root. |
49 new_root = FindOrAllocateAndConstruct(root_node, layer_id_map); | 41 new_root = FindOrAllocateAndConstruct(root_node, layer_id_map); |
50 } | 42 } |
51 new_root->FromLayerNodeProto(root_node, layer_id_map, layer_tree_host); | 43 new_root->FromLayerNodeProto(root_node, layer_id_map, layer_tree_host); |
52 return new_root; | 44 return new_root; |
53 } | 45 } |
54 | 46 |
55 // static | 47 // static |
56 void LayerProtoConverter::SerializeLayerProperties( | 48 void LayerProtoConverter::SerializeLayerProperties( |
57 LayerTreeHost* host, | 49 LayerTreeHost* host, |
58 proto::LayerUpdate* layer_update) { | 50 proto::LayerUpdate* layer_update) { |
59 TRACE_EVENT0("cc.remote", "LayerProtoConverter::SerializeLayerProperties"); | 51 TRACE_EVENT0("cc.remote", "LayerProtoConverter::SerializeLayerProperties"); |
60 for (auto* layer : host->GetLayerTree()->LayersThatShouldPushProperties()) | 52 for (auto* layer : host->GetLayerTree()->LayersThatShouldPushProperties()) |
61 layer->ToLayerPropertiesProto(layer_update); | 53 layer->ToLayerPropertiesProto(layer_update, false); |
ajuma
2016/10/04 15:45:10
Please create a variable for the bool argument.
Khushal
2016/10/04 18:34:47
Done.
| |
62 host->GetLayerTree()->LayersThatShouldPushProperties().clear(); | 54 host->GetLayerTree()->LayersThatShouldPushProperties().clear(); |
63 } | 55 } |
64 | 56 |
65 // static | 57 // static |
66 void LayerProtoConverter::DeserializeLayerProperties( | 58 void LayerProtoConverter::DeserializeLayerProperties( |
67 Layer* existing_root, | 59 Layer* existing_root, |
68 const proto::LayerUpdate& layer_update) { | 60 const proto::LayerUpdate& layer_update) { |
69 DCHECK(existing_root); | 61 DCHECK(existing_root); |
70 LayerIdMap layer_id_map; | 62 LayerIdMap layer_id_map; |
71 RecursivelyFindAllLayers(existing_root, &layer_id_map); | 63 RecursivelyFindAllLayers(existing_root, &layer_id_map); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 return SolidColorScrollbarLayer::Create(ScrollbarOrientation::HORIZONTAL, | 110 return SolidColorScrollbarLayer::Create(ScrollbarOrientation::HORIZONTAL, |
119 -1, -1, false, Layer::INVALID_ID); | 111 -1, -1, false, Layer::INVALID_ID); |
120 } | 112 } |
121 // TODO(nyquist): Add the rest of the necessary LayerTypes. This function | 113 // TODO(nyquist): Add the rest of the necessary LayerTypes. This function |
122 // should not return null. | 114 // should not return null. |
123 NOTREACHED(); | 115 NOTREACHED(); |
124 return nullptr; | 116 return nullptr; |
125 } | 117 } |
126 | 118 |
127 } // namespace cc | 119 } // namespace cc |
OLD | NEW |