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