public static final class ScriptGroup.Builder2 extends Object
A script group is created using closures (see class ScriptGroup.Closure
).
A closure is a function call to a kernel or
invocable function. Each function argument or global variable accessed inside
the function is bound to 1) a known value, 2) a script group input
(see class ScriptGroup.Input
), or 3) a
future (see class ScriptGroup.Future
).
A future is the output of a closure, either the return value of the
function or a global variable written by that function.
Closures are created using the addKernel(android.support.v8.renderscript.Script.KernelID, android.support.v8.renderscript.Type, java.lang.Object...)
or addInvoke(android.support.v8.renderscript.Script.InvokeID, java.lang.Object...)
methods.
When a closure is created, futures from previously created closures
can be used as its inputs.
External script group inputs can be used as inputs to individual closures as well.
An external script group input is created using the addInput()
method.
A script group is created by a call to the create(java.lang.String, android.support.v8.renderscript.ScriptGroup.Future...)
method, which
accepts an array of futures as the outputs for the script group.
Closures in a script group can be evaluated in any order as long as the following conditions are met: 1) a closure must be evaluated before any other closures that take its futures as inputs; 2) all closures added before an invoke closure must be evaluated before it; and 3) all closures added after an invoke closure must be evaluated after it. As a special case, the order that the closures are added is a legal evaluation order. However, other evaluation orders are possible, including concurrently evaluating independent closures.
Constructor and Description |
---|
Builder2(RenderScript rs)
Returns a Builder object
|
Modifier and Type | Method and Description |
---|---|
ScriptGroup.Input |
addInput()
Adds a script group input
|
ScriptGroup.Closure |
addInvoke(Script.InvokeID invoke,
Object... argsAndBindings)
Adds a closure for an invocable function
|
ScriptGroup.Closure |
addKernel(Script.KernelID k,
Type returnType,
Object... argsAndBindings)
Adds a closure for a kernel
|
ScriptGroup |
create(String name,
ScriptGroup.Future... outputs)
Creates a script group
|
public Builder2(RenderScript rs)
rs
- the RenderScript contextpublic ScriptGroup.Input addInput()
public ScriptGroup.Closure addKernel(Script.KernelID k, Type returnType, Object... argsAndBindings)
k
- Kernel ID for the kernel functionargsAndBindings
- arguments followed by bindings for global variablespublic ScriptGroup.Closure addInvoke(Script.InvokeID invoke, Object... argsAndBindings)
invoke
- Invoke ID for the invocable functionargsAndBindings
- arguments followed by bindings for global variablespublic ScriptGroup create(String name, ScriptGroup.Future... outputs)
name
- name for the script group. Legal names can only contain letters, digits,
'-', or '_'. The name can be no longer than 100 characters.outputs
- futures intended as outputs of the script group