summaryrefslogtreecommitdiffstats
path: root/rs/java
diff options
context:
space:
mode:
authorYang Ni <yangni@google.com>2015-03-19 23:35:14 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-03-19 23:35:14 +0000
commit53699ec613acf76277b69db57bf2f378d0dc374a (patch)
treecd406ef88d7bca6d1f40a385d4635e896a13460a /rs/java
parent62c595aaee29d88c7ae0694f8aeb83179f33150c (diff)
parentd3e6428aea34ce3297123c63b4dd6223dac5d5a8 (diff)
downloadframeworks_base-53699ec613acf76277b69db57bf2f378d0dc374a.zip
frameworks_base-53699ec613acf76277b69db57bf2f378d0dc374a.tar.gz
frameworks_base-53699ec613acf76277b69db57bf2f378d0dc374a.tar.bz2
am d3e6428a: Merge "New API methods for Script Group"
* commit 'd3e6428aea34ce3297123c63b4dd6223dac5d5a8': New API methods for Script Group
Diffstat (limited to 'rs/java')
-rw-r--r--rs/java/android/renderscript/ScriptGroup2.java53
1 files changed, 52 insertions, 1 deletions
diff --git a/rs/java/android/renderscript/ScriptGroup2.java b/rs/java/android/renderscript/ScriptGroup2.java
index 2e171b6..4a56572 100644
--- a/rs/java/android/renderscript/ScriptGroup2.java
+++ b/rs/java/android/renderscript/ScriptGroup2.java
@@ -345,11 +345,22 @@ public class ScriptGroup2 extends BaseObj {
/**
@hide Pending Android public API approval.
*/
+ public static final class Binding {
+ public Script.FieldID mField;
+ public Object mValue;
+ public Binding(Script.FieldID field, Object value) {
+ mField = field;
+ mValue = value;
+ }
+ }
+
+ /**
+ @hide Pending Android public API approval.
+ */
public static final class Builder {
RenderScript mRS;
List<Closure> mClosures;
List<UnboundValue> mInputs;
-
private static final String TAG = "ScriptGroup2.Builder";
public Builder(RenderScript rs) {
@@ -378,10 +389,50 @@ public class ScriptGroup2 extends BaseObj {
return unbound;
}
+ public Closure addKernel(Script.KernelID k, Type returnType, Object... argsAndBindings) {
+ ArrayList<Object> args = new ArrayList<Object>();
+ Map<Script.FieldID, Object> bindingMap = new HashMap<Script.FieldID, Object>();
+ if (!seperateArgsAndBindings(argsAndBindings, args, bindingMap)) {
+ return null;
+ }
+ return addKernel(k, returnType, args.toArray(), bindingMap);
+ }
+
+ public Closure addInvoke(Script.InvokeID invoke, Object... argsAndBindings) {
+ ArrayList<Object> args = new ArrayList<Object>();
+ Map<Script.FieldID, Object> bindingMap = new HashMap<Script.FieldID, Object>();
+ if (!seperateArgsAndBindings(argsAndBindings, args, bindingMap)) {
+ return null;
+ }
+ return addInvoke(invoke, args.toArray(), bindingMap);
+ }
+
public ScriptGroup2 create(Future... outputs) {
ScriptGroup2 ret = new ScriptGroup2(mRS, mClosures, mInputs, outputs);
return ret;
}
+ private boolean seperateArgsAndBindings(Object[] argsAndBindings,
+ ArrayList<Object> args,
+ Map<Script.FieldID, Object> bindingMap) {
+ int i;
+ for (i = 0; i < argsAndBindings.length; i++) {
+ if (argsAndBindings[i] instanceof Binding) {
+ break;
+ }
+ args.add(argsAndBindings[i]);
+ }
+
+ for (; i < argsAndBindings.length; i++) {
+ if (!(argsAndBindings[i] instanceof Binding)) {
+ return false;
+ }
+ Binding b = (Binding)argsAndBindings[i];
+ bindingMap.put(b.mField, b.mValue);
+ }
+
+ return true;
+ }
+
}
}