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

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

Issue 2718833002: Refactor unreliable hit test code to avoid owning_layers (Closed)
Patch Set: Fix mistake in HitTestVisibleScrollableOrTouchableFunctor, cleaup comments Created 3 years, 9 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
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_impl.h" 5 #include "cc/trees/layer_tree_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 1911 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 if (!state->closest_match || in_front_of_previous_candidate) { 1922 if (!state->closest_match || in_front_of_previous_candidate) {
1923 state->closest_distance = distance_to_intersection; 1923 state->closest_distance = distance_to_intersection;
1924 state->closest_match = layer; 1924 state->closest_match = layer;
1925 } 1925 }
1926 } 1926 }
1927 UMA_HISTOGRAM_COUNTS("Compositing.LayerTreeImpl.FindClosestMatchingLayerUs", 1927 UMA_HISTOGRAM_COUNTS("Compositing.LayerTreeImpl.FindClosestMatchingLayerUs",
1928 timer.Elapsed().InMicroseconds()); 1928 timer.Elapsed().InMicroseconds());
1929 } 1929 }
1930 } 1930 }
1931 1931
1932 static bool IsScrollableOrDrawnScrollbarLayer(LayerImpl* layer) { 1932 struct FindScrollingLayerOrDrawnScrollbarFunctor {
1933 return layer->scrollable() ||
1934 (layer->ToScrollbarLayer() &&
1935 layer->is_drawn_render_surface_layer_list_member());
1936 }
1937
1938 struct FindScrollingLayerOrScrollbarLayerFunctor {
1939 bool operator()(LayerImpl* layer) const { 1933 bool operator()(LayerImpl* layer) const {
1940 return IsScrollableOrDrawnScrollbarLayer(layer); 1934 return layer->scrollable() || layer->IsDrawnScrollbar();
1941 } 1935 }
1942 }; 1936 };
1943 1937
1944 LayerImpl* 1938 LayerImpl*
1945 LayerTreeImpl::FindFirstScrollingLayerOrScrollbarLayerThatIsHitByPoint( 1939 LayerTreeImpl::FindFirstScrollingLayerOrDrawnScrollbarThatIsHitByPoint(
1946 const gfx::PointF& screen_space_point) { 1940 const gfx::PointF& screen_space_point) {
1947 FindClosestMatchingLayerState state; 1941 FindClosestMatchingLayerState state;
1948 LayerImpl* root_layer = layer_list_.empty() ? nullptr : layer_list_[0]; 1942 LayerImpl* root_layer = layer_list_.empty() ? nullptr : layer_list_[0];
1949 FindClosestMatchingLayer(screen_space_point, root_layer, 1943 FindClosestMatchingLayer(screen_space_point, root_layer,
1950 FindScrollingLayerOrScrollbarLayerFunctor(), &state); 1944 FindScrollingLayerOrDrawnScrollbarFunctor(), &state);
1951 return state.closest_match; 1945 return state.closest_match;
1952 } 1946 }
1953 1947
1954 struct HitTestVisibleScrollableOrTouchableFunctor { 1948 struct HitTestVisibleScrollableOrTouchableFunctor {
1955 bool operator()(LayerImpl* layer) const { 1949 bool operator()(LayerImpl* layer) const {
1956 return layer->is_drawn_render_surface_layer_list_member() || 1950 return layer->scrollable() ||
pdr. 2017/02/27 21:40:05 The original code was really checking the followin
1957 IsScrollableOrDrawnScrollbarLayer(layer) || 1951 layer->is_drawn_render_surface_layer_list_member() ||
1958 !layer->touch_event_handler_region().IsEmpty(); 1952 !layer->touch_event_handler_region().IsEmpty();
1959 } 1953 }
1960 }; 1954 };
1961 1955
1962 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint( 1956 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint(
1963 const gfx::PointF& screen_space_point) { 1957 const gfx::PointF& screen_space_point) {
1964 if (layer_list_.empty()) 1958 if (layer_list_.empty())
1965 return NULL; 1959 return NULL;
1966 bool update_lcd_text = false; 1960 bool update_lcd_text = false;
1967 if (!UpdateDrawProperties(update_lcd_text)) 1961 if (!UpdateDrawProperties(update_lcd_text))
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
2118 2112
2119 void LayerTreeImpl::ResetAllChangeTracking() { 2113 void LayerTreeImpl::ResetAllChangeTracking() {
2120 layers_that_should_push_properties_.clear(); 2114 layers_that_should_push_properties_.clear();
2121 // Iterate over all layers, including masks. 2115 // Iterate over all layers, including masks.
2122 for (auto& layer : *layers_) 2116 for (auto& layer : *layers_)
2123 layer->ResetChangeTracking(); 2117 layer->ResetChangeTracking();
2124 property_trees_.ResetAllChangeTracking(); 2118 property_trees_.ResetAllChangeTracking();
2125 } 2119 }
2126 2120
2127 } // namespace cc 2121 } // namespace cc
OLDNEW
« cc/trees/layer_tree_host_impl_unittest.cc ('K') | « cc/trees/layer_tree_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698