Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 2621133002: Return main thread scroll layer in FindScrollLayerForDeviceViewportPoint (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 1652
1653 // Collect all resource ids in the render passes into a single array. 1653 // Collect all resource ids in the render passes into a single array.
1654 ResourceProvider::ResourceIdArray resources; 1654 ResourceProvider::ResourceIdArray resources;
1655 for (const auto& render_pass : frame->render_passes) { 1655 for (const auto& render_pass : frame->render_passes) {
1656 for (auto* quad : render_pass->quad_list) { 1656 for (auto* quad : render_pass->quad_list) {
1657 for (ResourceId resource_id : quad->resources) 1657 for (ResourceId resource_id : quad->resources)
1658 resources.push_back(resource_id); 1658 resources.push_back(resource_id);
1659 } 1659 }
1660 } 1660 }
1661 1661
1662
1663 CompositorFrame compositor_frame; 1662 CompositorFrame compositor_frame;
1664 compositor_frame.metadata = std::move(metadata); 1663 compositor_frame.metadata = std::move(metadata);
1665 resource_provider_->PrepareSendToParent(resources, 1664 resource_provider_->PrepareSendToParent(resources,
1666 &compositor_frame.resource_list); 1665 &compositor_frame.resource_list);
1667 compositor_frame.render_pass_list = std::move(frame->render_passes); 1666 compositor_frame.render_pass_list = std::move(frame->render_passes);
1668 compositor_frame_sink_->SubmitCompositorFrame(std::move(compositor_frame)); 1667 compositor_frame_sink_->SubmitCompositorFrame(std::move(compositor_frame));
1669 1668
1670 // Clears the list of swap promises after calling DidSwap on each of them to 1669 // Clears the list of swap promises after calling DidSwap on each of them to
1671 // signal that the swap is over. 1670 // signal that the swap is over.
1672 active_tree()->ClearSwapPromises(); 1671 active_tree()->ClearSwapPromises();
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
2569 if (IsMainThreadScrolling(status, scroll_node)) { 2568 if (IsMainThreadScrolling(status, scroll_node)) {
2570 *scroll_on_main_thread = true; 2569 *scroll_on_main_thread = true;
2571 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; 2570 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons;
2572 return NULL; 2571 return NULL;
2573 } 2572 }
2574 } 2573 }
2575 2574
2576 return potentially_scrolling_layer_impl; 2575 return potentially_scrolling_layer_impl;
2577 } 2576 }
2578 2577
2578 LayerImpl* LayerTreeHostImpl::FindScrollLayerByLayer(
bokan 2017/01/10 22:36:22 This method avoids the walk up the parent layers l
2579 LayerImpl* layer_impl) const {
2580 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree;
2581 LayerImpl* potentially_scrolling_layer_impl = nullptr;
2582 if (layer_impl) {
2583 ScrollNode* scroll_node = scroll_tree.Node(layer_impl->scroll_tree_index());
2584 potentially_scrolling_layer_impl =
2585 active_tree_->LayerById(scroll_node->owning_layer_id);
2586 }
2587
2588 // Falling back to the viewport layer ensures generation of root overscroll
2589 // notifications. We use the viewport's main scroll layer to represent the
2590 // viewport in scrolling code.
2591 if (!potentially_scrolling_layer_impl ||
2592 potentially_scrolling_layer_impl == OuterViewportScrollLayer() ||
2593 potentially_scrolling_layer_impl == InnerViewportScrollLayer()) {
2594 potentially_scrolling_layer_impl = viewport()->MainScrollLayer();
2595 }
2596
2597 return potentially_scrolling_layer_impl;
2598 }
2599
2579 static bool IsClosestScrollAncestor(LayerImpl* child, 2600 static bool IsClosestScrollAncestor(LayerImpl* child,
2580 LayerImpl* scroll_ancestor) { 2601 LayerImpl* scroll_ancestor) {
2581 DCHECK(scroll_ancestor); 2602 DCHECK(scroll_ancestor);
2582 if (!child) 2603 if (!child)
2583 return false; 2604 return false;
2584 ScrollTree& scroll_tree = 2605 ScrollTree& scroll_tree =
2585 child->layer_tree_impl()->property_trees()->scroll_tree; 2606 child->layer_tree_impl()->property_trees()->scroll_tree;
2586 ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index()); 2607 ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index());
2587 for (; scroll_tree.parent(scroll_node); 2608 for (; scroll_tree.parent(scroll_node);
2588 scroll_node = scroll_tree.parent(scroll_node)) { 2609 scroll_node = scroll_tree.parent(scroll_node)) {
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
3236 } 3257 }
3237 3258
3238 void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) { 3259 void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) {
3239 float distance_to_scrollbar = std::numeric_limits<float>::max(); 3260 float distance_to_scrollbar = std::numeric_limits<float>::max();
3240 gfx::PointF device_viewport_point = gfx::ScalePoint( 3261 gfx::PointF device_viewport_point = gfx::ScalePoint(
3241 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); 3262 gfx::PointF(viewport_point), active_tree_->device_scale_factor());
3242 LayerImpl* layer_impl = 3263 LayerImpl* layer_impl =
3243 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); 3264 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point);
3244 3265
3245 // Check if mouse is over a scrollbar or not. 3266 // Check if mouse is over a scrollbar or not.
3246 // TODO(sahel): get rid of this extera checking when
3247 // FindScrollLayerForDeviceViewportPoint finds the proper layer for
3248 // scrolling on main thread, as well.
3249 int new_id = Layer::INVALID_ID; 3267 int new_id = Layer::INVALID_ID;
3250 if (layer_impl && layer_impl->ToScrollbarLayer()) 3268 if (layer_impl && layer_impl->ToScrollbarLayer())
3251 new_id = layer_impl->ToScrollbarLayer()->ScrollLayerId(); 3269 new_id = layer_impl->ToScrollbarLayer()->ScrollLayerId();
3252 if (new_id != Layer::INVALID_ID) { 3270 if (new_id != Layer::INVALID_ID) {
3253 // Mouse over a scrollbar. 3271 // Mouse over a scrollbar.
3254 distance_to_scrollbar = 0; 3272 distance_to_scrollbar = 0;
3255 } else { 3273 } else {
3256 bool scroll_on_main_thread = false; 3274 LayerImpl* scroll_layer_impl = FindScrollLayerByLayer(layer_impl);
3257 uint32_t main_thread_scrolling_reasons;
3258 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint(
3259 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl,
3260 &scroll_on_main_thread, &main_thread_scrolling_reasons);
3261 3275
3262 // Scrollbars for the viewport are registered with the outer viewport layer. 3276 // Scrollbars for the viewport are registered with the outer viewport layer.
3263 if (scroll_layer_impl == InnerViewportScrollLayer()) 3277 if (scroll_layer_impl == InnerViewportScrollLayer())
3264 scroll_layer_impl = OuterViewportScrollLayer(); 3278 scroll_layer_impl = OuterViewportScrollLayer();
3265 3279
3266 new_id = scroll_layer_impl ? scroll_layer_impl->id() : Layer::INVALID_ID; 3280 new_id = scroll_layer_impl ? scroll_layer_impl->id() : Layer::INVALID_ID;
3267 } 3281 }
3268 3282
3269 if (new_id != scroll_layer_id_mouse_currently_over_) { 3283 if (new_id != scroll_layer_id_mouse_currently_over_) {
3270 ScrollbarAnimationController* old_animation_controller = 3284 ScrollbarAnimationController* old_animation_controller =
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
4092 worker_context_visibility_ = 4106 worker_context_visibility_ =
4093 worker_context->CacheController()->ClientBecameVisible(); 4107 worker_context->CacheController()->ClientBecameVisible();
4094 } else { 4108 } else {
4095 worker_context->CacheController()->ClientBecameNotVisible( 4109 worker_context->CacheController()->ClientBecameNotVisible(
4096 std::move(worker_context_visibility_)); 4110 std::move(worker_context_visibility_));
4097 } 4111 }
4098 } 4112 }
4099 } 4113 }
4100 4114
4101 } // namespace cc 4115 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698