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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 frame_viewer_instrumentation::IsTracingLayerTreeSnapshots() && | 282 frame_viewer_instrumentation::IsTracingLayerTreeSnapshots() && |
| 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 DCHECK(host_impl->AdvanceSyncState(BEGINNING_SYNC)); | |
| 293 | |
| 292 LayerTreeImpl* sync_tree = host_impl->sync_tree(); | 294 LayerTreeImpl* sync_tree = host_impl->sync_tree(); |
| 293 | 295 |
| 294 if (next_commit_forces_redraw_) { | 296 if (next_commit_forces_redraw_) { |
| 295 sync_tree->ForceRedrawNextActivation(); | 297 sync_tree->ForceRedrawNextActivation(); |
| 296 next_commit_forces_redraw_ = false; | 298 next_commit_forces_redraw_ = false; |
| 297 } | 299 } |
| 298 if (next_commit_forces_recalculate_raster_scales_) { | 300 if (next_commit_forces_recalculate_raster_scales_) { |
| 299 sync_tree->ForceRecalculateRasterScales(); | 301 sync_tree->ForceRecalculateRasterScales(); |
| 300 next_commit_forces_recalculate_raster_scales_ = false; | 302 next_commit_forces_recalculate_raster_scales_ = false; |
| 301 } | 303 } |
| 302 | 304 |
| 303 sync_tree->set_source_frame_number(SourceFrameNumber()); | 305 sync_tree->set_source_frame_number(SourceFrameNumber()); |
| 304 | 306 |
| 305 if (needs_full_tree_sync_) | 307 if (needs_full_tree_sync_) |
| 306 TreeSynchronizer::SynchronizeTrees(root_layer(), sync_tree); | 308 TreeSynchronizer::SynchronizeTrees(root_layer(), sync_tree); |
| 307 | 309 |
| 308 PushPropertiesTo(sync_tree); | |
| 309 | |
| 310 sync_tree->PassSwapPromises(swap_promise_manager_.TakeSwapPromises()); | |
| 311 | |
| 312 host_impl->SetHasGpuRasterizationTrigger(has_gpu_rasterization_trigger_); | |
| 313 host_impl->SetContentIsSuitableForGpuRasterization( | |
| 314 content_is_suitable_for_gpu_rasterization_); | |
| 315 RecordGpuRasterizationHistogram(host_impl); | |
| 316 | |
| 317 host_impl->SetViewportSize(device_viewport_size_); | |
| 318 sync_tree->SetDeviceScaleFactor(device_scale_factor_); | |
| 319 host_impl->SetDebugState(debug_state_); | |
| 320 | |
| 321 if (did_navigate_) { | |
| 322 did_navigate_ = false; | |
| 323 host_impl->ClearImageCacheOnNavigation(); | |
| 324 } | |
| 325 | |
| 326 sync_tree->set_ui_resource_request_queue( | |
| 327 ui_resource_manager_->TakeUIResourcesRequests()); | |
| 328 | |
| 329 { | 310 { |
| 330 TRACE_EVENT0("cc", "LayerTreeHostInProcess::PushProperties"); | 311 TRACE_EVENT0("cc", "LayerTreeHostInProcess::PushProperties"); |
| 331 | 312 |
| 313 bool property_trees_changed_on_active_tree = | |
| 314 sync_tree->IsActiveTree() && sync_tree->property_trees()->changed; | |
| 315 // Property trees may store damage status. We preserve the sync tree damage | |
| 316 // status by pushing the damage status from sync tree property trees to main | |
| 317 // thread property trees or by moving it onto the layers. | |
| 318 if (root_layer_ && property_trees_changed_on_active_tree) { | |
| 319 if (property_trees_.sequence_number == | |
| 320 sync_tree->property_trees()->sequence_number) | |
| 321 sync_tree->property_trees()->PushChangeTrackingTo(&property_trees_); | |
| 322 else | |
| 323 sync_tree->MoveChangeTrackingToLayers(); | |
| 324 } | |
| 325 | |
| 326 PushPropertyTreesTo(sync_tree); | |
| 327 DCHECK(host_impl->AdvanceSyncState(SYNCED_PROPERTY_TREES)); | |
| 328 | |
| 332 TreeSynchronizer::PushLayerProperties(this, sync_tree); | 329 TreeSynchronizer::PushLayerProperties(this, sync_tree); |
| 330 DCHECK(host_impl->AdvanceSyncState(SYNCED_LAYER_PROPERTIES)); | |
| 331 | |
| 332 PushPropertiesTo(sync_tree); | |
|
chrishtr
2017/05/12 23:13:29
How about renaming this to PushLayerTreeHostProper
pdr.
2017/05/15 18:30:24
Done, we now do:
PushLayerTreePropertiesTo(sync_tr
| |
| 333 DCHECK(host_impl->AdvanceSyncState(SYNCED_LAYER_TREE_HOST_PROPERTIES)); | |
| 334 | |
| 335 sync_tree->PassSwapPromises(swap_promise_manager_.TakeSwapPromises()); | |
| 336 | |
| 337 host_impl->SetHasGpuRasterizationTrigger(has_gpu_rasterization_trigger_); | |
|
chrishtr
2017/05/12 23:13:29
Put this inside of PushPropertiesTo?
pdr.
2017/05/15 18:30:24
I put this in PushLayerTreeHostPropertiesTo. I thi
| |
| 338 host_impl->SetContentIsSuitableForGpuRasterization( | |
| 339 content_is_suitable_for_gpu_rasterization_); | |
| 340 RecordGpuRasterizationHistogram(host_impl); | |
| 341 | |
| 342 host_impl->SetViewportSize(device_viewport_size_); | |
| 343 sync_tree->SetDeviceScaleFactor(device_scale_factor_); | |
| 344 host_impl->SetDebugState(debug_state_); | |
| 345 | |
| 346 if (did_navigate_) { | |
| 347 did_navigate_ = false; | |
| 348 host_impl->ClearImageCacheOnNavigation(); | |
| 349 } | |
| 350 | |
| 351 sync_tree->set_ui_resource_request_queue( | |
| 352 ui_resource_manager_->TakeUIResourcesRequests()); | |
| 333 | 353 |
| 334 // This must happen after synchronizing property trees and after pushing | 354 // This must happen after synchronizing property trees and after pushing |
| 335 // properties, which updates the clobber_active_value flag. | 355 // properties, which updates the clobber_active_value flag. |
| 336 sync_tree->property_trees()->scroll_tree.PushScrollUpdatesFromMainThread( | 356 sync_tree->property_trees()->scroll_tree.PushScrollUpdatesFromMainThread( |
| 337 property_trees(), sync_tree); | 357 property_trees(), sync_tree); |
| 338 | 358 |
| 339 // This must happen after synchronizing property trees and after push | 359 // This must happen after synchronizing property trees and after push |
| 340 // properties, which updates property tree indices, but before animation | 360 // properties, which updates property tree indices, but before animation |
| 341 // host pushes properties as animation host push properties can change | 361 // host pushes properties as animation host push properties can change |
| 342 // Animation::InEffect and we want the old InEffect value for updating | 362 // Animation::InEffect and we want the old InEffect value for updating |
| 343 // property tree scrolling and animation. | 363 // property tree scrolling and animation. |
| 344 bool is_impl_side_update = false; | 364 bool is_impl_side_update = false; |
| 345 sync_tree->UpdatePropertyTreeScrollingAndAnimationFromMainThread( | 365 sync_tree->UpdatePropertyTreeScrollingAndAnimationFromMainThread( |
| 346 is_impl_side_update); | 366 is_impl_side_update); |
| 347 | 367 |
| 348 TRACE_EVENT0("cc", "LayerTreeHostInProcess::AnimationHost::PushProperties"); | 368 TRACE_EVENT0("cc", "LayerTreeHostInProcess::AnimationHost::PushProperties"); |
| 349 DCHECK(host_impl->mutator_host()); | 369 DCHECK(host_impl->mutator_host()); |
| 350 mutator_host_->PushPropertiesTo(host_impl->mutator_host()); | 370 mutator_host_->PushPropertiesTo(host_impl->mutator_host()); |
| 371 | |
| 372 DCHECK(host_impl->AdvanceSyncState(NOT_SYNCING)); | |
| 351 } | 373 } |
| 352 | 374 |
| 353 // Transfer image decode requests to the impl thread. | 375 // Transfer image decode requests to the impl thread. |
| 354 for (auto& request : queued_image_decodes_) | 376 for (auto& request : queued_image_decodes_) |
| 355 host_impl->QueueImageDecode(std::move(request.first), request.second); | 377 host_impl->QueueImageDecode(std::move(request.first), request.second); |
| 356 queued_image_decodes_.clear(); | 378 queued_image_decodes_.clear(); |
| 357 | 379 |
| 358 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); | 380 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); |
| 359 property_trees_.ResetAllChangeTracking(); | 381 property_trees_.ResetAllChangeTracking(); |
| 360 } | 382 } |
| (...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1115 needs_full_tree_sync_ = true; | 1137 needs_full_tree_sync_ = true; |
| 1116 property_trees_.needs_rebuild = true; | 1138 property_trees_.needs_rebuild = true; |
| 1117 SetNeedsCommit(); | 1139 SetNeedsCommit(); |
| 1118 } | 1140 } |
| 1119 | 1141 |
| 1120 void LayerTreeHost::SetPropertyTreesNeedRebuild() { | 1142 void LayerTreeHost::SetPropertyTreesNeedRebuild() { |
| 1121 property_trees_.needs_rebuild = true; | 1143 property_trees_.needs_rebuild = true; |
| 1122 SetNeedsUpdateLayers(); | 1144 SetNeedsUpdateLayers(); |
| 1123 } | 1145 } |
| 1124 | 1146 |
| 1147 void LayerTreeHost::PushPropertyTreesTo(LayerTreeImpl* tree_impl) { | |
|
chrishtr
2017/05/12 23:13:29
Inline this, or push change tracking down into thi
pdr.
2017/05/15 18:30:24
Moved change tracking down here.
For consistency,
| |
| 1148 tree_impl->SetPropertyTrees(&property_trees_); | |
| 1149 } | |
| 1150 | |
| 1125 void LayerTreeHost::PushPropertiesTo(LayerTreeImpl* tree_impl) { | 1151 void LayerTreeHost::PushPropertiesTo(LayerTreeImpl* tree_impl) { |
| 1126 tree_impl->set_needs_full_tree_sync(needs_full_tree_sync_); | 1152 tree_impl->set_needs_full_tree_sync(needs_full_tree_sync_); |
| 1127 needs_full_tree_sync_ = false; | 1153 needs_full_tree_sync_ = false; |
| 1128 | 1154 |
| 1129 if (hud_layer_.get()) { | 1155 if (hud_layer_.get()) { |
| 1130 LayerImpl* hud_impl = tree_impl->LayerById(hud_layer_->id()); | 1156 LayerImpl* hud_impl = tree_impl->LayerById(hud_layer_->id()); |
| 1131 tree_impl->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>(hud_impl)); | 1157 tree_impl->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>(hud_impl)); |
| 1132 } else { | 1158 } else { |
| 1133 tree_impl->set_hud_layer(nullptr); | 1159 tree_impl->set_hud_layer(nullptr); |
| 1134 } | 1160 } |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1153 page_scale_layer_->id(), inner_viewport_scroll_layer_->id(), | 1179 page_scale_layer_->id(), inner_viewport_scroll_layer_->id(), |
| 1154 outer_viewport_scroll_layer_ ? outer_viewport_scroll_layer_->id() | 1180 outer_viewport_scroll_layer_ ? outer_viewport_scroll_layer_->id() |
| 1155 : Layer::INVALID_ID); | 1181 : Layer::INVALID_ID); |
| 1156 DCHECK(inner_viewport_scroll_layer_->IsContainerForFixedPositionLayers()); | 1182 DCHECK(inner_viewport_scroll_layer_->IsContainerForFixedPositionLayers()); |
| 1157 } else { | 1183 } else { |
| 1158 tree_impl->ClearViewportLayers(); | 1184 tree_impl->ClearViewportLayers(); |
| 1159 } | 1185 } |
| 1160 | 1186 |
| 1161 tree_impl->RegisterSelection(selection_); | 1187 tree_impl->RegisterSelection(selection_); |
| 1162 | 1188 |
| 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( | 1189 tree_impl->PushPageScaleFromMainThread( |
| 1179 page_scale_factor_, min_page_scale_factor_, max_page_scale_factor_); | 1190 page_scale_factor_, min_page_scale_factor_, max_page_scale_factor_); |
| 1180 | 1191 |
| 1181 tree_impl->set_browser_controls_shrink_blink_size( | 1192 tree_impl->set_browser_controls_shrink_blink_size( |
| 1182 browser_controls_shrink_blink_size_); | 1193 browser_controls_shrink_blink_size_); |
| 1183 tree_impl->set_top_controls_height(top_controls_height_); | 1194 tree_impl->set_top_controls_height(top_controls_height_); |
| 1184 tree_impl->set_bottom_controls_height(bottom_controls_height_); | 1195 tree_impl->set_bottom_controls_height(bottom_controls_height_); |
| 1185 tree_impl->PushBrowserControlsFromMainThread(top_controls_shown_ratio_); | 1196 tree_impl->PushBrowserControlsFromMainThread(top_controls_shown_ratio_); |
| 1186 tree_impl->elastic_overscroll()->PushFromMainThread(elastic_overscroll_); | 1197 tree_impl->elastic_overscroll()->PushFromMainThread(elastic_overscroll_); |
| 1187 if (tree_impl->IsActiveTree()) | 1198 if (tree_impl->IsActiveTree()) |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1438 void LayerTreeHost::SetNeedsDisplayOnAllLayers() { | 1449 void LayerTreeHost::SetNeedsDisplayOnAllLayers() { |
| 1439 for (auto* layer : *this) | 1450 for (auto* layer : *this) |
| 1440 layer->SetNeedsDisplay(); | 1451 layer->SetNeedsDisplay(); |
| 1441 } | 1452 } |
| 1442 | 1453 |
| 1443 void LayerTreeHost::SetHasCopyRequest(bool has_copy_request) { | 1454 void LayerTreeHost::SetHasCopyRequest(bool has_copy_request) { |
| 1444 has_copy_request_ = has_copy_request; | 1455 has_copy_request_ = has_copy_request; |
| 1445 } | 1456 } |
| 1446 | 1457 |
| 1447 } // namespace cc | 1458 } // namespace cc |
| OLD | NEW |