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 2520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2531 scroll_status.thread = InputHandler::SCROLL_IGNORED; | 2531 scroll_status.thread = InputHandler::SCROLL_IGNORED; |
2532 scroll_status.main_thread_scrolling_reasons = | 2532 scroll_status.main_thread_scrolling_reasons = |
2533 MainThreadScrollingReason::kNotScrollable; | 2533 MainThreadScrollingReason::kNotScrollable; |
2534 return scroll_status; | 2534 return scroll_status; |
2535 } | 2535 } |
2536 | 2536 |
2537 scroll_status.thread = InputHandler::SCROLL_ON_IMPL_THREAD; | 2537 scroll_status.thread = InputHandler::SCROLL_ON_IMPL_THREAD; |
2538 return scroll_status; | 2538 return scroll_status; |
2539 } | 2539 } |
2540 | 2540 |
| 2541 static bool IsMainThreadScrolling(const InputHandler::ScrollStatus& status, |
| 2542 const ScrollNode* scroll_node, |
| 2543 bool* scroll_on_main_thread, |
| 2544 uint32_t* main_thread_scrolling_reasons) { |
| 2545 if (status.thread == InputHandler::SCROLL_ON_MAIN_THREAD) { |
| 2546 if (!!scroll_node->data.main_thread_scrolling_reasons) { |
| 2547 DCHECK(MainThreadScrollingReason::MainThreadCanSetScrollReasons( |
| 2548 status.main_thread_scrolling_reasons)); |
| 2549 } else { |
| 2550 DCHECK(MainThreadScrollingReason::CompositorCanSetScrollReasons( |
| 2551 status.main_thread_scrolling_reasons)); |
| 2552 } |
| 2553 |
| 2554 *scroll_on_main_thread = true; |
| 2555 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; |
| 2556 return true; |
| 2557 } |
| 2558 return false; |
| 2559 } |
| 2560 |
2541 LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( | 2561 LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( |
2542 const gfx::PointF& device_viewport_point, | 2562 const gfx::PointF& device_viewport_point, |
2543 InputHandler::ScrollInputType type, | 2563 InputHandler::ScrollInputType type, |
2544 LayerImpl* layer_impl, | 2564 LayerImpl* layer_impl, |
2545 bool* scroll_on_main_thread, | 2565 bool* scroll_on_main_thread, |
2546 uint32_t* main_thread_scrolling_reasons) const { | 2566 uint32_t* main_thread_scrolling_reasons) const { |
2547 DCHECK(scroll_on_main_thread); | 2567 DCHECK(scroll_on_main_thread); |
2548 DCHECK(main_thread_scrolling_reasons); | 2568 DCHECK(main_thread_scrolling_reasons); |
2549 *main_thread_scrolling_reasons = | 2569 *main_thread_scrolling_reasons = |
2550 MainThreadScrollingReason::kNotScrollingOnMain; | 2570 MainThreadScrollingReason::kNotScrollingOnMain; |
2551 | 2571 |
2552 // Walk up the hierarchy and look for a scrollable layer. | 2572 // Walk up the hierarchy and look for a scrollable layer. |
| 2573 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
2553 LayerImpl* potentially_scrolling_layer_impl = NULL; | 2574 LayerImpl* potentially_scrolling_layer_impl = NULL; |
2554 if (layer_impl) { | 2575 if (layer_impl) { |
2555 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; | |
2556 ScrollNode* scroll_node = scroll_tree.Node(layer_impl->scroll_tree_index()); | 2576 ScrollNode* scroll_node = scroll_tree.Node(layer_impl->scroll_tree_index()); |
2557 for (; scroll_tree.parent(scroll_node); | 2577 for (; scroll_tree.parent(scroll_node); |
2558 scroll_node = scroll_tree.parent(scroll_node)) { | 2578 scroll_node = scroll_tree.parent(scroll_node)) { |
2559 // The content layer can also block attempts to scroll outside the main | 2579 // The content layer can also block attempts to scroll outside the main |
2560 // thread. | 2580 // thread. |
2561 ScrollStatus status = | 2581 ScrollStatus status = |
2562 TryScroll(device_viewport_point, type, scroll_tree, scroll_node); | 2582 TryScroll(device_viewport_point, type, scroll_tree, scroll_node); |
2563 if (status.thread == SCROLL_ON_MAIN_THREAD) { | 2583 if (IsMainThreadScrolling(status, scroll_node, scroll_on_main_thread, |
2564 if (!!scroll_node->data.main_thread_scrolling_reasons) { | 2584 main_thread_scrolling_reasons)) |
2565 DCHECK(MainThreadScrollingReason::MainThreadCanSetScrollReasons( | |
2566 status.main_thread_scrolling_reasons)); | |
2567 } else { | |
2568 DCHECK(MainThreadScrollingReason::CompositorCanSetScrollReasons( | |
2569 status.main_thread_scrolling_reasons)); | |
2570 } | |
2571 | |
2572 *scroll_on_main_thread = true; | |
2573 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; | |
2574 return NULL; | 2585 return NULL; |
2575 } | |
2576 | 2586 |
2577 if (status.thread == InputHandler::SCROLL_ON_IMPL_THREAD && | 2587 if (status.thread == InputHandler::SCROLL_ON_IMPL_THREAD && |
2578 !potentially_scrolling_layer_impl) { | 2588 !potentially_scrolling_layer_impl) { |
2579 potentially_scrolling_layer_impl = | 2589 potentially_scrolling_layer_impl = |
2580 active_tree_->LayerById(scroll_node->owner_id); | 2590 active_tree_->LayerById(scroll_node->owner_id); |
2581 } | 2591 } |
2582 } | 2592 } |
2583 } | 2593 } |
| 2594 |
2584 // Falling back to the root scroll layer ensures generation of root overscroll | 2595 // Falling back to the root scroll layer ensures generation of root overscroll |
2585 // notifications while preventing scroll updates from being unintentionally | 2596 // notifications. The inner viewport layer represents the viewport during |
2586 // forwarded to the main thread. The inner viewport layer represents the | 2597 // scrolling. |
2587 // viewport during scrolling. | |
2588 if (!potentially_scrolling_layer_impl) | 2598 if (!potentially_scrolling_layer_impl) |
2589 potentially_scrolling_layer_impl = InnerViewportScrollLayer(); | 2599 potentially_scrolling_layer_impl = InnerViewportScrollLayer(); |
2590 | 2600 |
2591 // The inner viewport layer represents the viewport. | 2601 // The inner viewport layer represents the viewport. |
2592 if (potentially_scrolling_layer_impl == OuterViewportScrollLayer()) | 2602 if (potentially_scrolling_layer_impl == OuterViewportScrollLayer()) |
2593 potentially_scrolling_layer_impl = InnerViewportScrollLayer(); | 2603 potentially_scrolling_layer_impl = InnerViewportScrollLayer(); |
2594 | 2604 |
| 2605 if (potentially_scrolling_layer_impl) { |
| 2606 // Ensure that final layer scrolls on impl thread (crbug.com/625100) |
| 2607 ScrollNode* scroll_node = |
| 2608 scroll_tree.Node(potentially_scrolling_layer_impl->scroll_tree_index()); |
| 2609 ScrollStatus status = |
| 2610 TryScroll(device_viewport_point, type, scroll_tree, scroll_node); |
| 2611 if (IsMainThreadScrolling(status, scroll_node, scroll_on_main_thread, |
| 2612 main_thread_scrolling_reasons)) |
| 2613 return NULL; |
| 2614 } |
| 2615 |
2595 return potentially_scrolling_layer_impl; | 2616 return potentially_scrolling_layer_impl; |
2596 } | 2617 } |
2597 | 2618 |
2598 // Similar to LayerImpl::HasAncestor, but walks up the scroll parents. | 2619 // Similar to LayerImpl::HasAncestor, but walks up the scroll parents. |
2599 static bool HasScrollAncestor(LayerImpl* child, LayerImpl* scroll_ancestor) { | 2620 static bool HasScrollAncestor(LayerImpl* child, LayerImpl* scroll_ancestor) { |
2600 DCHECK(scroll_ancestor); | 2621 DCHECK(scroll_ancestor); |
2601 if (!child) | 2622 if (!child) |
2602 return false; | 2623 return false; |
2603 ScrollTree& scroll_tree = | 2624 ScrollTree& scroll_tree = |
2604 child->layer_tree_impl()->property_trees()->scroll_tree; | 2625 child->layer_tree_impl()->property_trees()->scroll_tree; |
(...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4018 return task_runner_provider_->HasImplThread(); | 4039 return task_runner_provider_->HasImplThread(); |
4019 } | 4040 } |
4020 | 4041 |
4021 bool LayerTreeHostImpl::CommitToActiveTree() const { | 4042 bool LayerTreeHostImpl::CommitToActiveTree() const { |
4022 // In single threaded mode we skip the pending tree and commit directly to the | 4043 // In single threaded mode we skip the pending tree and commit directly to the |
4023 // active tree. | 4044 // active tree. |
4024 return !task_runner_provider_->HasImplThread(); | 4045 return !task_runner_provider_->HasImplThread(); |
4025 } | 4046 } |
4026 | 4047 |
4027 } // namespace cc | 4048 } // namespace cc |
OLD | NEW |