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

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: Add early return in LayerProtoConverter::RecursivelySerializeLayerProperties 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..970c446577c28cc161cfd8c5fb04c686eb8cf0c7 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(
+ const scoped_refptr<Layer> root_layer,
+ proto::LayerUpdate* layer_update) {
+ RecursivelySerializeLayerProperties(root_layer, layer_update);
+}
+
+// static
+void LayerProtoConverter::DeserializeLayerProperties(
+ scoped_refptr<Layer> existing_root,
vmpstr 2015/11/18 04:05:25 Can you pass a raw pointer here instead?
nyquist 2015/11/18 07:15:59 Done.
+ 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(
+ const scoped_refptr<Layer> layer,
+ proto::LayerUpdate* layer_update) {
+ bool serialize_descendants = layer->ToLayerPropertiesProto(layer_update);
+ if (!serialize_descendants)
vmpstr 2015/11/18 04:05:25 Are mask/replica considered descendants? That is,
nyquist 2015/11/18 07:15:59 According to Layer::SetMaskLayer(...) ( https://ch
+ return;
+
+ for (const auto& child : layer->children()) {
+ RecursivelySerializeLayerProperties(child, 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) {

Powered by Google App Engine
This is Rietveld 408576698