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

Unified Diff: cc/layer_tree_host_common.cc

Issue 12280014: cc: Don't consider HUD layer for touches (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: moved funcs around Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: cc/layer_tree_host_common.cc
diff --git a/cc/layer_tree_host_common.cc b/cc/layer_tree_host_common.cc
index 4d3377a919de45164bb5a33f7b0663b8d4397fcd..d2ae5a11ce11f1077f8535be891f9643dec9d741 100644
--- a/cc/layer_tree_host_common.cc
+++ b/cc/layer_tree_host_common.cc
@@ -1071,24 +1071,6 @@ void LayerTreeHostCommon::calculateDrawProperties(LayerImpl* rootLayer, const gf
DCHECK(rootLayer->renderSurface());
}
-static bool pointHitsRect(const gfx::PointF& screenSpacePoint, const gfx::Transform& localSpaceToScreenSpaceTransform, gfx::RectF localSpaceRect)
-{
- // If the transform is not invertible, then assume that this point doesn't hit this rect.
- gfx::Transform inverseLocalSpaceToScreenSpace(gfx::Transform::kSkipInitialization);
- if (!localSpaceToScreenSpaceTransform.GetInverse(&inverseLocalSpaceToScreenSpace))
- return false;
-
- // Transform the hit test point from screen space to the local space of the given rect.
- bool clipped = false;
- gfx::PointF hitTestPointInLocalSpace = MathUtil::projectPoint(inverseLocalSpaceToScreenSpace, screenSpacePoint, clipped);
-
- // If projectPoint could not project to a valid value, then we assume that this point doesn't hit this rect.
- if (clipped)
- return false;
-
- return localSpaceRect.Contains(hitTestPointInLocalSpace);
-}
-
static bool pointHitsRegion(gfx::PointF screenSpacePoint, const gfx::Transform& screenSpaceTransform, const Region& layerSpaceRegion, float layerContentScaleX, float layerContentScaleY)
{
// If the transform is not invertible, then assume that this point doesn't hit this region.
@@ -1108,19 +1090,19 @@ static bool pointHitsRegion(gfx::PointF screenSpacePoint, const gfx::Transform&
return layerSpaceRegion.Contains(gfx::ToRoundedPoint(hitTestPointInLayerSpace));
}
-static bool pointIsClippedBySurfaceOrClipRect(const gfx::PointF& screenSpacePoint, LayerImpl* layer)
+bool LayerTreeHostCommon::pointIsClippedBySurfaceOrClipRect(const gfx::PointF& screenSpacePoint, LayerImpl* layer)
{
LayerImpl* currentLayer = layer;
// Walk up the layer tree and hit-test any renderSurfaces and any layer clipRects that are active.
while (currentLayer) {
- if (currentLayer->renderSurface() && !pointHitsRect(screenSpacePoint, currentLayer->renderSurface()->screenSpaceTransform(), currentLayer->renderSurface()->contentRect()))
+ if (currentLayer->renderSurface() && !MathUtil::pointHitsRect(screenSpacePoint, currentLayer->renderSurface()->screenSpaceTransform(), currentLayer->renderSurface()->contentRect()))
return true;
// Note that drawableContentRects are actually in targetSurface space, so the transform we
// have to provide is the target surface's screenSpaceTransform.
LayerImpl* renderTarget = currentLayer->renderTarget();
- if (layerClipsSubtree(currentLayer) && !pointHitsRect(screenSpacePoint, renderTarget->renderSurface()->screenSpaceTransform(), currentLayer->drawableContentRect()))
+ if (layerClipsSubtree(currentLayer) && !MathUtil::pointHitsRect(screenSpacePoint, renderTarget->renderSurface()->screenSpaceTransform(), currentLayer->drawableContentRect()))
return true;
currentLayer = currentLayer->parent();
@@ -1130,38 +1112,6 @@ static bool pointIsClippedBySurfaceOrClipRect(const gfx::PointF& screenSpacePoin
return false;
}
-LayerImpl* LayerTreeHostCommon::findLayerThatIsHitByPoint(const gfx::PointF& screenSpacePoint, const std::vector<LayerImpl*>& renderSurfaceLayerList)
-{
- LayerImpl* foundLayer = 0;
-
- typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl, LayerIteratorActions::FrontToBack> LayerIteratorType;
- LayerIteratorType end = LayerIteratorType::end(&renderSurfaceLayerList);
-
- for (LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); it != end; ++it) {
- // We don't want to consider renderSurfaces for hit testing.
- if (!it.representsItself())
- continue;
-
- LayerImpl* currentLayer = (*it);
-
- gfx::RectF contentRect(gfx::PointF(), currentLayer->contentBounds());
- if (!pointHitsRect(screenSpacePoint, currentLayer->screenSpaceTransform(), contentRect))
- continue;
-
- // At this point, we think the point does hit the layer, but we need to walk up
- // the parents to ensure that the layer was not clipped in such a way that the
- // hit point actually should not hit the layer.
- if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, currentLayer))
- continue;
-
- foundLayer = currentLayer;
- break;
- }
-
- // This can potentially return 0, which means the screenSpacePoint did not successfully hit test any layers, not even the root layer.
- return foundLayer;
-}
-
LayerImpl* LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(const gfx::PointF& screenSpacePoint, const std::vector<LayerImpl*>& renderSurfaceLayerList)
{
LayerImpl* foundLayer = 0;

Powered by Google App Engine
This is Rietveld 408576698