Implement USAGE_IO_INPUT
Change-Id: Idbf7bb21f5ab673ad77082c5c19921d2b276c04b
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 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 @@
*
* @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 @@
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 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 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 @@
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();