RenderScriptpublic class RenderScript extends Object This class provides access to a RenderScript context, which controls RenderScript
initialization, resource management, and teardown. An instance of the RenderScript
class must be created before any other RS objects can be created.
Developer Guides
For more information about creating an application that uses RenderScript, read the
RenderScript developer guide.
|
Fields Summary |
---|
static final String | LOG_TAG | static final boolean | DEBUG | static final boolean | LOG_ENABLED | private android.content.Context | mApplicationContext | static boolean | sInitialized | static boolean | sUseGCHooks | static Object | sRuntime | static Method | registerNativeAllocation | static Method | registerNativeFree | static Object | lock | static boolean | isNative | private static int | sThunk | private static int | sSdkVersion | private static final String | CACHE_PATHName of the file that holds the object cache. | static String | mCachePath | int | mDev | int | mContext | ReentrantReadWriteLock | mRWLock | MessageThread | mMessageThread | Element | mElement_U8 | Element | mElement_I8 | Element | mElement_U16 | Element | mElement_I16 | Element | mElement_U32 | Element | mElement_I32 | Element | mElement_U64 | Element | mElement_I64 | Element | mElement_F32 | Element | mElement_F64 | Element | mElement_BOOLEAN | Element | mElement_ELEMENT | Element | mElement_TYPE | Element | mElement_ALLOCATION | Element | mElement_SAMPLER | Element | mElement_SCRIPT | Element | mElement_A_8 | Element | mElement_RGB_565 | Element | mElement_RGB_888 | Element | mElement_RGBA_5551 | Element | mElement_RGBA_4444 | Element | mElement_RGBA_8888 | Element | mElement_FLOAT_2 | Element | mElement_FLOAT_3 | Element | mElement_FLOAT_4 | Element | mElement_DOUBLE_2 | Element | mElement_DOUBLE_3 | Element | mElement_DOUBLE_4 | Element | mElement_UCHAR_2 | Element | mElement_UCHAR_3 | Element | mElement_UCHAR_4 | Element | mElement_CHAR_2 | Element | mElement_CHAR_3 | Element | mElement_CHAR_4 | Element | mElement_USHORT_2 | Element | mElement_USHORT_3 | Element | mElement_USHORT_4 | Element | mElement_SHORT_2 | Element | mElement_SHORT_3 | Element | mElement_SHORT_4 | Element | mElement_UINT_2 | Element | mElement_UINT_3 | Element | mElement_UINT_4 | Element | mElement_INT_2 | Element | mElement_INT_3 | Element | mElement_INT_4 | Element | mElement_ULONG_2 | Element | mElement_ULONG_3 | Element | mElement_ULONG_4 | Element | mElement_LONG_2 | Element | mElement_LONG_3 | Element | mElement_LONG_4 | Element | mElement_MATRIX_4X4 | Element | mElement_MATRIX_3X3 | Element | mElement_MATRIX_2X2 | Sampler | mSampler_CLAMP_NEAREST | Sampler | mSampler_CLAMP_LINEAR | Sampler | mSampler_CLAMP_LINEAR_MIP_LINEAR | 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 | RSMessageHandler | mMessageCallbackIf an application is expecting messages, it should set this
field to an instance of {@link RSMessageHandler}. This
instance will receive all the user messages sent from {@code
sendToClient} by scripts from this context. | RSErrorHandler | mErrorCallbackApplication Error handler. All runtime errors will be dispatched to the
instance of RSAsyncError set here. If this field is null a
{@link RSRuntimeException} will instead be thrown with details about the error.
This will cause program termaination. |
Constructors Summary |
---|
RenderScript(android.content.Context ctx)
if (ctx != null) {
mApplicationContext = ctx.getApplicationContext();
}
mRWLock = new ReentrantReadWriteLock();
|
Methods Summary |
---|
public void | contextDump()Print the currently available debugging information about the state of
the RS context to the log.
validate();
nContextDump(0);
| public static android.support.v8.renderscript.RenderScript | create(android.content.Context ctx, int sdkVersion)
return create(ctx, sdkVersion, ContextType.NORMAL);
| public static android.support.v8.renderscript.RenderScript | create(android.content.Context ctx, int sdkVersion, android.support.v8.renderscript.RenderScript$ContextType ct)Create a RenderScript context.
RenderScript rs = new RenderScript(ctx);
if (sSdkVersion == -1) {
sSdkVersion = sdkVersion;
} else if (sSdkVersion != sdkVersion) {
throw new RSRuntimeException("Can't have two contexts with different SDK versions in support lib");
}
if (setupThunk(sSdkVersion, ctx)) {
android.util.Log.v(LOG_TAG, "RS native mode");
return RenderScriptThunker.create(ctx, sSdkVersion);
}
synchronized(lock) {
if (sInitialized == false) {
try {
Class<?> vm_runtime = Class.forName("dalvik.system.VMRuntime");
Method get_runtime = vm_runtime.getDeclaredMethod("getRuntime");
sRuntime = get_runtime.invoke(null);
registerNativeAllocation = vm_runtime.getDeclaredMethod("registerNativeAllocation", Integer.TYPE);
registerNativeFree = vm_runtime.getDeclaredMethod("registerNativeFree", Integer.TYPE);
sUseGCHooks = true;
} catch (Exception e) {
Log.e(LOG_TAG, "No GC methods");
sUseGCHooks = false;
}
try {
System.loadLibrary("RSSupport");
System.loadLibrary("rsjni");
sInitialized = true;
} catch (UnsatisfiedLinkError e) {
Log.e(LOG_TAG, "Error loading RS jni library: " + e);
throw new RSRuntimeException("Error loading RS jni library: " + e);
}
}
}
android.util.Log.v(LOG_TAG, "RS compat mode");
rs.mDev = rs.nDeviceCreate();
rs.mContext = rs.nContextCreate(rs.mDev, 0, sdkVersion, ct.mID);
if (rs.mContext == 0) {
throw new RSDriverException("Failed to create RS context.");
}
rs.mMessageThread = new MessageThread(rs);
rs.mMessageThread.start();
return rs;
| public static android.support.v8.renderscript.RenderScript | create(android.content.Context ctx)Create a RenderScript context.
return create(ctx, ContextType.NORMAL);
| public static android.support.v8.renderscript.RenderScript | create(android.content.Context ctx, android.support.v8.renderscript.RenderScript$ContextType ct)Create a RenderScript context.
int v = ctx.getApplicationInfo().targetSdkVersion;
return create(ctx, v, ct);
| public void | destroy()Destroys this RenderScript context. Once this function is called,
using this context or any objects belonging to this context is
illegal.
validate();
nContextFinish();
nContextDeinitToClient(mContext);
mMessageThread.mRun = false;
try {
mMessageThread.join();
} catch(InterruptedException e) {
}
nContextDestroy();
nDeviceDestroy(mDev);
mDev = 0;
| public void | finish()Wait for any pending asynchronous opeations (such as copies to a RS
allocation or RS script executions) to complete.
nContextFinish();
| public final android.content.Context | getApplicationContext()Gets the application context associated with the RenderScript context.
return mApplicationContext;
| public android.support.v8.renderscript.RenderScript$RSErrorHandler | getErrorHandler()
return mErrorCallback;
| public android.support.v8.renderscript.RenderScript$RSMessageHandler | getMessageHandler()
return mMessageCallback;
| boolean | isAlive()
return mContext != 0;
| synchronized void | nAllocationCopyFromBitmap(int alloc, android.graphics.Bitmap bmp)
validate();
rsnAllocationCopyFromBitmap(mContext, alloc, bmp);
| synchronized void | nAllocationCopyToBitmap(int alloc, android.graphics.Bitmap bmp)
validate();
rsnAllocationCopyToBitmap(mContext, alloc, bmp);
| synchronized int | nAllocationCreateBitmapBackedAllocation(int type, int mip, android.graphics.Bitmap bmp, int usage)
validate();
return rsnAllocationCreateBitmapBackedAllocation(mContext, type, mip, bmp, usage);
| synchronized int | nAllocationCreateBitmapRef(int type, android.graphics.Bitmap bmp)
validate();
return rsnAllocationCreateBitmapRef(mContext, type, bmp);
| synchronized int | nAllocationCreateFromAssetStream(int mips, int assetStream, int usage)
validate();
return rsnAllocationCreateFromAssetStream(mContext, mips, assetStream, usage);
| synchronized int | nAllocationCreateFromBitmap(int type, int mip, android.graphics.Bitmap bmp, int usage)
validate();
return rsnAllocationCreateFromBitmap(mContext, type, mip, bmp, usage);
| synchronized int | nAllocationCreateTyped(int type, int mip, int usage, int pointer)
validate();
return rsnAllocationCreateTyped(mContext, type, mip, usage, pointer);
| synchronized int | nAllocationCubeCreateFromBitmap(int type, int mip, android.graphics.Bitmap bmp, int usage)
validate();
return rsnAllocationCubeCreateFromBitmap(mContext, type, mip, bmp, usage);
| synchronized void | nAllocationData1D(int id, int off, int mip, int count, int[] d, int sizeBytes)
validate();
rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes);
| synchronized void | nAllocationData1D(int id, int off, int mip, int count, short[] d, int sizeBytes)
validate();
rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes);
| synchronized void | nAllocationData1D(int id, int off, int mip, int count, byte[] d, int sizeBytes)
validate();
rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes);
| synchronized void | nAllocationData1D(int id, int off, int mip, int count, float[] d, int sizeBytes)
validate();
rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes);
| synchronized void | nAllocationData2D(int dstAlloc, int dstXoff, int dstYoff, int dstMip, int dstFace, int width, int height, int srcAlloc, int srcXoff, int srcYoff, int srcMip, int srcFace)
validate();
rsnAllocationData2D(mContext,
dstAlloc, dstXoff, dstYoff,
dstMip, dstFace,
width, height,
srcAlloc, srcXoff, srcYoff,
srcMip, srcFace);
| synchronized void | nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, byte[] d, int sizeBytes)
validate();
rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes);
| synchronized void | nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, short[] d, int sizeBytes)
validate();
rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes);
| synchronized void | nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, int[] d, int sizeBytes)
validate();
rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes);
| synchronized void | nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, float[] d, int sizeBytes)
validate();
rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes);
| synchronized void | nAllocationData2D(int id, int xoff, int yoff, int mip, int face, android.graphics.Bitmap b)
validate();
rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, b);
| synchronized void | nAllocationData3D(int dstAlloc, int dstXoff, int dstYoff, int dstZoff, int dstMip, int width, int height, int depth, int srcAlloc, int srcXoff, int srcYoff, int srcZoff, int srcMip)
validate();
rsnAllocationData3D(mContext,
dstAlloc, dstXoff, dstYoff, dstZoff,
dstMip, width, height, depth,
srcAlloc, srcXoff, srcYoff, srcZoff, srcMip);
| synchronized void | nAllocationData3D(int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, byte[] d, int sizeBytes)
validate();
rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes);
| synchronized void | nAllocationData3D(int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, short[] d, int sizeBytes)
validate();
rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes);
| synchronized void | nAllocationData3D(int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, int[] d, int sizeBytes)
validate();
rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes);
| synchronized void | nAllocationData3D(int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, float[] d, int sizeBytes)
validate();
rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes);
| synchronized void | nAllocationElementData1D(int id, int xoff, int mip, int compIdx, byte[] d, int sizeBytes)
validate();
rsnAllocationElementData1D(mContext, id, xoff, mip, compIdx, d, sizeBytes);
| synchronized void | nAllocationGenerateMipmaps(int alloc)
validate();
rsnAllocationGenerateMipmaps(mContext, alloc);
| synchronized int | nAllocationGetType(int id)
validate();
return rsnAllocationGetType(mContext, id);
| synchronized void | nAllocationIoReceive(int alloc)
validate();
rsnAllocationIoReceive(mContext, alloc);
| synchronized void | nAllocationIoSend(int alloc)
validate();
rsnAllocationIoSend(mContext, alloc);
| synchronized void | nAllocationRead(int id, float[] d)
validate();
rsnAllocationRead(mContext, id, d);
| synchronized void | nAllocationRead(int id, byte[] d)
validate();
rsnAllocationRead(mContext, id, d);
| synchronized void | nAllocationRead(int id, short[] d)
validate();
rsnAllocationRead(mContext, id, d);
| synchronized void | nAllocationRead(int id, int[] d)
validate();
rsnAllocationRead(mContext, id, d);
| synchronized void | nAllocationResize1D(int id, int dimX)
validate();
rsnAllocationResize1D(mContext, id, dimX);
| synchronized void | nAllocationResize2D(int id, int dimX, int dimY)
validate();
rsnAllocationResize2D(mContext, id, dimX, dimY);
| synchronized void | nAllocationSyncAll(int alloc, int src)
validate();
rsnAllocationSyncAll(mContext, alloc, src);
| synchronized int | nContextCreate(int dev, int ver, int sdkVer, int contextType)
return rsnContextCreate(dev, ver, sdkVer, contextType);
| native void | nContextDeinitToClient(int con)
| synchronized void | nContextDestroy()
validate();
// take teardown lock
// teardown lock can only be taken when no objects are being destroyed
ReentrantReadWriteLock.WriteLock wlock = mRWLock.writeLock();
wlock.lock();
int curCon = mContext;
// context is considered dead as of this point
mContext = 0;
wlock.unlock();
rsnContextDestroy(curCon);
| synchronized void | nContextDump(int bits)
validate();
rsnContextDump(mContext, bits);
| synchronized void | nContextFinish()
validate();
rsnContextFinish(mContext);
| native java.lang.String | nContextGetErrorMessage(int con)
| native int | nContextGetUserMessage(int con, int[] data)
| native void | nContextInitToClient(int con)
| native int | nContextPeekMessage(int con, int[] subID)
| synchronized void | nContextSendMessage(int id, int[] data)
validate();
rsnContextSendMessage(mContext, id, data);
| synchronized void | nContextSetPriority(int p)
validate();
rsnContextSetPriority(mContext, p);
| native int | nDeviceCreate()
| native void | nDeviceDestroy(int dev)
| native void | nDeviceSetConfig(int dev, int param, int value)
| synchronized int | nElementCreate(int type, int kind, boolean norm, int vecSize)
validate();
return rsnElementCreate(mContext, type, kind, norm, vecSize);
| synchronized int | nElementCreate2(int[] elements, java.lang.String[] names, int[] arraySizes)
validate();
return rsnElementCreate2(mContext, elements, names, arraySizes);
| synchronized void | nElementGetNativeData(int id, int[] elementData)
validate();
rsnElementGetNativeData(mContext, id, elementData);
| synchronized void | nElementGetSubElements(int id, int[] IDs, java.lang.String[] names, int[] arraySizes)
validate();
rsnElementGetSubElements(mContext, id, IDs, names, arraySizes);
| void | nObjDestroy(int id)
// There is a race condition here. The calling code may be run
// by the gc while teardown is occuring. This protects againts
// deleting dead objects.
if (mContext != 0) {
rsnObjDestroy(mContext, id);
}
| synchronized int | nSamplerCreate(int magFilter, int minFilter, int wrapS, int wrapT, int wrapR, float aniso)
validate();
return rsnSamplerCreate(mContext, magFilter, minFilter, wrapS, wrapT, wrapR, aniso);
| synchronized void | nScriptBindAllocation(int script, int alloc, int slot)
validate();
rsnScriptBindAllocation(mContext, script, alloc, slot);
| synchronized int | nScriptCCreate(java.lang.String resName, java.lang.String cacheDir, byte[] script, int length)
validate();
return rsnScriptCCreate(mContext, resName, cacheDir, script, length);
| synchronized int | nScriptFieldIDCreate(int sid, int slot)
validate();
return rsnScriptFieldIDCreate(mContext, sid, slot);
| synchronized void | nScriptForEach(int id, int slot, int ain, int aout, byte[] params)
validate();
if (params == null) {
rsnScriptForEach(mContext, id, slot, ain, aout);
} else {
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);
}
| synchronized int | nScriptGroupCreate(int[] kernels, int[] src, int[] dstk, int[] dstf, int[] types)
validate();
return rsnScriptGroupCreate(mContext, kernels, src, dstk, dstf, types);
| synchronized void | nScriptGroupExecute(int group)
validate();
rsnScriptGroupExecute(mContext, group);
| synchronized void | nScriptGroupSetInput(int group, int kernel, int alloc)
validate();
rsnScriptGroupSetInput(mContext, group, kernel, alloc);
| synchronized void | nScriptGroupSetOutput(int group, int kernel, int alloc)
validate();
rsnScriptGroupSetOutput(mContext, group, kernel, alloc);
| synchronized int | nScriptIntrinsicCreate(int id, int eid)
validate();
return rsnScriptIntrinsicCreate(mContext, id, eid);
| synchronized void | nScriptInvoke(int id, int slot)
validate();
rsnScriptInvoke(mContext, id, slot);
| synchronized void | nScriptInvokeV(int id, int slot, byte[] params)
validate();
rsnScriptInvokeV(mContext, id, slot, params);
| synchronized int | nScriptKernelIDCreate(int sid, int slot, int sig)
validate();
return rsnScriptKernelIDCreate(mContext, sid, slot, sig);
| synchronized void | nScriptSetTimeZone(int script, byte[] timeZone)
validate();
rsnScriptSetTimeZone(mContext, script, timeZone);
| synchronized void | nScriptSetVarD(int id, int slot, double val)
validate();
rsnScriptSetVarD(mContext, id, slot, val);
| synchronized void | nScriptSetVarF(int id, int slot, float val)
validate();
rsnScriptSetVarF(mContext, id, slot, val);
| synchronized void | nScriptSetVarI(int id, int slot, int val)
validate();
rsnScriptSetVarI(mContext, id, slot, val);
| synchronized void | nScriptSetVarJ(int id, int slot, long val)
validate();
rsnScriptSetVarJ(mContext, id, slot, val);
| synchronized void | nScriptSetVarObj(int id, int slot, int val)
validate();
rsnScriptSetVarObj(mContext, id, slot, val);
| synchronized void | nScriptSetVarV(int id, int slot, byte[] val)
validate();
rsnScriptSetVarV(mContext, id, slot, val);
| synchronized void | nScriptSetVarVE(int id, int slot, byte[] val, int e, int[] dims)
validate();
rsnScriptSetVarVE(mContext, id, slot, val, e, dims);
| 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, yuv);
| synchronized void | nTypeGetNativeData(int id, int[] typeData)
validate();
rsnTypeGetNativeData(mContext, id, typeData);
| native void | rsnAllocationCopyFromBitmap(int con, int alloc, android.graphics.Bitmap bmp)
| native void | rsnAllocationCopyToBitmap(int con, int alloc, android.graphics.Bitmap bmp)
| native int | rsnAllocationCreateBitmapBackedAllocation(int con, int type, int mip, android.graphics.Bitmap bmp, int usage)
| native int | rsnAllocationCreateBitmapRef(int con, int type, android.graphics.Bitmap bmp)
| native int | rsnAllocationCreateFromAssetStream(int con, int mips, int assetStream, int usage)
| native int | rsnAllocationCreateFromBitmap(int con, int type, int mip, android.graphics.Bitmap bmp, int usage)
| native int | rsnAllocationCreateTyped(int con, int type, int mip, int usage, int pointer)
| native int | rsnAllocationCubeCreateFromBitmap(int con, int type, int mip, android.graphics.Bitmap bmp, int usage)
| native void | rsnAllocationData1D(int con, int id, int off, int mip, int count, int[] d, int sizeBytes)
| native void | rsnAllocationData1D(int con, int id, int off, int mip, int count, short[] d, int sizeBytes)
| native void | rsnAllocationData1D(int con, int id, int off, int mip, int count, byte[] d, int sizeBytes)
| native void | rsnAllocationData1D(int con, int id, int off, int mip, int count, float[] d, int sizeBytes)
| native void | rsnAllocationData2D(int con, int dstAlloc, int dstXoff, int dstYoff, int dstMip, int dstFace, int width, int height, int srcAlloc, int srcXoff, int srcYoff, int srcMip, int srcFace)
| native void | rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, byte[] d, int sizeBytes)
| native void | rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, short[] d, int sizeBytes)
| native void | rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, int[] d, int sizeBytes)
| native void | rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, float[] d, int sizeBytes)
| native void | rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, android.graphics.Bitmap b)
| native void | rsnAllocationData3D(int con, int dstAlloc, int dstXoff, int dstYoff, int dstZoff, int dstMip, int width, int height, int depth, int srcAlloc, int srcXoff, int srcYoff, int srcZoff, int srcMip)
| native void | rsnAllocationData3D(int con, int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, byte[] d, int sizeBytes)
| native void | rsnAllocationData3D(int con, int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, short[] d, int sizeBytes)
| native void | rsnAllocationData3D(int con, int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, int[] d, int sizeBytes)
| native void | rsnAllocationData3D(int con, int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, float[] d, int sizeBytes)
| native void | rsnAllocationElementData1D(int con, int id, int xoff, int mip, int compIdx, byte[] d, int sizeBytes)
| native void | rsnAllocationGenerateMipmaps(int con, int alloc)
| native int | rsnAllocationGetType(int con, int id)
| native void | rsnAllocationIoReceive(int con, int alloc)
| native void | rsnAllocationIoSend(int con, int alloc)
| native void | rsnAllocationRead(int con, int id, float[] d)
| native void | rsnAllocationRead(int con, int id, byte[] d)
| native void | rsnAllocationRead(int con, int id, short[] d)
| native void | rsnAllocationRead(int con, int id, int[] d)
| native void | rsnAllocationResize1D(int con, int id, int dimX)
| native void | rsnAllocationResize2D(int con, int id, int dimX, int dimY)
| native void | rsnAllocationSyncAll(int con, int alloc, int src)
| native int | rsnContextCreate(int dev, int ver, int sdkVer, int contextType)
| native void | rsnContextDestroy(int con)
| native void | rsnContextDump(int con, int bits)
| native void | rsnContextFinish(int con)
| native void | rsnContextSendMessage(int con, int id, int[] data)
| native void | rsnContextSetPriority(int con, int p)
| native int | rsnElementCreate(int con, int type, int kind, boolean norm, int vecSize)
| native int | rsnElementCreate2(int con, int[] elements, java.lang.String[] names, int[] arraySizes)
| native void | rsnElementGetNativeData(int con, int id, int[] elementData)
| native void | rsnElementGetSubElements(int con, int id, int[] IDs, java.lang.String[] names, int[] arraySizes)
| native void | rsnObjDestroy(int con, int id)
| native int | rsnSamplerCreate(int con, int magFilter, int minFilter, int wrapS, int wrapT, int wrapR, float aniso)
| native void | rsnScriptBindAllocation(int con, int script, int alloc, int slot)
| native int | rsnScriptCCreate(int con, java.lang.String resName, java.lang.String cacheDir, byte[] script, int length)
| native int | rsnScriptFieldIDCreate(int con, int sid, int slot)
| 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)
| native int | rsnScriptGroupCreate(int con, int[] kernels, int[] src, int[] dstk, int[] dstf, int[] types)
| native void | rsnScriptGroupExecute(int con, int group)
| native void | rsnScriptGroupSetInput(int con, int group, int kernel, int alloc)
| native void | rsnScriptGroupSetOutput(int con, int group, int kernel, int alloc)
| native int | rsnScriptIntrinsicCreate(int con, int id, int eid)
| native void | rsnScriptInvoke(int con, int id, int slot)
| native void | rsnScriptInvokeV(int con, int id, int slot, byte[] params)
| native int | rsnScriptKernelIDCreate(int con, int sid, int slot, int sig)
| native void | rsnScriptSetTimeZone(int con, int script, byte[] timeZone)
| native void | rsnScriptSetVarD(int con, int id, int slot, double val)
| native void | rsnScriptSetVarF(int con, int id, int slot, float val)
| native void | rsnScriptSetVarI(int con, int id, int slot, int val)
| native void | rsnScriptSetVarJ(int con, int id, int slot, long val)
| native void | rsnScriptSetVarObj(int con, int id, int slot, int val)
| native void | rsnScriptSetVarV(int con, int id, int slot, byte[] val)
| native void | rsnScriptSetVarVE(int con, int id, int slot, byte[] val, int e, int[] dims)
| native int | rsnTypeCreate(int con, int eid, int x, int y, int z, boolean mips, boolean faces, int yuv)
| native void | rsnTypeGetNativeData(int con, int id, int[] typeData)
| int | safeID(BaseObj o)
if(o != null) {
return o.getID(this);
}
return 0;
| public void | sendMessage(int id, int[] data)Place a message into the message queue to be sent back to the message
handler once all previous commands have been executed.
nContextSendMessage(id, data);
| public void | setErrorHandler(android.support.v8.renderscript.RenderScript$RSErrorHandler msg)
mErrorCallback = msg;
if (isNative) {
RenderScriptThunker rst = (RenderScriptThunker) this;
rst.setErrorHandler(msg);
}
| public void | setMessageHandler(android.support.v8.renderscript.RenderScript$RSMessageHandler msg)
mMessageCallback = msg;
if (isNative) {
RenderScriptThunker rst = (RenderScriptThunker) this;
rst.setMessageHandler(msg);
}
| public void | setPriority(android.support.v8.renderscript.RenderScript$Priority p)Change the priority of the worker threads for this context.
validate();
nContextSetPriority(p.mID);
| public static void | setupDiskCache(java.io.File cacheDir)Sets the directory to use as a persistent storage for the
renderscript object file cache.
File f = new File(cacheDir, CACHE_PATH);
mCachePath = f.getAbsolutePath();
f.mkdirs();
| private static boolean | setupThunk(int sdkVersion, android.content.Context ctx)Determines whether or not we should be thunking into the native
RenderScript layer or actually using the compatibility library.
if (sThunk == -1) {
// get the value of the debug.rs.forcecompat property
int forcecompat = 0;
try {
Class<?> sysprop = Class.forName("android.os.SystemProperties");
Class[] signature = {String.class, Integer.TYPE};
Method getint = sysprop.getDeclaredMethod("getInt", signature);
Object[] args = {"debug.rs.forcecompat", new Integer(0)};
forcecompat = ((java.lang.Integer)getint.invoke(null, args)).intValue();
} catch (Exception e) {
}
// use compat on Jelly Bean MR2 if we're requesting SDK 19+
if (android.os.Build.VERSION.SDK_INT == 18 && sdkVersion >= 19) {
sThunk = 0;
}
else if ((android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2)
&& forcecompat == 0) {
sThunk = 1;
} else {
sThunk = 0;
}
if (sThunk == 1) {
// Workarounds that may disable thunking go here
ApplicationInfo info;
try {
info = ctx.getPackageManager().getApplicationInfo(ctx.getPackageName(),
PackageManager.GET_META_DATA);
} catch (PackageManager.NameNotFoundException e) {
// assume no workarounds needed
return true;
}
long minorVersion = 0;
// load minorID from reflection
try {
Class<?> javaRS = Class.forName("android.renderscript.RenderScript");
Method getMinorID = javaRS.getDeclaredMethod("getMinorID");
minorVersion = ((java.lang.Long)getMinorID.invoke(null)).longValue();
} catch (Exception e) {
// minor version remains 0 on devices with no possible WARs
}
if (info.metaData != null) {
// asynchronous teardown: minor version 1+
if (info.metaData.getBoolean("com.android.support.v8.renderscript.EnableAsyncTeardown") == true) {
if (minorVersion == 0) {
sThunk = 0;
}
}
// blur issues on some drivers with 4.4
if (info.metaData.getBoolean("com.android.support.v8.renderscript.EnableBlurWorkaround") == true) {
if (android.os.Build.VERSION.SDK_INT <= 19) {
//android.util.Log.e("rs", "war on");
sThunk = 0;
}
}
}
// end of workarounds
}
}
if (sThunk == 1) {
return true;
}
return false;
| static boolean | shouldThunk()
if (sThunk == -1) {
throw new RSRuntimeException("Can't use RS classes before setting up a RenderScript context");
} else if (sThunk == 1) {
return true;
}
return false;
| void | validate()
if (mContext == 0) {
throw new RSInvalidStateException("Calling RS with no Context active.");
}
|
|