diff options
| author | Jason Sams <rjsams@android.com> | 2012-02-10 13:24:18 -0800 |
|---|---|---|
| committer | Jason Sams <rjsams@android.com> | 2012-02-10 13:24:18 -0800 |
| commit | 532efd3ce261f9901bfa51d37377069fe6e8ccdf (patch) | |
| tree | bd76cb870aa11a0a906de323e3d75b594fd4b93b /graphics/java/android/renderscript | |
| parent | d51280f10bb06a2d7abb8bd2980415733673c88b (diff) | |
| download | frameworks_base-532efd3ce261f9901bfa51d37377069fe6e8ccdf.zip frameworks_base-532efd3ce261f9901bfa51d37377069fe6e8ccdf.tar.gz frameworks_base-532efd3ce261f9901bfa51d37377069fe6e8ccdf.tar.bz2 | |
Start implementing SurfaceTexture streaming into RS allocations.
Change-Id: I561fbb63c63371ea59047c07fb2d68c21d16e76b
Conflicts:
libs/rs/rsAllocation.h
Diffstat (limited to 'graphics/java/android/renderscript')
| -rw-r--r-- | graphics/java/android/renderscript/Allocation.java | 64 | ||||
| -rw-r--r-- | graphics/java/android/renderscript/RenderScript.java | 6 |
2 files changed, 69 insertions, 1 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index 11c2427..509b972 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -22,6 +22,7 @@ import android.content.res.Resources; import android.content.res.AssetManager; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.graphics.SurfaceTexture; import android.util.Log; import android.util.TypedValue; @@ -78,6 +79,8 @@ public class Allocation extends BaseObj { boolean mConstrainedFace; boolean mConstrainedY; boolean mConstrainedZ; + boolean mReadAllowed = true; + boolean mWriteAllowed = true; int mSelectedY; int mSelectedZ; int mSelectedLOD; @@ -127,6 +130,32 @@ public class Allocation extends BaseObj { */ public static final int USAGE_GRAPHICS_RENDER_TARGET = 0x0010; + /** + * USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT The allcation will be + * used with a SurfaceTexture object. This usage will cause the + * allocation to be created read only. + * + * @hide + */ + public static final int USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE = 0x0020; + + /** + * USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT The allcation will be + * used with a SurfaceTexture object. This usage will cause the + * allocation to be created read only. + * + * @hide + */ + + public static final int USAGE_IO_INPUT = 0x0040; + /** + * USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT The allcation will be + * used with a SurfaceTexture object. This usage will cause the + * allocation to be created read only. + * + * @hide + */ + public static final int USAGE_IO_OUTPUT = 0x0080; /** * Controls mipmap behavior when using the bitmap creation and @@ -187,10 +216,26 @@ public class Allocation extends BaseObj { USAGE_GRAPHICS_TEXTURE | USAGE_GRAPHICS_VERTEX | USAGE_GRAPHICS_CONSTANTS | - USAGE_GRAPHICS_RENDER_TARGET)) != 0) { + 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) { + mWriteAllowed = false; + + if ((usage & ~(USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE | + USAGE_IO_INPUT | + USAGE_GRAPHICS_TEXTURE | + USAGE_SCRIPT)) != 0) { + throw new RSIllegalArgumentException("Invalid usage combination."); + } + } + mType = t; + mUsage = usage; if (t != null) { updateCacheInfo(t); @@ -1006,6 +1051,23 @@ public class Allocation extends BaseObj { } /** + * + * + * @hide + * + */ + public SurfaceTexture getSurfaceTexture() { + if ((mUsage & USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE) == 0) { + throw new RSInvalidStateException("Allocation is not a surface texture."); + } + + int id = mRS.nAllocationGetSurfaceTextureID(getID()); + return new SurfaceTexture(id); + + } + + + /** * Creates a non-mipmapped renderscript allocation to use as a * graphics texture * diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index bfe412c..3f3033b 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -269,6 +269,12 @@ public class RenderScript { validate(); rsnAllocationSyncAll(mContext, alloc, src); } + native int rsnAllocationGetSurfaceTextureID(int con, int alloc); + synchronized int nAllocationGetSurfaceTextureID(int alloc) { + validate(); + return rsnAllocationGetSurfaceTextureID(mContext, alloc); + } + native void rsnAllocationGenerateMipmaps(int con, int alloc); synchronized void nAllocationGenerateMipmaps(int alloc) { validate(); |
