diff options
author | Yang Ni <yangni@google.com> | 2015-03-26 14:35:22 -0700 |
---|---|---|
committer | Yang Ni <yangni@google.com> | 2015-03-30 10:45:34 -0700 |
commit | 4c93c8c93a66a8932d84a52bd922c3b7ad1565bb (patch) | |
tree | 4606ec940c7fb54256a499aef84be6aba4d94b2d /rs/java/android | |
parent | 631565abd6cadd65befe197afa7bac0d44f70fb2 (diff) | |
download | frameworks_base-4c93c8c93a66a8932d84a52bd922c3b7ad1565bb.zip frameworks_base-4c93c8c93a66a8932d84a52bd922c3b7ad1565bb.tar.gz frameworks_base-4c93c8c93a66a8932d84a52bd922c3b7ad1565bb.tar.bz2 |
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
Diffstat (limited to 'rs/java/android')
-rw-r--r-- | rs/java/android/renderscript/ScriptGroup2.java | 9 |
1 files changed, 7 insertions, 2 deletions
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<Script.FieldID, Object> mBindings; @@ -62,8 +63,9 @@ public class ScriptGroup2 extends BaseObj { 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 @@ public class ScriptGroup2 extends BaseObj { 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 @@ 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); } |