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

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: Add framework for base Layer class properties 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.cc
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc
index 5ebe0d8c41a422e8a8e786c5ec7dde89c7cc4bbb..5045cfbc5ee71145c2eaf9b3e4de0324440b2390 100644
--- a/cc/layers/layer.cc
+++ b/cc/layers/layer.cc
@@ -1418,6 +1418,61 @@ void Layer::FromLayerNodeProto(const proto::LayerNode& proto,
}
}
+void Layer::ToLayerPropertiesProto(proto::LayerUpdate* layer_update) {
+ if (!needs_push_properties_ && num_dependents_need_push_properties_ == 0)
+ return;
+
+ // 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);
+
+ if (num_dependents_need_push_properties_ > 0) {
+ for (const auto& child : children_) {
+ child->ToLayerPropertiesProto(layer_update);
+ }
+ if (mask_layer_)
+ mask_layer_->ToLayerPropertiesProto(layer_update);
+ if (replica_layer_)
+ replica_layer_->ToLayerPropertiesProto(layer_update);
+ }
+
+ needs_push_properties_ = false;
+ num_dependents_need_push_properties_ = 0;
+}
+
+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);

Powered by Google App Engine
This is Rietveld 408576698