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

Side by Side Diff: cc/layers/layer_proto_converter.cc

Issue 2375363002: cc/blimp: Set up the framework for state serialization. (Closed)
Patch Set: test update Created 4 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 unified diff | Download patch
« no previous file with comments | « cc/layers/layer_proto_converter.h ('k') | cc/layers/layer_proto_converter_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "cc/layers/empty_content_layer_client.h" 9 #include "cc/layers/empty_content_layer_client.h"
10 #include "cc/layers/heads_up_display_layer.h" 10 #include "cc/layers/heads_up_display_layer.h"
11 #include "cc/layers/layer.h" 11 #include "cc/layers/layer.h"
12 #include "cc/layers/picture_layer.h" 12 #include "cc/layers/picture_layer.h"
13 #include "cc/layers/solid_color_scrollbar_layer.h" 13 #include "cc/layers/solid_color_scrollbar_layer.h"
14 #include "cc/proto/layer.pb.h" 14 #include "cc/proto/layer.pb.h"
15 #include "cc/trees/layer_tree_host.h" 15 #include "cc/trees/layer_tree_host.h"
16 #include "cc/trees/layer_tree_host_common.h" 16 #include "cc/trees/layer_tree_host_common.h"
17 #include "cc/trees/layer_tree_settings.h" 17 #include "cc/trees/layer_tree_settings.h"
18 18
19 namespace cc { 19 namespace cc {
20 20
21 LayerProtoConverter::LayerProtoConverter() {} 21 LayerProtoConverter::LayerProtoConverter() {}
22 22
23 LayerProtoConverter::~LayerProtoConverter() {} 23 LayerProtoConverter::~LayerProtoConverter() {}
24 24
25 // static 25 // static
26 void LayerProtoConverter::SerializeLayerHierarchy(
27 const scoped_refptr<Layer> root_layer,
28 proto::LayerNode* root_node) {
29 TRACE_EVENT0("cc.remote", "LayerProtoConverter::SerializeLayerHierarchy");
30 root_layer->ToLayerNodeProto(root_node);
31 }
32
33 // static
34 scoped_refptr<Layer> LayerProtoConverter::DeserializeLayerHierarchy( 26 scoped_refptr<Layer> LayerProtoConverter::DeserializeLayerHierarchy(
35 scoped_refptr<Layer> existing_root, 27 scoped_refptr<Layer> existing_root,
36 const proto::LayerNode& root_node, 28 const proto::LayerNode& root_node,
37 LayerTreeHost* layer_tree_host) { 29 LayerTreeHost* layer_tree_host) {
38 LayerIdMap layer_id_map; 30 LayerIdMap layer_id_map;
39 if (existing_root) { 31 if (existing_root) {
40 existing_root->ClearLayerTreePropertiesForDeserializationAndAddToMap( 32 existing_root->ClearLayerTreePropertiesForDeserializationAndAddToMap(
41 &layer_id_map); 33 &layer_id_map);
42 } 34 }
43 35
44 scoped_refptr<Layer> new_root = existing_root; 36 scoped_refptr<Layer> new_root = existing_root;
45 if (!existing_root || 37 if (!existing_root ||
46 (root_node.has_id() && root_node.id() != existing_root->id())) { 38 (root_node.has_id() && root_node.id() != existing_root->id())) {
47 // The root node has changed or there was no root node, 39 // The root node has changed or there was no root node,
48 // so find or create the new root. 40 // so find or create the new root.
49 new_root = FindOrAllocateAndConstruct(root_node, layer_id_map); 41 new_root = FindOrAllocateAndConstruct(root_node, layer_id_map);
50 } 42 }
51 new_root->FromLayerNodeProto(root_node, layer_id_map, layer_tree_host); 43 new_root->FromLayerNodeProto(root_node, layer_id_map, layer_tree_host);
52 return new_root; 44 return new_root;
53 } 45 }
54 46
55 // static 47 // static
56 void LayerProtoConverter::SerializeLayerProperties( 48 void LayerProtoConverter::SerializeLayerProperties(
57 LayerTreeHost* host, 49 LayerTreeHost* host,
58 proto::LayerUpdate* layer_update) { 50 proto::LayerUpdate* layer_update) {
59 TRACE_EVENT0("cc.remote", "LayerProtoConverter::SerializeLayerProperties"); 51 TRACE_EVENT0("cc.remote", "LayerProtoConverter::SerializeLayerProperties");
52 const bool inputs_only = false;
60 for (auto* layer : host->GetLayerTree()->LayersThatShouldPushProperties()) 53 for (auto* layer : host->GetLayerTree()->LayersThatShouldPushProperties())
61 layer->ToLayerPropertiesProto(layer_update); 54 layer->ToLayerPropertiesProto(layer_update, inputs_only);
62 host->GetLayerTree()->LayersThatShouldPushProperties().clear(); 55 host->GetLayerTree()->LayersThatShouldPushProperties().clear();
63 } 56 }
64 57
65 // static 58 // static
66 void LayerProtoConverter::DeserializeLayerProperties( 59 void LayerProtoConverter::DeserializeLayerProperties(
67 Layer* existing_root, 60 Layer* existing_root,
68 const proto::LayerUpdate& layer_update) { 61 const proto::LayerUpdate& layer_update) {
69 DCHECK(existing_root); 62 DCHECK(existing_root);
70 LayerIdMap layer_id_map; 63 LayerIdMap layer_id_map;
71 RecursivelyFindAllLayers(existing_root, &layer_id_map); 64 RecursivelyFindAllLayers(existing_root, &layer_id_map);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 return SolidColorScrollbarLayer::Create(ScrollbarOrientation::HORIZONTAL, 111 return SolidColorScrollbarLayer::Create(ScrollbarOrientation::HORIZONTAL,
119 -1, -1, false, Layer::INVALID_ID); 112 -1, -1, false, Layer::INVALID_ID);
120 } 113 }
121 // TODO(nyquist): Add the rest of the necessary LayerTypes. This function 114 // TODO(nyquist): Add the rest of the necessary LayerTypes. This function
122 // should not return null. 115 // should not return null.
123 NOTREACHED(); 116 NOTREACHED();
124 return nullptr; 117 return nullptr;
125 } 118 }
126 119
127 } // namespace cc 120 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_proto_converter.h ('k') | cc/layers/layer_proto_converter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698