FileDocCategorySizeDatePackage
ScriptGroup.javaAPI DocAndroid 5.1 API16287Thu Mar 12 22:22:42 GMT 2015android.renderscript

ScriptGroup

public final class ScriptGroup extends BaseObj
ScriptGroup creates a group of kernels that are executed together with one execution call as if they were a single kernel. The kernels may be connected internally or to an external allocation. The intermediate results for internal connections are not observable after the execution of the script.

External connections are grouped into inputs and outputs. All outputs are produced by a script kernel and placed into a user-supplied allocation. Inputs provide the input of a kernel. Inputs bound to script globals are set directly upon the script.

A ScriptGroup must contain at least one kernel. A ScriptGroup must contain only a single directed acyclic graph (DAG) of script kernels and connections. Attempting to create a ScriptGroup with multiple DAGs or attempting to create a cycle within a ScriptGroup will throw an exception.

Currently, all kernels in a ScriptGroup must be from separate Script objects. Attempting to use multiple kernels from the same Script object will result in an {@link android.renderscript.RSInvalidStateException}.

Fields Summary
IO[]
mOutputs
IO[]
mInputs
Constructors Summary
ScriptGroup(long id, RenderScript rs)

        super(id, rs);
    
Methods Summary
public voidexecute()
Execute the ScriptGroup. This will run all the kernels in the ScriptGroup. No internal connection results will be visible after execution of the ScriptGroup.

        mRS.nScriptGroupExecute(getID(mRS));
    
public voidsetInput(Script.KernelID s, Allocation a)
Sets an input of the ScriptGroup. This specifies an Allocation to be used for kernels that require an input Allocation provided from outside of the ScriptGroup.

param
s The ID of the kernel where the allocation should be connected.
param
a The allocation to connect.

        for (int ct=0; ct < mInputs.length; ct++) {
            if (mInputs[ct].mKID == s) {
                mInputs[ct].mAllocation = a;
                mRS.nScriptGroupSetInput(getID(mRS), s.getID(mRS), mRS.safeID(a));
                return;
            }
        }
        throw new RSIllegalArgumentException("Script not found");
    
public voidsetOutput(Script.KernelID s, Allocation a)
Sets an output of the ScriptGroup. This specifies an Allocation to be used for the kernels that require an output Allocation visible after the ScriptGroup is executed.

param
s The ID of the kernel where the allocation should be connected.
param
a The allocation to connect.

        for (int ct=0; ct < mOutputs.length; ct++) {
            if (mOutputs[ct].mKID == s) {
                mOutputs[ct].mAllocation = a;
                mRS.nScriptGroupSetOutput(getID(mRS), s.getID(mRS), mRS.safeID(a));
                return;
            }
        }
        throw new RSIllegalArgumentException("Script not found");