Recalculate Transform type after obtaining an inverse Transform
When getting the inverse of a Transform, the type can change. For
example, the inverse of a ROT_90 transform is a ROT_270 transform. We
need to recalculate the type of the inverse Transform.
Bug: 200794735
Bug: 179274888
Test: atest Transform_test
Change-Id: I10c8613e34edf8e76a5692c01bc58ce7e498cf4b
diff --git a/libs/ui/Transform.cpp b/libs/ui/Transform.cpp
index cd68c1c..b34d906 100644
--- a/libs/ui/Transform.cpp
+++ b/libs/ui/Transform.cpp
@@ -396,6 +396,11 @@
result.mMatrix[1][0] = -b*idet;
result.mMatrix[1][1] = a*idet;
result.mType = mType;
+ if (getOrientation() & ROT_90) {
+ // Recalculate the type if there is a 90-degree rotation component, since the inverse
+ // of ROT_90 is ROT_270 and vice versa.
+ result.mType |= UNKNOWN_TYPE;
+ }
vec2 T(-x, -y);
T = result.transform(T);