From b0ba48c95ea8768a051100c5adb4c906caa1e080 Mon Sep 17 00:00:00 2001 From: Jamie Gennis Date: Sun, 9 Jan 2011 18:22:05 -0800 Subject: [PATCH] Add getTransformMatrix to the SurfaceTexture API. Change-Id: Icd11ed4982220be9d08b00498aef02531610ce1f --- api/current.xml | 13 ++++++++++ core/jni/android/graphics/SurfaceTexture.cpp | 10 ++++++++ .../java/android/graphics/SurfaceTexture.java | 25 +++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/api/current.xml b/api/current.xml index 3b1c900a8fc17..20a2814a02f6d 100644 --- a/api/current.xml +++ b/api/current.xml @@ -86020,6 +86020,19 @@ + + + + updateTexImage(); } +static void SurfaceTexture_getTransformMatrix(JNIEnv* env, jobject clazz, + jfloatArray jmtx) +{ + sp surfaceTexture(getSurfaceTexture(env, clazz)); + float* mtx = env->GetFloatArrayElements(jmtx, NULL); + surfaceTexture->getTransformMatrix(mtx); + env->ReleaseFloatArrayElements(jmtx, mtx, 0); +} + // ---------------------------------------------------------------------------- const char* const kSurfaceTextureClassPathName = "android/graphics/SurfaceTexture"; @@ -91,6 +100,7 @@ static JNINativeMethod gSurfaceTextureMethods[] = { {"nativeClassInit", "()V", (void*)nativeClassInit }, {"init", "(I)V", (void*)SurfaceTexture_init }, {"updateTexImage", "()V", (void*)SurfaceTexture_updateTexImage }, + {"getTransformMatrixImpl", "([F)V", (void*)SurfaceTexture_getTransformMatrix }, }; static void nativeClassInit(JNIEnv* env, jclass clazz) diff --git a/graphics/java/android/graphics/SurfaceTexture.java b/graphics/java/android/graphics/SurfaceTexture.java index 883c4ebbb750c..3eb0b03d4cc1a 100644 --- a/graphics/java/android/graphics/SurfaceTexture.java +++ b/graphics/java/android/graphics/SurfaceTexture.java @@ -79,6 +79,31 @@ public class SurfaceTexture { */ public native void updateTexImage(); + + /** + * Retrieve the 4x4 texture coordinate transform matrix associated with the texture image set by + * the most recent call to updateTexImage. + * + * This transform matrix maps 2D homogeneous texture coordinates of the form (s, t, 0, 1) with s + * and t in the inclusive range [0, 1] to the texture coordinate that should be used to sample + * that location from the texture. Sampling the texture outside of the range of this transform + * is undefined. + * + * The matrix is stored in column-major order so that it may be passed directly to OpenGL ES via + * the glLoadMatrixf or glUniformMatrix4fv functions. + * + * @param mtx the array into which the 4x4 matrix will be stored. The array must have exactly + * 16 elements. + */ + public void getTransformMatrix(float[] mtx) { + if (mtx.length != 16) { + throw new IllegalArgumentException(); + } + getTransformMatrixImpl(mtx); + } + + private native void getTransformMatrixImpl(float[] mtx); + private native void init(int texName); /*