Fix value size data type in closure creation.
b/19944127
Also added references to arguments and global values in a closure to
keep them live in Java while native code may access them.
Change-Id: I1179d34aa67f845578740e71cc2da4f82419f251
diff --git a/rs/java/android/renderscript/ScriptGroup2.java b/rs/java/android/renderscript/ScriptGroup2.java
index 4a56572..13e22aa 100644
--- a/rs/java/android/renderscript/ScriptGroup2.java
+++ b/rs/java/android/renderscript/ScriptGroup2.java
@@ -44,6 +44,7 @@
public class ScriptGroup2 extends BaseObj {
public static class Closure extends BaseObj {
+ private Object[] mArgs;
private Allocation mReturnValue;
private Map<Script.FieldID, Object> mBindings;
@@ -62,8 +63,9 @@
Object[] args, Map<Script.FieldID, Object> globals) {
super(0, rs);
+ mArgs = args;
mReturnValue = Allocation.createTyped(rs, returnType);
- mBindings = new HashMap<Script.FieldID, Object>();
+ mBindings = globals;
mGlobalFuture = new HashMap<Script.FieldID, Future>();
int numValues = args.length + globals.size();
@@ -112,7 +114,8 @@
super(0, rs);
mFP = FieldPacker.createFieldPack(args);
- mBindings = new HashMap<Script.FieldID, Object>();
+ mArgs = args;
+ mBindings = globals;
mGlobalFuture = new HashMap<Script.FieldID, Future>();
int numValues = globals.size();
@@ -198,11 +201,13 @@
}
void setArg(int index, Object obj) {
+ mArgs[index] = obj;
ValueAndSize vs = new ValueAndSize(mRS, obj);
mRS.nClosureSetArg(getID(mRS), index, vs.value, vs.size);
}
void setGlobal(Script.FieldID fieldID, Object obj) {
+ mBindings.put(fieldID, obj);
ValueAndSize vs = new ValueAndSize(mRS, obj);
mRS.nClosureSetGlobal(getID(mRS), fieldID.getID(mRS), vs.value, vs.size);
}