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_deserializer.h" | |
| 6 | |
| 7 #include "base/stl_util.h" | |
| 8 #include "cc/layers/layer.h" | |
| 9 #include "cc/layers/layer_proto_factory.h" | |
| 10 #include "cc/proto/layer.pb.h" | |
| 11 | |
| 12 namespace cc { | |
| 13 | |
| 14 LayerDeserializer::LayerDeserializer() {} | |
| 15 | |
| 16 LayerDeserializer::~LayerDeserializer() {} | |
| 17 | |
| 18 // static | |
| 19 scoped_refptr<Layer> LayerDeserializer::DeserializeLayerHierarchy( | |
| 20 scoped_refptr<Layer> existing_root, | |
| 21 const proto::LayerNode& root_node) { | |
| 22 LayerIdMap layer_id_map; | |
| 23 RecursivelyFindAllLayers(existing_root, &layer_id_map); | |
| 24 | |
| 25 scoped_refptr<Layer> new_root = existing_root; | |
| 26 if (!existing_root || | |
| 27 (root_node.has_id() && root_node.id() != (uint32)existing_root->id())) { | |
|
vmpstr
2015/10/21 22:34:14
no c-style casts, is the type of the id in the pro
nyquist
2015/10/23 00:12:30
My bad. Fixed proto.
| |
| 28 // The root node has changed or there was no root node, | |
| 29 // so find or create the new root. | |
| 30 new_root = | |
| 31 LayerProtoFactory::FindOrAllocateAndConstruct(root_node, layer_id_map); | |
| 32 } | |
| 33 new_root->FromLayerNodeProto(root_node, layer_id_map); | |
| 34 return new_root; | |
| 35 } | |
| 36 | |
| 37 // static | |
| 38 void LayerDeserializer::RecursivelyFindAllLayers(scoped_refptr<Layer> layer, | |
|
vmpstr
2015/10/21 22:34:14
Can you use LayerTreeHostComon::CallFunctionForSub
nyquist
2015/10/23 00:12:30
Awesome! Thanks!
| |
| 39 LayerIdMap* layer_id_map) { | |
| 40 (*layer_id_map)[layer->id()] = layer; | |
| 41 for (auto child : layer->children()) { | |
| 42 RecursivelyFindAllLayers(child, layer_id_map); | |
| 43 } | |
| 44 | |
| 45 if (layer->mask_layer()) | |
| 46 RecursivelyFindAllLayers(layer->mask_layer(), layer_id_map); | |
| 47 if (layer->replica_layer()) | |
| 48 RecursivelyFindAllLayers(layer->replica_layer(), layer_id_map); | |
| 49 } | |
| 50 | |
| 51 } // namespace cc | |
| OLD | NEW |