Add rsnScriptForEachClipped() implementation with no param array.
JNI doesn't let us pass down a NULL parameter array (from the usrData part
of our reflection). In this case, we simply clone our existing function, but
remove the offending array parameter.
Change-Id: Ib1d6e202f2a55ba8922eec3da5a93d8daa882250
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index 50d888f..c3ddd32 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -519,6 +519,8 @@
native void rsnScriptForEach(int con, int id, int slot, int ain, int aout);
native void rsnScriptForEachClipped(int con, int id, int slot, int ain, int aout, byte[] params,
int xstart, int xend, int ystart, int yend, int zstart, int zend);
+ native void rsnScriptForEachClipped(int con, int id, int slot, int ain, int aout,
+ int xstart, int xend, int ystart, int yend, int zstart, int zend);
synchronized void nScriptForEach(int id, int slot, int ain, int aout, byte[] params) {
validate();
if (params == null) {
@@ -531,7 +533,11 @@
synchronized void nScriptForEachClipped(int id, int slot, int ain, int aout, byte[] params,
int xstart, int xend, int ystart, int yend, int zstart, int zend) {
validate();
- rsnScriptForEachClipped(mContext, id, slot, ain, aout, params, xstart, xend, ystart, yend, zstart, zend);
+ if (params == null) {
+ rsnScriptForEachClipped(mContext, id, slot, ain, aout, xstart, xend, ystart, yend, zstart, zend);
+ } else {
+ rsnScriptForEachClipped(mContext, id, slot, ain, aout, params, xstart, xend, ystart, yend, zstart, zend);
+ }
}
native void rsnScriptInvokeV(int con, int id, int slot, byte[] params);
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp
index 9a8a6e8..8830685 100644
--- a/graphics/jni/android_renderscript_RenderScript.cpp
+++ b/graphics/jni/android_renderscript_RenderScript.cpp
@@ -1055,10 +1055,30 @@
static void
nScriptForEachClipped(JNIEnv *_env, jobject _this, RsContext con,
jint script, jint slot, jint ain, jint aout,
- jbyteArray params, jint xstart, jint xend,
+ jint xstart, jint xend,
jint ystart, jint yend, jint zstart, jint zend)
{
LOG_API("nScriptForEachClipped, con(%p), s(%p), slot(%i)", con, (void *)script, slot);
+ RsScriptCall sc;
+ sc.xStart = xstart;
+ sc.xEnd = xend;
+ sc.yStart = ystart;
+ sc.yEnd = yend;
+ sc.zStart = zstart;
+ sc.zEnd = zend;
+ sc.strategy = RS_FOR_EACH_STRATEGY_DONT_CARE;
+ sc.arrayStart = 0;
+ sc.arrayEnd = 0;
+ rsScriptForEach(con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, NULL, 0, &sc, sizeof(sc));
+}
+
+static void
+nScriptForEachClippedV(JNIEnv *_env, jobject _this, RsContext con,
+ jint script, jint slot, jint ain, jint aout,
+ jbyteArray params, jint xstart, jint xend,
+ jint ystart, jint yend, jint zstart, jint zend)
+{
+ LOG_API("nScriptForEachClipped, con(%p), s(%p), slot(%i)", con, (void *)script, slot);
jint len = _env->GetArrayLength(params);
jbyte *ptr = _env->GetByteArrayElements(params, NULL);
RsScriptCall sc;
@@ -1536,7 +1556,8 @@
{"rsnScriptInvokeV", "(III[B)V", (void*)nScriptInvokeV },
{"rsnScriptForEach", "(IIIII)V", (void*)nScriptForEach },
{"rsnScriptForEach", "(IIIII[B)V", (void*)nScriptForEachV },
-{"rsnScriptForEachClipped", "(IIIII[BIIIIII)V", (void*)nScriptForEachClipped },
+{"rsnScriptForEachClipped", "(IIIIIIIIIII)V", (void*)nScriptForEachClipped },
+{"rsnScriptForEachClipped", "(IIIII[BIIIIII)V", (void*)nScriptForEachClippedV },
{"rsnScriptSetVarI", "(IIII)V", (void*)nScriptSetVarI },
{"rsnScriptSetVarJ", "(IIIJ)V", (void*)nScriptSetVarJ },
{"rsnScriptSetVarF", "(IIIF)V", (void*)nScriptSetVarF },