Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/layers/layer_proto_converter.h" | 5 #include "cc/layers/layer_proto_converter.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "cc/layers/empty_content_layer_client.h" | 8 #include "cc/layers/empty_content_layer_client.h" |
| 9 #include "cc/layers/heads_up_display_layer.h" | 9 #include "cc/layers/heads_up_display_layer.h" |
| 10 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 proto::LayerNode* root_node) { | 25 proto::LayerNode* root_node) { |
| 26 root_layer->ToLayerNodeProto(root_node); | 26 root_layer->ToLayerNodeProto(root_node); |
| 27 } | 27 } |
| 28 | 28 |
| 29 // static | 29 // static |
| 30 scoped_refptr<Layer> LayerProtoConverter::DeserializeLayerHierarchy( | 30 scoped_refptr<Layer> LayerProtoConverter::DeserializeLayerHierarchy( |
| 31 scoped_refptr<Layer> existing_root, | 31 scoped_refptr<Layer> existing_root, |
| 32 const proto::LayerNode& root_node) { | 32 const proto::LayerNode& root_node) { |
| 33 LayerIdMap layer_id_map; | 33 LayerIdMap layer_id_map; |
| 34 if (existing_root) | 34 if (existing_root) |
| 35 RecursivelyFindAllLayers(existing_root, &layer_id_map); | 35 RecursivelyFindAllLayers(existing_root.get(), &layer_id_map); |
| 36 | 36 |
| 37 scoped_refptr<Layer> new_root = existing_root; | 37 scoped_refptr<Layer> new_root = existing_root; |
| 38 if (!existing_root || | 38 if (!existing_root || |
| 39 (root_node.has_id() && root_node.id() != existing_root->id())) { | 39 (root_node.has_id() && root_node.id() != existing_root->id())) { |
| 40 // The root node has changed or there was no root node, | 40 // The root node has changed or there was no root node, |
| 41 // so find or create the new root. | 41 // so find or create the new root. |
| 42 new_root = FindOrAllocateAndConstruct(root_node, layer_id_map); | 42 new_root = FindOrAllocateAndConstruct(root_node, layer_id_map); |
| 43 } | 43 } |
| 44 new_root->FromLayerNodeProto(root_node, layer_id_map); | 44 new_root->FromLayerNodeProto(root_node, layer_id_map); |
| 45 return new_root; | 45 return new_root; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 for (const auto& child : layer->children()) { | 82 for (const auto& child : layer->children()) { |
| 83 RecursivelySerializeLayerProperties(child.get(), layer_update); | 83 RecursivelySerializeLayerProperties(child.get(), layer_update); |
| 84 } | 84 } |
| 85 if (layer->mask_layer()) | 85 if (layer->mask_layer()) |
| 86 RecursivelySerializeLayerProperties(layer->mask_layer(), layer_update); | 86 RecursivelySerializeLayerProperties(layer->mask_layer(), layer_update); |
| 87 if (layer->replica_layer()) | 87 if (layer->replica_layer()) |
| 88 RecursivelySerializeLayerProperties(layer->replica_layer(), layer_update); | 88 RecursivelySerializeLayerProperties(layer->replica_layer(), layer_update); |
| 89 } | 89 } |
| 90 | 90 |
| 91 // static | 91 // static |
| 92 void LayerProtoConverter::RecursivelyFindAllLayers( | 92 void LayerProtoConverter::RecursivelyFindAllLayers(Layer* root_layer, |
| 93 const scoped_refptr<Layer>& layer, | 93 LayerIdMap* layer_id_map) { |
| 94 LayerIdMap* layer_id_map) { | |
| 95 LayerTreeHostCommon::CallFunctionForSubtree( | 94 LayerTreeHostCommon::CallFunctionForSubtree( |
| 96 layer.get(), | 95 root_layer, |
| 97 [layer_id_map](Layer* layer) { (*layer_id_map)[layer->id()] = layer; }); | 96 [layer_id_map](Layer* layer) { (*layer_id_map)[layer->id()] = layer; }); |
|
danakj
2016/03/16 00:08:15
https://code.google.com/p/chromium/codesearch#chro
| |
| 98 } | 97 } |
| 99 | 98 |
| 100 // static | 99 // static |
| 101 scoped_refptr<Layer> LayerProtoConverter::FindOrAllocateAndConstruct( | 100 scoped_refptr<Layer> LayerProtoConverter::FindOrAllocateAndConstruct( |
| 102 const proto::LayerNode& proto, | 101 const proto::LayerNode& proto, |
| 103 const Layer::LayerIdMap& layer_id_map) { | 102 const Layer::LayerIdMap& layer_id_map) { |
| 104 DCHECK(proto.has_id()); | 103 DCHECK(proto.has_id()); |
| 105 Layer::LayerIdMap::const_iterator iter = layer_id_map.find(proto.id()); | 104 Layer::LayerIdMap::const_iterator iter = layer_id_map.find(proto.id()); |
| 106 if (iter != layer_id_map.end()) | 105 if (iter != layer_id_map.end()) |
| 107 return iter->second; | 106 return iter->second; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 118 case proto::LayerNode::HEADS_UP_DISPLAY_LAYER: | 117 case proto::LayerNode::HEADS_UP_DISPLAY_LAYER: |
| 119 return HeadsUpDisplayLayer::Create(); | 118 return HeadsUpDisplayLayer::Create(); |
| 120 } | 119 } |
| 121 // TODO(nyquist): Add the rest of the necessary LayerTypes. This function | 120 // TODO(nyquist): Add the rest of the necessary LayerTypes. This function |
| 122 // should not return null. | 121 // should not return null. |
| 123 NOTREACHED(); | 122 NOTREACHED(); |
| 124 return nullptr; | 123 return nullptr; |
| 125 } | 124 } |
| 126 | 125 |
| 127 } // namespace cc | 126 } // namespace cc |
| OLD | NEW |