From 949610653fdf55dd2cb3c846047e6aa2c6d73f0d Mon Sep 17 00:00:00 2001 From: Chris Wailes Date: Wed, 11 Jun 2014 12:01:28 -0700 Subject: Adds support for multi-input kernels to Frameworks/Base/RS. * Added a new JNI call to pass arrays of Allocations to the RS runtime. * Added a new version of ForEach that takes an array of Allocations. * Added some casts to disambiguate existing calls to forEach. Change-Id: I46d2834c37075b2a2407fd8b010546818a4540d1 --- rs/java/android/renderscript/Script.java | 49 +++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'rs/java/android/renderscript/Script.java') diff --git a/rs/java/android/renderscript/Script.java b/rs/java/android/renderscript/Script.java index 0e46f94a583e..c49ef948db97 100644 --- a/rs/java/android/renderscript/Script.java +++ b/rs/java/android/renderscript/Script.java @@ -182,6 +182,54 @@ public class Script extends BaseObj { mRS.nScriptForEachClipped(getID(mRS), slot, in_id, out_id, params, sc.xstart, sc.xend, sc.ystart, sc.yend, sc.zstart, sc.zend); } + /** + * Only intended for use by generated reflected code. + * + * @hide + */ + protected void forEach(int slot, Allocation[] ains, Allocation aout, FieldPacker v) { + forEach(slot, ains, aout, v, new LaunchOptions()); + } + + /** + * Only intended for use by generated reflected code. + * + * @hide + */ + protected void forEach(int slot, Allocation[] ains, Allocation aout, FieldPacker v, LaunchOptions sc) { + mRS.validate(); + + for (Allocation ain : ains) { + mRS.validateObject(ain); + } + + mRS.validateObject(aout); + if (ains == null && aout == null) { + throw new RSIllegalArgumentException( + "At least one of ain or aout is required to be non-null."); + } + + if (sc == null) { + forEach(slot, ains, aout, v); + return; + } + + long[] in_ids = new long[ains.length]; + for (int index = 0; index < ains.length; ++index) { + in_ids[index] = ains[index].getID(mRS); + } + + long out_id = 0; + if (aout != null) { + out_id = aout.getID(mRS); + } + byte[] params = null; + if (v != null) { + params = v.getData(); + } + mRS.nScriptForEachMultiClipped(getID(mRS), slot, in_ids, out_id, params, sc.xstart, sc.xend, sc.ystart, sc.yend, sc.zstart, sc.zend); + } + Script(long id, RenderScript rs) { super(id, rs); } @@ -477,4 +525,3 @@ public class Script extends BaseObj { } } - -- cgit v1.2.3