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

Side by Side Diff: cc/trees/layer_tree_host.cc

Issue 1808373002: cc : Make tree synchronization independent of layer tree hierarchy (2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 sync_tree->set_ui_resource_request_queue(ui_resource_request_queue_); 475 sync_tree->set_ui_resource_request_queue(ui_resource_request_queue_);
476 ui_resource_request_queue_.clear(); 476 ui_resource_request_queue_.clear();
477 } 477 }
478 478
479 DCHECK(!sync_tree->ViewportSizeInvalid()); 479 DCHECK(!sync_tree->ViewportSizeInvalid());
480 480
481 sync_tree->set_has_ever_been_drawn(false); 481 sync_tree->set_has_ever_been_drawn(false);
482 482
483 { 483 {
484 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); 484 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties");
485 TreeSynchronizer::PushProperties(root_layer(), sync_tree->root_layer()); 485
486 std::unordered_set<Layer*> layers_that_should_push_properties =
487 layers_that_should_push_properties_;
488 for (auto layer : layers_that_should_push_properties) {
489 LayerImpl* sync_tree_layer = sync_tree->LayerById(layer->id());
490 DCHECK(sync_tree_layer);
491 layer->PushPropertiesTo(sync_tree_layer);
492 }
486 493
487 if (animation_host_) { 494 if (animation_host_) {
488 TRACE_EVENT0("cc", "LayerTreeHost::AnimationHost::PushProperties"); 495 TRACE_EVENT0("cc", "LayerTreeHost::AnimationHost::PushProperties");
489 DCHECK(host_impl->animation_host()); 496 DCHECK(host_impl->animation_host());
490 animation_host_->PushPropertiesTo(host_impl->animation_host()); 497 animation_host_->PushPropertiesTo(host_impl->animation_host());
491 } 498 }
492 } 499 }
493 500
494 // This must happen after synchronizing property trees and after push 501 // This must happen after synchronizing property trees and after push
495 // properties, which updates property tree indices. 502 // properties, which updates property tree indices.
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { 1259 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
1253 client_->RecordFrameTimingEvents(std::move(composite_events), 1260 client_->RecordFrameTimingEvents(std::move(composite_events),
1254 std::move(main_frame_events)); 1261 std::move(main_frame_events));
1255 } 1262 }
1256 1263
1257 Layer* LayerTreeHost::LayerById(int id) const { 1264 Layer* LayerTreeHost::LayerById(int id) const {
1258 LayerIdMap::const_iterator iter = layer_id_map_.find(id); 1265 LayerIdMap::const_iterator iter = layer_id_map_.find(id);
1259 return iter != layer_id_map_.end() ? iter->second : NULL; 1266 return iter != layer_id_map_.end() ? iter->second : NULL;
1260 } 1267 }
1261 1268
1269 void LayerTreeHost::AddLayerShouldPushProperties(Layer* layer) {
1270 layers_that_should_push_properties_.insert(layer);
1271 }
1272
1273 void LayerTreeHost::RemoveLayerShouldPushProperties(Layer* layer) {
1274 layers_that_should_push_properties_.erase(layer);
1275 }
1276
1277 std::unordered_set<Layer*>& LayerTreeHost::LayersThatShouldPushProperties() {
1278 return layers_that_should_push_properties_;
1279 }
1280
1281 bool LayerTreeHost::LayerNeedsPushPropertiesForTesting(Layer* layer) {
1282 return layers_that_should_push_properties_.find(layer) !=
1283 layers_that_should_push_properties_.end();
1284 }
1285
1262 void LayerTreeHost::RegisterLayer(Layer* layer) { 1286 void LayerTreeHost::RegisterLayer(Layer* layer) {
1263 DCHECK(!LayerById(layer->id())); 1287 DCHECK(!LayerById(layer->id()));
1264 DCHECK(!in_paint_layer_contents_); 1288 DCHECK(!in_paint_layer_contents_);
1265 layer_id_map_[layer->id()] = layer; 1289 layer_id_map_[layer->id()] = layer;
1266 if (animation_host_) 1290 if (animation_host_)
1267 animation_host_->RegisterLayer(layer->id(), LayerTreeType::ACTIVE); 1291 animation_host_->RegisterLayer(layer->id(), LayerTreeType::ACTIVE);
1268 } 1292 }
1269 1293
1270 void LayerTreeHost::UnregisterLayer(Layer* layer) { 1294 void LayerTreeHost::UnregisterLayer(Layer* layer) {
1271 DCHECK(LayerById(layer->id())); 1295 DCHECK(LayerById(layer->id()));
1272 DCHECK(!in_paint_layer_contents_); 1296 DCHECK(!in_paint_layer_contents_);
1297 RemoveLayerShouldPushProperties(layer);
ajuma 2016/03/18 14:33:16 Do we have a test that removes a layer needing pus
jaydasika 2016/03/19 02:17:58 There are many tests that check this implicitly. M
1273 if (animation_host_) 1298 if (animation_host_)
1274 animation_host_->UnregisterLayer(layer->id(), LayerTreeType::ACTIVE); 1299 animation_host_->UnregisterLayer(layer->id(), LayerTreeType::ACTIVE);
1275 layer_id_map_.erase(layer->id()); 1300 layer_id_map_.erase(layer->id());
1276 } 1301 }
1277 1302
1278 bool LayerTreeHost::IsLayerInTree(int layer_id, LayerTreeType tree_type) const { 1303 bool LayerTreeHost::IsLayerInTree(int layer_id, LayerTreeType tree_type) const {
1279 return tree_type == LayerTreeType::ACTIVE && LayerById(layer_id); 1304 return tree_type == LayerTreeType::ACTIVE && LayerById(layer_id);
1280 } 1305 }
1281 1306
1282 void LayerTreeHost::SetMutatorsNeedCommit() { 1307 void LayerTreeHost::SetMutatorsNeedCommit() {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 // The LayerTreeHost on the server does not have an impl task runner. 1477 // The LayerTreeHost on the server does not have an impl task runner.
1453 return compositor_mode_ == CompositorMode::REMOTE && 1478 return compositor_mode_ == CompositorMode::REMOTE &&
1454 !task_runner_provider_->HasImplThread(); 1479 !task_runner_provider_->HasImplThread();
1455 } 1480 }
1456 1481
1457 bool LayerTreeHost::IsRemoteClient() const { 1482 bool LayerTreeHost::IsRemoteClient() const {
1458 return compositor_mode_ == CompositorMode::REMOTE && 1483 return compositor_mode_ == CompositorMode::REMOTE &&
1459 task_runner_provider_->HasImplThread(); 1484 task_runner_provider_->HasImplThread();
1460 } 1485 }
1461 1486
1462 void LayerTreeHost::ToProtobufForCommit(proto::LayerTreeHost* proto) const { 1487 void LayerTreeHost::ToProtobufForCommit(proto::LayerTreeHost* proto) {
1463 // Not all fields are serialized, as they are eiher not needed for a commit, 1488 // Not all fields are serialized, as they are either not needed for a commit,
1464 // or implementation isn't ready yet. 1489 // or implementation isn't ready yet.
1465 // Unsupported items: 1490 // Unsupported items:
1466 // - animations 1491 // - animations
1467 // - UI resources 1492 // - UI resources
1468 // - instrumentation of stats 1493 // - instrumentation of stats
1469 // - histograms 1494 // - histograms
1470 // Skipped items: 1495 // Skipped items:
1471 // - SwapPromise as they are mostly used for perf measurements. 1496 // - SwapPromise as they are mostly used for perf measurements.
1472 // - The bitmap and GPU memory related items. 1497 // - The bitmap and GPU memory related items.
1473 // Other notes: 1498 // Other notes:
1474 // - The output surfaces are only valid on the client-side so they are 1499 // - The output surfaces are only valid on the client-side so they are
1475 // therefore not serialized. 1500 // therefore not serialized.
1476 // - LayerTreeSettings are needed only during construction of the 1501 // - LayerTreeSettings are needed only during construction of the
1477 // LayerTreeHost, so they are serialized outside of the LayerTreeHost 1502 // LayerTreeHost, so they are serialized outside of the LayerTreeHost
1478 // serialization. 1503 // serialization.
1479 // - The |visible_| flag will be controlled from the client separately and 1504 // - The |visible_| flag will be controlled from the client separately and
1480 // will need special handling outside of the serialization of the 1505 // will need special handling outside of the serialization of the
1481 // LayerTreeHost. 1506 // LayerTreeHost.
1482 // TODO(nyquist): Figure out how to support animations. See crbug.com/570376. 1507 // TODO(nyquist): Figure out how to support animations. See crbug.com/570376.
1483 proto->set_needs_full_tree_sync(needs_full_tree_sync_); 1508 proto->set_needs_full_tree_sync(needs_full_tree_sync_);
1484 proto->set_needs_meta_info_recomputation(needs_meta_info_recomputation_); 1509 proto->set_needs_meta_info_recomputation(needs_meta_info_recomputation_);
1485 proto->set_source_frame_number(source_frame_number_); 1510 proto->set_source_frame_number(source_frame_number_);
1486 proto->set_meta_information_sequence_number( 1511 proto->set_meta_information_sequence_number(
1487 meta_information_sequence_number_); 1512 meta_information_sequence_number_);
1488 LayerProtoConverter::SerializeLayerHierarchy(root_layer_, 1513 LayerProtoConverter::SerializeLayerHierarchy(root_layer_,
1489 proto->mutable_root_layer()); 1514 proto->mutable_root_layer());
1490 LayerProtoConverter::SerializeLayerProperties(root_layer_.get(), 1515 // layers_that_should_push_properties_ should be serialized before layer
1516 // properties because the it is cleared during the properties serialization.
1517 for (auto layer : layers_that_should_push_properties_)
1518 proto->add_layers_that_should_push_properties(layer->id());
1519 LayerProtoConverter::SerializeLayerProperties(this,
1491 proto->mutable_layer_updates()); 1520 proto->mutable_layer_updates());
1492 proto->set_hud_layer_id(hud_layer_ ? hud_layer_->id() : Layer::INVALID_ID); 1521 proto->set_hud_layer_id(hud_layer_ ? hud_layer_->id() : Layer::INVALID_ID);
1493 debug_state_.ToProtobuf(proto->mutable_debug_state()); 1522 debug_state_.ToProtobuf(proto->mutable_debug_state());
1494 SizeToProto(device_viewport_size_, proto->mutable_device_viewport_size()); 1523 SizeToProto(device_viewport_size_, proto->mutable_device_viewport_size());
1495 proto->set_top_controls_shrink_blink_size(top_controls_shrink_blink_size_); 1524 proto->set_top_controls_shrink_blink_size(top_controls_shrink_blink_size_);
1496 proto->set_top_controls_height(top_controls_height_); 1525 proto->set_top_controls_height(top_controls_height_);
1497 proto->set_top_controls_shown_ratio(top_controls_shown_ratio_); 1526 proto->set_top_controls_shown_ratio(top_controls_shown_ratio_);
1498 proto->set_device_scale_factor(device_scale_factor_); 1527 proto->set_device_scale_factor(device_scale_factor_);
1499 proto->set_painted_device_scale_factor(painted_device_scale_factor_); 1528 proto->set_painted_device_scale_factor(painted_device_scale_factor_);
1500 proto->set_page_scale_factor(page_scale_factor_); 1529 proto->set_page_scale_factor(page_scale_factor_);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 root_layer_->SetLayerTreeHost(nullptr); 1578 root_layer_->SetLayerTreeHost(nullptr);
1550 root_layer_ = new_root_layer; 1579 root_layer_ = new_root_layer;
1551 root_layer_->SetLayerTreeHost(this); 1580 root_layer_->SetLayerTreeHost(this);
1552 } 1581 }
1553 1582
1554 // Populate layer_id_map_ with the new layers. 1583 // Populate layer_id_map_ with the new layers.
1555 layer_id_map_.clear(); 1584 layer_id_map_.clear();
1556 LayerTreeHostCommon::CallFunctionForSubtree( 1585 LayerTreeHostCommon::CallFunctionForSubtree(
1557 root_layer(), 1586 root_layer(),
1558 [this](Layer* layer) { layer_id_map_[layer->id()] = layer; }); 1587 [this](Layer* layer) { layer_id_map_[layer->id()] = layer; });
1588 for (auto layer_id : proto.layers_that_should_push_properties())
1589 layers_that_should_push_properties_.insert(layer_id_map_[layer_id]);
1559 1590
1560 LayerProtoConverter::DeserializeLayerProperties(root_layer_.get(), 1591 LayerProtoConverter::DeserializeLayerProperties(root_layer_.get(),
1561 proto.layer_updates()); 1592 proto.layer_updates());
1562 1593
1563 debug_state_.FromProtobuf(proto.debug_state()); 1594 debug_state_.FromProtobuf(proto.debug_state());
1564 device_viewport_size_ = ProtoToSize(proto.device_viewport_size()); 1595 device_viewport_size_ = ProtoToSize(proto.device_viewport_size());
1565 top_controls_shrink_blink_size_ = proto.top_controls_shrink_blink_size(); 1596 top_controls_shrink_blink_size_ = proto.top_controls_shrink_blink_size();
1566 top_controls_height_ = proto.top_controls_height(); 1597 top_controls_height_ = proto.top_controls_height();
1567 top_controls_shown_ratio_ = proto.top_controls_shown_ratio(); 1598 top_controls_shown_ratio_ = proto.top_controls_shown_ratio();
1568 device_scale_factor_ = proto.device_scale_factor(); 1599 device_scale_factor_ = proto.device_scale_factor();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 LayerTreeHostCommon::CallFunctionForSubtree( 1648 LayerTreeHostCommon::CallFunctionForSubtree(
1618 root_layer(), [seq_num](Layer* layer) { 1649 root_layer(), [seq_num](Layer* layer) {
1619 layer->set_property_tree_sequence_number(seq_num); 1650 layer->set_property_tree_sequence_number(seq_num);
1620 }); 1651 });
1621 1652
1622 surface_id_namespace_ = proto.surface_id_namespace(); 1653 surface_id_namespace_ = proto.surface_id_namespace();
1623 next_surface_sequence_ = proto.next_surface_sequence(); 1654 next_surface_sequence_ = proto.next_surface_sequence();
1624 } 1655 }
1625 1656
1626 } // namespace cc 1657 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698