RenderScript: implement a Script entry point for calling a
reduce-style kernel.
Bug: 22631253
This adds a new (currently hidden) API to the Script class and the
corresponding code for the RenderScript JNI layer.
Change-Id: I40f19aaeb90411b859bd6b0bffc3f071fa327c21
diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java
index 0f4dced..326f273 100644
--- a/rs/java/android/renderscript/RenderScript.java
+++ b/rs/java/android/renderscript/RenderScript.java
@@ -31,6 +31,8 @@
import android.os.Trace;
import java.util.ArrayList;
+// TODO: Clean up the whitespace that separates methods in this class.
+
/**
* This class provides access to a RenderScript context, which controls RenderScript
* initialization, resource management, and teardown. An instance of the RenderScript
@@ -727,6 +729,14 @@
rsnScriptForEach(mContext, id, slot, ains, aout, params, limits);
}
+ native void rsnScriptReduce(long con, long id, int slot, long ain,
+ long aout, int[] limits);
+ synchronized void nScriptReduce(long id, int slot, long ain, long aout,
+ int[] limits) {
+ validate();
+ rsnScriptReduce(mContext, id, slot, ain, aout, limits);
+ }
+
native void rsnScriptInvokeV(long con, long id, int slot, byte[] params);
synchronized void nScriptInvokeV(long id, int slot, byte[] params) {
validate();
diff --git a/rs/java/android/renderscript/Script.java b/rs/java/android/renderscript/Script.java
index 1083114..dfd0ea3 100644
--- a/rs/java/android/renderscript/Script.java
+++ b/rs/java/android/renderscript/Script.java
@@ -284,6 +284,35 @@
mRS.nScriptForEach(getID(mRS), slot, in_ids, out_id, params, limits);
}
+ /**
+ * Only intended for use by generated reflected code.
+ *
+ * @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);
+ }
+
long[] mInIdsBuffer;
Script(long id, RenderScript rs) {
@@ -292,7 +321,6 @@
mInIdsBuffer = new long[1];
}
-
/**
* Only intended for use by generated reflected code.
*