From 4c93c8c93a66a8932d84a52bd922c3b7ad1565bb Mon Sep 17 00:00:00 2001 From: Yang Ni Date: Thu, 26 Mar 2015 14:35:22 -0700 Subject: 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 --- rs/java/android/renderscript/ScriptGroup2.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'rs/java/android') 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 @@ you will need approval. public class ScriptGroup2 extends BaseObj { public static class Closure extends BaseObj { + private Object[] mArgs; private Allocation mReturnValue; private Map mBindings; @@ -62,8 +63,9 @@ public class ScriptGroup2 extends BaseObj { Object[] args, Map globals) { super(0, rs); + mArgs = args; mReturnValue = Allocation.createTyped(rs, returnType); - mBindings = new HashMap(); + mBindings = globals; mGlobalFuture = new HashMap(); int numValues = args.length + globals.size(); @@ -112,7 +114,8 @@ public class ScriptGroup2 extends BaseObj { super(0, rs); mFP = FieldPacker.createFieldPack(args); - mBindings = new HashMap(); + mArgs = args; + mBindings = globals; mGlobalFuture = new HashMap(); int numValues = globals.size(); @@ -198,11 +201,13 @@ public class ScriptGroup2 extends BaseObj { } 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); } -- cgit v1.1