summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Prabir Pradhan <prabirmsp@google.com> 2021-10-27 11:20:17 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2021-10-27 11:20:17 +0000
commit272460f87c5778b533df230cc761fa690d54e387 (patch)
tree66fa644e33fcfc3c027c58499f541034a5d81e30
parentd8469616bbb17a1cd3bee6a148e113ee989bdf3c (diff)
parent4bb5ae9fa81fbc818556c2642b61ed0f95046f4b (diff)
MotionEvent: Avoid clipping tranformed orientation angle values am: 4bb5ae9fa8
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/16121849 Change-Id: Id39f16d41c989adebc2bb87473e06ef8908c097e
-rw-r--r--libs/input/Input.cpp9
1 files changed, 2 insertions, 7 deletions
diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp
index 35209f7a07..5f440b77e2 100644
--- a/libs/input/Input.cpp
+++ b/libs/input/Input.cpp
@@ -67,13 +67,8 @@ float transformAngle(const ui::Transform& transform, float angleRadians) {
transformedPoint.y -= origin.y;
// Derive the transformed vector's clockwise angle from vertical.
- float result = atan2f(transformedPoint.x, -transformedPoint.y);
- if (result < -M_PI_2) {
- result += M_PI;
- } else if (result > M_PI_2) {
- result -= M_PI;
- }
- return result;
+ // The return value of atan2f is in range [-pi, pi] which conforms to the orientation API.
+ return atan2f(transformedPoint.x, -transformedPoint.y);
}
// Rotates the given point to the specified orientation. If the display width and height are