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

Unified Diff: cc/layers/layer_proto_converter.cc

Issue 1423523002: Add support for (de)serializing cc::Layer properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@serialize-layer-hierarchy
Patch Set: Addressed comments from dtrainor@ Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: cc/layers/layer_proto_converter.cc
diff --git a/cc/layers/layer_proto_converter.cc b/cc/layers/layer_proto_converter.cc
index 2dcc3d90a441209006cffd8f9fc55a3fc6bd4610..8cc48bb6c102057aea135d5a1a76f3b6c089a14b 100644
--- a/cc/layers/layer_proto_converter.cc
+++ b/cc/layers/layer_proto_converter.cc
@@ -42,6 +42,31 @@ scoped_refptr<Layer> LayerProtoConverter::DeserializeLayerHierarchy(
}
// static
+void LayerProtoConverter::SerializeLayerProperties(
vmpstr 2015/11/17 21:05:44 I think these should be more symmetrical wrt to ch
nyquist 2015/11/18 00:24:34 Done.
+ const scoped_refptr<Layer> root_layer,
+ proto::LayerUpdate* layer_update) {
+ root_layer->ToLayerPropertiesProto(layer_update);
+}
+
+// static
+void LayerProtoConverter::DeserializeLayerProperties(
+ scoped_refptr<Layer> existing_root,
+ const proto::LayerUpdate& layer_update) {
+ LayerIdMap layer_id_map;
+ RecursivelyFindAllLayers(existing_root, &layer_id_map);
+
+ for (int i = 0; i < layer_update.layers_size(); ++i) {
+ const proto::LayerProperties& layer_properties = layer_update.layers(i);
+
+ Layer::LayerIdMap::const_iterator iter =
+ layer_id_map.find(layer_properties.id());
+ DCHECK(iter != layer_id_map.end());
+
+ iter->second->FromLayerPropertiesProto(layer_properties);
+ }
+}
+
+// static
void LayerProtoConverter::RecursivelyFindAllLayers(
const scoped_refptr<Layer>& layer,
LayerIdMap* layer_id_map) {

Powered by Google App Engine
This is Rietveld 408576698