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

Unified Diff: cc/math_util.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
« cc/layer_tree_host_impl.cc ('K') | « cc/math_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/math_util.cc
diff --git a/cc/math_util.cc b/cc/math_util.cc
index f5c0cb4eae3f447f214018ba766bfa102ca7ea9d..47bddd3a4b1ecbe0c4c4ead4cda787c75544f4a1 100644
--- a/cc/math_util.cc
+++ b/cc/math_util.cc
@@ -386,6 +386,26 @@ gfx::Vector2dF MathUtil::projectVector(gfx::Vector2dF source, gfx::Vector2dF des
return gfx::Vector2dF(projectedLength * destination.x(), projectedLength * destination.y());
}
+bool MathUtil::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 = 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);
+}
+
scoped_ptr<base::Value> MathUtil::asValue(gfx::Size s) {
scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue());
res->SetDouble("width", s.width());
« cc/layer_tree_host_impl.cc ('K') | « cc/math_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698