FileDocCategorySizeDatePackage
RenderScript.javaAPI DocAndroid 5.1 API43056Thu Mar 12 22:22:56 GMT 2015android.support.v8.renderscript

RenderScript

public 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_PATH
Name 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
mMessageCallback
If 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
mErrorCallback
Application 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 voidcontextDump()
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.RenderScriptcreate(android.content.Context ctx, int sdkVersion)

hide

        return create(ctx, sdkVersion, ContextType.NORMAL);
    
public static android.support.v8.renderscript.RenderScriptcreate(android.content.Context ctx, int sdkVersion, android.support.v8.renderscript.RenderScript$ContextType ct)
Create a RenderScript context.

hide
param
ctx The context.
return
RenderScript

        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.RenderScriptcreate(android.content.Context ctx)
Create a RenderScript context.

param
ctx The context.
return
RenderScript

        return create(ctx, ContextType.NORMAL);
    
public static android.support.v8.renderscript.RenderScriptcreate(android.content.Context ctx, android.support.v8.renderscript.RenderScript$ContextType ct)
Create a RenderScript context.

hide
param
ctx The context.
param
ct The type of context to be created.
return
RenderScript

        int v = ctx.getApplicationInfo().targetSdkVersion;
        return create(ctx, v, ct);
    
public voiddestroy()
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 voidfinish()
Wait for any pending asynchronous opeations (such as copies to a RS allocation or RS script executions) to complete.

        nContextFinish();
    
public final android.content.ContextgetApplicationContext()
Gets the application context associated with the RenderScript context.

return
The application context.

        return mApplicationContext;
    
public android.support.v8.renderscript.RenderScript$RSErrorHandlergetErrorHandler()

        return mErrorCallback;
    
public android.support.v8.renderscript.RenderScript$RSMessageHandlergetMessageHandler()

        return mMessageCallback;
    
booleanisAlive()

        return mContext != 0;
    
synchronized voidnAllocationCopyFromBitmap(int alloc, android.graphics.Bitmap bmp)

        validate();
        rsnAllocationCopyFromBitmap(mContext, alloc, bmp);
    
synchronized voidnAllocationCopyToBitmap(int alloc, android.graphics.Bitmap bmp)

        validate();
        rsnAllocationCopyToBitmap(mContext, alloc, bmp);
    
synchronized intnAllocationCreateBitmapBackedAllocation(int type, int mip, android.graphics.Bitmap bmp, int usage)

        validate();
        return rsnAllocationCreateBitmapBackedAllocation(mContext, type, mip, bmp, usage);
    
synchronized intnAllocationCreateBitmapRef(int type, android.graphics.Bitmap bmp)

        validate();
        return rsnAllocationCreateBitmapRef(mContext, type, bmp);
    
synchronized intnAllocationCreateFromAssetStream(int mips, int assetStream, int usage)

        validate();
        return rsnAllocationCreateFromAssetStream(mContext, mips, assetStream, usage);
    
synchronized intnAllocationCreateFromBitmap(int type, int mip, android.graphics.Bitmap bmp, int usage)

        validate();
        return rsnAllocationCreateFromBitmap(mContext, type, mip, bmp, usage);
    
synchronized intnAllocationCreateTyped(int type, int mip, int usage, int pointer)

        validate();
        return rsnAllocationCreateTyped(mContext, type, mip, usage, pointer);
    
synchronized intnAllocationCubeCreateFromBitmap(int type, int mip, android.graphics.Bitmap bmp, int usage)

        validate();
        return rsnAllocationCubeCreateFromBitmap(mContext, type, mip, bmp, usage);
    
synchronized voidnAllocationData1D(int id, int off, int mip, int count, int[] d, int sizeBytes)

        validate();
        rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes);
    
synchronized voidnAllocationData1D(int id, int off, int mip, int count, short[] d, int sizeBytes)

        validate();
        rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes);
    
synchronized voidnAllocationData1D(int id, int off, int mip, int count, byte[] d, int sizeBytes)

        validate();
        rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes);
    
synchronized voidnAllocationData1D(int id, int off, int mip, int count, float[] d, int sizeBytes)

        validate();
        rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes);
    
