Chromium Code Reviews| 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_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 Loading... | |
| 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; | 1109 LayerImpl* render_target = NULL; |
| 1110 bool last_layer_had_surface = false; | |
| 1102 | 1111 |
| 1103 // Walk up the layer tree and hit-test any render_surfaces and any layer | 1112 // Walk up the layer tree and hit-test any render_surfaces and any layer |
| 1104 // clip rects that are active. | 1113 // clip rects that are active. |
| 1105 while (current_layer) { | 1114 for (; layer; layer = GetNextClippingLayer(layer)) { |
| 1106 if (current_layer->render_surface() && | 1115 if (last_layer_had_surface || layer->IsDrawnRenderSurfaceLayerListMember()) |
| 1116 render_target = layer->render_target(); | |
| 1117 | |
| 1118 if (layer->render_surface() && | |
| 1119 !PointHitsRect(screen_space_point, | |
| 1120 layer->render_surface()->screen_space_transform(), | |
| 1121 layer->render_surface()->content_rect(), | |
| 1122 NULL)) | |
| 1123 return true; | |
| 1124 | |
| 1125 // Note that drawable content rects are actually in target surface space, | |
| 1126 // so the transform we have to provide is the target surface's | |
| 1127 // screen_space_transform. | |
| 1128 if (render_target && LayerClipsSubtree(layer) && | |
| 1107 !PointHitsRect( | 1129 !PointHitsRect( |
| 1108 screen_space_point, | 1130 screen_space_point, |
| 1109 current_layer->render_surface()->screen_space_transform(), | 1131 render_target->render_surface()->screen_space_transform(), |
| 1110 current_layer->render_surface()->content_rect(), | 1132 gfx::Rect(layer->drawable_content_rect()), |
|
danakj
2014/06/11 17:43:06
no gfx::Rect needed
is there some guarantee that
| |
| 1111 NULL)) | 1133 NULL)) |
| 1112 return true; | 1134 return true; |
| 1113 | 1135 |
| 1114 // Note that drawable content rects are actually in target surface space, so | 1136 last_layer_had_surface = !!layer->render_surface(); |
| 1115 // the transform we have to provide is the target surface's | |
| 1116 // screen_space_transform. | |
| 1117 LayerImpl* render_target = current_layer->render_target(); | |
| 1118 if (LayerClipsSubtree(current_layer) && | |
| 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; | |
| 1125 | |
| 1126 current_layer = current_layer->parent(); | |
| 1127 } | 1137 } |
| 1128 | 1138 |
| 1129 // If we have finished walking all ancestors without having already exited, | 1139 // If we have finished walking all ancestors without having already exited, |
| 1130 // then the point is not clipped by any ancestors. | 1140 // then the point is not clipped by any ancestors. |
| 1131 return false; | 1141 return false; |
| 1132 } | 1142 } |
| 1133 | 1143 |
| 1134 static bool PointHitsLayer(LayerImpl* layer, | 1144 static bool PointHitsLayer(LayerImpl* layer, |
| 1135 const gfx::PointF& screen_space_point, | 1145 const gfx::PointF& screen_space_point, |
| 1136 float* distance_to_intersection) { | 1146 float* distance_to_intersection) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1269 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion( | 1279 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 1270 const gfx::PointF& screen_space_point) { | 1280 const gfx::PointF& screen_space_point) { |
| 1271 FindTouchEventLayerFunctor func = {screen_space_point}; | 1281 FindTouchEventLayerFunctor func = {screen_space_point}; |
| 1272 FindClosestMatchingLayerDataForRecursion data_for_recursion; | 1282 FindClosestMatchingLayerDataForRecursion data_for_recursion; |
| 1273 FindClosestMatchingLayer( | 1283 FindClosestMatchingLayer( |
| 1274 screen_space_point, root_layer(), func, &data_for_recursion); | 1284 screen_space_point, root_layer(), func, &data_for_recursion); |
| 1275 return data_for_recursion.closest_match; | 1285 return data_for_recursion.closest_match; |
| 1276 } | 1286 } |
| 1277 | 1287 |
| 1278 } // namespace cc | 1288 } // namespace cc |
| OLD | NEW |