Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "cc/layers/layer_proto_factory.h" | |
| 6 | |
| 7 #include "cc/layers/layer.h" | |
| 8 #include "cc/proto/layer.pb.h" | |
| 9 #include "cc/trees/layer_tree_settings.h" | |
| 10 | |
| 11 namespace cc { | |
| 12 | |
| 13 // static | |
| 14 scoped_refptr<Layer> LayerProtoFactory::FindOrAllocateAndConstruct( | |
| 15 const proto::LayerNode& proto, | |
| 16 const Layer::LayerIdMap& layer_id_map) { | |
| 17 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.
| |
| 18 Layer::LayerIdMap::const_iterator iter = layer_id_map.find(proto.id()); | |
| 19 if (iter != layer_id_map.end()) | |
| 20 return iter->second; | |
| 21 } | |
| 22 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.
| |
| 23 return nullptr; | |
| 24 switch (proto.type()) { | |
| 25 case proto::Base: | |
| 26 return Layer::Create(LayerSettings()).get(); | |
| 27 default: | |
| 28 // TODO(nyquist): Add the rest of the necessary LayerTypes. | |
| 29 return nullptr; | |
| 30 } | |
| 31 } | |
| 32 | |
| 33 } // namespace cc | |
| OLD | NEW |