synchronized voidnAllocationData2D(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 voidnAllocationData2D(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 voidnAllocationData2D(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 voidnAllocationData2D(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 voidnAllocationData2D(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 voidnAllocationData2D(int id, int xoff, int yoff, int mip, int face, android.graphics.Bitmap b)

        validate();
        rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, b);
    
synchronized voidnAllocationData3D(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 voidnAllocationData3D(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 voidnAllocationData3D(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 voidnAllocationData3D(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 voidnAllocationData3D(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 voidnAllocationElementData1D(int id, int xoff, int mip, int compIdx, byte[] d, int sizeBytes)

        validate();
        rsnAllocationElementData1D(mContext, id, xoff, mip, compIdx, d, sizeBytes);
    
synchronized voidnAllocationGenerateMipmaps(int alloc)

        validate();
        rsnAllocationGenerateMipmaps(mContext, alloc);
    
synchronized intnAllocationGetType(int id)

        validate();
        return rsnAllocationGetType(mContext, id);
    
synchronized voidnAllocationIoReceive(int alloc)

        validate();
        rsnAllocationIoReceive(mContext, alloc);
    
synchronized voidnAllocationIoSend(int alloc)

        validate();
        rsnAllocationIoSend(mContext, alloc);
    
synchronized voidnAllocationRead(int id, float[] d)

        validate();
        rsnAllocationRead(mContext, id, d);
    
synchronized voidnAllocationRead(int id, byte[] d)

        validate();
        rsnAllocationRead(mContext, id, d);
    
synchronized voidnAllocationRead(int id, short[] d)

        validate();
        rsnAllocationRead(mContext, id, d);
    
synchronized voidnAllocationRead(int id, int[] d)

        validate();
        rsnAllocationRead(mContext, id, d);
    
synchronized voidnAllocationResize1D(int id, int dimX)

        validate();
        rsnAllocationResize1D(mContext, id, dimX);
    
synchronized voidnAllocationResize2D(int id, int dimX, int dimY)

        validate();
        rsnAllocationResize2D(mContext, id, dimX, dimY);
    
synchronized voidnAllocationSyncAll(int alloc, int src)

        validate();
        rsnAllocationSyncAll(mContext, alloc, src);
    
synchronized intnContextCreate(int dev, int ver, int sdkVer, int contextType)

        return rsnContextCreate(dev, ver, sdkVer, contextType);
    
native voidnContextDeinitToClient(int con)

synchronized voidnContextDestroy()

        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 voidnContextDump(int bits)

        validate();
        rsnContextDump(mContext, bits);
    
synchronized voidnContextFinish()

        validate();
        rsnContextFinish(mContext);
    
native java.lang.StringnContextGetErrorMessage(int con)

native intnContextGetUserMessage(int con, int[] data)

native voidnContextInitToClient(int con)

native intnContextPeekMessage(int con, int[] subID)

synchronized voidnContextSendMessage(int id, int[] data)

        validate();
        rsnContextSendMessage(mContext, id, data);
    
synchronized voidnContextSetPriority(int p)

        validate();
        rsnContextSetPriority(mContext, p);
    
native intnDeviceCreate()

native voidnDeviceDestroy(int dev)

native voidnDeviceSetConfig(int dev, int param, int value)

synchronized intnElementCreate(int type, int kind, boolean norm, int vecSize)

        validate();
        return rsnElementCreate(mContext, type, kind, norm, vecSize);
    
synchronized intnElementCreate2(int[] elements, java.lang.String[] names, int[] arraySizes)

        validate();
        return rsnElementCreate2(mContext, elements, names, arraySizes);
    
synchronized voidnElementGetNativeData(int id, int[] elementData)

        validate();
        rsnElementGetNativeData(mContext, id, elementData);
    
synchronized voidnElementGetSubElements(int id, int[] IDs, java.lang.String[] names, int[] arraySizes)

        validate();
        rsnElementGetSubElements(mContext, id, IDs, names, arraySizes);
    
voidnObjDestroy(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 intnSamplerCreate(int magFilter, int minFilter, int wrapS, int wrapT, int wrapR, float aniso)

        validate();
        return rsnSamplerCreate(mContext, magFilter, minFilter, wrapS, wrapT, wrapR, aniso);
    
synchronized voidnScriptBindAllocation(int script, int alloc, int slot)

        validate();
        rsnScriptBindAllocation(mContext, script, alloc, slot);
    
synchronized intnScriptCCreate(java.lang.String resName, java.lang.String cacheDir, byte[] script, int length)

        validate();
        return rsnScriptCCreate(mContext, resName, cacheDir, script, length);
    
synchronized intnScriptFieldIDCreate(int sid, int slot)

        validate();
        return rsnScriptFieldIDCreate(mContext, sid, slot);
    
synchronized voidnScriptForEach(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 voidnScriptForEachClipped(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 intnScriptGroupCreate(int[] kernels, int[] src, int[] dstk, int[] dstf, int[] types)

        validate();
        return rsnScriptGroupCreate(mContext, kernels, src, dstk, dstf, types);
    
synchronized voidnScriptGroupExecute(int group)

        validate();
        rsnScriptGroupExecute(mContext, group);
    
synchronized voidnScriptGroupSetInput(int group, int kernel, int alloc)

        validate();
        rsnScriptGroupSetInput(mContext, group, kernel, alloc);
    
synchronized voidnScriptGroupSetOutput(int group, int kernel, int alloc)

        validate();
        rsnScriptGroupSetOutput(mContext, group, kernel, alloc);
    
synchronized intnScriptIntrinsicCreate(int id, int eid)

        validate();
        return rsnScriptIntrinsicCreate(mContext, id, eid);
    
synchronized voidnScriptInvoke(int id, int slot)

        validate();
        rsnScriptInvoke(mContext, id, slot);
    
synchronized voidnScriptInvokeV(int id, int slot, byte[] params)

        validate();
        rsnScriptInvokeV(mContext, id, slot, params);
    
synchronized intnScriptKernelIDCreate(int sid, int slot, int sig)

        validate();
        return rsnScriptKernelIDCreate(mContext, sid, slot, sig);
    
synchronized voidnScriptSetTimeZone(int script, byte[] timeZone)

        validate();
        rsnScriptSetTimeZone(mContext, script, timeZone);
    
synchronized voidnScriptSetVarD(int id, int slot, double val)

        validate();
        rsnScriptSetVarD(mContext, id, slot, val);
    
synchronized voidnScriptSetVarF(int id, int slot, float val)

        validate();
        rsnScriptSetVarF(mContext, id, slot, val);
    
synchronized voidnScriptSetVarI(int id, int slot, int val)

        validate();
        rsnScriptSetVarI(mContext, id, slot, val);
    
synchronized voidnScriptSetVarJ(int id, int slot, long val)

        validate();
        rsnScriptSetVarJ(mContext, id, slot, val);
    
synchronized voidnScriptSetVarObj(int id, int slot, int val)

        validate();
        rsnScriptSetVarObj(mContext, id, slot, val);
    
synchronized voidnScriptSetVarV(int id, int slot, byte[] val)

        validate();
        rsnScriptSetVarV(mContext, id, slot, val);
    
synchronized voidnScriptSetVarVE(int id, int slot, byte[] val, int e, int[] dims)

        validate();
        rsnScriptSetVarVE(mContext, id, slot, val, e, dims);
    
synchronized intnTypeCreate(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 voidnTypeGetNativeData(int id, int[] typeData)

        validate();
        rsnTypeGetNativeData(mContext, id, typeData);
    
native voidrsnAllocationCopyFromBitmap(int con, int alloc, android.graphics.Bitmap bmp)

native voidrsnAllocationCopyToBitmap(int con, int alloc, android.graphics.Bitmap bmp)

native intrsnAllocationCreateBitmapBackedAllocation(int con, int type, int mip, android.graphics.Bitmap bmp, int usage)

native intrsnAllocationCreateBitmapRef(int con, int type, android.graphics.Bitmap bmp)

native intrsnAllocationCreateFromAssetStream(int con, int mips, int assetStream, int usage)

native intrsnAllocationCreateFromBitmap(int con, int type, int mip, android.graphics.Bitmap bmp, int usage)

native intrsnAllocationCreateTyped(int con, int type, int mip, int usage, int pointer)

native intrsnAllocationCubeCreateFromBitmap(int con, int type, int mip, android.graphics.Bitmap bmp, int usage)

native voidrsnAllocationData1D(int con, int id, int off, int mip, int count, int[] d, int sizeBytes)

native voidrsnAllocationData1D(int con, int id, int off, int mip, int count, short[] d, int sizeBytes)

native voidrsnAllocationData1D(int con, int id, int off, int mip, int count, byte[] d, int sizeBytes)

native voidrsnAllocationData1D(int con, int id, int off, int mip, int count, float[] d, int sizeBytes)

native voidrsnAllocationData2D(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 voidrsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, byte[] d, int sizeBytes)

native voidrsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, short[] d, int sizeBytes)

native voidrsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, int[] d, int sizeBytes)

native voidrsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, float[] d, int sizeBytes)

native voidrsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, android.graphics.Bitmap b)

native voidrsnAllocationData3D(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 voidrsnAllocationData3D(int con, int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, byte[] d, int sizeBytes)

native voidrsnAllocationData3D(int con, int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, short[] d, int sizeBytes)

native voidrsnAllocationData3D(int con, int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, int[] d, int sizeBytes)

native voidrsnAllocationData3D(int con, int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, float[] d, int sizeBytes)

native voidrsnAllocationElementData1D(int con, int id, int xoff, int mip, int compIdx, byte[] d, int sizeBytes)

native voidrsnAllocationGenerateMipmaps(int con, int alloc)

native intrsnAllocationGetType(int con, int id)

native voidrsnAllocationIoReceive(int con, int alloc)

native voidrsnAllocationIoSend(int con, int alloc)

native voidrsnAllocationRead(int con, int id, float[] d)

native voidrsnAllocationRead(int con, int id, byte[] d)

native voidrsnAllocationRead(int con, int id, short[] d)

native voidrsnAllocationRead(int con, int id, int[] d)

native voidrsnAllocationResize1D(int con, int id, int dimX)

native voidrsnAllocationResize2D(int con, int id, int dimX, int dimY)

native voidrsnAllocationSyncAll(int con, int alloc, int src)

native intrsnContextCreate(int dev, int ver, int sdkVer, int contextType)

native voidrsnContextDestroy(int con)

native voidrsnContextDump(int con, int bits)

native voidrsnContextFinish(int con)

native voidrsnContextSendMessage(int con, int id, int[] data)

native voidrsnContextSetPriority(int con, int p)

native intrsnElementCreate(int con, int type, int kind, boolean norm, int vecSize)

native intrsnElementCreate2(int con, int[] elements, java.lang.String[] names, int[] arraySizes)

native voidrsnElementGetNativeData(int con, int id, int[] elementData)

native voidrsnElementGetSubElements(int con, int id, int[] IDs, java.lang.String[] names, int[] arraySizes)

native voidrsnObjDestroy(int con, int id)

native intrsnSamplerCreate(int con, int magFilter, int minFilter, int wrapS, int wrapT, int wrapR, float aniso)

native voidrsnScriptBindAllocation(int con, int script, int alloc, int slot)

native intrsnScriptCCreate(int con, java.lang.String resName, java.lang.String cacheDir, byte[] script, int length)

native intrsnScriptFieldIDCreate(int con, int sid, int slot)

native voidrsnScriptForEach(int con, int id, int slot, int ain, int aout, byte[] params)

native voidrsnScriptForEach(int con, int id, int slot, int ain, int aout)

native voidrsnScriptForEachClipped(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 voidrsnScriptForEachClipped(int con, int id, int slot, int ain, int aout, int xstart, int xend, int ystart, int yend, int zstart, int zend)

native intrsnScriptGroupCreate(int con, int[] kernels, int[] src, int[] dstk, int[] dstf, int[] types)

native voidrsnScriptGroupExecute(int con, int group)

native voidrsnScriptGroupSetInput(int con, int group, int kernel, int alloc)

native voidrsnScriptGroupSetOutput(int con, int group, int kernel, int alloc)

native intrsnScriptIntrinsicCreate(int con, int id, int eid)

native voidrsnScriptInvoke(int con, int id, int slot)

native voidrsnScriptInvokeV(int con, int id, int slot, byte[] params)

native intrsnScriptKernelIDCreate(int con, int sid, int slot, int sig)

native voidrsnScriptSetTimeZone(int con, int script, byte[] timeZone)

native voidrsnScriptSetVarD(int con, int id, int slot, double val)

native voidrsnScriptSetVarF(int con, int id, int slot, float val)

native voidrsnScriptSetVarI(int con, int id, int slot, int val)

native voidrsnScriptSetVarJ(int con, int id, int slot, long val)

native voidrsnScriptSetVarObj(int con, int id, int slot, int val)

native voidrsnScriptSetVarV(int con, int id, int slot, byte[] val)

native voidrsnScriptSetVarVE(int con, int id, int slot, byte[] val, int e, int[] dims)

native intrsnTypeCreate(int con, int eid, int x, int y, int z, boolean mips, boolean faces, int yuv)

native voidrsnTypeGetNativeData(int con, int id, int[] typeData)

intsafeID(BaseObj o)

        if(o != null) {
            return o.getID(this);
        }
        return 0;
    
public voidsendMessage(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.

hide
param
id
param
data

        nContextSendMessage(id, data);
    
public voidsetErrorHandler(android.support.v8.renderscript.RenderScript$RSErrorHandler msg)


        
        mErrorCallback = msg;
        if (isNative) {
            RenderScriptThunker rst = (RenderScriptThunker) this;
            rst.setErrorHandler(msg);
        }
    
public voidsetMessageHandler(android.support.v8.renderscript.RenderScript$RSMessageHandler msg)


        
        mMessageCallback = msg;
        if (isNative) {
            RenderScriptThunker rst = (RenderScriptThunker) this;
            rst.setMessageHandler(msg);
        }
    
public voidsetPriority(android.support.v8.renderscript.RenderScript$Priority p)
Change the priority of the worker threads for this context.

param
p New priority to be set.

        validate();
        nContextSetPriority(p.mID);
    
public static voidsetupDiskCache(java.io.File cacheDir)
Sets the directory to use as a persistent storage for the renderscript object file cache.

hide
param
cacheDir A directory the current process can write to


                                    
         
        File f = new File(cacheDir, CACHE_PATH);
        mCachePath = f.getAbsolutePath();
        f.mkdirs();
    
private static booleansetupThunk(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 booleanshouldThunk()


       
        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;
    
voidvalidate()

        if (mContext == 0) {
            throw new RSInvalidStateException("Calling RS with no Context active.");
        }