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

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

Issue 328753002: Clean up PointIsClippedBySurfaceOrClipRect (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | cc/trees/layer_tree_impl_unittest.cc » ('j') | 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_impl.h" 5 #include "cc/trees/layer_tree_impl.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <set> 8 #include <set>
9 9
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 1088
1089 // If ProjectPoint could not project to a valid value, then we assume that 1089 // If ProjectPoint could not project to a valid value, then we assume that
1090 // this point doesn't hit this region. 1090 // this point doesn't hit this region.
1091 if (clipped) 1091 if (clipped)
1092 return false; 1092 return false;
1093 1093
1094 return layer_space_region.Contains( 1094 return layer_space_region.Contains(
1095 gfx::ToRoundedPoint(hit_test_point_in_layer_space)); 1095 gfx::ToRoundedPoint(hit_test_point_in_layer_space));
1096 } 1096 }
1097 1097
1098 static LayerImpl* GetNextClippingLayer(LayerImpl* layer) {
1099 if (layer->scroll_parent())
1100 return layer->scroll_parent();
1101 if (layer->clip_parent())
1102 return layer->clip_parent();
1103 return layer->parent();
1104 }
1105
1098 static bool PointIsClippedBySurfaceOrClipRect( 1106 static bool PointIsClippedBySurfaceOrClipRect(
1099 const gfx::PointF& screen_space_point, 1107 const gfx::PointF& screen_space_point,
1100 LayerImpl* layer) { 1108 LayerImpl* layer) {
1101 LayerImpl* current_layer = layer;
1102
1103 // Walk up the layer tree and hit-test any render_surfaces and any layer 1109 // Walk up the layer tree and hit-test any render_surfaces and any layer
1104 // clip rects that are active. 1110 // clip rects that are active.
1105 while (current_layer) { 1111 for (; layer; layer = GetNextClippingLayer(layer)) {
1106 if (current_layer->render_surface() && 1112 if (layer->render_surface() &&
1107 !PointHitsRect( 1113 !PointHitsRect(screen_space_point,
1108 screen_space_point, 1114 layer->render_surface()->screen_space_transform(),
1109 current_layer->render_surface()->screen_space_transform(), 1115 layer->render_surface()->content_rect(),
1110 current_layer->render_surface()->content_rect(), 1116 NULL))
1111 NULL))
1112 return true; 1117 return true;
1113 1118
1114 // Note that drawable content rects are actually in target surface space, so 1119 if (LayerClipsSubtree(layer) &&
1115 // the transform we have to provide is the target surface's 1120 !PointHitsRect(screen_space_point,
1116 // screen_space_transform. 1121 layer->screen_space_transform(),
1117 LayerImpl* render_target = current_layer->render_target(); 1122 gfx::Rect(layer->content_bounds()),
1118 if (LayerClipsSubtree(current_layer) && 1123 NULL))
1119 !PointHitsRect(
1120 screen_space_point,
1121 render_target->render_surface()->screen_space_transform(),
1122 current_layer->drawable_content_rect(),
1123 NULL))
1124 return true; 1124 return true;
1125
1126 current_layer = current_layer->parent();
1127 } 1125 }
1128 1126
1129 // If we have finished walking all ancestors without having already exited, 1127 // If we have finished walking all ancestors without having already exited,
1130 // then the point is not clipped by any ancestors. 1128 // then the point is not clipped by any ancestors.
1131 return false; 1129 return false;
1132 } 1130 }
1133 1131
1134 static bool PointHitsLayer(LayerImpl* layer, 1132 static bool PointHitsLayer(LayerImpl* layer,
1135 const gfx::PointF& screen_space_point, 1133 const gfx::PointF& screen_space_point,
1136 float* distance_to_intersection) { 1134 float* distance_to_intersection) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion( 1267 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion(
1270 const gfx::PointF& screen_space_point) { 1268 const gfx::PointF& screen_space_point) {
1271 FindTouchEventLayerFunctor func = {screen_space_point}; 1269 FindTouchEventLayerFunctor func = {screen_space_point};
1272 FindClosestMatchingLayerDataForRecursion data_for_recursion; 1270 FindClosestMatchingLayerDataForRecursion data_for_recursion;
1273 FindClosestMatchingLayer( 1271 FindClosestMatchingLayer(
1274 screen_space_point, root_layer(), func, &data_for_recursion); 1272 screen_space_point, root_layer(), func, &data_for_recursion);
1275 return data_for_recursion.closest_match; 1273 return data_for_recursion.closest_match;
1276 } 1274 }
1277 1275
1278 } // namespace cc 1276 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/trees/layer_tree_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698