Merge "Adds support for multi-input kernels to Frameworks/Base/RS."
This commit is contained in:
@@ -615,6 +615,29 @@ public class RenderScript {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multi-input code.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @hide
|
||||||
|
native void rsnScriptForEachMultiClipped(long con, long id, int slot, long[] ains, long aout, byte[] params,
|
||||||
|
int xstart, int xend, int ystart, int yend, int zstart, int zend);
|
||||||
|
// @hide
|
||||||
|
native void rsnScriptForEachMultiClipped(long con, long id, int slot, long[] ains, long aout,
|
||||||
|
int xstart, int xend, int ystart, int yend, int zstart, int zend);
|
||||||
|
|
||||||
|
// @hide
|
||||||
|
synchronized void nScriptForEachMultiClipped(long id, int slot, long[] ains, long aout, byte[] params,
|
||||||
|
int xstart, int xend, int ystart, int yend, int zstart, int zend) {
|
||||||
|
validate();
|
||||||
|
if (params == null) {
|
||||||
|
rsnScriptForEachMultiClipped(mContext, id, slot, ains, aout, xstart, xend, ystart, yend, zstart, zend);
|
||||||
|
} else {
|
||||||
|
rsnScriptForEachMultiClipped(mContext, id, slot, ains, aout, params, xstart, xend, ystart, yend, zstart, zend);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
native void rsnScriptInvokeV(long con, long id, int slot, byte[] params);
|
native void rsnScriptInvokeV(long con, long id, int slot, byte[] params);
|
||||||
synchronized void nScriptInvokeV(long id, int slot, byte[] params) {
|
synchronized void nScriptInvokeV(long id, int slot, byte[] params) {
|
||||||
validate();
|
validate();
|
||||||
|
|||||||
@@ -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);
|
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) {
|
Script(long id, RenderScript rs) {
|
||||||
super(id, rs);
|
super(id, rs);
|
||||||
}
|
}
|
||||||
@@ -477,4 +525,3 @@ public class Script extends BaseObj {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public final class ScriptIntrinsicBlur extends ScriptIntrinsic {
|
|||||||
* type.
|
* type.
|
||||||
*/
|
*/
|
||||||
public void forEach(Allocation aout) {
|
public void forEach(Allocation aout) {
|
||||||
forEach(0, null, aout, null);
|
forEach(0, (Allocation) null, aout, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -109,4 +109,3 @@ public final class ScriptIntrinsicBlur extends ScriptIntrinsic {
|
|||||||
return createFieldID(1, null);
|
return createFieldID(1, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ public final class ScriptIntrinsicConvolve3x3 extends ScriptIntrinsic {
|
|||||||
* type.
|
* type.
|
||||||
*/
|
*/
|
||||||
public void forEach(Allocation aout) {
|
public void forEach(Allocation aout) {
|
||||||
forEach(0, null, aout, null);
|
forEach(0, (Allocation) null, aout, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -130,4 +130,3 @@ public final class ScriptIntrinsicConvolve3x3 extends ScriptIntrinsic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public final class ScriptIntrinsicConvolve5x5 extends ScriptIntrinsic {
|
|||||||
* type.
|
* type.
|
||||||
*/
|
*/
|
||||||
public void forEach(Allocation aout) {
|
public void forEach(Allocation aout) {
|
||||||
forEach(0, null, aout, null);
|
forEach(0, (Allocation) null, aout, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -130,4 +130,3 @@ public final class ScriptIntrinsicConvolve5x5 extends ScriptIntrinsic {
|
|||||||
return createFieldID(1, null);
|
return createFieldID(1, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ public final class ScriptIntrinsicResize extends ScriptIntrinsic {
|
|||||||
* @param opt LaunchOptions for clipping
|
* @param opt LaunchOptions for clipping
|
||||||
*/
|
*/
|
||||||
public void forEach_bicubic(Allocation aout, Script.LaunchOptions opt) {
|
public void forEach_bicubic(Allocation aout, Script.LaunchOptions opt) {
|
||||||
forEach(0, null, aout, null, opt);
|
forEach(0, (Allocation) null, aout, null, opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,4 +110,3 @@ public final class ScriptIntrinsicResize extends ScriptIntrinsic {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public final class ScriptIntrinsicYuvToRGB extends ScriptIntrinsic {
|
|||||||
* type.
|
* type.
|
||||||
*/
|
*/
|
||||||
public void forEach(Allocation aout) {
|
public void forEach(Allocation aout) {
|
||||||
forEach(0, null, aout, null);
|
forEach(0, (Allocation) null, aout, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1154,6 +1154,101 @@ nScriptForEachClippedV(JNIEnv *_env, jobject _this, jlong con,
|
|||||||
_env->ReleaseByteArrayElements(params, ptr, JNI_ABORT);
|
_env->ReleaseByteArrayElements(params, ptr, JNI_ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nScriptForEachMultiClipped(JNIEnv *_env, jobject _this, jlong con,
|
||||||
|
jlong script, jint slot, jlongArray ains, jlong aout,
|
||||||
|
jint xstart, jint xend,
|
||||||
|
jint ystart, jint yend, jint zstart, jint zend)
|
||||||
|
{
|
||||||
|
LOG_API("nScriptForEachMultiClipped, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot);
|
||||||
|
|
||||||
|
jint in_len = _env->GetArrayLength(ains);
|
||||||
|
jlong* in_ptr = _env->GetLongArrayElements(ains, NULL);
|
||||||
|
|
||||||
|
RsAllocation *in_allocs = NULL;
|
||||||
|
|
||||||
|
if (sizeof(RsAllocation) == sizeof(jlong)) {
|
||||||
|
in_allocs = (RsAllocation*)in_ptr;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Convert from 64-bit jlong types to the native pointer type.
|
||||||
|
|
||||||
|
in_allocs = new RsAllocation[in_len];
|
||||||
|
|
||||||
|
for (int index = in_len; --index >= 0;) {
|
||||||
|
in_allocs[index] = (RsAllocation)in_ptr[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
rsScriptForEachMulti((RsContext)con, (RsScript)script, slot, in_allocs, in_len, (RsAllocation)aout, NULL, 0, &sc, sizeof(sc));
|
||||||
|
|
||||||
|
if (sizeof(RsAllocation) != sizeof(jlong)) {
|
||||||
|
delete[] in_allocs;
|
||||||
|
}
|
||||||
|
|
||||||
|
_env->ReleaseLongArrayElements(ains, in_ptr, JNI_ABORT);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nScriptForEachMultiClippedV(JNIEnv *_env, jobject _this, jlong con,
|
||||||
|
jlong script, jint slot, jlongArray ains, jlong aout,
|
||||||
|
jbyteArray params, jint xstart, jint xend,
|
||||||
|
jint ystart, jint yend, jint zstart, jint zend)
|
||||||
|
{
|
||||||
|
LOG_API("nScriptForEachMultiClippedV, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot);
|
||||||
|
|
||||||
|
jint in_len = _env->GetArrayLength(ains);
|
||||||
|
jlong* in_ptr = _env->GetLongArrayElements(ains, NULL);
|
||||||
|
|
||||||
|
RsAllocation *in_allocs = NULL;
|
||||||
|
|
||||||
|
if (sizeof(RsAllocation) == sizeof(jlong)) {
|
||||||
|
in_allocs = (RsAllocation*)in_ptr;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Convert from 64-bit jlong types to the native pointer type.
|
||||||
|
|
||||||
|
in_allocs = new RsAllocation[in_len];
|
||||||
|
|
||||||
|
for (int index = in_len; --index >= 0;) {
|
||||||
|
in_allocs[index] = (RsAllocation)in_ptr[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jint param_len = _env->GetArrayLength(params);
|
||||||
|
jbyte* param_ptr = _env->GetByteArrayElements(params, NULL);
|
||||||
|
|
||||||
|
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;
|
||||||
|
rsScriptForEachMulti((RsContext)con, (RsScript)script, slot, in_allocs, in_len, (RsAllocation)aout, param_ptr, param_len, &sc, sizeof(sc));
|
||||||
|
|
||||||
|
if (sizeof(RsAllocation) != sizeof(jlong)) {
|
||||||
|
delete[] in_allocs;
|
||||||
|
}
|
||||||
|
|
||||||
|
_env->ReleaseLongArrayElements(ains, in_ptr, JNI_ABORT);
|
||||||
|
_env->ReleaseByteArrayElements(params, param_ptr, JNI_ABORT);
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
|
|
||||||
static jlong
|
static jlong
|
||||||
@@ -1669,6 +1764,8 @@ static JNINativeMethod methods[] = {
|
|||||||
{"rsnScriptForEach", "(JJIJJ[B)V", (void*)nScriptForEachV },
|
{"rsnScriptForEach", "(JJIJJ[B)V", (void*)nScriptForEachV },
|
||||||
{"rsnScriptForEachClipped", "(JJIJJIIIIII)V", (void*)nScriptForEachClipped },
|
{"rsnScriptForEachClipped", "(JJIJJIIIIII)V", (void*)nScriptForEachClipped },
|
||||||
{"rsnScriptForEachClipped", "(JJIJJ[BIIIIII)V", (void*)nScriptForEachClippedV },
|
{"rsnScriptForEachClipped", "(JJIJJ[BIIIIII)V", (void*)nScriptForEachClippedV },
|
||||||
|
{"rsnScriptForEachMultiClipped", "(JJI[JJIIIIII)V", (void*)nScriptForEachMultiClipped },
|
||||||
|
{"rsnScriptForEachMultiClipped", "(JJI[JJ[BIIIIII)V", (void*)nScriptForEachMultiClippedV },
|
||||||
{"rsnScriptSetVarI", "(JJII)V", (void*)nScriptSetVarI },
|
{"rsnScriptSetVarI", "(JJII)V", (void*)nScriptSetVarI },
|
||||||
{"rsnScriptGetVarI", "(JJI)I", (void*)nScriptGetVarI },
|
{"rsnScriptGetVarI", "(JJI)I", (void*)nScriptGetVarI },
|
||||||
{"rsnScriptSetVarJ", "(JJIJ)V", (void*)nScriptSetVarJ },
|
{"rsnScriptSetVarJ", "(JJIJ)V", (void*)nScriptSetVarJ },
|
||||||
|
|||||||
Reference in New Issue
Block a user