summaryrefslogtreecommitdiff
path: root/graphics/java/android/renderscript/RenderScript.java
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/java/android/renderscript/RenderScript.java')
-rw-r--r--graphics/java/android/renderscript/RenderScript.java101
1 files changed, 84 insertions, 17 deletions
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index 66960bcdbebf..bef28aa89709 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -102,6 +102,16 @@ public class RenderScript {
f.mkdirs();
}
+ public enum ContextType {
+ NORMAL (0),
+ DEBUG (1),
+ PROFILE (2);
+
+ int mID;
+ ContextType(int id) {
+ mID = id;
+ }
+ }
// Methods below are wrapped to protect the non-threadsafe
// lockless fifo.
@@ -122,9 +132,9 @@ public class RenderScript {
stencilMin, stencilPref,
samplesMin, samplesPref, samplesQ, dpi);
}
- native int rsnContextCreate(int dev, int ver, int sdkVer);
- synchronized int nContextCreate(int dev, int ver, int sdkVer) {
- return rsnContextCreate(dev, ver, sdkVer);
+ native int rsnContextCreate(int dev, int ver, int sdkVer, int contextType);
+ synchronized int nContextCreate(int dev, int ver, int sdkVer, int contextType) {
+ return rsnContextCreate(dev, ver, sdkVer, contextType);
}
native void rsnContextDestroy(int con);
synchronized void nContextDestroy() {
@@ -157,6 +167,12 @@ public class RenderScript {
rsnContextFinish(mContext);
}
+ native void rsnContextSendMessage(int con, int id, int[] data);
+ synchronized void nContextSendMessage(int id, int[] data) {
+ validate();
+ rsnContextSendMessage(mContext, id, data);
+ }
+
native void rsnContextBindRootScript(int con, int script);
synchronized void nContextBindRootScript(int script) {
validate();
@@ -240,10 +256,10 @@ public class RenderScript {
rsnElementGetSubElements(mContext, id, IDs, names, arraySizes);
}
- native int rsnTypeCreate(int con, int eid, int x, int y, int z, boolean mips, boolean faces);
- synchronized int nTypeCreate(int eid, int x, int y, int z, boolean mips, boolean faces) {
+ native int rsnTypeCreate(int con, int eid, int x, int y, int z, boolean mips, boolean faces, int yuv);
+ synchronized int nTypeCreate(int eid, int x, int y, int z, boolean mips, boolean faces, int yuv) {
validate();
- return rsnTypeCreate(mContext, eid, x, y, z, mips, faces);
+ return rsnTypeCreate(mContext, eid, x, y, z, mips, faces, yuv);
}
native void rsnTypeGetNativeData(int con, int id, int[] typeData);
synchronized void nTypeGetNativeData(int id, int[] typeData) {
@@ -261,6 +277,14 @@ public class RenderScript {
validate();
return rsnAllocationCreateFromBitmap(mContext, type, mip, bmp, usage);
}
+
+ native int rsnAllocationCreateBitmapBackedAllocation(int con, int type, int mip, Bitmap bmp, int usage);
+ synchronized int nAllocationCreateBitmapBackedAllocation(int type, int mip, Bitmap bmp, int usage) {
+ validate();
+ return rsnAllocationCreateBitmapBackedAllocation(mContext, type, mip, bmp, usage);
+ }
+
+
native int rsnAllocationCubeCreateFromBitmap(int con, int type, int mip, Bitmap bmp, int usage);
synchronized int nAllocationCubeCreateFromBitmap(int type, int mip, Bitmap bmp, int usage) {
validate();
@@ -289,15 +313,10 @@ 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 rsnAllocationGetSurfaceTextureID2(int con, int alloc, SurfaceTexture st);
- synchronized void nAllocationGetSurfaceTextureID2(int alloc, SurfaceTexture st) {
+ native Surface rsnAllocationGetSurface(int con, int alloc);
+ synchronized Surface nAllocationGetSurface(int alloc) {
validate();
- rsnAllocationGetSurfaceTextureID2(mContext, alloc, st);
+ return rsnAllocationGetSurface(mContext, alloc);
}
native void rsnAllocationSetSurface(int con, int alloc, Surface sur);
synchronized void nAllocationSetSurface(int alloc, Surface sur) {
@@ -503,6 +522,10 @@ public class RenderScript {
}
native void rsnScriptForEach(int con, int id, int slot, int ain, int aout, byte[] params);
native void rsnScriptForEach(int con, int id, int slot, int ain, int aout);
+ native void rsnScriptForEachClipped(int con, int id, int slot, int ain, int aout, byte[] params,
+ int xstart, int xend, int ystart, int yend, int zstart, int zend);
+ native void rsnScriptForEachClipped(int con, int id, int slot, int ain, int aout,
+ int xstart, int xend, int ystart, int yend, int zstart, int zend);
synchronized void nScriptForEach(int id, int slot, int ain, int aout, byte[] params) {
validate();
if (params == null) {
@@ -511,6 +534,17 @@ public class RenderScript {
rsnScriptForEach(mContext, id, slot, ain, aout, params);
}
}
+
+ synchronized void nScriptForEachClipped(int id, int slot, int ain, int aout, byte[] params,
+ int xstart, int xend, int ystart, int yend, int zstart, int zend) {
+ validate();
+ if (params == null) {
+ rsnScriptForEachClipped(mContext, id, slot, ain, aout, xstart, xend, ystart, yend, zstart, zend);
+ } else {
+ rsnScriptForEachClipped(mContext, id, slot, ain, aout, params, xstart, xend, ystart, yend, zstart, zend);
+ }
+ }
+
native void rsnScriptInvokeV(int con, int id, int slot, byte[] params);
synchronized void nScriptInvokeV(int id, int slot, byte[] params) {
validate();
@@ -772,6 +806,9 @@ public class RenderScript {
Sampler mSampler_WRAP_NEAREST;
Sampler mSampler_WRAP_LINEAR;
Sampler mSampler_WRAP_LINEAR_MIP_LINEAR;
+ Sampler mSampler_MIRRORED_REPEAT_NEAREST;
+ Sampler mSampler_MIRRORED_REPEAT_LINEAR;
+ Sampler mSampler_MIRRORED_REPEAT_LINEAR_MIP_LINEAR;
ProgramStore mProgramStore_BLEND_NONE_DEPTH_TEST;
ProgramStore mProgramStore_BLEND_NONE_DEPTH_NO_DEPTH;
@@ -816,6 +853,16 @@ public class RenderScript {
}
/**
+ * @hide
+ *
+ * @param id
+ * @param data
+ */
+ public void sendMessage(int id, int[] data) {
+ nContextSendMessage(id, data);
+ }
+
+ /**
* Runtime error base class. An application should derive from this class
* if it wishes to install an error handler. When errors occur at runtime
* the fields in this class will be filled and the run method called.
@@ -939,6 +986,7 @@ public class RenderScript {
mRS.mErrorCallback.mErrorNum = subID;
mRS.mErrorCallback.run();
} else {
+ android.util.Log.e(LOG_TAG, "non fatal RS error, " + e);
// Do not throw here. In these cases, we do not have
// a fatal error.
}
@@ -974,17 +1022,24 @@ public class RenderScript {
}
/**
+ * @hide
+ */
+ public static RenderScript create(Context ctx, int sdkVersion) {
+ return create(ctx, sdkVersion, ContextType.NORMAL);
+ }
+
+ /**
* Create a basic RenderScript context.
*
* @hide
* @param ctx The context.
* @return RenderScript
*/
- public static RenderScript create(Context ctx, int sdkVersion) {
+ public static RenderScript create(Context ctx, int sdkVersion, ContextType ct) {
RenderScript rs = new RenderScript(ctx);
rs.mDev = rs.nDeviceCreate();
- rs.mContext = rs.nContextCreate(rs.mDev, 0, sdkVersion);
+ rs.mContext = rs.nContextCreate(rs.mDev, 0, sdkVersion, ct.mID);
if (rs.mContext == 0) {
throw new RSDriverException("Failed to create RS context.");
}
@@ -1000,8 +1055,20 @@ public class RenderScript {
* @return RenderScript
*/
public static RenderScript create(Context ctx) {
+ return create(ctx, ContextType.NORMAL);
+ }
+
+ /**
+ * Create a basic RenderScript context.
+ *
+ * @hide
+ *
+ * @param ctx The context.
+ * @return RenderScript
+ */
+ public static RenderScript create(Context ctx, ContextType ct) {
int v = ctx.getApplicationInfo().targetSdkVersion;
- return create(ctx, v);
+ return create(ctx, v, ct);
}
/**