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

Unified Diff: mojo/services/geometry/cpp/geometry_util.cc

Issue 1776473005: Mozart: Implement basic input event dispatch with hit testing. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-7
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/services/geometry/cpp/geometry_util.h ('k') | services/ui/input_manager/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/services/geometry/cpp/geometry_util.cc
diff --git a/mojo/services/geometry/cpp/geometry_util.cc b/mojo/services/geometry/cpp/geometry_util.cc
index 570f707a2462db19f7e2cbfeb79c8308e8b5c573..f81e0ea2c2acec5437d04522c32a873bd42008cd 100644
--- a/mojo/services/geometry/cpp/geometry_util.cc
+++ b/mojo/services/geometry/cpp/geometry_util.cc
@@ -26,4 +26,22 @@ void SetTranslationTransform(Transform* transform, float x, float y, float z) {
transform->matrix[11] = z;
}
+Point TransformPoint(const Transform& transform, const Point& point) {
+ // TODO(jeffbrown): If w is 0, then the point should be at infinity.
+ // Also, we should perhaps be using PointF here rather than Point.
+ float w = transform.matrix[12] * point.x + transform.matrix[13] * point.y +
+ transform.matrix[15];
+ if (!w)
+ w = 1.f / w;
+
+ Point result;
+ result.x = (transform.matrix[0] * point.x + transform.matrix[1] * point.y +
+ transform.matrix[3]) *
+ w;
+ result.y = (transform.matrix[4] * point.x + transform.matrix[5] * point.y +
+ transform.matrix[7]) *
+ w;
+ return result;
+}
+
} // namespace mojo
« no previous file with comments | « mojo/services/geometry/cpp/geometry_util.h ('k') | services/ui/input_manager/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698