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

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
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..bb9353d1c1826dc13cc169331ba1df1c1b997ae1 100644
--- a/mojo/services/geometry/cpp/geometry_util.cc
+++ b/mojo/services/geometry/cpp/geometry_util.cc
@@ -26,4 +26,19 @@ void SetTranslationTransform(Transform* transform, float x, float y, float z) {
transform->matrix[11] = z;
}
+Point TransformPoint(const Transform& transform, const Point& point) {
+ Point result;
+ result.x = transform.matrix[0] * point.x + transform.matrix[1] * point.y +
+ transform.matrix[3];
+ result.y = transform.matrix[4] * point.x + transform.matrix[5] * point.y +
+ transform.matrix[7];
+ float z = transform.matrix[12] * point.x + transform.matrix[13] * point.y +
abarth 2016/03/09 04:17:37 We usually call this quantity `w`
+ transform.matrix[15];
+ if (z)
+ z = 1.f / z;
abarth 2016/03/09 04:17:37 If `w` is zero, the Point should be at infinity.
jeffbrown 2016/03/09 19:38:50 Well, but which infinity? This behavior is consis
+ result.x *= z;
+ result.y *= z;
+ return result;
+}
+
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698