Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 #include "cc/debug/rendering_stats_instrumentation.h" | 37 #include "cc/debug/rendering_stats_instrumentation.h" |
| 38 #include "cc/input/layer_selection_bound.h" | 38 #include "cc/input/layer_selection_bound.h" |
| 39 #include "cc/input/page_scale_animation.h" | 39 #include "cc/input/page_scale_animation.h" |
| 40 #include "cc/layers/heads_up_display_layer.h" | 40 #include "cc/layers/heads_up_display_layer.h" |
| 41 #include "cc/layers/heads_up_display_layer_impl.h" | 41 #include "cc/layers/heads_up_display_layer_impl.h" |
| 42 #include "cc/layers/layer.h" | 42 #include "cc/layers/layer.h" |
| 43 #include "cc/layers/layer_iterator.h" | 43 #include "cc/layers/layer_iterator.h" |
| 44 #include "cc/layers/layer_proto_converter.h" | 44 #include "cc/layers/layer_proto_converter.h" |
| 45 #include "cc/layers/painted_scrollbar_layer.h" | 45 #include "cc/layers/painted_scrollbar_layer.h" |
| 46 #include "cc/proto/gfx_conversions.h" | 46 #include "cc/proto/gfx_conversions.h" |
| 47 #include "cc/proto/layer_tree.pb.h" | |
| 47 #include "cc/proto/layer_tree_host.pb.h" | 48 #include "cc/proto/layer_tree_host.pb.h" |
| 48 #include "cc/resources/ui_resource_request.h" | 49 #include "cc/resources/ui_resource_request.h" |
| 49 #include "cc/scheduler/begin_frame_source.h" | 50 #include "cc/scheduler/begin_frame_source.h" |
| 50 #include "cc/trees/draw_property_utils.h" | 51 #include "cc/trees/draw_property_utils.h" |
| 51 #include "cc/trees/layer_tree_host_client.h" | 52 #include "cc/trees/layer_tree_host_client.h" |
| 52 #include "cc/trees/layer_tree_host_common.h" | 53 #include "cc/trees/layer_tree_host_common.h" |
| 53 #include "cc/trees/layer_tree_host_impl.h" | 54 #include "cc/trees/layer_tree_host_impl.h" |
| 54 #include "cc/trees/layer_tree_impl.h" | 55 #include "cc/trees/layer_tree_impl.h" |
| 55 #include "cc/trees/property_tree_builder.h" | 56 #include "cc/trees/property_tree_builder.h" |
| 56 #include "cc/trees/proxy_main.h" | 57 #include "cc/trees/proxy_main.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 animation_host_(std::move(params->animation_host)), | 245 animation_host_(std::move(params->animation_host)), |
| 245 did_complete_scale_animation_(false), | 246 did_complete_scale_animation_(false), |
| 246 in_paint_layer_contents_(false), | 247 in_paint_layer_contents_(false), |
| 247 id_(s_layer_tree_host_sequence_number.GetNext() + 1), | 248 id_(s_layer_tree_host_sequence_number.GetNext() + 1), |
| 248 next_commit_forces_redraw_(false), | 249 next_commit_forces_redraw_(false), |
| 249 shared_bitmap_manager_(params->shared_bitmap_manager), | 250 shared_bitmap_manager_(params->shared_bitmap_manager), |
| 250 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager), | 251 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager), |
| 251 task_graph_runner_(params->task_graph_runner), | 252 task_graph_runner_(params->task_graph_runner), |
| 252 image_serialization_processor_(params->image_serialization_processor), | 253 image_serialization_processor_(params->image_serialization_processor), |
| 253 surface_client_id_(0u), | 254 surface_client_id_(0u), |
| 254 next_surface_sequence_(1u) { | 255 next_surface_sequence_(1u), |
| 256 layer_tree_() { | |
|
Khushal
2016/07/18 16:59:33
Don't need to initialize it for a default ctor.
xingliu
2016/07/19 22:47:38
Done.
| |
| 255 DCHECK(task_graph_runner_); | 257 DCHECK(task_graph_runner_); |
| 256 | 258 |
| 257 DCHECK(animation_host_); | 259 DCHECK(animation_host_); |
| 258 animation_host_->SetMutatorHostClient(this); | 260 animation_host_->SetMutatorHostClient(this); |
| 259 | 261 |
| 260 rendering_stats_instrumentation_->set_record_rendering_stats( | 262 rendering_stats_instrumentation_->set_record_rendering_stats( |
| 261 debug_state_.RecordRenderingStats()); | 263 debug_state_.RecordRenderingStats()); |
| 262 } | 264 } |
| 263 | 265 |
| 264 void LayerTreeHost::InitializeThreaded( | 266 void LayerTreeHost::InitializeThreaded( |
| (...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1337 element_layers_map_[layer->element_id()] = layer; | 1339 element_layers_map_[layer->element_id()] = layer; |
| 1338 } | 1340 } |
| 1339 | 1341 |
| 1340 void LayerTreeHost::RemoveFromElementMap(Layer* layer) { | 1342 void LayerTreeHost::RemoveFromElementMap(Layer* layer) { |
| 1341 if (!layer->element_id()) | 1343 if (!layer->element_id()) |
| 1342 return; | 1344 return; |
| 1343 | 1345 |
| 1344 element_layers_map_.erase(layer->element_id()); | 1346 element_layers_map_.erase(layer->element_id()); |
| 1345 } | 1347 } |
| 1346 | 1348 |
| 1347 void LayerTreeHost::AddLayerShouldPushProperties(Layer* layer) { | 1349 void LayerTreeHost::AddLayerShouldPushProperties(Layer* layer) { |
|
Khushal
2016/07/18 16:59:33
Why do we still need these methods on the host? Th
xingliu
2016/07/19 22:47:38
Done.
| |
| 1348 layers_that_should_push_properties_.insert(layer); | 1350 layer_tree_.AddLayerShouldPushProperties(layer); |
| 1349 } | 1351 } |
| 1350 | 1352 |
| 1351 void LayerTreeHost::RemoveLayerShouldPushProperties(Layer* layer) { | 1353 void LayerTreeHost::RemoveLayerShouldPushProperties(Layer* layer) { |
| 1352 layers_that_should_push_properties_.erase(layer); | 1354 layer_tree_.RemoveLayerShouldPushProperties(layer); |
| 1353 } | 1355 } |
| 1354 | 1356 |
| 1355 std::unordered_set<Layer*>& LayerTreeHost::LayersThatShouldPushProperties() { | 1357 std::unordered_set<Layer*>& LayerTreeHost::LayersThatShouldPushProperties() { |
| 1356 return layers_that_should_push_properties_; | 1358 return layer_tree_.layers_that_should_push_properties(); |
| 1357 } | 1359 } |
| 1358 | 1360 |
| 1359 bool LayerTreeHost::LayerNeedsPushPropertiesForTesting(Layer* layer) { | 1361 bool LayerTreeHost::LayerNeedsPushPropertiesForTesting(Layer* layer) { |
| 1360 return layers_that_should_push_properties_.find(layer) != | 1362 const LayerSet& layers = layer_tree_.layers_that_should_push_properties(); |
| 1361 layers_that_should_push_properties_.end(); | 1363 return layers.find(layer) != layers.end(); |
| 1362 } | 1364 } |
| 1363 | 1365 |
| 1364 void LayerTreeHost::RegisterLayer(Layer* layer) { | 1366 void LayerTreeHost::RegisterLayer(Layer* layer) { |
| 1365 DCHECK(!LayerById(layer->id())); | 1367 DCHECK(!LayerById(layer->id())); |
| 1366 DCHECK(!in_paint_layer_contents_); | 1368 DCHECK(!in_paint_layer_contents_); |
| 1367 layer_id_map_[layer->id()] = layer; | 1369 layer_id_map_[layer->id()] = layer; |
| 1368 if (layer->element_id()) { | 1370 if (layer->element_id()) { |
| 1369 animation_host_->RegisterElement(layer->element_id(), | 1371 animation_host_->RegisterElement(layer->element_id(), |
| 1370 ElementListType::ACTIVE); | 1372 ElementListType::ACTIVE); |
| 1371 } | 1373 } |
| 1372 } | 1374 } |
| 1373 | 1375 |
| 1374 void LayerTreeHost::UnregisterLayer(Layer* layer) { | 1376 void LayerTreeHost::UnregisterLayer(Layer* layer) { |
| 1375 DCHECK(LayerById(layer->id())); | 1377 DCHECK(LayerById(layer->id())); |
| 1376 DCHECK(!in_paint_layer_contents_); | 1378 DCHECK(!in_paint_layer_contents_); |
| 1377 if (layer->element_id()) { | 1379 if (layer->element_id()) { |
| 1378 animation_host_->UnregisterElement(layer->element_id(), | 1380 animation_host_->UnregisterElement(layer->element_id(), |
| 1379 ElementListType::ACTIVE); | 1381 ElementListType::ACTIVE); |
| 1380 } | 1382 } |
| 1381 RemoveLayerShouldPushProperties(layer); | 1383 |
| 1384 layer_tree_.RemoveLayerShouldPushProperties(layer); | |
| 1382 layer_id_map_.erase(layer->id()); | 1385 layer_id_map_.erase(layer->id()); |
| 1383 } | 1386 } |
| 1384 | 1387 |
| 1385 bool LayerTreeHost::IsElementInList(ElementId element_id, | 1388 bool LayerTreeHost::IsElementInList(ElementId element_id, |
| 1386 ElementListType list_type) const { | 1389 ElementListType list_type) const { |
| 1387 return list_type == ElementListType::ACTIVE && LayerByElementId(element_id); | 1390 return list_type == ElementListType::ACTIVE && LayerByElementId(element_id); |
| 1388 } | 1391 } |
| 1389 | 1392 |
| 1390 void LayerTreeHost::SetMutatorsNeedCommit() { | 1393 void LayerTreeHost::SetMutatorsNeedCommit() { |
| 1391 SetNeedsCommit(); | 1394 SetNeedsCommit(); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1533 | 1536 |
| 1534 proto->set_needs_full_tree_sync(needs_full_tree_sync_); | 1537 proto->set_needs_full_tree_sync(needs_full_tree_sync_); |
| 1535 proto->set_needs_meta_info_recomputation(needs_meta_info_recomputation_); | 1538 proto->set_needs_meta_info_recomputation(needs_meta_info_recomputation_); |
| 1536 proto->set_source_frame_number(source_frame_number_); | 1539 proto->set_source_frame_number(source_frame_number_); |
| 1537 | 1540 |
| 1538 LayerProtoConverter::SerializeLayerHierarchy(root_layer_, | 1541 LayerProtoConverter::SerializeLayerHierarchy(root_layer_, |
| 1539 proto->mutable_root_layer()); | 1542 proto->mutable_root_layer()); |
| 1540 | 1543 |
| 1541 // layers_that_should_push_properties_ should be serialized before layer | 1544 // layers_that_should_push_properties_ should be serialized before layer |
| 1542 // properties because it is cleared during the properties serialization. | 1545 // properties because it is cleared during the properties serialization. |
| 1543 for (auto layer : layers_that_should_push_properties_) | 1546 layer_tree_.ToProtobuf(proto->mutable_layer_tree()); |
| 1544 proto->add_layers_that_should_push_properties(layer->id()); | |
| 1545 | 1547 |
| 1546 LayerProtoConverter::SerializeLayerProperties(this, | 1548 LayerProtoConverter::SerializeLayerProperties(this, |
| 1547 proto->mutable_layer_updates()); | 1549 proto->mutable_layer_updates()); |
| 1548 | 1550 |
| 1549 std::vector<PictureData> pictures = | 1551 std::vector<PictureData> pictures = |
| 1550 engine_picture_cache_->CalculateCacheUpdateAndFlush(); | 1552 engine_picture_cache_->CalculateCacheUpdateAndFlush(); |
| 1551 proto::PictureDataVectorToSkPicturesProto(pictures, | 1553 proto::PictureDataVectorToSkPicturesProto(pictures, |
| 1552 proto->mutable_pictures()); | 1554 proto->mutable_pictures()); |
| 1553 | 1555 |
| 1554 proto->set_hud_layer_id(hud_layer_ ? hud_layer_->id() : Layer::INVALID_ID); | 1556 proto->set_hud_layer_id(hud_layer_ ? hud_layer_->id() : Layer::INVALID_ID); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1614 source_frame_number_ = proto.source_frame_number(); | 1616 source_frame_number_ = proto.source_frame_number(); |
| 1615 | 1617 |
| 1616 // Layer hierarchy. | 1618 // Layer hierarchy. |
| 1617 scoped_refptr<Layer> new_root_layer = | 1619 scoped_refptr<Layer> new_root_layer = |
| 1618 LayerProtoConverter::DeserializeLayerHierarchy(root_layer_, | 1620 LayerProtoConverter::DeserializeLayerHierarchy(root_layer_, |
| 1619 proto.root_layer(), this); | 1621 proto.root_layer(), this); |
| 1620 if (root_layer_ != new_root_layer) { | 1622 if (root_layer_ != new_root_layer) { |
| 1621 root_layer_ = new_root_layer; | 1623 root_layer_ = new_root_layer; |
| 1622 } | 1624 } |
| 1623 | 1625 |
| 1624 for (auto layer_id : proto.layers_that_should_push_properties()) | 1626 layer_tree_.FromProtobuf(proto.layer_tree(), &layer_id_map_); |
| 1625 layers_that_should_push_properties_.insert(layer_id_map_[layer_id]); | |
| 1626 | 1627 |
| 1627 // Ensure ClientPictureCache contains all the necessary SkPictures before | 1628 // Ensure ClientPictureCache contains all the necessary SkPictures before |
| 1628 // deserializing the properties. | 1629 // deserializing the properties. |
| 1629 proto::SkPictures proto_pictures = proto.pictures(); | 1630 proto::SkPictures proto_pictures = proto.pictures(); |
| 1630 std::vector<PictureData> pictures = | 1631 std::vector<PictureData> pictures = |
| 1631 SkPicturesProtoToPictureDataVector(proto_pictures); | 1632 SkPicturesProtoToPictureDataVector(proto_pictures); |
| 1632 client_picture_cache_->ApplyCacheUpdate(pictures); | 1633 client_picture_cache_->ApplyCacheUpdate(pictures); |
| 1633 | 1634 |
| 1634 LayerProtoConverter::DeserializeLayerProperties(root_layer_.get(), | 1635 LayerProtoConverter::DeserializeLayerProperties(root_layer_.get(), |
| 1635 proto.layer_updates()); | 1636 proto.layer_updates()); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1698 int seq_num = property_trees_.sequence_number; | 1699 int seq_num = property_trees_.sequence_number; |
| 1699 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [seq_num](Layer* layer) { | 1700 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [seq_num](Layer* layer) { |
| 1700 layer->set_property_tree_sequence_number(seq_num); | 1701 layer->set_property_tree_sequence_number(seq_num); |
| 1701 }); | 1702 }); |
| 1702 | 1703 |
| 1703 surface_client_id_ = proto.surface_client_id(); | 1704 surface_client_id_ = proto.surface_client_id(); |
| 1704 next_surface_sequence_ = proto.next_surface_sequence(); | 1705 next_surface_sequence_ = proto.next_surface_sequence(); |
| 1705 } | 1706 } |
| 1706 | 1707 |
| 1707 } // namespace cc | 1708 } // namespace cc |
| OLD | NEW |