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

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
« no previous file with comments | « cc/trees/layer_tree_host.h ('k') | cc/trees/layer_tree_host_impl.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 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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 sync_tree->set_ui_resource_request_queue(ui_resource_request_queue_); 459 sync_tree->set_ui_resource_request_queue(ui_resource_request_queue_);
460 ui_resource_request_queue_.clear(); 460 ui_resource_request_queue_.clear();
461 } 461 }
462 462
463 DCHECK(!sync_tree->ViewportSizeInvalid()); 463 DCHECK(!sync_tree->ViewportSizeInvalid());
464 464
465 sync_tree->set_has_ever_been_drawn(false); 465 sync_tree->set_has_ever_been_drawn(false);
466 466
467 { 467 {
468 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); 468 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties");
469 TreeSynchronizer::PushProperties(root_layer(), sync_tree->root_layer()); 469
470 TreeSynchronizer::PushLayerProperties(this, sync_tree);
470 471
471 TRACE_EVENT0("cc", "LayerTreeHost::AnimationHost::PushProperties"); 472 TRACE_EVENT0("cc", "LayerTreeHost::AnimationHost::PushProperties");
472 DCHECK(host_impl->animation_host()); 473 DCHECK(host_impl->animation_host());
473 animation_host_->PushPropertiesTo(host_impl->animation_host()); 474 animation_host_->PushPropertiesTo(host_impl->animation_host());
474 } 475 }
475 476
476 // This must happen after synchronizing property trees and after push 477 // This must happen after synchronizing property trees and after push
477 // properties, which updates property tree indices. 478 // properties, which updates property tree indices.
478 sync_tree->UpdatePropertyTreeScrollingAndAnimationFromMainThread(); 479 sync_tree->UpdatePropertyTreeScrollingAndAnimationFromMainThread();
479 480
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { 1216 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
1216 client_->RecordFrameTimingEvents(std::move(composite_events), 1217 client_->RecordFrameTimingEvents(std::move(composite_events),
1217 std::move(main_frame_events)); 1218 std::move(main_frame_events));
1218 } 1219 }
1219 1220
1220 Layer* LayerTreeHost::LayerById(int id) const { 1221 Layer* LayerTreeHost::LayerById(int id) const {
1221 LayerIdMap::const_iterator iter = layer_id_map_.find(id); 1222 LayerIdMap::const_iterator iter = layer_id_map_.find(id);
1222 return iter != layer_id_map_.end() ? iter->second : NULL; 1223 return iter != layer_id_map_.end() ? iter->second : NULL;
1223 } 1224 }
1224 1225
1226 void LayerTreeHost::AddLayerShouldPushProperties(Layer* layer) {
1227 layers_that_should_push_properties_.insert(layer);
1228 }
1229
1230 void LayerTreeHost::RemoveLayerShouldPushProperties(Layer* layer) {
1231 layers_that_should_push_properties_.erase(layer);
1232 }
1233
1234 std::unordered_set<Layer*>& LayerTreeHost::LayersThatShouldPushProperties() {
1235 return layers_that_should_push_properties_;
1236 }
1237
1238 bool LayerTreeHost::LayerNeedsPushPropertiesForTesting(Layer* layer) {
1239 return layers_that_should_push_properties_.find(layer) !=
1240 layers_that_should_push_properties_.end();
1241 }
1242
1225 void LayerTreeHost::RegisterLayer(Layer* layer) { 1243 void LayerTreeHost::RegisterLayer(Layer* layer) {
1226 DCHECK(!LayerById(layer->id())); 1244 DCHECK(!LayerById(layer->id()));
1227 DCHECK(!in_paint_layer_contents_); 1245 DCHECK(!in_paint_layer_contents_);
1228 layer_id_map_[layer->id()] = layer; 1246 layer_id_map_[layer->id()] = layer;
1229 animation_host_->RegisterLayer(layer->id(), LayerTreeType::ACTIVE); 1247 animation_host_->RegisterLayer(layer->id(), LayerTreeType::ACTIVE);
1230 } 1248 }
1231 1249
1232 void LayerTreeHost::UnregisterLayer(Layer* layer) { 1250 void LayerTreeHost::UnregisterLayer(Layer* layer) {
1233 DCHECK(LayerById(layer->id())); 1251 DCHECK(LayerById(layer->id()));
1234 DCHECK(!in_paint_layer_contents_); 1252 DCHECK(!in_paint_layer_contents_);
1235 animation_host_->UnregisterLayer(layer->id(), LayerTreeType::ACTIVE); 1253 animation_host_->UnregisterLayer(layer->id(), LayerTreeType::ACTIVE);
1254 RemoveLayerShouldPushProperties(layer);
1236 layer_id_map_.erase(layer->id()); 1255 layer_id_map_.erase(layer->id());
1237 } 1256 }
1238 1257
1239 bool LayerTreeHost::IsLayerInTree(int layer_id, LayerTreeType tree_type) const { 1258 bool LayerTreeHost::IsLayerInTree(int layer_id, LayerTreeType tree_type) const {
1240 return tree_type == LayerTreeType::ACTIVE && LayerById(layer_id); 1259 return tree_type == LayerTreeType::ACTIVE && LayerById(layer_id);
1241 } 1260 }
1242 1261
1243 void LayerTreeHost::SetMutatorsNeedCommit() { 1262 void LayerTreeHost::SetMutatorsNeedCommit() {
1244 SetNeedsCommit(); 1263 SetNeedsCommit();
1245 } 1264 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 // The LayerTreeHost on the server does not have an impl task runner. 1406 // The LayerTreeHost on the server does not have an impl task runner.
1388 return compositor_mode_ == CompositorMode::REMOTE && 1407 return compositor_mode_ == CompositorMode::REMOTE &&
1389 !task_runner_provider_->HasImplThread(); 1408 !task_runner_provider_->HasImplThread();
1390 } 1409 }
1391 1410
1392 bool LayerTreeHost::IsRemoteClient() const { 1411 bool LayerTreeHost::IsRemoteClient() const {
1393 return compositor_mode_ == CompositorMode::REMOTE && 1412 return compositor_mode_ == CompositorMode::REMOTE &&
1394 task_runner_provider_->HasImplThread(); 1413 task_runner_provider_->HasImplThread();
1395 } 1414 }
1396 1415
1397 void LayerTreeHost::ToProtobufForCommit(proto::LayerTreeHost* proto) const { 1416 void LayerTreeHost::ToProtobufForCommit(proto::LayerTreeHost* proto) {
1398 // Not all fields are serialized, as they are eiher not needed for a commit, 1417 // Not all fields are serialized, as they are either not needed for a commit,
1399 // or implementation isn't ready yet. 1418 // or implementation isn't ready yet.
1400 // Unsupported items: 1419 // Unsupported items:
1401 // - animations 1420 // - animations
1402 // - UI resources 1421 // - UI resources
1403 // - instrumentation of stats 1422 // - instrumentation of stats
1404 // - histograms 1423 // - histograms
1405 // Skipped items: 1424 // Skipped items:
1406 // - SwapPromise as they are mostly used for perf measurements. 1425 // - SwapPromise as they are mostly used for perf measurements.
1407 // - The bitmap and GPU memory related items. 1426 // - The bitmap and GPU memory related items.
1408 // Other notes: 1427 // Other notes:
1409 // - The output surfaces are only valid on the client-side so they are 1428 // - The output surfaces are only valid on the client-side so they are
1410 // therefore not serialized. 1429 // therefore not serialized.
1411 // - LayerTreeSettings are needed only during construction of the 1430 // - LayerTreeSettings are needed only during construction of the
1412 // LayerTreeHost, so they are serialized outside of the LayerTreeHost 1431 // LayerTreeHost, so they are serialized outside of the LayerTreeHost
1413 // serialization. 1432 // serialization.
1414 // - The |visible_| flag will be controlled from the client separately and 1433 // - The |visible_| flag will be controlled from the client separately and
1415 // will need special handling outside of the serialization of the 1434 // will need special handling outside of the serialization of the
1416 // LayerTreeHost. 1435 // LayerTreeHost.
1417 // TODO(nyquist): Figure out how to support animations. See crbug.com/570376. 1436 // TODO(nyquist): Figure out how to support animations. See crbug.com/570376.
1418 proto->set_needs_full_tree_sync(needs_full_tree_sync_); 1437 proto->set_needs_full_tree_sync(needs_full_tree_sync_);
1419 proto->set_needs_meta_info_recomputation(needs_meta_info_recomputation_); 1438 proto->set_needs_meta_info_recomputation(needs_meta_info_recomputation_);
1420 proto->set_source_frame_number(source_frame_number_); 1439 proto->set_source_frame_number(source_frame_number_);
1421 proto->set_meta_information_sequence_number( 1440 proto->set_meta_information_sequence_number(
1422 meta_information_sequence_number_); 1441 meta_information_sequence_number_);
1423 LayerProtoConverter::SerializeLayerHierarchy(root_layer_, 1442 LayerProtoConverter::SerializeLayerHierarchy(root_layer_,
1424 proto->mutable_root_layer()); 1443 proto->mutable_root_layer());
1425 LayerProtoConverter::SerializeLayerProperties(root_layer_.get(), 1444 // layers_that_should_push_properties_ should be serialized before layer
1445 // properties because it is cleared during the properties serialization.
1446 for (auto layer : layers_that_should_push_properties_)
1447 proto->add_layers_that_should_push_properties(layer->id());
1448 LayerProtoConverter::SerializeLayerProperties(this,
1426 proto->mutable_layer_updates()); 1449 proto->mutable_layer_updates());
1427 proto->set_hud_layer_id(hud_layer_ ? hud_layer_->id() : Layer::INVALID_ID); 1450 proto->set_hud_layer_id(hud_layer_ ? hud_layer_->id() : Layer::INVALID_ID);
1428 debug_state_.ToProtobuf(proto->mutable_debug_state()); 1451 debug_state_.ToProtobuf(proto->mutable_debug_state());
1429 SizeToProto(device_viewport_size_, proto->mutable_device_viewport_size()); 1452 SizeToProto(device_viewport_size_, proto->mutable_device_viewport_size());
1430 proto->set_top_controls_shrink_blink_size(top_controls_shrink_blink_size_); 1453 proto->set_top_controls_shrink_blink_size(top_controls_shrink_blink_size_);
1431 proto->set_top_controls_height(top_controls_height_); 1454 proto->set_top_controls_height(top_controls_height_);
1432 proto->set_top_controls_shown_ratio(top_controls_shown_ratio_); 1455 proto->set_top_controls_shown_ratio(top_controls_shown_ratio_);
1433 proto->set_device_scale_factor(device_scale_factor_); 1456 proto->set_device_scale_factor(device_scale_factor_);
1434 proto->set_painted_device_scale_factor(painted_device_scale_factor_); 1457 proto->set_painted_device_scale_factor(painted_device_scale_factor_);
1435 proto->set_page_scale_factor(page_scale_factor_); 1458 proto->set_page_scale_factor(page_scale_factor_);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 root_layer_->SetLayerTreeHost(nullptr); 1507 root_layer_->SetLayerTreeHost(nullptr);
1485 root_layer_ = new_root_layer; 1508 root_layer_ = new_root_layer;
1486 root_layer_->SetLayerTreeHost(this); 1509 root_layer_->SetLayerTreeHost(this);
1487 } 1510 }
1488 1511
1489 // Populate layer_id_map_ with the new layers. 1512 // Populate layer_id_map_ with the new layers.
1490 layer_id_map_.clear(); 1513 layer_id_map_.clear();
1491 LayerTreeHostCommon::CallFunctionForSubtree( 1514 LayerTreeHostCommon::CallFunctionForSubtree(
1492 root_layer(), 1515 root_layer(),
1493 [this](Layer* layer) { layer_id_map_[layer->id()] = layer; }); 1516 [this](Layer* layer) { layer_id_map_[layer->id()] = layer; });
1517 for (auto layer_id : proto.layers_that_should_push_properties())
1518 layers_that_should_push_properties_.insert(layer_id_map_[layer_id]);
1494 1519
1495 LayerProtoConverter::DeserializeLayerProperties(root_layer_.get(), 1520 LayerProtoConverter::DeserializeLayerProperties(root_layer_.get(),
1496 proto.layer_updates()); 1521 proto.layer_updates());
1497 1522
1498 debug_state_.FromProtobuf(proto.debug_state()); 1523 debug_state_.FromProtobuf(proto.debug_state());
1499 device_viewport_size_ = ProtoToSize(proto.device_viewport_size()); 1524 device_viewport_size_ = ProtoToSize(proto.device_viewport_size());
1500 top_controls_shrink_blink_size_ = proto.top_controls_shrink_blink_size(); 1525 top_controls_shrink_blink_size_ = proto.top_controls_shrink_blink_size();
1501 top_controls_height_ = proto.top_controls_height(); 1526 top_controls_height_ = proto.top_controls_height();
1502 top_controls_shown_ratio_ = proto.top_controls_shown_ratio(); 1527 top_controls_shown_ratio_ = proto.top_controls_shown_ratio();
1503 device_scale_factor_ = proto.device_scale_factor(); 1528 device_scale_factor_ = proto.device_scale_factor();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 LayerTreeHostCommon::CallFunctionForSubtree( 1577 LayerTreeHostCommon::CallFunctionForSubtree(
1553 root_layer(), [seq_num](Layer* layer) { 1578 root_layer(), [seq_num](Layer* layer) {
1554 layer->set_property_tree_sequence_number(seq_num); 1579 layer->set_property_tree_sequence_number(seq_num);
1555 }); 1580 });
1556 1581
1557 surface_id_namespace_ = proto.surface_id_namespace(); 1582 surface_id_namespace_ = proto.surface_id_namespace();
1558 next_surface_sequence_ = proto.next_surface_sequence(); 1583 next_surface_sequence_ = proto.next_surface_sequence();
1559 } 1584 }
1560 1585
1561 } // namespace cc 1586 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host.h ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698