diff options
author | chaviw <chaviw@google.com> | 2021-08-10 13:56:04 -0500 |
---|---|---|
committer | Chavi Weingarten <chaviw@google.com> | 2021-08-16 14:50:22 +0000 |
commit | 8ca2be726d07ad0810c29692158a0c9c57b563d4 (patch) | |
tree | 5c08a76959d5dc3f4215134e0228615f8872b252 /libs/hwui | |
parent | 577a74da8d0afb7a869a07a2fb5996b13906237d (diff) |
Add transform matrix to InputWindowHandle.
Added the transform matrix from WindowInfo native to the Java side
InputWindowHandle. This is to allow clients that register a
WindowInfoListener to translate the window's screen coordinates to
window space.
Test: Transform is now sent to WindowInfoListener
Bug: 188792659
Change-Id: Ifba8488ff470d3c6c8066e23b871c3d541cff0a1
Diffstat (limited to 'libs/hwui')
-rw-r--r-- | libs/hwui/apex/android_matrix.cpp | 7 | ||||
-rw-r--r-- | libs/hwui/apex/include/android/graphics/matrix.h | 10 | ||||
-rw-r--r-- | libs/hwui/jni/android_graphics_Matrix.cpp | 7 | ||||
-rw-r--r-- | libs/hwui/jni/android_graphics_Matrix.h | 3 | ||||
-rw-r--r-- | libs/hwui/libhwui.map.txt | 1 |
5 files changed, 28 insertions, 0 deletions
diff --git a/libs/hwui/apex/android_matrix.cpp b/libs/hwui/apex/android_matrix.cpp index 693b22b62663..04ac3cf0ebc8 100644 --- a/libs/hwui/apex/android_matrix.cpp +++ b/libs/hwui/apex/android_matrix.cpp @@ -35,3 +35,10 @@ bool AMatrix_getContents(JNIEnv* env, jobject matrixObj, float values[9]) { } return false; } + +jobject AMatrix_newInstance(JNIEnv* env, float values[9]) { + jobject matrixObj = android::android_graphics_Matrix_newInstance(env); + SkMatrix* m = android::android_graphics_Matrix_getSkMatrix(env, matrixObj); + m->set9(values); + return matrixObj; +} diff --git a/libs/hwui/apex/include/android/graphics/matrix.h b/libs/hwui/apex/include/android/graphics/matrix.h index 987ad13f7635..5705ba485ba3 100644 --- a/libs/hwui/apex/include/android/graphics/matrix.h +++ b/libs/hwui/apex/include/android/graphics/matrix.h @@ -34,6 +34,16 @@ __BEGIN_DECLS */ ANDROID_API bool AMatrix_getContents(JNIEnv* env, jobject matrixObj, float values[9]); +/** + * Returns a new Matrix jobject that contains the values passed in as initial values. + * @param values The 9 values of the 3x3 matrix in the following order. + * values[0] = scaleX values[1] = skewX values[2] = transX + * values[3] = skewY values[4] = scaleY values[5] = transY + * values[6] = persp0 values[7] = persp1 values[8] = persp2 + * @return The matrix jobject + */ +ANDROID_API jobject AMatrix_newInstance(JNIEnv* env, float values[9]); + __END_DECLS #endif // ANDROID_GRAPHICS_MATRIX_H diff --git a/libs/hwui/jni/android_graphics_Matrix.cpp b/libs/hwui/jni/android_graphics_Matrix.cpp index 7338ef24cb58..cf6702e45fff 100644 --- a/libs/hwui/jni/android_graphics_Matrix.cpp +++ b/libs/hwui/jni/android_graphics_Matrix.cpp @@ -378,13 +378,17 @@ static const JNINativeMethod methods[] = { {"nEquals", "(JJ)Z", (void*) SkMatrixGlue::equals} }; +static jclass sClazz; static jfieldID sNativeInstanceField; +static jmethodID sCtor; int register_android_graphics_Matrix(JNIEnv* env) { int result = RegisterMethodsOrDie(env, "android/graphics/Matrix", methods, NELEM(methods)); jclass clazz = FindClassOrDie(env, "android/graphics/Matrix"); + sClazz = MakeGlobalRefOrDie(env, clazz); sNativeInstanceField = GetFieldIDOrDie(env, clazz, "native_instance", "J"); + sCtor = GetMethodIDOrDie(env, clazz, "<init>", "()V"); return result; } @@ -393,4 +397,7 @@ SkMatrix* android_graphics_Matrix_getSkMatrix(JNIEnv* env, jobject matrixObj) { return reinterpret_cast<SkMatrix*>(env->GetLongField(matrixObj, sNativeInstanceField)); } +jobject android_graphics_Matrix_newInstance(JNIEnv* env) { + return env->NewObject(sClazz, sCtor); +} } diff --git a/libs/hwui/jni/android_graphics_Matrix.h b/libs/hwui/jni/android_graphics_Matrix.h index fe90d2ef945d..79de48b46954 100644 --- a/libs/hwui/jni/android_graphics_Matrix.h +++ b/libs/hwui/jni/android_graphics_Matrix.h @@ -25,6 +25,9 @@ namespace android { /* Gets the underlying SkMatrix from a Matrix object. */ SkMatrix* android_graphics_Matrix_getSkMatrix(JNIEnv* env, jobject matrixObj); +/* Creates a new Matrix java object. */ +jobject android_graphics_Matrix_newInstance(JNIEnv* env); + } // namespace android #endif // _ANDROID_GRAPHICS_MATRIX_H_ diff --git a/libs/hwui/libhwui.map.txt b/libs/hwui/libhwui.map.txt index 73de0d12a60b..77b8a44d85a1 100644 --- a/libs/hwui/libhwui.map.txt +++ b/libs/hwui/libhwui.map.txt @@ -28,6 +28,7 @@ LIBHWUI { register_android_graphics_GraphicsStatsService; zygote_preload_graphics; AMatrix_getContents; + AMatrix_newInstance; APaint_createPaint; APaint_destroyPaint; APaint_setBlendMode; |