diff options
Diffstat (limited to 'rs/java/android/renderscript/Script.java')
-rw-r--r-- | rs/java/android/renderscript/Script.java | 69 |
1 files changed, 68 insertions, 1 deletions
diff --git a/rs/java/android/renderscript/Script.java b/rs/java/android/renderscript/Script.java index 7cd6d09e2812..2b0678046e32 100644 --- a/rs/java/android/renderscript/Script.java +++ b/rs/java/android/renderscript/Script.java @@ -283,6 +283,74 @@ public class Script extends BaseObj { mRS.nScriptForEach(getID(mRS), slot, in_ids, out_id, params, limits); } + /** + * Only intended for use by generated reflected code. (Simple reduction) + * + * @hide + */ + protected void reduce(int slot, Allocation ain, Allocation aout, LaunchOptions sc) { + mRS.validate(); + mRS.validateObject(ain); + mRS.validateObject(aout); + + if (ain == null || aout == null) { + throw new RSIllegalArgumentException( + "Both ain and aout are required to be non-null."); + } + + long in_id = ain.getID(mRS); + long out_id = aout.getID(mRS); + + int[] limits = null; + if (sc != null) { + limits = new int[2]; + + limits[0] = sc.xstart; + limits[1] = sc.xend; + } + + mRS.nScriptReduce(getID(mRS), slot, in_id, out_id, limits); + } + + /** + * Only intended for use by generated reflected code. (General reduction) + * + */ + protected void reduce(int slot, Allocation[] ains, Allocation aout, LaunchOptions sc) { + mRS.validate(); + if (ains == null || ains.length < 1) { + throw new RSIllegalArgumentException( + "At least one input is required."); + } + if (aout == null) { + throw new RSIllegalArgumentException( + "aout is required to be non-null."); + } + for (Allocation ain : ains) { + mRS.validateObject(ain); + } + + 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 = aout.getID(mRS); + + int[] limits = null; + if (sc != null) { + limits = new int[6]; + + limits[0] = sc.xstart; + limits[1] = sc.xend; + limits[2] = sc.ystart; + limits[3] = sc.yend; + limits[4] = sc.zstart; + limits[5] = sc.zend; + } + + mRS.nScriptReduceNew(getID(mRS), slot, in_ids, out_id, limits); + } + long[] mInIdsBuffer; Script(long id, RenderScript rs) { @@ -291,7 +359,6 @@ public class Script extends BaseObj { mInIdsBuffer = new long[1]; } - /** * Only intended for use by generated reflected code. * |