| 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_in_process.h" | 5 #include "cc/trees/layer_tree_host_in_process.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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 if (next_commit_forces_recalculate_raster_scales_) { | 295 if (next_commit_forces_recalculate_raster_scales_) { |
| 296 sync_tree->ForceRecalculateRasterScales(); | 296 sync_tree->ForceRecalculateRasterScales(); |
| 297 next_commit_forces_recalculate_raster_scales_ = false; | 297 next_commit_forces_recalculate_raster_scales_ = false; |
| 298 } | 298 } |
| 299 | 299 |
| 300 sync_tree->set_source_frame_number(SourceFrameNumber()); | 300 sync_tree->set_source_frame_number(SourceFrameNumber()); |
| 301 | 301 |
| 302 if (layer_tree_->needs_full_tree_sync()) | 302 if (layer_tree_->needs_full_tree_sync()) |
| 303 TreeSynchronizer::SynchronizeTrees(layer_tree_->root_layer(), sync_tree); | 303 TreeSynchronizer::SynchronizeTrees(layer_tree_->root_layer(), sync_tree); |
| 304 | 304 |
| 305 float page_scale_delta = 1.f; | 305 layer_tree_->PushPropertiesTo(sync_tree); |
| 306 if (reflected_main_frame_state_) | |
| 307 page_scale_delta = reflected_main_frame_state_->page_scale_delta; | |
| 308 layer_tree_->PushPropertiesTo(sync_tree, page_scale_delta); | |
| 309 | 306 |
| 310 sync_tree->PassSwapPromises(swap_promise_manager_.TakeSwapPromises()); | 307 sync_tree->PassSwapPromises(swap_promise_manager_.TakeSwapPromises()); |
| 311 | 308 |
| 312 host_impl->SetHasGpuRasterizationTrigger(has_gpu_rasterization_trigger_); | 309 host_impl->SetHasGpuRasterizationTrigger(has_gpu_rasterization_trigger_); |
| 313 host_impl->SetContentIsSuitableForGpuRasterization( | 310 host_impl->SetContentIsSuitableForGpuRasterization( |
| 314 content_is_suitable_for_gpu_rasterization_); | 311 content_is_suitable_for_gpu_rasterization_); |
| 315 RecordGpuRasterizationHistogram(); | 312 RecordGpuRasterizationHistogram(); |
| 316 | 313 |
| 317 host_impl->SetViewportSize(layer_tree_->device_viewport_size()); | 314 host_impl->SetViewportSize(layer_tree_->device_viewport_size()); |
| 318 sync_tree->SetDeviceScaleFactor(layer_tree_->device_scale_factor()); | 315 sync_tree->SetDeviceScaleFactor(layer_tree_->device_scale_factor()); |
| 319 host_impl->SetDebugState(debug_state_); | 316 host_impl->SetDebugState(debug_state_); |
| 320 | 317 |
| 321 sync_tree->set_ui_resource_request_queue( | 318 sync_tree->set_ui_resource_request_queue( |
| 322 ui_resource_manager_->TakeUIResourcesRequests()); | 319 ui_resource_manager_->TakeUIResourcesRequests()); |
| 323 | 320 |
| 324 { | 321 { |
| 325 TRACE_EVENT0("cc", "LayerTreeHostInProcess::PushProperties"); | 322 TRACE_EVENT0("cc", "LayerTreeHostInProcess::PushProperties"); |
| 326 | 323 |
| 327 TreeSynchronizer::PushLayerProperties(layer_tree_.get(), sync_tree); | 324 TreeSynchronizer::PushLayerProperties(layer_tree_.get(), sync_tree); |
| 328 | 325 |
| 329 if (reflected_main_frame_state_) { | |
| 330 for (const auto& scroll_update : reflected_main_frame_state_->scrolls) { | |
| 331 int layer_id = scroll_update.layer_id; | |
| 332 gfx::Vector2dF scroll_delta = scroll_update.scroll_delta; | |
| 333 | |
| 334 PropertyTrees* property_trees = layer_tree_->property_trees(); | |
| 335 property_trees->scroll_tree.SetScrollOffset( | |
| 336 layer_id, gfx::ScrollOffsetWithDelta( | |
| 337 layer_tree_->LayerById(layer_id)->scroll_offset(), | |
| 338 scroll_delta)); | |
| 339 } | |
| 340 } | |
| 341 | |
| 342 // This must happen after synchronizing property trees and after pushing | 326 // This must happen after synchronizing property trees and after pushing |
| 343 // properties, which updates the clobber_active_value flag. | 327 // properties, which updates the clobber_active_value flag. |
| 344 sync_tree->property_trees()->scroll_tree.PushScrollUpdatesFromMainThread( | 328 sync_tree->property_trees()->scroll_tree.PushScrollUpdatesFromMainThread( |
| 345 layer_tree_->property_trees(), sync_tree); | 329 layer_tree_->property_trees(), sync_tree); |
| 346 | 330 |
| 347 // This must happen after synchronizing property trees and after push | 331 // This must happen after synchronizing property trees and after push |
| 348 // properties, which updates property tree indices, but before animation | 332 // properties, which updates property tree indices, but before animation |
| 349 // host pushes properties as animation host push properties can change | 333 // host pushes properties as animation host push properties can change |
| 350 // Animation::InEffect and we want the old InEffect value for updating | 334 // Animation::InEffect and we want the old InEffect value for updating |
| 351 // property tree scrolling and animation. | 335 // property tree scrolling and animation. |
| 352 sync_tree->UpdatePropertyTreeScrollingAndAnimationFromMainThread(); | 336 sync_tree->UpdatePropertyTreeScrollingAndAnimationFromMainThread(); |
| 353 | 337 |
| 354 TRACE_EVENT0("cc", "LayerTreeHostInProcess::AnimationHost::PushProperties"); | 338 TRACE_EVENT0("cc", "LayerTreeHostInProcess::AnimationHost::PushProperties"); |
| 355 DCHECK(host_impl->mutator_host()); | 339 DCHECK(host_impl->mutator_host()); |
| 356 layer_tree_->mutator_host()->PushPropertiesTo(host_impl->mutator_host()); | 340 layer_tree_->mutator_host()->PushPropertiesTo(host_impl->mutator_host()); |
| 357 } | 341 } |
| 358 | 342 |
| 359 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); | 343 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); |
| 360 layer_tree_->property_trees()->ResetAllChangeTracking(); | 344 layer_tree_->property_trees()->ResetAllChangeTracking(); |
| 361 reflected_main_frame_state_ = nullptr; | |
| 362 } | 345 } |
| 363 | 346 |
| 364 void LayerTreeHostInProcess::WillCommit() { | 347 void LayerTreeHostInProcess::WillCommit() { |
| 365 swap_promise_manager_.WillCommit(); | 348 swap_promise_manager_.WillCommit(); |
| 366 client_->WillCommit(); | 349 client_->WillCommit(); |
| 367 } | 350 } |
| 368 | 351 |
| 369 void LayerTreeHostInProcess::UpdateHudLayer() {} | 352 void LayerTreeHostInProcess::UpdateHudLayer() {} |
| 370 | 353 |
| 371 void LayerTreeHostInProcess::CommitComplete() { | 354 void LayerTreeHostInProcess::CommitComplete() { |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 layer->SetScrollbarsHiddenFromImplSide(info->scrollbars[i].hidden); | 753 layer->SetScrollbarsHiddenFromImplSide(info->scrollbars[i].hidden); |
| 771 } | 754 } |
| 772 } | 755 } |
| 773 | 756 |
| 774 // This needs to happen after scroll deltas have been sent to prevent top | 757 // This needs to happen after scroll deltas have been sent to prevent top |
| 775 // controls from clamping the layout viewport both on the compositor and | 758 // controls from clamping the layout viewport both on the compositor and |
| 776 // on the main thread. | 759 // on the main thread. |
| 777 ApplyViewportDeltas(info); | 760 ApplyViewportDeltas(info); |
| 778 } | 761 } |
| 779 | 762 |
| 780 void LayerTreeHostInProcess::SetReflectedMainFrameState( | |
| 781 std::unique_ptr<ReflectedMainFrameState> reflected_main_frame_state) { | |
| 782 DCHECK(IsThreaded()); | |
| 783 | |
| 784 reflected_main_frame_state_ = std::move(reflected_main_frame_state); | |
| 785 SetNeedsCommit(); | |
| 786 } | |
| 787 | |
| 788 const base::WeakPtr<InputHandler>& LayerTreeHostInProcess::GetInputHandler() | 763 const base::WeakPtr<InputHandler>& LayerTreeHostInProcess::GetInputHandler() |
| 789 const { | 764 const { |
| 790 return input_handler_weak_ptr_; | 765 return input_handler_weak_ptr_; |
| 791 } | 766 } |
| 792 | 767 |
| 793 void LayerTreeHostInProcess::UpdateBrowserControlsState( | 768 void LayerTreeHostInProcess::UpdateBrowserControlsState( |
| 794 BrowserControlsState constraints, | 769 BrowserControlsState constraints, |
| 795 BrowserControlsState current, | 770 BrowserControlsState current, |
| 796 bool animate) { | 771 bool animate) { |
| 797 // Browser controls are only used in threaded mode. | 772 // Browser controls are only used in threaded mode. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 return compositor_mode_ == CompositorMode::SINGLE_THREADED; | 810 return compositor_mode_ == CompositorMode::SINGLE_THREADED; |
| 836 } | 811 } |
| 837 | 812 |
| 838 bool LayerTreeHostInProcess::IsThreaded() const { | 813 bool LayerTreeHostInProcess::IsThreaded() const { |
| 839 DCHECK(compositor_mode_ != CompositorMode::THREADED || | 814 DCHECK(compositor_mode_ != CompositorMode::THREADED || |
| 840 task_runner_provider_->HasImplThread()); | 815 task_runner_provider_->HasImplThread()); |
| 841 return compositor_mode_ == CompositorMode::THREADED; | 816 return compositor_mode_ == CompositorMode::THREADED; |
| 842 } | 817 } |
| 843 | 818 |
| 844 } // namespace cc | 819 } // namespace cc |
| OLD | NEW |