Merge "[RenderScript] Update the java API about Allocation copyTo & From FieldPacker"
This commit is contained in:
@ -797,6 +797,7 @@ public class Allocation extends BaseObj {
|
|||||||
copy1DRangeFromUnchecked(xoff, count, data);
|
copy1DRangeFromUnchecked(xoff, count, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is only intended to be used by auto-generated code reflected from
|
* This is only intended to be used by auto-generated code reflected from
|
||||||
* the RenderScript script files.
|
* the RenderScript script files.
|
||||||
@ -809,20 +810,6 @@ public class Allocation extends BaseObj {
|
|||||||
setFromFieldPacker(xoff, 0, 0, component_number, fp);
|
setFromFieldPacker(xoff, 0, 0, component_number, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide
|
|
||||||
* This is only intended to be used by auto-generated code reflected from
|
|
||||||
* the RenderScript script files.
|
|
||||||
*
|
|
||||||
* @param xoff
|
|
||||||
* @param yoff
|
|
||||||
* @param component_number
|
|
||||||
* @param fp
|
|
||||||
*/
|
|
||||||
public void setFromFieldPacker(int xoff, int yoff, int component_number, FieldPacker fp) {
|
|
||||||
setFromFieldPacker(xoff, yoff, 0, component_number, fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
* This is only intended to be used by auto-generated code reflected from
|
* This is only intended to be used by auto-generated code reflected from
|
||||||
@ -1423,35 +1410,8 @@ public class Allocation extends BaseObj {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
* Copy subelement from the Allocation into an object array.
|
* This is only intended to be used by auto-generated code reflected from
|
||||||
* This is intended to be used with user defined structs
|
* the RenderScript script files and should not be used by developers.
|
||||||
*
|
|
||||||
* @param xoff
|
|
||||||
* @param component_number
|
|
||||||
* @param array
|
|
||||||
*/
|
|
||||||
public void copyElementTo(int xoff, int component_number, Object array) {
|
|
||||||
copyElementTo(xoff, 0, 0, component_number, array);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide
|
|
||||||
* Copy subelement from the Allocation into an object array.
|
|
||||||
* This is intended to be used with user defined structs
|
|
||||||
*
|
|
||||||
* @param xoff
|
|
||||||
* @param yoff
|
|
||||||
* @param component_number
|
|
||||||
* @param array
|
|
||||||
*/
|
|
||||||
public void copyElementTo(int xoff, int yoff, int component_number, Object array) {
|
|
||||||
copyElementTo(xoff, yoff, 0, component_number, array);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide
|
|
||||||
* Copy subelement from the Allocation into an object array.
|
|
||||||
* This is intended to be used with user defined structs
|
|
||||||
*
|
*
|
||||||
* @param xoff
|
* @param xoff
|
||||||
* @param yoff
|
* @param yoff
|
||||||
@ -1459,8 +1419,7 @@ public class Allocation extends BaseObj {
|
|||||||
* @param component_number
|
* @param component_number
|
||||||
* @param array
|
* @param array
|
||||||
*/
|
*/
|
||||||
public void copyElementTo(int xoff, int yoff, int zoff, int component_number, Object array) {
|
public void copyToFieldPacker(int xoff, int yoff, int zoff, int component_number, FieldPacker fp) {
|
||||||
Trace.traceBegin(RenderScript.TRACE_TAG, "copyElementTo");
|
|
||||||
mRS.validate();
|
mRS.validate();
|
||||||
if (component_number >= mType.mElement.mElements.length) {
|
if (component_number >= mType.mElement.mElements.length) {
|
||||||
throw new RSIllegalArgumentException("Component_number " + component_number + " out of range.");
|
throw new RSIllegalArgumentException("Component_number " + component_number + " out of range.");
|
||||||
@ -1475,19 +1434,18 @@ public class Allocation extends BaseObj {
|
|||||||
throw new RSIllegalArgumentException("Offset z must be >= 0.");
|
throw new RSIllegalArgumentException("Offset z must be >= 0.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Element.DataType dt = validateObjectIsPrimitiveArray(array, false);
|
final byte[] data = fp.getData();
|
||||||
int array_size = java.lang.reflect.Array.getLength(array) * dt.mSize;
|
int data_length = fp.getPos();
|
||||||
int eSize = mType.mElement.mElements[component_number].getBytesSize();
|
int eSize = mType.mElement.mElements[component_number].getBytesSize();
|
||||||
eSize *= mType.mElement.mArraySizes[component_number];
|
eSize *= mType.mElement.mArraySizes[component_number];
|
||||||
|
|
||||||
if (array_size < eSize) {
|
if (data_length != eSize) {
|
||||||
throw new RSIllegalArgumentException("Array Size (bytes)" + array_size +
|
throw new RSIllegalArgumentException("Field packer sizelength " + data_length +
|
||||||
" is smaller than component size " + eSize + ".");
|
" does not match component size " + eSize + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
mRS.nAllocationElementRead(getIDSafe(), xoff, yoff, zoff, mSelectedLOD,
|
mRS.nAllocationElementRead(getIDSafe(), xoff, yoff, zoff, mSelectedLOD,
|
||||||
component_number, array, eSize, dt);
|
component_number, data, data_length);
|
||||||
Trace.traceEnd(RenderScript.TRACE_TAG);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Resize a 1D allocation. The contents of the allocation are preserved.
|
* Resize a 1D allocation. The contents of the allocation are preserved.
|
||||||
|
@ -579,12 +579,11 @@ public class RenderScript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
native void rsnAllocationElementRead(long con,long id, int xoff, int yoff, int zoff,
|
native void rsnAllocationElementRead(long con,long id, int xoff, int yoff, int zoff,
|
||||||
int mip, int compIdx, Object d, int sizeBytes, int dt);
|
int mip, int compIdx, byte[] d, int sizeBytes);
|
||||||
synchronized void nAllocationElementRead(long id, int xoff, int yoff, int zoff,
|
synchronized void nAllocationElementRead(long id, int xoff, int yoff, int zoff,
|
||||||
int mip, int compIdx, Object d, int sizeBytes,
|
int mip, int compIdx, byte[] d, int sizeBytes) {
|
||||||
Element.DataType dt) {
|
|
||||||
validate();
|
validate();
|
||||||
rsnAllocationElementRead(mContext, id, xoff, yoff, zoff, mip, compIdx, d, sizeBytes, dt.mID);
|
rsnAllocationElementRead(mContext, id, xoff, yoff, zoff, mip, compIdx, d, sizeBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
native void rsnAllocationRead2D(long con, long id, int xoff, int yoff, int mip, int face,
|
native void rsnAllocationRead2D(long con, long id, int xoff, int yoff, int mip, int face,
|
||||||
|
@ -1302,19 +1302,21 @@ nAllocationRead1D(JNIEnv *_env, jobject _this, jlong con, jlong _alloc, jint off
|
|||||||
|
|
||||||
// Copies from the Element in the Allocation pointed to by _alloc into the Java array data.
|
// Copies from the Element in the Allocation pointed to by _alloc into the Java array data.
|
||||||
static void
|
static void
|
||||||
nAllocationElementRead(JNIEnv *_env, jobject _this, jlong con, jlong _alloc,
|
nAllocationElementRead(JNIEnv *_env, jobject _this, jlong con, jlong alloc,
|
||||||
jint xoff, jint yoff, jint zoff,
|
jint xoff, jint yoff, jint zoff,
|
||||||
jint lod, jint compIdx, jobject data, jint sizeBytes, int dataType)
|
jint lod, jint compIdx, jbyteArray data, jint sizeBytes)
|
||||||
{
|
{
|
||||||
RsAllocation *alloc = (RsAllocation *)_alloc;
|
jint len = _env->GetArrayLength(data);
|
||||||
if (kLogApi) {
|
if (kLogApi) {
|
||||||
ALOGD("nAllocationElementRead, con(%p), alloc(%p), xoff(%i), yoff(%i), zoff(%i), comp(%i), "
|
ALOGD("nAllocationElementRead, con(%p), alloc(%p), xoff(%i), yoff(%i), zoff(%i), comp(%i), len(%i), "
|
||||||
"sizeBytes(%i)", (RsContext)con, alloc, xoff, yoff, zoff, compIdx, sizeBytes);
|
"sizeBytes(%i)", (RsContext)con, (RsAllocation)alloc, xoff, yoff, zoff, compIdx, len,
|
||||||
|
sizeBytes);
|
||||||
}
|
}
|
||||||
int mSize = sizeBytes;
|
jbyte *ptr = _env->GetByteArrayElements(data, nullptr);
|
||||||
int count = 0;
|
rsAllocationElementRead((RsContext)con, (RsAllocation)alloc,
|
||||||
PER_ARRAY_TYPE(0, rsAllocationElementRead, false, (RsContext)con, alloc,
|
xoff, yoff, zoff,
|
||||||
xoff, yoff, zoff, lod, ptr, sizeBytes, compIdx);
|
lod, ptr, sizeBytes, compIdx);
|
||||||
|
_env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copies from the Allocation pointed to by _alloc into the Java object data.
|
// Copies from the Allocation pointed to by _alloc into the Java object data.
|
||||||
@ -2377,7 +2379,7 @@ static JNINativeMethod methods[] = {
|
|||||||
{"rsnAllocationData3D", "(JJIIIIIIIJIIII)V", (void*)nAllocationData3D_alloc },
|
{"rsnAllocationData3D", "(JJIIIIIIIJIIII)V", (void*)nAllocationData3D_alloc },
|
||||||
{"rsnAllocationRead", "(JJLjava/lang/Object;IIZ)V", (void*)nAllocationRead },
|
{"rsnAllocationRead", "(JJLjava/lang/Object;IIZ)V", (void*)nAllocationRead },
|
||||||
{"rsnAllocationRead1D", "(JJIIILjava/lang/Object;IIIZ)V", (void*)nAllocationRead1D },
|
{"rsnAllocationRead1D", "(JJIIILjava/lang/Object;IIIZ)V", (void*)nAllocationRead1D },
|
||||||
{"rsnAllocationElementRead", "(JJIIIIILjava/lang/Object;II)V", (void*)nAllocationElementRead },
|
{"rsnAllocationElementRead", "(JJIIIII[BI)V", (void*)nAllocationElementRead },
|
||||||
{"rsnAllocationRead2D", "(JJIIIIIILjava/lang/Object;IIIZ)V", (void*)nAllocationRead2D },
|
{"rsnAllocationRead2D", "(JJIIIIIILjava/lang/Object;IIIZ)V", (void*)nAllocationRead2D },
|
||||||
{"rsnAllocationRead3D", "(JJIIIIIIILjava/lang/Object;IIIZ)V", (void*)nAllocationRead3D },
|
{"rsnAllocationRead3D", "(JJIIIIIIILjava/lang/Object;IIIZ)V", (void*)nAllocationRead3D },
|
||||||
{"rsnAllocationGetType", "(JJ)J", (void*)nAllocationGetType},
|
{"rsnAllocationGetType", "(JJ)J", (void*)nAllocationGetType},
|
||||||
|
Reference in New Issue
Block a user