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 |