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

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 about raw pointers and new test. 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
« no previous file with comments | « cc/layers/layer_proto_converter.h ('k') | cc/layers/layer_proto_converter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..7644c7e1f058db563bfb4db0fefa4298b2bfb673 100644
--- a/cc/layers/layer_proto_converter.cc
+++ b/cc/layers/layer_proto_converter.cc
@@ -42,6 +42,48 @@ scoped_refptr<Layer> LayerProtoConverter::DeserializeLayerHierarchy(
}
// static
+void LayerProtoConverter::SerializeLayerProperties(
+ Layer* root_layer,
+ proto::LayerUpdate* layer_update) {
+ RecursivelySerializeLayerProperties(root_layer, layer_update);
+}
+
+// static
+void LayerProtoConverter::DeserializeLayerProperties(
+ 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::RecursivelySerializeLayerProperties(
+ Layer* layer,
+ proto::LayerUpdate* layer_update) {
+ bool serialize_descendants = layer->ToLayerPropertiesProto(layer_update);
+ if (!serialize_descendants)
+ return;
+
+ for (const auto& child : layer->children()) {
+ RecursivelySerializeLayerProperties(child.get(), layer_update);
+ }
+ if (layer->mask_layer())
+ RecursivelySerializeLayerProperties(layer->mask_layer(), layer_update);
+ if (layer->replica_layer())
+ RecursivelySerializeLayerProperties(layer->replica_layer(), layer_update);
+}
+
+// static
void LayerProtoConverter::RecursivelyFindAllLayers(
const scoped_refptr<Layer>& layer,
LayerIdMap* layer_id_map) {
« no previous file with comments | « cc/layers/layer_proto_converter.h ('k') | cc/layers/layer_proto_converter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698