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

Side by Side Diff: cc/blimp/compositor_state_deserializer.cc

Issue 2397843003: cc/blimp: Add (de)-serialization for PictureLayer and ScrollbarLayer. (Closed)
Patch Set: Addressed comments 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/blimp/compositor_state_deserializer.h" 5 #include "cc/blimp/compositor_state_deserializer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "cc/blimp/client_picture_cache.h"
9 #include "cc/blimp/compositor_state_deserializer_client.h" 10 #include "cc/blimp/compositor_state_deserializer_client.h"
11 #include "cc/blimp/deserialized_content_layer_client.h"
10 #include "cc/blimp/layer_factory.h" 12 #include "cc/blimp/layer_factory.h"
13 #include "cc/blimp/picture_data_conversions.h"
11 #include "cc/input/layer_selection_bound.h" 14 #include "cc/input/layer_selection_bound.h"
12 #include "cc/layers/layer.h" 15 #include "cc/layers/layer.h"
16 #include "cc/layers/picture_layer.h"
17 #include "cc/layers/solid_color_scrollbar_layer.h"
13 #include "cc/proto/cc_conversions.h" 18 #include "cc/proto/cc_conversions.h"
14 #include "cc/proto/gfx_conversions.h" 19 #include "cc/proto/gfx_conversions.h"
15 #include "cc/proto/layer_tree_host.pb.h" 20 #include "cc/proto/layer_tree_host.pb.h"
16 #include "cc/proto/skia_conversions.h" 21 #include "cc/proto/skia_conversions.h"
17 #include "cc/trees/layer_tree_host.h" 22 #include "cc/trees/layer_tree_host.h"
18 23
19 namespace cc { 24 namespace cc {
20 namespace { 25 namespace {
21 26
22 class DefaultLayerFactory : public LayerFactory { 27 class DefaultLayerFactory : public LayerFactory {
23 public: 28 public:
24 DefaultLayerFactory() = default; 29 DefaultLayerFactory() = default;
25 ~DefaultLayerFactory() override = default; 30 ~DefaultLayerFactory() override = default;
26 31
27 // LayerFactory implementation. 32 // LayerFactory implementation.
28 scoped_refptr<Layer> CreateLayer(int engine_layer_id) override { 33 scoped_refptr<Layer> CreateLayer(int engine_layer_id) override {
29 return Layer::Create(); 34 return Layer::Create();
30 } 35 }
36 scoped_refptr<PictureLayer> CreatePictureLayer(
37 int engine_layer_id,
38 ContentLayerClient* content_layer_client) override {
39 return PictureLayer::Create(content_layer_client);
40 }
41 scoped_refptr<SolidColorScrollbarLayer> CreateSolidColorScrollbarLayer(
42 int engine_layer_id,
43 ScrollbarOrientation orientation,
44 int thumb_thickness,
45 int track_start,
46 bool is_left_side_vertical_scrollbar,
47 int scroll_layer_id) override {
48 return SolidColorScrollbarLayer::Create(
49 orientation, thumb_thickness, track_start,
50 is_left_side_vertical_scrollbar, scroll_layer_id);
51 }
31 }; 52 };
32 53
33 } // namespace 54 } // namespace
34 55
56 CompositorStateDeserializer::LayerData::LayerData() = default;
57
58 CompositorStateDeserializer::LayerData::~LayerData() = default;
59
60 CompositorStateDeserializer::LayerData::LayerData(LayerData&& other) = default;
61
62 CompositorStateDeserializer::LayerData& CompositorStateDeserializer::LayerData::
63 operator=(LayerData&& other) = default;
64
35 CompositorStateDeserializer::CompositorStateDeserializer( 65 CompositorStateDeserializer::CompositorStateDeserializer(
36 LayerTreeHost* layer_tree_host, 66 LayerTreeHost* layer_tree_host,
37 ScrollCallback scroll_callback, 67 std::unique_ptr<ClientPictureCache> client_picture_cache,
68 const ScrollCallback& scroll_callback,
38 CompositorStateDeserializerClient* client) 69 CompositorStateDeserializerClient* client)
39 : layer_factory_(base::MakeUnique<DefaultLayerFactory>()), 70 : layer_factory_(base::MakeUnique<DefaultLayerFactory>()),
40 layer_tree_host_(layer_tree_host), 71 layer_tree_host_(layer_tree_host),
72 client_picture_cache_(std::move(client_picture_cache)),
41 scroll_callback_(scroll_callback), 73 scroll_callback_(scroll_callback),
42 client_(client) { 74 client_(client) {
43 DCHECK(layer_tree_host_); 75 DCHECK(layer_tree_host_);
44 DCHECK(client_); 76 DCHECK(client_);
45 } 77 }
46 78
47 CompositorStateDeserializer::~CompositorStateDeserializer() = default; 79 CompositorStateDeserializer::~CompositorStateDeserializer() = default;
48 80
49 Layer* CompositorStateDeserializer::GetLayerForEngineId( 81 Layer* CompositorStateDeserializer::GetLayerForEngineId(
50 int engine_layer_id) const { 82 int engine_layer_id) const {
51 EngineIdToLayerMap::const_iterator layer_it = 83 EngineIdToLayerMap::const_iterator layer_it =
52 engine_id_to_layer_.find(engine_layer_id); 84 engine_id_to_layer_.find(engine_layer_id);
53 return layer_it != engine_id_to_layer_.end() ? layer_it->second.get() 85 return layer_it != engine_id_to_layer_.end() ? layer_it->second.layer.get()
54 : nullptr; 86 : nullptr;
55 } 87 }
56 88
57 void CompositorStateDeserializer::DeserializeCompositorUpdate( 89 void CompositorStateDeserializer::DeserializeCompositorUpdate(
58 const proto::LayerTreeHost& layer_tree_host_proto) { 90 const proto::LayerTreeHost& layer_tree_host_proto) {
59 SychronizeLayerTreeState(layer_tree_host_proto.layer_tree()); 91 SychronizeLayerTreeState(layer_tree_host_proto.layer_tree());
60 92
93 // Ensure ClientPictureCache contains all the necessary SkPictures before
94 // deserializing the properties.
95 proto::SkPictures proto_pictures = layer_tree_host_proto.pictures();
96 std::vector<PictureData> pictures =
97 SkPicturesProtoToPictureDataVector(proto_pictures);
98 client_picture_cache_->ApplyCacheUpdate(pictures);
99
61 const proto::LayerUpdate& layer_updates = 100 const proto::LayerUpdate& layer_updates =
62 layer_tree_host_proto.layer_updates(); 101 layer_tree_host_proto.layer_updates();
63 for (int i = 0; i < layer_updates.layers_size(); ++i) { 102 for (int i = 0; i < layer_updates.layers_size(); ++i) {
64 SynchronizeLayerState(layer_updates.layers(i)); 103 SynchronizeLayerState(layer_updates.layers(i));
65 } 104 }
105
106 // The deserialization is finished, so now clear the cache.
107 client_picture_cache_->Flush();
66 } 108 }
67 109
68 void CompositorStateDeserializer::SetLayerFactoryForTesting( 110 void CompositorStateDeserializer::SetLayerFactoryForTesting(
69 std::unique_ptr<LayerFactory> layer_factory) { 111 std::unique_ptr<LayerFactory> layer_factory) {
70 layer_factory_ = std::move(layer_factory); 112 layer_factory_ = std::move(layer_factory);
71 } 113 }
72 114
73 void CompositorStateDeserializer::SychronizeLayerTreeState( 115 void CompositorStateDeserializer::SychronizeLayerTreeState(
74 const proto::LayerTree& layer_tree_proto) { 116 const proto::LayerTree& layer_tree_proto) {
75 LayerTree* layer_tree = layer_tree_host_->GetLayerTree(); 117 LayerTree* layer_tree = layer_tree_host_->GetLayerTree();
76 118
77 // Synchronize the tree hierarchy first. 119 // Synchronize the tree hierarchy first.
78 // TODO(khushalsagar): Don't do this if the hierarchy didn't change. See 120 // TODO(khushalsagar): Don't do this if the hierarchy didn't change. See
79 // crbug.com/605170. 121 // crbug.com/605170.
80 EngineIdToLayerMap new_engine_id_to_layer; 122 EngineIdToLayerMap new_engine_id_to_layer;
123 ScrollbarLayerToScrollLayerId scrollbar_layer_to_scroll_layer;
81 if (layer_tree_proto.has_root_layer()) { 124 if (layer_tree_proto.has_root_layer()) {
82 const proto::LayerNode& root_layer_node = layer_tree_proto.root_layer(); 125 const proto::LayerNode& root_layer_node = layer_tree_proto.root_layer();
83 layer_tree->SetRootLayer( 126 layer_tree->SetRootLayer(
84 GetLayerAndAddToNewMap(root_layer_node, &new_engine_id_to_layer)); 127 GetLayerAndAddToNewMap(root_layer_node, &new_engine_id_to_layer,
85 SynchronizeLayerHierarchyRecursive( 128 &scrollbar_layer_to_scroll_layer));
86 layer_tree->root_layer(), root_layer_node, &new_engine_id_to_layer); 129 SynchronizeLayerHierarchyRecursive(layer_tree->root_layer(),
130 root_layer_node, &new_engine_id_to_layer,
131 &scrollbar_layer_to_scroll_layer);
87 } else { 132 } else {
88 layer_tree->SetRootLayer(nullptr); 133 layer_tree->SetRootLayer(nullptr);
89 } 134 }
90 engine_id_to_layer_.swap(new_engine_id_to_layer); 135 engine_id_to_layer_.swap(new_engine_id_to_layer);
91 136
137 // Now that the tree has been synced, we can set up the scroll layers, since
138 // the corresponding engine layers have been created.
139 for (const auto& scrollbar : scrollbar_layer_to_scroll_layer) {
140 // This corresponds to the id of the Scrollbar Layer.
141 int scrollbar_layer_id = scrollbar.first;
142
143 // This corresponds to the id of the scroll layer for this scrollbar.
144 int scroll_layer_id = scrollbar.second;
145
146 SolidColorScrollbarLayer* scrollbar_layer =
147 static_cast<SolidColorScrollbarLayer*>(
148 GetLayerForEngineId(scrollbar_layer_id));
149
150 scrollbar_layer->SetScrollLayer(GetClientIdFromEngineId(scroll_layer_id));
151 }
152
92 // Synchronize rest of the tree state. 153 // Synchronize rest of the tree state.
93 layer_tree->RegisterViewportLayers( 154 layer_tree->RegisterViewportLayers(
94 GetLayer(layer_tree_proto.overscroll_elasticity_layer_id()), 155 GetLayer(layer_tree_proto.overscroll_elasticity_layer_id()),
95 GetLayer(layer_tree_proto.page_scale_layer_id()), 156 GetLayer(layer_tree_proto.page_scale_layer_id()),
96 GetLayer(layer_tree_proto.inner_viewport_scroll_layer_id()), 157 GetLayer(layer_tree_proto.inner_viewport_scroll_layer_id()),
97 GetLayer(layer_tree_proto.outer_viewport_scroll_layer_id())); 158 GetLayer(layer_tree_proto.outer_viewport_scroll_layer_id()));
98 159
99 layer_tree->SetDeviceScaleFactor(layer_tree_proto.device_scale_factor()); 160 layer_tree->SetDeviceScaleFactor(layer_tree_proto.device_scale_factor());
100 layer_tree->SetPaintedDeviceScaleFactor( 161 layer_tree->SetPaintedDeviceScaleFactor(
101 layer_tree_proto.painted_device_scale_factor()); 162 layer_tree_proto.painted_device_scale_factor());
(...skipping 30 matching lines...) Expand all
132 EventListenerClass::kTouchEndOrCancel, 193 EventListenerClass::kTouchEndOrCancel,
133 static_cast<EventListenerProperties>( 194 static_cast<EventListenerProperties>(
134 layer_tree_proto.touch_end_or_cancel_event_listener_properties())); 195 layer_tree_proto.touch_end_or_cancel_event_listener_properties()));
135 } 196 }
136 197
137 void CompositorStateDeserializer::SynchronizeLayerState( 198 void CompositorStateDeserializer::SynchronizeLayerState(
138 const proto::LayerProperties& layer_properties_proto) { 199 const proto::LayerProperties& layer_properties_proto) {
139 int engine_layer_id = layer_properties_proto.id(); 200 int engine_layer_id = layer_properties_proto.id();
140 Layer* layer = GetLayerForEngineId(engine_layer_id); 201 Layer* layer = GetLayerForEngineId(engine_layer_id);
141 202
203 // Layer Inputs -----------------------------------------------------
142 const proto::BaseLayerProperties& base = layer_properties_proto.base(); 204 const proto::BaseLayerProperties& base = layer_properties_proto.base();
143
144 layer->SetNeedsDisplayRect(ProtoToRect(base.update_rect())); 205 layer->SetNeedsDisplayRect(ProtoToRect(base.update_rect()));
145 layer->SetBounds(ProtoToSize(base.bounds())); 206 layer->SetBounds(ProtoToSize(base.bounds()));
146 layer->SetMasksToBounds(base.masks_to_bounds()); 207 layer->SetMasksToBounds(base.masks_to_bounds());
147 layer->SetOpacity(base.opacity()); 208 layer->SetOpacity(base.opacity());
148 layer->SetBlendMode(SkXfermodeModeFromProto(base.blend_mode())); 209 layer->SetBlendMode(SkXfermodeModeFromProto(base.blend_mode()));
149 layer->SetIsRootForIsolatedGroup(base.is_root_for_isolated_group()); 210 layer->SetIsRootForIsolatedGroup(base.is_root_for_isolated_group());
150 layer->SetContentsOpaque(base.contents_opaque()); 211 layer->SetContentsOpaque(base.contents_opaque());
151 layer->SetPosition(ProtoToPointF(base.position())); 212 layer->SetPosition(ProtoToPointF(base.position()));
152 layer->SetTransform(ProtoToTransform(base.transform())); 213 layer->SetTransform(ProtoToTransform(base.transform()));
153 layer->SetTransformOrigin(ProtoToPoint3F(base.transform_origin())); 214 layer->SetTransformOrigin(ProtoToPoint3F(base.transform_origin()));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 layer->SetPositionConstraint(position_constraint); 250 layer->SetPositionConstraint(position_constraint);
190 251
191 LayerStickyPositionConstraint sticky_position_constraint; 252 LayerStickyPositionConstraint sticky_position_constraint;
192 sticky_position_constraint.FromProtobuf(base.sticky_position_constraint()); 253 sticky_position_constraint.FromProtobuf(base.sticky_position_constraint());
193 layer->SetStickyPositionConstraint(sticky_position_constraint); 254 layer->SetStickyPositionConstraint(sticky_position_constraint);
194 layer->SetScrollParent(GetLayerForEngineId(base.scroll_parent_id())); 255 layer->SetScrollParent(GetLayerForEngineId(base.scroll_parent_id()));
195 layer->SetClipParent(GetLayerForEngineId(base.clip_parent_id())); 256 layer->SetClipParent(GetLayerForEngineId(base.clip_parent_id()));
196 257
197 layer->SetHasWillChangeTransformHint(base.has_will_change_transform_hint()); 258 layer->SetHasWillChangeTransformHint(base.has_will_change_transform_hint());
198 layer->SetHideLayerAndSubtree(base.hide_layer_and_subtree()); 259 layer->SetHideLayerAndSubtree(base.hide_layer_and_subtree());
260
261 // ------------------------------------------------------------------
262
263 // PictureLayer Properties deserialization.
264 if (layer_properties_proto.has_picture()) {
265 const proto::PictureLayerProperties& picture_properties =
266 layer_properties_proto.picture();
267
268 // Only PictureLayers set picture.
269 PictureLayer* picture_layer =
270 static_cast<PictureLayer*>(GetLayerForEngineId(engine_layer_id));
271 picture_layer->SetNearestNeighbor(picture_properties.nearest_neighbor());
272
273 gfx::Rect recorded_viewport =
274 ProtoToRect(picture_properties.recorded_viewport());
275 scoped_refptr<DisplayItemList> display_list;
276 std::vector<uint32_t> used_engine_picture_ids;
277 if (picture_properties.has_display_list()) {
278 display_list = DisplayItemList::CreateFromProto(
279 picture_properties.display_list(), client_picture_cache_.get(),
280 &used_engine_picture_ids);
281 } else {
282 display_list = nullptr;
283 }
284
285 // TODO(khushalsagar): The caching here is sub-optimal. If a layer does not
286 // PushProperties, its pictures won't get counted here even if the layer
287 // is drawn in the current frame.
288 for (uint32_t engine_picture_id : used_engine_picture_ids)
289 client_picture_cache_->MarkUsed(engine_picture_id);
290
291 GetContentLayerClient(engine_layer_id)
292 ->UpdateDisplayListAndRecordedViewport(display_list, recorded_viewport);
293 }
199 } 294 }
200 295
201 void CompositorStateDeserializer::SynchronizeLayerHierarchyRecursive( 296 void CompositorStateDeserializer::SynchronizeLayerHierarchyRecursive(
202 Layer* layer, 297 Layer* layer,
203 const proto::LayerNode& layer_node, 298 const proto::LayerNode& layer_node,
204 EngineIdToLayerMap* new_layer_map) { 299 EngineIdToLayerMap* new_layer_map,
300 ScrollbarLayerToScrollLayerId* scrollbar_layer_to_scroll_layer) {
205 layer->RemoveAllChildren(); 301 layer->RemoveAllChildren();
206 302
207 // Children. 303 // Children.
208 for (int i = 0; i < layer_node.children_size(); i++) { 304 for (int i = 0; i < layer_node.children_size(); i++) {
209 const proto::LayerNode& child_layer_node = layer_node.children(i); 305 const proto::LayerNode& child_layer_node = layer_node.children(i);
210 scoped_refptr<Layer> child_layer = 306 scoped_refptr<Layer> child_layer = GetLayerAndAddToNewMap(
211 GetLayerAndAddToNewMap(child_layer_node, new_layer_map); 307 child_layer_node, new_layer_map, scrollbar_layer_to_scroll_layer);
212 layer->AddChild(child_layer); 308 layer->AddChild(child_layer);
213 SynchronizeLayerHierarchyRecursive(child_layer.get(), child_layer_node, 309 SynchronizeLayerHierarchyRecursive(child_layer.get(), child_layer_node,
214 new_layer_map); 310 new_layer_map,
311 scrollbar_layer_to_scroll_layer);
215 } 312 }
216 313
217 // Mask Layer. 314 // Mask Layer.
218 if (layer_node.has_mask_layer()) { 315 if (layer_node.has_mask_layer()) {
219 const proto::LayerNode& mask_layer_node = layer_node.mask_layer(); 316 const proto::LayerNode& mask_layer_node = layer_node.mask_layer();
220 scoped_refptr<Layer> mask_layer = 317 scoped_refptr<Layer> mask_layer = GetLayerAndAddToNewMap(
221 GetLayerAndAddToNewMap(mask_layer_node, new_layer_map); 318 mask_layer_node, new_layer_map, scrollbar_layer_to_scroll_layer);
222 layer->SetMaskLayer(mask_layer.get()); 319 layer->SetMaskLayer(mask_layer.get());
223 SynchronizeLayerHierarchyRecursive(mask_layer.get(), mask_layer_node, 320 SynchronizeLayerHierarchyRecursive(mask_layer.get(), mask_layer_node,
224 new_layer_map); 321 new_layer_map,
322 scrollbar_layer_to_scroll_layer);
225 } else { 323 } else {
226 layer->SetMaskLayer(nullptr); 324 layer->SetMaskLayer(nullptr);
227 } 325 }
228 326
229 // Scroll callback. 327 // Scroll callback.
230 layer->set_did_scroll_callback(base::Bind(scroll_callback_, layer_node.id())); 328 layer->set_did_scroll_callback(base::Bind(scroll_callback_, layer_node.id()));
231 } 329 }
232 330
233 scoped_refptr<Layer> CompositorStateDeserializer::GetLayerAndAddToNewMap( 331 scoped_refptr<Layer> CompositorStateDeserializer::GetLayerAndAddToNewMap(
234 const proto::LayerNode& layer_node, 332 const proto::LayerNode& layer_node,
235 EngineIdToLayerMap* new_layer_map) { 333 EngineIdToLayerMap* new_layer_map,
334 ScrollbarLayerToScrollLayerId* scrollbar_layer_to_scroll_layer) {
236 DCHECK(new_layer_map->find(layer_node.id()) == new_layer_map->end()) 335 DCHECK(new_layer_map->find(layer_node.id()) == new_layer_map->end())
237 << "A LayerNode should have been de-serialized only once"; 336 << "A LayerNode should have been de-serialized only once";
238 337
338 scoped_refptr<Layer> layer;
239 EngineIdToLayerMap::iterator layer_map_it = 339 EngineIdToLayerMap::iterator layer_map_it =
240 engine_id_to_layer_.find(layer_node.id()); 340 engine_id_to_layer_.find(layer_node.id());
241 341
242 if (layer_map_it != engine_id_to_layer_.end()) { 342 if (layer_map_it != engine_id_to_layer_.end()) {
243 // We can re-use the old layer. 343 // We can re-use the old layer.
244 (*new_layer_map)[layer_node.id()] = layer_map_it->second; 344 layer = layer_map_it->second.layer;
245 return layer_map_it->second; 345 (*new_layer_map)[layer_node.id()] = std::move(layer_map_it->second);
346 engine_id_to_layer_.erase(layer_map_it);
347 return layer;
246 } 348 }
247 349
248 // We need to create a new layer. 350 // We need to create a new layer.
249 scoped_refptr<Layer> layer; 351 auto& layer_data = (*new_layer_map)[layer_node.id()];
250 switch (layer_node.type()) { 352 switch (layer_node.type()) {
251 case proto::LayerNode::UNKNOWN: 353 case proto::LayerNode::UNKNOWN:
252 NOTREACHED() << "Unknown Layer type"; 354 NOTREACHED() << "Unknown Layer type";
253 case proto::LayerNode::LAYER: 355 case proto::LayerNode::LAYER:
254 layer = layer_factory_->CreateLayer(layer_node.id()); 356 layer_data.layer = layer_factory_->CreateLayer(layer_node.id());
255 break; 357 break;
256 default: 358 case proto::LayerNode::PICTURE_LAYER:
257 // TODO(khushalsagar): Add other Layer types. 359 layer_data.content_layer_client =
360 base::MakeUnique<DeserializedContentLayerClient>();
361 layer_data.layer = layer_factory_->CreatePictureLayer(
362 layer_node.id(), layer_data.content_layer_client.get());
363 break;
364 case proto::LayerNode::SOLID_COLOR_SCROLLBAR_LAYER: {
365 // SolidColorScrollbarLayers attach their properties in the LayerNode
366 // itself.
367 const proto::SolidColorScrollbarLayerProperties& scrollbar =
368 layer_node.solid_scrollbar();
369
370 DCHECK(scrollbar_layer_to_scroll_layer->find(layer_node.id()) ==
371 scrollbar_layer_to_scroll_layer->end());
372 int scroll_layer_id = scrollbar.scroll_layer_id();
373 (*scrollbar_layer_to_scroll_layer)[layer_node.id()] = scroll_layer_id;
374
375 int thumb_thickness = scrollbar.thumb_thickness();
376 int track_start = scrollbar.track_start();
377 bool is_left_side_vertical_scrollbar =
378 scrollbar.is_left_side_vertical_scrollbar();
379 ScrollbarOrientation orientation =
380 ScrollbarOrientationFromProto(scrollbar.orientation());
381
382 // We use the invalid id for the |scroll_layer_id| because the
383 // corresponding layer on the client may not have been created yet.
384 layer_data.layer = layer_factory_->CreateSolidColorScrollbarLayer(
385 layer_node.id(), orientation, thumb_thickness, track_start,
386 is_left_side_vertical_scrollbar, Layer::LayerIdLabels::INVALID_ID);
387 } break;
388 case proto::LayerNode::HEADS_UP_DISPLAY_LAYER:
389 // TODO(khushalsagar): Remove this from proto.
258 NOTREACHED(); 390 NOTREACHED();
259 } 391 }
260 392
261 (*new_layer_map)[layer_node.id()] = layer; 393 layer = layer_data.layer;
262 return layer; 394 return layer;
263 } 395 }
264 396
265 int CompositorStateDeserializer::GetClientIdFromEngineId(int engine_layer_id) { 397 int CompositorStateDeserializer::GetClientIdFromEngineId(
398 int engine_layer_id) const {
266 Layer* layer = GetLayerForEngineId(engine_layer_id); 399 Layer* layer = GetLayerForEngineId(engine_layer_id);
267 return layer ? layer->id() : Layer::LayerIdLabels::INVALID_ID; 400 return layer ? layer->id() : Layer::LayerIdLabels::INVALID_ID;
268 } 401 }
269 402
270 scoped_refptr<Layer> CompositorStateDeserializer::GetLayer( 403 scoped_refptr<Layer> CompositorStateDeserializer::GetLayer(
271 int engine_layer_id) { 404 int engine_layer_id) const {
272 EngineIdToLayerMap::const_iterator layer_it = 405 EngineIdToLayerMap::const_iterator layer_it =
273 engine_id_to_layer_.find(engine_layer_id); 406 engine_id_to_layer_.find(engine_layer_id);
274 return layer_it != engine_id_to_layer_.end() ? layer_it->second : nullptr; 407 return layer_it != engine_id_to_layer_.end() ? layer_it->second.layer
408 : nullptr;
409 }
410
411 DeserializedContentLayerClient*
412 CompositorStateDeserializer::GetContentLayerClient(int engine_layer_id) const {
413 EngineIdToLayerMap::const_iterator layer_it =
414 engine_id_to_layer_.find(engine_layer_id);
415 return layer_it != engine_id_to_layer_.end()
416 ? layer_it->second.content_layer_client.get()
417 : nullptr;
275 } 418 }
276 419
277 } // namespace cc 420 } // namespace cc
OLDNEW
« no previous file with comments | « cc/blimp/compositor_state_deserializer.h ('k') | cc/blimp/compositor_state_deserializer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698