summaryrefslogtreecommitdiff
path: root/rs/java/android/renderscript/Script.java
diff options
context:
space:
mode:
Diffstat (limited to 'rs/java/android/renderscript/Script.java')
-rw-r--r--rs/java/android/renderscript/Script.java113
1 files changed, 98 insertions, 15 deletions
diff --git a/rs/java/android/renderscript/Script.java b/rs/java/android/renderscript/Script.java
index 7cd6d09e2812..fc3280be3ac7 100644
--- a/rs/java/android/renderscript/Script.java
+++ b/rs/java/android/renderscript/Script.java
@@ -41,6 +41,7 @@ public class Script extends BaseObj {
mScript = s;
mSlot = slot;
mSig = sig;
+ guard.open("destroy");
}
}
@@ -118,6 +119,7 @@ public class Script extends BaseObj {
super(id, rs);
mScript = s;
mSlot = slot;
+ guard.open("destroy");
}
}
@@ -283,14 +285,94 @@ 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) {
super(id, rs);
mInIdsBuffer = new long[1];
- }
+ /* The constructors for the derived classes (including ScriptIntrinsic
+ * derived classes and ScriptC derived classes generated by Slang
+ * reflection) seem to be simple enough, so we just put the guard.open()
+ * call here, rather than in the end of the constructor for the derived
+ * class. This, of course, assumes the derived constructor would not
+ * throw any exception after calling this constructor.
+ *
+ * If new derived classes are added with more complicated constructors
+ * that throw exceptions, this call has to be (duplicated and) moved
+ * to the end of each derived class constructor.
+ */
+ guard.open("destroy");
+ }
/**
* Only intended for use by generated reflected code.
@@ -474,21 +556,22 @@ public class Script extends BaseObj {
/**
* Class for specifying the specifics about how a kernel will be
- * launched
+ * launched.
*
* This class can specify a potential range of cells on which to
* run a kernel. If no set is called for a dimension then this
* class will have no impact on that dimension when the kernel
* is executed.
*
- * The forEach launch will operate over the intersection of the
- * dimensions.
+ * The forEach kernel launch will operate over the intersection of
+ * the dimensions.
*
* Example:
* LaunchOptions with setX(5, 15)
* Allocation with dimension X=10, Y=10
- * The resulting forEach run would execute over x = 5 to 10 and
- * y = 0 to 10.
+ * The resulting forEach run would execute over:
+ * x = 5 to 9 (inclusive) and
+ * y = 0 to 9 (inclusive).
*
*
*/
@@ -502,11 +585,11 @@ public class Script extends BaseObj {
private int strategy;
/**
- * Set the X range. If the end value is set to 0 the X dimension is not
- * clipped.
+ * Set the X range. xstartArg is the lowest coordinate of the range,
+ * and xendArg-1 is the highest coordinate of the range.
*
* @param xstartArg Must be >= 0
- * @param xendArg Must be >= xstartArg
+ * @param xendArg Must be > xstartArg
*
* @return LaunchOptions
*/
@@ -520,11 +603,11 @@ public class Script extends BaseObj {
}
/**
- * Set the Y range. If the end value is set to 0 the Y dimension is not
- * clipped.
+ * Set the Y range. ystartArg is the lowest coordinate of the range,
+ * and yendArg-1 is the highest coordinate of the range.
*
* @param ystartArg Must be >= 0
- * @param yendArg Must be >= ystartArg
+ * @param yendArg Must be > ystartArg
*
* @return LaunchOptions
*/
@@ -538,11 +621,11 @@ public class Script extends BaseObj {
}
/**
- * Set the Z range. If the end value is set to 0 the Z dimension is not
- * clipped.
+ * Set the Z range. zstartArg is the lowest coordinate of the range,
+ * and zendArg-1 is the highest coordinate of the range.
*
* @param zstartArg Must be >= 0
- * @param zendArg Must be >= zstartArg
+ * @param zendArg Must be > zstartArg
*
* @return LaunchOptions
*/