diff options
author | Jason Sams <jsams@google.com> | 2012-03-23 11:47:26 -0700 |
---|---|---|
committer | Jason Sams <jsams@google.com> | 2012-03-23 11:47:26 -0700 |
commit | fe1d5ffd1b6c4977a9f301997d2ad90e5b049a3b (patch) | |
tree | 7a3135d31e4415a4b6b31c7e44ad15cfa1ccc86f /graphics | |
parent | 3da5525558ad84757c48907eead66f44f0f5dd32 (diff) | |
download | frameworks_base-fe1d5ffd1b6c4977a9f301997d2ad90e5b049a3b.zip frameworks_base-fe1d5ffd1b6c4977a9f301997d2ad90e5b049a3b.tar.gz frameworks_base-fe1d5ffd1b6c4977a9f301997d2ad90e5b049a3b.tar.bz2 |
Implement USAGE_IO_INPUT
Change-Id: Idbf7bb21f5ab673ad77082c5c19921d2b276c04b
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/renderscript/Allocation.java | 27 | ||||
-rw-r--r-- | graphics/java/android/renderscript/RenderScript.java | 7 | ||||
-rw-r--r-- | graphics/jni/android_renderscript_RenderScript.cpp | 12 |
3 files changed, 26 insertions, 20 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index 6539ff3..adeeaca 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -131,22 +131,13 @@ public class Allocation extends BaseObj { public static final int USAGE_GRAPHICS_RENDER_TARGET = 0x0010; /** - * USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE The allocation - * will be used as a SurfaceTexture graphics consumer. This - * usage may only be used with USAGE_GRAPHICS_TEXTURE. - * - * @hide - */ - public static final int USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE = 0x0020; - - /** * USAGE_IO_INPUT The allocation will be used as SurfaceTexture * consumer. This usage will cause the allocation to be created * read only. * * @hide */ - public static final int USAGE_IO_INPUT = 0x0040; + public static final int USAGE_IO_INPUT = 0x0020; /** * USAGE_IO_OUTPUT The allocation will be used as a @@ -155,7 +146,7 @@ public class Allocation extends BaseObj { * * @hide */ - public static final int USAGE_IO_OUTPUT = 0x0080; + public static final int USAGE_IO_OUTPUT = 0x0040; /** * Controls mipmap behavior when using the bitmap creation and @@ -217,17 +208,15 @@ public class Allocation extends BaseObj { USAGE_GRAPHICS_VERTEX | USAGE_GRAPHICS_CONSTANTS | USAGE_GRAPHICS_RENDER_TARGET | - USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE | USAGE_IO_INPUT | USAGE_IO_OUTPUT)) != 0) { throw new RSIllegalArgumentException("Unknown usage specified."); } - if ((usage & (USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE | USAGE_IO_INPUT)) != 0) { + if ((usage & USAGE_IO_INPUT) != 0) { mWriteAllowed = false; - if ((usage & ~(USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE | - USAGE_IO_INPUT | + if ((usage & ~(USAGE_IO_INPUT | USAGE_GRAPHICS_TEXTURE | USAGE_SCRIPT)) != 0) { throw new RSIllegalArgumentException("Invalid usage combination."); @@ -348,7 +337,7 @@ public class Allocation extends BaseObj { public void ioGetInput() { if ((mUsage & USAGE_IO_INPUT) == 0) { throw new RSIllegalArgumentException( - "Can only send buffer if IO_OUTPUT usage specified."); + "Can only receive if IO_INPUT usage specified."); } mRS.validate(); mRS.nAllocationIoReceive(getID()); @@ -1134,13 +1123,15 @@ public class Allocation extends BaseObj { * */ public SurfaceTexture getSurfaceTexture() { - if ((mUsage & USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE) == 0) { + if ((mUsage & USAGE_IO_INPUT) == 0) { throw new RSInvalidStateException("Allocation is not a surface texture."); } int id = mRS.nAllocationGetSurfaceTextureID(getID()); - return new SurfaceTexture(id); + SurfaceTexture st = new SurfaceTexture(id); + mRS.nAllocationGetSurfaceTextureID2(getID(), st); + return st; } /** diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index 6921f37..ab6ba54 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -16,8 +16,8 @@ package android.renderscript; -import java.lang.reflect.Field; import java.io.File; +import java.lang.reflect.Field; import android.content.Context; import android.content.pm.ApplicationInfo; @@ -294,6 +294,11 @@ public class RenderScript { validate(); return rsnAllocationGetSurfaceTextureID(mContext, alloc); } + native void rsnAllocationGetSurfaceTextureID2(int con, int alloc, SurfaceTexture st); + synchronized void nAllocationGetSurfaceTextureID2(int alloc, SurfaceTexture st) { + validate(); + rsnAllocationGetSurfaceTextureID2(mContext, alloc, st); + } native void rsnAllocationSetSurfaceTexture(int con, int alloc, SurfaceTexture sur); synchronized void nAllocationSetSurfaceTexture(int alloc, SurfaceTexture sur) { validate(); diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index 9fc4fd4..9d4c64f 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -477,6 +477,15 @@ nAllocationGetSurfaceTextureID(JNIEnv *_env, jobject _this, RsContext con, jint } static void +nAllocationGetSurfaceTextureID2(JNIEnv *_env, jobject _this, RsContext con, jint a, jobject jst) +{ + LOG_API("nAllocationGetSurfaceTextureID2, con(%p), a(%p)", con, (RsAllocation)a); + sp<SurfaceTexture> st = SurfaceTexture_getSurfaceTexture(_env, jst); + + rsAllocationGetSurfaceTextureID2(con, (RsAllocation)a, st.get(), sizeof(SurfaceTexture *)); +} + +static void nAllocationSetSurfaceTexture(JNIEnv *_env, jobject _this, RsContext con, RsAllocation alloc, jobject sur) { @@ -1352,7 +1361,8 @@ static JNINativeMethod methods[] = { {"rsnAllocationSyncAll", "(III)V", (void*)nAllocationSyncAll }, {"rsnAllocationGetSurfaceTextureID", "(II)I", (void*)nAllocationGetSurfaceTextureID }, -{"rsnAllocationSetSurfaceTexture", "(IILandroid/graphics/SurfaceTexture;)V", (void*)nAllocationSetSurfaceTexture }, +{"rsnAllocationGetSurfaceTextureID2","(IILandroid/graphics/SurfaceTexture;)V",(void*)nAllocationGetSurfaceTextureID2 }, +{"rsnAllocationSetSurfaceTexture", "(IILandroid/graphics/SurfaceTexture;)V",(void*)nAllocationSetSurfaceTexture }, {"rsnAllocationIoSend", "(II)V", (void*)nAllocationIoSend }, {"rsnAllocationIoReceive", "(II)V", (void*)nAllocationIoReceive }, {"rsnAllocationData1D", "(IIIII[II)V", (void*)nAllocationData1D_i }, |