Ensure insets for input are transformed correctly.
This change does the following:
1. Takes the inverse transform and transforms the final layer bounds.
This is to find the real bounds, including insets after insets have been
added.
2. Use the top and left of the real bounds to get the translation value
for the transform. This is done by applying the original transform on
the new left and top.
3. Set the translation of the input transform as the calculated values
from above.
4. Send the inverse transform to input so the input coordinates can be
transformed to window space.
Also use the transform to correctly update the touchable regions in the
layer space.
Test: libgui_tests
Test: Rotated layer gets correct input
Fixes: 158802274
Change-Id: Ib0bfaa043509032ed702f442d806097bfd48d418
diff --git a/libs/ui/Transform.cpp b/libs/ui/Transform.cpp
index ec8a78a..cd68c1c 100644
--- a/libs/ui/Transform.cpp
+++ b/libs/ui/Transform.cpp
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#undef LOG_TAG
+#define LOG_TAG "Transform"
+
#include <math.h>
#include <android-base/stringprintf.h>
@@ -132,7 +135,7 @@
}
float Transform::getScaleX() const {
- return sqrt(dsdx() * dsdx()) + (dtdx() * dtdx());
+ return sqrt((dsdx() * dsdx()) + (dtdx() * dtdx()));
}
float Transform::getScaleY() const {