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

Unified Diff: cc/layers/layer_proto_factory.cc

Issue 1398443008: Add support for (de)serializing cc::Layer hierarchy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@review-1394353002
Patch Set: Fixed CC_EXPORT Created 5 years, 2 months 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_factory.cc
diff --git a/cc/layers/layer_proto_factory.cc b/cc/layers/layer_proto_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..251bd8b9a7b0490ec24935cb1ea58fbe2b0ff087
--- /dev/null
+++ b/cc/layers/layer_proto_factory.cc
@@ -0,0 +1,33 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/layers/layer_proto_factory.h"
+
+#include "cc/layers/layer.h"
+#include "cc/proto/layer.pb.h"
+#include "cc/trees/layer_tree_settings.h"
+
+namespace cc {
+
+// static
+scoped_refptr<Layer> LayerProtoFactory::FindOrAllocateAndConstruct(
+ const proto::LayerNode& proto,
+ const Layer::LayerIdMap& layer_id_map) {
+ if (proto.has_id()) {
vmpstr 2015/10/21 22:34:14 Can you DCHECK that it has id?
nyquist 2015/10/23 00:12:31 Done.
+ Layer::LayerIdMap::const_iterator iter = layer_id_map.find(proto.id());
+ if (iter != layer_id_map.end())
+ return iter->second;
+ }
+ if (!proto.has_type())
vmpstr 2015/10/21 22:34:14 When can this happen? I don't think we handle null
nyquist 2015/10/23 00:12:31 Done.
+ return nullptr;
+ switch (proto.type()) {
+ case proto::Base:
+ return Layer::Create(LayerSettings()).get();
+ default:
+ // TODO(nyquist): Add the rest of the necessary LayerTypes.
+ return nullptr;
+ }
+}
+
+} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698