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

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

Issue 2873313004: Harmonize LayerTreeHost/LayerTreeHostImpl synchronization steps (Closed)
Patch Set: Ace of rebase Created 3 years, 7 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 root_layer()) { 283 root_layer()) {
284 // We'll be dumping layer trees as part of trace, so make sure 284 // We'll be dumping layer trees as part of trace, so make sure
285 // PushPropertiesTo() propagates layer debug info to the impl side -- 285 // PushPropertiesTo() propagates layer debug info to the impl side --
286 // otherwise this won't happen for the layers that remain unchanged since 286 // otherwise this won't happen for the layers that remain unchanged since
287 // tracing started. 287 // tracing started.
288 LayerTreeHostCommon::CallFunctionForEveryLayer( 288 LayerTreeHostCommon::CallFunctionForEveryLayer(
289 this, [](Layer* layer) { layer->SetNeedsPushProperties(); }); 289 this, [](Layer* layer) { layer->SetNeedsPushProperties(); });
290 } 290 }
291 291
292 LayerTreeImpl* sync_tree = host_impl->sync_tree(); 292 LayerTreeImpl* sync_tree = host_impl->sync_tree();
293 sync_tree->lifecycle().AdvanceTo(LayerTreeLifecycle::kBeginningSync);
293 294
294 if (next_commit_forces_redraw_) { 295 if (next_commit_forces_redraw_) {
295 sync_tree->ForceRedrawNextActivation(); 296 sync_tree->ForceRedrawNextActivation();
296 next_commit_forces_redraw_ = false; 297 next_commit_forces_redraw_ = false;
297 } 298 }
298 if (next_commit_forces_recalculate_raster_scales_) { 299 if (next_commit_forces_recalculate_raster_scales_) {
299 sync_tree->ForceRecalculateRasterScales(); 300 sync_tree->ForceRecalculateRasterScales();
300 next_commit_forces_recalculate_raster_scales_ = false; 301 next_commit_forces_recalculate_raster_scales_ = false;
301 } 302 }
302 303
303 sync_tree->set_source_frame_number(SourceFrameNumber()); 304 sync_tree->set_source_frame_number(SourceFrameNumber());
304 305
305 if (needs_full_tree_sync_) 306 if (needs_full_tree_sync_)
306 TreeSynchronizer::SynchronizeTrees(root_layer(), sync_tree); 307 TreeSynchronizer::SynchronizeTrees(root_layer(), sync_tree);
307 308
308 // Track the navigation state before pushing properties since it overwrites 309 // Track the navigation state before pushing properties since it overwrites
309 // the |content_source_id_| on the sync tree. 310 // the |content_source_id_| on the sync tree.
310 bool did_navigate = content_source_id_ != sync_tree->content_source_id(); 311 bool did_navigate = content_source_id_ != sync_tree->content_source_id();
311 if (did_navigate) 312 if (did_navigate)
312 host_impl->ClearImageCacheOnNavigation(); 313 host_impl->ClearImageCacheOnNavigation();
313 314
314 PushPropertiesTo(sync_tree);
315
316 sync_tree->PassSwapPromises(swap_promise_manager_.TakeSwapPromises());
317
318 host_impl->SetHasGpuRasterizationTrigger(has_gpu_rasterization_trigger_);
319 host_impl->SetContentIsSuitableForGpuRasterization(
320 content_is_suitable_for_gpu_rasterization_);
321 RecordGpuRasterizationHistogram(host_impl);
322
323 host_impl->SetViewportSize(device_viewport_size_);
324 sync_tree->SetDeviceScaleFactor(device_scale_factor_);
325 host_impl->SetDebugState(debug_state_);
326
327 sync_tree->set_ui_resource_request_queue(
328 ui_resource_manager_->TakeUIResourcesRequests());
329
330 { 315 {
331 TRACE_EVENT0("cc", "LayerTreeHostInProcess::PushProperties"); 316 TRACE_EVENT0("cc", "LayerTreeHostInProcess::PushProperties");
332 317
318 PushPropertyTreesTo(sync_tree);
319 sync_tree->lifecycle().AdvanceTo(LayerTreeLifecycle::kSyncedPropertyTrees);
320
333 TreeSynchronizer::PushLayerProperties(this, sync_tree); 321 TreeSynchronizer::PushLayerProperties(this, sync_tree);
322 sync_tree->lifecycle().AdvanceTo(
323 LayerTreeLifecycle::kSyncedLayerProperties);
324
325 PushLayerTreePropertiesTo(sync_tree);
326 PushLayerTreeHostPropertiesTo(host_impl);
327
328 sync_tree->PassSwapPromises(swap_promise_manager_.TakeSwapPromises());
329
330 // TODO(pdr): Move this into PushPropertyTreesTo or introduce a lifecycle
331 // state for it.
332 sync_tree->SetDeviceScaleFactor(device_scale_factor_);
333
334 sync_tree->set_ui_resource_request_queue(
335 ui_resource_manager_->TakeUIResourcesRequests());
334 336
335 // This must happen after synchronizing property trees and after pushing 337 // This must happen after synchronizing property trees and after pushing
336 // properties, which updates the clobber_active_value flag. 338 // properties, which updates the clobber_active_value flag.
339 // TODO(pdr): Enforce this comment with DCHECKS and a lifecycle state.
337 sync_tree->property_trees()->scroll_tree.PushScrollUpdatesFromMainThread( 340 sync_tree->property_trees()->scroll_tree.PushScrollUpdatesFromMainThread(
338 property_trees(), sync_tree); 341 property_trees(), sync_tree);
339 342
340 // This must happen after synchronizing property trees and after push 343 // This must happen after synchronizing property trees and after push
341 // properties, which updates property tree indices, but before animation 344 // properties, which updates property tree indices, but before animation
342 // host pushes properties as animation host push properties can change 345 // host pushes properties as animation host push properties can change
343 // Animation::InEffect and we want the old InEffect value for updating 346 // Animation::InEffect and we want the old InEffect value for updating
344 // property tree scrolling and animation. 347 // property tree scrolling and animation.
348 // TODO(pdr): Enforce this comment with DCHECKS and a lifecycle state.
345 bool is_impl_side_update = false; 349 bool is_impl_side_update = false;
346 sync_tree->UpdatePropertyTreeScrollingAndAnimationFromMainThread( 350 sync_tree->UpdatePropertyTreeScrollingAndAnimationFromMainThread(
347 is_impl_side_update); 351 is_impl_side_update);
348 352
349 TRACE_EVENT0("cc", "LayerTreeHostInProcess::AnimationHost::PushProperties"); 353 TRACE_EVENT0("cc", "LayerTreeHostInProcess::AnimationHost::PushProperties");
350 DCHECK(host_impl->mutator_host()); 354 DCHECK(host_impl->mutator_host());
351 mutator_host_->PushPropertiesTo(host_impl->mutator_host()); 355 mutator_host_->PushPropertiesTo(host_impl->mutator_host());
356
357 sync_tree->lifecycle().AdvanceTo(LayerTreeLifecycle::kNotSyncing);
352 } 358 }
353 359
354 // Transfer image decode requests to the impl thread. 360 // Transfer image decode requests to the impl thread.
355 for (auto& request : queued_image_decodes_) 361 for (auto& request : queued_image_decodes_)
356 host_impl->QueueImageDecode(std::move(request.first), request.second); 362 host_impl->QueueImageDecode(std::move(request.first), request.second);
357 queued_image_decodes_.clear(); 363 queued_image_decodes_.clear();
358 364
359 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); 365 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl);
360 property_trees_.ResetAllChangeTracking(); 366 property_trees_.ResetAllChangeTracking();
361 } 367 }
362 368
369 void LayerTreeHost::PushPropertyTreesTo(LayerTreeImpl* tree_impl) {
370 bool property_trees_changed_on_active_tree =
371 tree_impl->IsActiveTree() && tree_impl->property_trees()->changed;
372 // Property trees may store damage status. We preserve the sync tree damage
373 // status by pushing the damage status from sync tree property trees to main
374 // thread property trees or by moving it onto the layers.
375 if (root_layer_ && property_trees_changed_on_active_tree) {
376 if (property_trees_.sequence_number ==
377 tree_impl->property_trees()->sequence_number)
378 tree_impl->property_trees()->PushChangeTrackingTo(&property_trees_);
379 else
380 tree_impl->MoveChangeTrackingToLayers();
381 }
382
383 tree_impl->SetPropertyTrees(&property_trees_);
384 }
385
363 void LayerTreeHost::WillCommit() { 386 void LayerTreeHost::WillCommit() {
364 swap_promise_manager_.WillCommit(); 387 swap_promise_manager_.WillCommit();
365 client_->WillCommit(); 388 client_->WillCommit();
366 } 389 }
367 390
368 391
369 void LayerTreeHost::UpdateDeferCommitsInternal() { 392 void LayerTreeHost::UpdateDeferCommitsInternal() {
370 proxy_->SetDeferCommits(defer_commits_ || 393 proxy_->SetDeferCommits(defer_commits_ ||
371 (settings_.enable_surface_synchronization && 394 (settings_.enable_surface_synchronization &&
372 !local_surface_id_.is_valid())); 395 !local_surface_id_.is_valid()));
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 needs_full_tree_sync_ = true; 1138 needs_full_tree_sync_ = true;
1116 property_trees_.needs_rebuild = true; 1139 property_trees_.needs_rebuild = true;
1117 SetNeedsCommit(); 1140 SetNeedsCommit();
1118 } 1141 }
1119 1142
1120 void LayerTreeHost::SetPropertyTreesNeedRebuild() { 1143 void LayerTreeHost::SetPropertyTreesNeedRebuild() {
1121 property_trees_.needs_rebuild = true; 1144 property_trees_.needs_rebuild = true;
1122 SetNeedsUpdateLayers(); 1145 SetNeedsUpdateLayers();
1123 } 1146 }
1124 1147
1125 void LayerTreeHost::PushPropertiesTo(LayerTreeImpl* tree_impl) { 1148 void LayerTreeHost::PushLayerTreePropertiesTo(LayerTreeImpl* tree_impl) {
1126 tree_impl->set_needs_full_tree_sync(needs_full_tree_sync_); 1149 tree_impl->set_needs_full_tree_sync(needs_full_tree_sync_);
1127 needs_full_tree_sync_ = false; 1150 needs_full_tree_sync_ = false;
1128 1151
1129 if (hud_layer_.get()) { 1152 if (hud_layer_.get()) {
1130 LayerImpl* hud_impl = tree_impl->LayerById(hud_layer_->id()); 1153 LayerImpl* hud_impl = tree_impl->LayerById(hud_layer_->id());
1131 tree_impl->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>(hud_impl)); 1154 tree_impl->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>(hud_impl));
1132 } else { 1155 } else {
1133 tree_impl->set_hud_layer(nullptr); 1156 tree_impl->set_hud_layer(nullptr);
1134 } 1157 }
1135 1158
(...skipping 17 matching lines...) Expand all
1153 page_scale_layer_->id(), inner_viewport_scroll_layer_->id(), 1176 page_scale_layer_->id(), inner_viewport_scroll_layer_->id(),
1154 outer_viewport_scroll_layer_ ? outer_viewport_scroll_layer_->id() 1177 outer_viewport_scroll_layer_ ? outer_viewport_scroll_layer_->id()
1155 : Layer::INVALID_ID); 1178 : Layer::INVALID_ID);
1156 DCHECK(inner_viewport_scroll_layer_->IsContainerForFixedPositionLayers()); 1179 DCHECK(inner_viewport_scroll_layer_->IsContainerForFixedPositionLayers());
1157 } else { 1180 } else {
1158 tree_impl->ClearViewportLayers(); 1181 tree_impl->ClearViewportLayers();
1159 } 1182 }
1160 1183
1161 tree_impl->RegisterSelection(selection_); 1184 tree_impl->RegisterSelection(selection_);
1162 1185
1163 bool property_trees_changed_on_active_tree =
1164 tree_impl->IsActiveTree() && tree_impl->property_trees()->changed;
1165 // Property trees may store damage status. We preserve the sync tree damage
1166 // status by pushing the damage status from sync tree property trees to main
1167 // thread property trees or by moving it onto the layers.
1168 if (root_layer_ && property_trees_changed_on_active_tree) {
1169 if (property_trees_.sequence_number ==
1170 tree_impl->property_trees()->sequence_number)
1171 tree_impl->property_trees()->PushChangeTrackingTo(&property_trees_);
1172 else
1173 tree_impl->MoveChangeTrackingToLayers();
1174 }
1175 // Setting property trees must happen before pushing the page scale.
1176 tree_impl->SetPropertyTrees(&property_trees_);
1177
1178 tree_impl->PushPageScaleFromMainThread( 1186 tree_impl->PushPageScaleFromMainThread(
1179 page_scale_factor_, min_page_scale_factor_, max_page_scale_factor_); 1187 page_scale_factor_, min_page_scale_factor_, max_page_scale_factor_);
1180 1188
1181 tree_impl->set_browser_controls_shrink_blink_size( 1189 tree_impl->set_browser_controls_shrink_blink_size(
1182 browser_controls_shrink_blink_size_); 1190 browser_controls_shrink_blink_size_);
1183 tree_impl->set_top_controls_height(top_controls_height_); 1191 tree_impl->set_top_controls_height(top_controls_height_);
1184 tree_impl->set_bottom_controls_height(bottom_controls_height_); 1192 tree_impl->set_bottom_controls_height(bottom_controls_height_);
1185 tree_impl->PushBrowserControlsFromMainThread(top_controls_shown_ratio_); 1193 tree_impl->PushBrowserControlsFromMainThread(top_controls_shown_ratio_);
1186 tree_impl->elastic_overscroll()->PushFromMainThread(elastic_overscroll_); 1194 tree_impl->elastic_overscroll()->PushFromMainThread(elastic_overscroll_);
1187 if (tree_impl->IsActiveTree()) 1195 if (tree_impl->IsActiveTree())
(...skipping 10 matching lines...) Expand all
1198 if (pending_page_scale_animation_) { 1206 if (pending_page_scale_animation_) {
1199 tree_impl->SetPendingPageScaleAnimation( 1207 tree_impl->SetPendingPageScaleAnimation(
1200 std::move(pending_page_scale_animation_)); 1208 std::move(pending_page_scale_animation_));
1201 } 1209 }
1202 1210
1203 DCHECK(!tree_impl->ViewportSizeInvalid()); 1211 DCHECK(!tree_impl->ViewportSizeInvalid());
1204 1212
1205 tree_impl->set_has_ever_been_drawn(false); 1213 tree_impl->set_has_ever_been_drawn(false);
1206 } 1214 }
1207 1215
1216 void LayerTreeHost::PushLayerTreeHostPropertiesTo(
1217 LayerTreeHostImpl* host_impl) {
1218 host_impl->SetHasGpuRasterizationTrigger(has_gpu_rasterization_trigger_);
1219 host_impl->SetContentIsSuitableForGpuRasterization(
1220 content_is_suitable_for_gpu_rasterization_);
1221 RecordGpuRasterizationHistogram(host_impl);
1222
1223 host_impl->SetViewportSize(device_viewport_size_);
1224 host_impl->SetDebugState(debug_state_);
1225 }
1226
1208 Layer* LayerTreeHost::LayerByElementId(ElementId element_id) const { 1227 Layer* LayerTreeHost::LayerByElementId(ElementId element_id) const {
1209 auto iter = element_layers_map_.find(element_id); 1228 auto iter = element_layers_map_.find(element_id);
1210 return iter != element_layers_map_.end() ? iter->second : nullptr; 1229 return iter != element_layers_map_.end() ? iter->second : nullptr;
1211 } 1230 }
1212 1231
1213 void LayerTreeHost::RegisterElement(ElementId element_id, 1232 void LayerTreeHost::RegisterElement(ElementId element_id,
1214 ElementListType list_type, 1233 ElementListType list_type,
1215 Layer* layer) { 1234 Layer* layer) {
1216 if (layer->element_id()) { 1235 if (layer->element_id()) {
1217 element_layers_map_[layer->element_id()] = layer; 1236 element_layers_map_[layer->element_id()] = layer;
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 void LayerTreeHost::SetNeedsDisplayOnAllLayers() { 1475 void LayerTreeHost::SetNeedsDisplayOnAllLayers() {
1457 for (auto* layer : *this) 1476 for (auto* layer : *this)
1458 layer->SetNeedsDisplay(); 1477 layer->SetNeedsDisplay();
1459 } 1478 }
1460 1479
1461 void LayerTreeHost::SetHasCopyRequest(bool has_copy_request) { 1480 void LayerTreeHost::SetHasCopyRequest(bool has_copy_request) {
1462 has_copy_request_ = has_copy_request; 1481 has_copy_request_ = has_copy_request;
1463 } 1482 }
1464 1483
1465 } // namespace cc 1484 } // 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