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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 | 545 |
546 gfx::PointF device_viewport_point = gfx::ScalePoint( | 546 gfx::PointF device_viewport_point = gfx::ScalePoint( |
547 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); | 547 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); |
548 | 548 |
549 LayerImpl* layer_impl = | 549 LayerImpl* layer_impl = |
550 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); | 550 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); |
551 | 551 |
552 bool scroll_on_main_thread = false; | 552 bool scroll_on_main_thread = false; |
553 uint32_t main_thread_scrolling_reasons; | 553 uint32_t main_thread_scrolling_reasons; |
554 LayerImpl* test_layer_impl = FindScrollLayerForDeviceViewportPoint( | 554 LayerImpl* test_layer_impl = FindScrollLayerForDeviceViewportPoint( |
555 device_viewport_point, type, layer_impl, &scroll_on_main_thread, nullptr, | 555 device_viewport_point, type, layer_impl, &scroll_on_main_thread, |
556 &main_thread_scrolling_reasons); | 556 &main_thread_scrolling_reasons); |
557 | 557 |
558 if (!test_layer_impl) | 558 if (!test_layer_impl) |
559 return false; | 559 return false; |
560 | 560 |
561 if (scrolling_layer_impl == test_layer_impl) | 561 if (scrolling_layer_impl == test_layer_impl) |
562 return true; | 562 return true; |
563 | 563 |
564 // For active scrolling state treat the inner/outer viewports interchangeably. | 564 // For active scrolling state treat the inner/outer viewports interchangeably. |
565 if ((scrolling_layer_impl == InnerViewportScrollLayer() && | 565 if ((scrolling_layer_impl == InnerViewportScrollLayer() && |
(...skipping 1860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2426 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { | 2426 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { |
2427 DCHECK(input_handler_client_ == NULL); | 2427 DCHECK(input_handler_client_ == NULL); |
2428 input_handler_client_ = client; | 2428 input_handler_client_ = client; |
2429 } | 2429 } |
2430 | 2430 |
2431 LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( | 2431 LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( |
2432 const gfx::PointF& device_viewport_point, | 2432 const gfx::PointF& device_viewport_point, |
2433 InputHandler::ScrollInputType type, | 2433 InputHandler::ScrollInputType type, |
2434 LayerImpl* layer_impl, | 2434 LayerImpl* layer_impl, |
2435 bool* scroll_on_main_thread, | 2435 bool* scroll_on_main_thread, |
2436 bool* optional_has_ancestor_scroll_handler, | |
2437 uint32_t* main_thread_scrolling_reasons) const { | 2436 uint32_t* main_thread_scrolling_reasons) const { |
2438 DCHECK(scroll_on_main_thread); | 2437 DCHECK(scroll_on_main_thread); |
2439 DCHECK(main_thread_scrolling_reasons); | 2438 DCHECK(main_thread_scrolling_reasons); |
2440 *main_thread_scrolling_reasons = | 2439 *main_thread_scrolling_reasons = |
2441 MainThreadScrollingReason::kNotScrollingOnMain; | 2440 MainThreadScrollingReason::kNotScrollingOnMain; |
2442 | 2441 |
2443 // Walk up the hierarchy and look for a scrollable layer. | 2442 // Walk up the hierarchy and look for a scrollable layer. |
2444 LayerImpl* potentially_scrolling_layer_impl = NULL; | 2443 LayerImpl* potentially_scrolling_layer_impl = NULL; |
2445 if (layer_impl) { | 2444 if (layer_impl) { |
2446 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; | 2445 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
(...skipping 13 matching lines...) Expand all Loading... |
2460 DCHECK_GT( | 2459 DCHECK_GT( |
2461 status.main_thread_scrolling_reasons, | 2460 status.main_thread_scrolling_reasons, |
2462 MainThreadScrollingReason::kMaxNonTransientScrollingReasons); | 2461 MainThreadScrollingReason::kMaxNonTransientScrollingReasons); |
2463 } | 2462 } |
2464 | 2463 |
2465 *scroll_on_main_thread = true; | 2464 *scroll_on_main_thread = true; |
2466 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; | 2465 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; |
2467 return NULL; | 2466 return NULL; |
2468 } | 2467 } |
2469 | 2468 |
2470 if (optional_has_ancestor_scroll_handler && | |
2471 layer_impl->have_scroll_event_handlers()) | |
2472 *optional_has_ancestor_scroll_handler = true; | |
2473 | |
2474 if (status.thread == InputHandler::SCROLL_ON_IMPL_THREAD && | 2469 if (status.thread == InputHandler::SCROLL_ON_IMPL_THREAD && |
2475 !potentially_scrolling_layer_impl) { | 2470 !potentially_scrolling_layer_impl) { |
2476 potentially_scrolling_layer_impl = layer_impl; | 2471 potentially_scrolling_layer_impl = layer_impl; |
2477 } | 2472 } |
2478 } | 2473 } |
2479 } | 2474 } |
2480 // Falling back to the root scroll layer ensures generation of root overscroll | 2475 // Falling back to the root scroll layer ensures generation of root overscroll |
2481 // notifications while preventing scroll updates from being unintentionally | 2476 // notifications while preventing scroll updates from being unintentionally |
2482 // forwarded to the main thread. The inner viewport layer represents the | 2477 // forwarded to the main thread. The inner viewport layer represents the |
2483 // viewport during scrolling. | 2478 // viewport during scrolling. |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2591 scroll_status.thread = SCROLL_UNKNOWN; | 2586 scroll_status.thread = SCROLL_UNKNOWN; |
2592 scroll_status.main_thread_scrolling_reasons = | 2587 scroll_status.main_thread_scrolling_reasons = |
2593 MainThreadScrollingReason::kFailedHitTest; | 2588 MainThreadScrollingReason::kFailedHitTest; |
2594 return scroll_status; | 2589 return scroll_status; |
2595 } | 2590 } |
2596 } | 2591 } |
2597 | 2592 |
2598 bool scroll_on_main_thread = false; | 2593 bool scroll_on_main_thread = false; |
2599 LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint( | 2594 LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint( |
2600 device_viewport_point, type, layer_impl, &scroll_on_main_thread, | 2595 device_viewport_point, type, layer_impl, &scroll_on_main_thread, |
2601 &scroll_affects_scroll_handler_, | |
2602 &scroll_status.main_thread_scrolling_reasons); | 2596 &scroll_status.main_thread_scrolling_reasons); |
2603 | 2597 |
| 2598 if (scrolling_layer_impl) |
| 2599 scroll_affects_scroll_handler_ = |
| 2600 scrolling_layer_impl->layer_tree_impl()->have_scroll_event_handlers(); |
| 2601 |
2604 if (scroll_on_main_thread) { | 2602 if (scroll_on_main_thread) { |
2605 RecordCompositorSlowScrollMetric(type, MAIN_THREAD); | 2603 RecordCompositorSlowScrollMetric(type, MAIN_THREAD); |
2606 | 2604 |
2607 // TODO(lanwei): Will remove this metric in M50 when we have used the new | 2605 // TODO(lanwei): Will remove this metric in M50 when we have used the new |
2608 // metrics for one milestone, see https://crbug.com/557787. | 2606 // metrics for one milestone, see https://crbug.com/557787. |
2609 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); | 2607 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); |
2610 scroll_status.thread = SCROLL_ON_MAIN_THREAD; | 2608 scroll_status.thread = SCROLL_ON_MAIN_THREAD; |
2611 return scroll_status; | 2609 return scroll_status; |
2612 } | 2610 } |
2613 | 2611 |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3068 LayerImpl* layer_impl = | 3066 LayerImpl* layer_impl = |
3069 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); | 3067 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); |
3070 HandleMouseOverScrollbar(layer_impl); | 3068 HandleMouseOverScrollbar(layer_impl); |
3071 if (scroll_layer_id_when_mouse_over_scrollbar_ != Layer::INVALID_ID) | 3069 if (scroll_layer_id_when_mouse_over_scrollbar_ != Layer::INVALID_ID) |
3072 return; | 3070 return; |
3073 | 3071 |
3074 bool scroll_on_main_thread = false; | 3072 bool scroll_on_main_thread = false; |
3075 uint32_t main_thread_scrolling_reasons; | 3073 uint32_t main_thread_scrolling_reasons; |
3076 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( | 3074 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( |
3077 device_viewport_point, InputHandler::GESTURE, layer_impl, | 3075 device_viewport_point, InputHandler::GESTURE, layer_impl, |
3078 &scroll_on_main_thread, NULL, &main_thread_scrolling_reasons); | 3076 &scroll_on_main_thread, &main_thread_scrolling_reasons); |
3079 if (scroll_layer_impl == InnerViewportScrollLayer()) | 3077 if (scroll_layer_impl == InnerViewportScrollLayer()) |
3080 scroll_layer_impl = OuterViewportScrollLayer(); | 3078 scroll_layer_impl = OuterViewportScrollLayer(); |
3081 if (scroll_on_main_thread || !scroll_layer_impl) | 3079 if (scroll_on_main_thread || !scroll_layer_impl) |
3082 return; | 3080 return; |
3083 | 3081 |
3084 ScrollbarAnimationController* animation_controller = | 3082 ScrollbarAnimationController* animation_controller = |
3085 ScrollbarAnimationControllerForId(scroll_layer_impl->id()); | 3083 ScrollbarAnimationControllerForId(scroll_layer_impl->id()); |
3086 if (!animation_controller) | 3084 if (!animation_controller) |
3087 return; | 3085 return; |
3088 | 3086 |
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3877 return task_runner_provider_->HasImplThread(); | 3875 return task_runner_provider_->HasImplThread(); |
3878 } | 3876 } |
3879 | 3877 |
3880 bool LayerTreeHostImpl::CommitToActiveTree() const { | 3878 bool LayerTreeHostImpl::CommitToActiveTree() const { |
3881 // In single threaded mode we skip the pending tree and commit directly to the | 3879 // In single threaded mode we skip the pending tree and commit directly to the |
3882 // active tree. | 3880 // active tree. |
3883 return !task_runner_provider_->HasImplThread(); | 3881 return !task_runner_provider_->HasImplThread(); |
3884 } | 3882 } |
3885 | 3883 |
3886 } // namespace cc | 3884 } // namespace cc |
OLD | NEW |