Merge "Add transform matrix to InputWindowHandle." into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
73f529933e
@@ -19,6 +19,7 @@ package android.view;
|
|||||||
import static android.view.Display.INVALID_DISPLAY;
|
import static android.view.Display.INVALID_DISPLAY;
|
||||||
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
|
import android.graphics.Matrix;
|
||||||
import android.graphics.Region;
|
import android.graphics.Region;
|
||||||
import android.gui.TouchOcclusionMode;
|
import android.gui.TouchOcclusionMode;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
@@ -122,6 +123,12 @@ public final class InputWindowHandle {
|
|||||||
*/
|
*/
|
||||||
public boolean replaceTouchableRegionWithCrop;
|
public boolean replaceTouchableRegionWithCrop;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The transform that should be applied to the Window to get it from screen coordinates to
|
||||||
|
* window coordinates
|
||||||
|
*/
|
||||||
|
public Matrix transform;
|
||||||
|
|
||||||
private native void nativeDispose();
|
private native void nativeDispose();
|
||||||
|
|
||||||
public InputWindowHandle(InputApplicationHandle inputApplicationHandle, int displayId) {
|
public InputWindowHandle(InputApplicationHandle inputApplicationHandle, int displayId) {
|
||||||
@@ -136,6 +143,8 @@ public final class InputWindowHandle {
|
|||||||
.append(frameRight).append(",").append(frameBottom).append("]")
|
.append(frameRight).append(",").append(frameBottom).append("]")
|
||||||
.append(", touchableRegion=").append(touchableRegion)
|
.append(", touchableRegion=").append(touchableRegion)
|
||||||
.append(", visible=").append(visible)
|
.append(", visible=").append(visible)
|
||||||
|
.append(", scaleFactor=").append(scaleFactor)
|
||||||
|
.append(", transform=").append(transform)
|
||||||
.toString();
|
.toString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <ui/Region.h>
|
#include <ui/Region.h>
|
||||||
#include <utils/threads.h>
|
#include <utils/threads.h>
|
||||||
|
|
||||||
|
#include <android/graphics/matrix.h>
|
||||||
#include <gui/WindowInfo.h>
|
#include <gui/WindowInfo.h>
|
||||||
#include "SkRegion.h"
|
#include "SkRegion.h"
|
||||||
#include "android_hardware_input_InputApplicationHandle.h"
|
#include "android_hardware_input_InputApplicationHandle.h"
|
||||||
@@ -74,6 +75,7 @@ static struct {
|
|||||||
jfieldID displayId;
|
jfieldID displayId;
|
||||||
jfieldID replaceTouchableRegionWithCrop;
|
jfieldID replaceTouchableRegionWithCrop;
|
||||||
WeakRefHandleField touchableRegionSurfaceControl;
|
WeakRefHandleField touchableRegionSurfaceControl;
|
||||||
|
jfieldID transform;
|
||||||
} gInputWindowHandleClassInfo;
|
} gInputWindowHandleClassInfo;
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
@@ -305,6 +307,13 @@ jobject android_view_InputWindowHandle_fromWindowInfo(JNIEnv* env, gui::WindowIn
|
|||||||
env->SetIntField(inputWindowHandle, gInputWindowHandleClassInfo.inputFeatures,
|
env->SetIntField(inputWindowHandle, gInputWindowHandleClassInfo.inputFeatures,
|
||||||
static_cast<int32_t>(windowInfo.inputFeatures.get()));
|
static_cast<int32_t>(windowInfo.inputFeatures.get()));
|
||||||
|
|
||||||
|
float transformVals[9];
|
||||||
|
for (int i = 0; i < 9; i++) {
|
||||||
|
transformVals[i] = windowInfo.transform[i % 3][i / 3];
|
||||||
|
}
|
||||||
|
ScopedLocalRef<jobject> matrixObj(env, AMatrix_newInstance(env, transformVals));
|
||||||
|
env->SetObjectField(inputWindowHandle, gInputWindowHandleClassInfo.transform, matrixObj.get());
|
||||||
|
|
||||||
return inputWindowHandle;
|
return inputWindowHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,6 +438,9 @@ int register_android_view_InputWindowHandle(JNIEnv* env) {
|
|||||||
GET_FIELD_ID(gInputWindowHandleClassInfo.replaceTouchableRegionWithCrop, clazz,
|
GET_FIELD_ID(gInputWindowHandleClassInfo.replaceTouchableRegionWithCrop, clazz,
|
||||||
"replaceTouchableRegionWithCrop", "Z");
|
"replaceTouchableRegionWithCrop", "Z");
|
||||||
|
|
||||||
|
GET_FIELD_ID(gInputWindowHandleClassInfo.transform, clazz, "transform",
|
||||||
|
"Landroid/graphics/Matrix;");
|
||||||
|
|
||||||
jclass weakRefClazz;
|
jclass weakRefClazz;
|
||||||
FIND_CLASS(weakRefClazz, "java/lang/ref/Reference");
|
FIND_CLASS(weakRefClazz, "java/lang/ref/Reference");
|
||||||
|
|
||||||
|
|||||||
@@ -35,3 +35,10 @@ bool AMatrix_getContents(JNIEnv* env, jobject matrixObj, float values[9]) {
|
|||||||
}
|
}
|
||||||
return false;
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -34,6 +34,16 @@ __BEGIN_DECLS
|
|||||||
*/
|
*/
|
||||||
ANDROID_API bool AMatrix_getContents(JNIEnv* env, jobject matrixObj, float values[9]);
|
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
|
__END_DECLS
|
||||||
|
|
||||||
#endif // ANDROID_GRAPHICS_MATRIX_H
|
#endif // ANDROID_GRAPHICS_MATRIX_H
|
||||||
|
|||||||
@@ -378,13 +378,17 @@ static const JNINativeMethod methods[] = {
|
|||||||
{"nEquals", "(JJ)Z", (void*) SkMatrixGlue::equals}
|
{"nEquals", "(JJ)Z", (void*) SkMatrixGlue::equals}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static jclass sClazz;
|
||||||
static jfieldID sNativeInstanceField;
|
static jfieldID sNativeInstanceField;
|
||||||
|
static jmethodID sCtor;
|
||||||
|
|
||||||
int register_android_graphics_Matrix(JNIEnv* env) {
|
int register_android_graphics_Matrix(JNIEnv* env) {
|
||||||
int result = RegisterMethodsOrDie(env, "android/graphics/Matrix", methods, NELEM(methods));
|
int result = RegisterMethodsOrDie(env, "android/graphics/Matrix", methods, NELEM(methods));
|
||||||
|
|
||||||
jclass clazz = FindClassOrDie(env, "android/graphics/Matrix");
|
jclass clazz = FindClassOrDie(env, "android/graphics/Matrix");
|
||||||
|
sClazz = MakeGlobalRefOrDie(env, clazz);
|
||||||
sNativeInstanceField = GetFieldIDOrDie(env, clazz, "native_instance", "J");
|
sNativeInstanceField = GetFieldIDOrDie(env, clazz, "native_instance", "J");
|
||||||
|
sCtor = GetMethodIDOrDie(env, clazz, "<init>", "()V");
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -393,4 +397,7 @@ SkMatrix* android_graphics_Matrix_getSkMatrix(JNIEnv* env, jobject matrixObj) {
|
|||||||
return reinterpret_cast<SkMatrix*>(env->GetLongField(matrixObj, sNativeInstanceField));
|
return reinterpret_cast<SkMatrix*>(env->GetLongField(matrixObj, sNativeInstanceField));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jobject android_graphics_Matrix_newInstance(JNIEnv* env) {
|
||||||
|
return env->NewObject(sClazz, sCtor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ namespace android {
|
|||||||
/* Gets the underlying SkMatrix from a Matrix object. */
|
/* Gets the underlying SkMatrix from a Matrix object. */
|
||||||
SkMatrix* android_graphics_Matrix_getSkMatrix(JNIEnv* env, jobject matrixObj);
|
SkMatrix* android_graphics_Matrix_getSkMatrix(JNIEnv* env, jobject matrixObj);
|
||||||
|
|
||||||
|
/* Creates a new Matrix java object. */
|
||||||
|
jobject android_graphics_Matrix_newInstance(JNIEnv* env);
|
||||||
|
|
||||||
} // namespace android
|
} // namespace android
|
||||||
|
|
||||||
#endif // _ANDROID_GRAPHICS_MATRIX_H_
|
#endif // _ANDROID_GRAPHICS_MATRIX_H_
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ LIBHWUI {
|
|||||||
register_android_graphics_GraphicsStatsService;
|
register_android_graphics_GraphicsStatsService;
|
||||||
zygote_preload_graphics;
|
zygote_preload_graphics;
|
||||||
AMatrix_getContents;
|
AMatrix_getContents;
|
||||||
|
AMatrix_newInstance;
|
||||||
APaint_createPaint;
|
APaint_createPaint;
|
||||||
APaint_destroyPaint;
|
APaint_destroyPaint;
|
||||||
APaint_setBlendMode;
|
APaint_setBlendMode;
|
||||||
|
|||||||
Reference in New Issue
Block a user