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

Unified Diff: cc/layers/layer.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.h ('k') | cc/layers/layer_proto_converter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/layer.cc
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc
index 5ebe0d8c41a422e8a8e786c5ec7dde89c7cc4bbb..1b506dc02f2169fbef14b61462c485832685fe81 100644
--- a/cc/layers/layer.cc
+++ b/cc/layers/layer.cc
@@ -1418,6 +1418,56 @@ void Layer::FromLayerNodeProto(const proto::LayerNode& proto,
}
}
+bool Layer::ToLayerPropertiesProto(proto::LayerUpdate* layer_update) {
+ if (!needs_push_properties_ && num_dependents_need_push_properties_ == 0)
+ return false;
+
+ // Always set properties metadata for serialized layers.
+ proto::LayerProperties* proto = layer_update->add_layers();
+ proto->set_id(layer_id_);
+ proto->set_needs_push_properties(needs_push_properties_);
+ proto->set_num_dependents_need_push_properties(
+ num_dependents_need_push_properties_);
+
+ if (needs_push_properties_)
+ LayerSpecificPropertiesToProto(proto);
+
+ needs_push_properties_ = false;
+
+ bool descendant_needs_push_properties =
+ num_dependents_need_push_properties_ > 0;
+ num_dependents_need_push_properties_ = 0;
+
+ return descendant_needs_push_properties;
+}
+
+void Layer::FromLayerPropertiesProto(const proto::LayerProperties& proto) {
+ DCHECK(proto.has_id());
+ DCHECK_EQ(layer_id_, proto.id());
+ DCHECK(proto.has_needs_push_properties());
+ needs_push_properties_ = proto.needs_push_properties();
+ DCHECK(proto.has_num_dependents_need_push_properties());
+ num_dependents_need_push_properties_ =
+ proto.num_dependents_need_push_properties();
+
+ if (!needs_push_properties_)
+ return;
+
+ FromLayerSpecificPropertiesProto(proto);
+}
+
+void Layer::LayerSpecificPropertiesToProto(proto::LayerProperties* proto) {
+ // TODO(nyquist): Write all required properties to |proto|.
+ // Create an empty proto::LayerProperties::base message.
+ proto->mutable_base();
+}
+
+void Layer::FromLayerSpecificPropertiesProto(
+ const proto::LayerProperties& proto) {
+ DCHECK(proto.has_base());
+ // TODO(nyquist): Read all required properties from |proto|.
+}
+
scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) {
return LayerImpl::Create(tree_impl, layer_id_,
new LayerImpl::SyncedScrollOffset);
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_proto_converter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698