| 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_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 | 276 |
| 277 DCHECK(!resource_provider_); | 277 DCHECK(!resource_provider_); |
| 278 DCHECK(!resource_pool_); | 278 DCHECK(!resource_pool_); |
| 279 DCHECK(!single_thread_synchronous_task_graph_runner_); | 279 DCHECK(!single_thread_synchronous_task_graph_runner_); |
| 280 DCHECK(!image_decode_controller_); | 280 DCHECK(!image_decode_controller_); |
| 281 | 281 |
| 282 if (input_handler_client_) { | 282 if (input_handler_client_) { |
| 283 input_handler_client_->WillShutdown(); | 283 input_handler_client_->WillShutdown(); |
| 284 input_handler_client_ = NULL; | 284 input_handler_client_ = NULL; |
| 285 } | 285 } |
| 286 if (scroll_elasticity_helper_) | 286 root_scroll_elasticity_helper_.reset(); |
| 287 scroll_elasticity_helper_.reset(); | |
| 288 | 287 |
| 289 // The layer trees must be destroyed before the layer tree host. We've | 288 // The layer trees must be destroyed before the layer tree host. We've |
| 290 // made a contract with our animation controllers that the animation_host | 289 // made a contract with our animation controllers that the animation_host |
| 291 // will outlive them, and we must make good. | 290 // will outlive them, and we must make good. |
| 292 if (recycle_tree_) | 291 if (recycle_tree_) |
| 293 recycle_tree_->Shutdown(); | 292 recycle_tree_->Shutdown(); |
| 294 if (pending_tree_) | 293 if (pending_tree_) |
| 295 pending_tree_->Shutdown(); | 294 pending_tree_->Shutdown(); |
| 296 active_tree_->Shutdown(); | 295 active_tree_->Shutdown(); |
| 297 recycle_tree_ = nullptr; | 296 recycle_tree_ = nullptr; |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 return layer_impl != NULL; | 603 return layer_impl != NULL; |
| 605 } | 604 } |
| 606 | 605 |
| 607 std::unique_ptr<SwapPromiseMonitor> | 606 std::unique_ptr<SwapPromiseMonitor> |
| 608 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( | 607 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( |
| 609 ui::LatencyInfo* latency) { | 608 ui::LatencyInfo* latency) { |
| 610 return base::WrapUnique( | 609 return base::WrapUnique( |
| 611 new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); | 610 new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); |
| 612 } | 611 } |
| 613 | 612 |
| 614 ScrollElasticityHelper* LayerTreeHostImpl::CreateScrollElasticityHelper() { | 613 ScrollElasticityHelper* LayerTreeHostImpl::CreateRootScrollElasticityHelper() { |
| 615 DCHECK(!scroll_elasticity_helper_); | 614 DCHECK(!root_scroll_elasticity_helper_); |
| 616 if (settings_.enable_elastic_overscroll) { | 615 if (settings_.enable_elastic_overscroll) { |
| 617 scroll_elasticity_helper_.reset( | 616 root_scroll_elasticity_helper_.reset( |
| 618 ScrollElasticityHelper::CreateForLayerTreeHostImpl(this)); | 617 ScrollElasticityHelper::CreateForLayerTreeHostImpl(this)); |
| 619 } | 618 } |
| 620 return scroll_elasticity_helper_.get(); | 619 return root_scroll_elasticity_helper_.get(); |
| 620 } |
| 621 |
| 622 base::WeakPtr<ScrollElasticityHelper> |
| 623 LayerTreeHostImpl::ScrollElasticityHelperForScrollingLayer() { |
| 624 LayerImpl* scrolling_layer_impl = CurrentlyScrollingLayer(); |
| 625 if (!scrolling_layer_impl) |
| 626 return nullptr; |
| 627 |
| 628 return ScrollElasticityHelperForId(scrolling_layer_impl->id())->GetWeakPtr(); |
| 621 } | 629 } |
| 622 | 630 |
| 623 bool LayerTreeHostImpl::GetScrollOffsetForLayer(int layer_id, | 631 bool LayerTreeHostImpl::GetScrollOffsetForLayer(int layer_id, |
| 624 gfx::ScrollOffset* offset) { | 632 gfx::ScrollOffset* offset) { |
| 625 LayerImpl* layer = active_tree()->FindActiveTreeLayerById(layer_id); | 633 LayerImpl* layer = active_tree()->FindActiveTreeLayerById(layer_id); |
| 626 if (!layer) | 634 if (!layer) |
| 627 return false; | 635 return false; |
| 628 | 636 |
| 629 *offset = layer->CurrentScrollOffset(); | 637 *offset = layer->CurrentScrollOffset(); |
| 630 return true; | 638 return true; |
| (...skipping 1976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2607 scroll_status.thread = SCROLL_ON_IMPL_THREAD; | 2615 scroll_status.thread = SCROLL_ON_IMPL_THREAD; |
| 2608 ScrollAnimationAbort(scrolling_layer_impl); | 2616 ScrollAnimationAbort(scrolling_layer_impl); |
| 2609 | 2617 |
| 2610 top_controls_manager_->ScrollBegin(); | 2618 top_controls_manager_->ScrollBegin(); |
| 2611 | 2619 |
| 2612 active_tree_->SetCurrentlyScrollingLayer(scrolling_layer_impl); | 2620 active_tree_->SetCurrentlyScrollingLayer(scrolling_layer_impl); |
| 2613 // TODO(majidvp): get rid of wheel_scrolling_ and set is_direct_manipulation | 2621 // TODO(majidvp): get rid of wheel_scrolling_ and set is_direct_manipulation |
| 2614 // in input_handler_proxy instead. | 2622 // in input_handler_proxy instead. |
| 2615 wheel_scrolling_ = IsWheelBasedScroll(type); | 2623 wheel_scrolling_ = IsWheelBasedScroll(type); |
| 2616 scroll_state->set_is_direct_manipulation(!wheel_scrolling_); | 2624 scroll_state->set_is_direct_manipulation(!wheel_scrolling_); |
| 2617 // Invoke |DistributeScrollDelta| even with zero delta and velocity to ensure | 2625 // Invoke |DistributeScrollDelta| even with zero delta and velocity to process |
| 2618 // scroll customization callbacks are invoked. | 2626 // overscroll and ensure scroll customization callbacks are invoked. |
| 2619 DistributeScrollDelta(scroll_state); | 2627 DistributeScrollDelta(scroll_state); |
| 2620 | 2628 |
| 2621 client_->RenewTreePriority(); | 2629 client_->RenewTreePriority(); |
| 2622 RecordCompositorSlowScrollMetric(type, CC_THREAD); | 2630 RecordCompositorSlowScrollMetric(type, CC_THREAD); |
| 2623 | 2631 |
| 2624 return scroll_status; | 2632 return scroll_status; |
| 2625 } | 2633 } |
| 2626 | 2634 |
| 2627 InputHandler::ScrollStatus LayerTreeHostImpl::RootScrollBegin( | 2635 InputHandler::ScrollStatus LayerTreeHostImpl::RootScrollBegin( |
| 2628 ScrollState* scroll_state, | 2636 ScrollState* scroll_state, |
| (...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3516 // is registered with the outer viewport. | 3524 // is registered with the outer viewport. |
| 3517 if (InnerViewportScrollLayer() && OuterViewportScrollLayer() && | 3525 if (InnerViewportScrollLayer() && OuterViewportScrollLayer() && |
| 3518 scroll_layer_id == InnerViewportScrollLayer()->id()) | 3526 scroll_layer_id == InnerViewportScrollLayer()->id()) |
| 3519 scroll_layer_id = OuterViewportScrollLayer()->id(); | 3527 scroll_layer_id = OuterViewportScrollLayer()->id(); |
| 3520 auto i = scrollbar_animation_controllers_.find(scroll_layer_id); | 3528 auto i = scrollbar_animation_controllers_.find(scroll_layer_id); |
| 3521 if (i == scrollbar_animation_controllers_.end()) | 3529 if (i == scrollbar_animation_controllers_.end()) |
| 3522 return nullptr; | 3530 return nullptr; |
| 3523 return i->second.get(); | 3531 return i->second.get(); |
| 3524 } | 3532 } |
| 3525 | 3533 |
| 3534 void LayerTreeHostImpl::RegisterScrollElasticityHelper(int scroll_layer_id) { |
| 3535 DCHECK(!InnerViewportScrollLayer() || |
| 3536 scroll_layer_id != InnerViewportScrollLayer()->id()); |
| 3537 DCHECK(!OuterViewportScrollLayer() || |
| 3538 scroll_layer_id != OuterViewportScrollLayer()->id()); |
| 3539 DCHECK(settings().enable_elastic_overscroll); |
| 3540 |
| 3541 auto& helper = scroll_elasticity_helpers_[scroll_layer_id]; |
| 3542 if (!helper) |
| 3543 helper = active_tree_->CreateScrollElasticityHelper(scroll_layer_id); |
| 3544 } |
| 3545 |
| 3546 void LayerTreeHostImpl::UnregisterScrollElasticityHelper(int scroll_layer_id) { |
| 3547 scroll_elasticity_helpers_.erase(scroll_layer_id); |
| 3548 } |
| 3549 |
| 3550 ScrollElasticityHelper* LayerTreeHostImpl::ScrollElasticityHelperForId( |
| 3551 int scroll_layer_id) { |
| 3552 if (!settings().enable_elastic_overscroll) |
| 3553 return nullptr; |
| 3554 |
| 3555 auto i = scroll_elasticity_helpers_.find(scroll_layer_id); |
| 3556 if (i != scroll_elasticity_helpers_.end()) |
| 3557 return i->second.get(); |
| 3558 |
| 3559 if (!root_scroll_elasticity_helper_) { |
| 3560 root_scroll_elasticity_helper_.reset( |
| 3561 ScrollElasticityHelper::CreateForLayerTreeHostImpl(this)); |
| 3562 } |
| 3563 return root_scroll_elasticity_helper_.get(); |
| 3564 } |
| 3565 |
| 3526 void LayerTreeHostImpl::PostDelayedScrollbarAnimationTask( | 3566 void LayerTreeHostImpl::PostDelayedScrollbarAnimationTask( |
| 3527 const base::Closure& task, | 3567 const base::Closure& task, |
| 3528 base::TimeDelta delay) { | 3568 base::TimeDelta delay) { |
| 3529 client_->PostDelayedAnimationTaskOnImplThread(task, delay); | 3569 client_->PostDelayedAnimationTaskOnImplThread(task, delay); |
| 3530 } | 3570 } |
| 3531 | 3571 |
| 3532 // TODO(danakj): Make this a return value from the Animate() call instead of an | 3572 // TODO(danakj): Make this a return value from the Animate() call instead of an |
| 3533 // interface on LTHI. (Also, crbug.com/551138.) | 3573 // interface on LTHI. (Also, crbug.com/551138.) |
| 3534 void LayerTreeHostImpl::SetNeedsAnimateForScrollbarAnimation() { | 3574 void LayerTreeHostImpl::SetNeedsAnimateForScrollbarAnimation() { |
| 3535 TRACE_EVENT0("cc", "LayerTreeHostImpl::SetNeedsAnimateForScrollbarAnimation"); | 3575 TRACE_EVENT0("cc", "LayerTreeHostImpl::SetNeedsAnimateForScrollbarAnimation"); |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4099 if (is_visible) { | 4139 if (is_visible) { |
| 4100 worker_context_visibility_ = | 4140 worker_context_visibility_ = |
| 4101 worker_context->CacheController()->ClientBecameVisible(); | 4141 worker_context->CacheController()->ClientBecameVisible(); |
| 4102 } else { | 4142 } else { |
| 4103 worker_context->CacheController()->ClientBecameNotVisible( | 4143 worker_context->CacheController()->ClientBecameNotVisible( |
| 4104 std::move(worker_context_visibility_)); | 4144 std::move(worker_context_visibility_)); |
| 4105 } | 4145 } |
| 4106 } | 4146 } |
| 4107 | 4147 |
| 4108 } // namespace cc | 4148 } // namespace cc |
| OLD | NEW |