diff options
author | Jason Sams <rjsams@android.com> | 2010-08-31 13:50:42 -0700 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2010-08-31 15:31:11 -0700 |
commit | 49bdaf0293408159df18a1d8540360f9623c40f7 (patch) | |
tree | c9d4d560963c563e98967b327221c5d98505c71f /graphics | |
parent | 522ea25f2be384fd027ce2f644ee647fd8d80634 (diff) | |
download | frameworks_base-49bdaf0293408159df18a1d8540360f9623c40f7.zip frameworks_base-49bdaf0293408159df18a1d8540360f9623c40f7.tar.gz frameworks_base-49bdaf0293408159df18a1d8540360f9623c40f7.tar.bz2 |
SubElementData data upload functions.
Change-Id: I5f8c738b5457ae7f6085fc4cd331cf3d13ad75cf
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/renderscript/Allocation.java | 26 | ||||
-rw-r--r-- | graphics/java/android/renderscript/RenderScript.java | 4 | ||||
-rw-r--r-- | graphics/jni/android_renderscript_RenderScript.cpp | 12 |
3 files changed, 39 insertions, 3 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index 6775c08..ee5dbc1 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -90,7 +90,7 @@ public class Allocation extends BaseObj { subData1D(0, mType.getElementCount(), d); } - public void subData(int off, FieldPacker fp) { + public void subData(int xoff, FieldPacker fp) { int eSize = mType.mElement.getSizeBytes(); final byte[] data = fp.getData(); @@ -99,8 +99,28 @@ public class Allocation extends BaseObj { throw new IllegalArgumentException("Field packer length " + data.length + " not divisible by element size " + eSize + "."); } - data1DChecks(off, count, data.length, data.length); - mRS.nAllocationSubData1D(mID, off, count, data, data.length); + data1DChecks(xoff, count, data.length, data.length); + mRS.nAllocationSubData1D(mID, xoff, count, data, data.length); + } + + + public void subElementData(int xoff, int component_number, FieldPacker fp) { + if (component_number >= mType.mElement.mElements.length) { + throw new IllegalArgumentException("Component_number " + component_number + " out of range."); + } + if(xoff < 0) { + throw new IllegalArgumentException("Offset must be >= 0."); + } + + final byte[] data = fp.getData(); + int eSize = mType.mElement.mElements[component_number].getSizeBytes(); + + if (data.length != eSize) { + throw new IllegalArgumentException("Field packer sizelength " + data.length + + " does not match component size " + eSize + "."); + } + + mRS.nAllocationSubElementData1D(mID, xoff, component_number, data, data.length); } private void data1DChecks(int off, int count, int len, int dataSize) { diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index 08ba7e2..d51257b 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -232,6 +232,10 @@ public class RenderScript { synchronized void nAllocationSubData1D(int id, int off, int count, byte[] d, int sizeBytes) { rsnAllocationSubData1D(mContext, id, off, count, d, sizeBytes); } + native void rsnAllocationSubElementData1D(int con, int id, int xoff, int compIdx, byte[] d, int sizeBytes); + synchronized void nAllocationSubElementData1D(int id, int xoff, int compIdx, byte[] d, int sizeBytes) { + rsnAllocationSubElementData1D(mContext, id, xoff, compIdx, d, sizeBytes); + } native void rsnAllocationSubData1D(int con, int id, int off, int count, float[] d, int sizeBytes); synchronized void nAllocationSubData1D(int id, int off, int count, float[] d, int sizeBytes) { rsnAllocationSubData1D(mContext, id, off, count, d, sizeBytes); diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index 81f08e9..23b71b0 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -649,6 +649,17 @@ nAllocationSubData1D_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, j } static void +// native void rsnAllocationSubElementData1D(int con, int id, int xoff, int compIdx, byte[] d, int sizeBytes); +nAllocationSubElementData1D(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint compIdx, jbyteArray data, int sizeBytes) +{ + jint len = _env->GetArrayLength(data); + LOG_API("nAllocationSubElementData1D, con(%p), alloc(%p), offset(%i), comp(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, compIdx, len, sizeBytes); + jbyte *ptr = _env->GetByteArrayElements(data, NULL); + rsAllocation1DSubElementData(con, (RsAllocation)alloc, offset, ptr, compIdx, sizeBytes); + _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); +} + +static void nAllocationSubData2D_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint w, jint h, jintArray data, int sizeBytes) { jint len = _env->GetArrayLength(data); @@ -1401,6 +1412,7 @@ static JNINativeMethod methods[] = { {"rsnAllocationSubData1D", "(IIII[SI)V", (void*)nAllocationSubData1D_s }, {"rsnAllocationSubData1D", "(IIII[BI)V", (void*)nAllocationSubData1D_b }, {"rsnAllocationSubData1D", "(IIII[FI)V", (void*)nAllocationSubData1D_f }, +{"rsnAllocationSubElementData1D", "(IIII[BI)V", (void*)nAllocationSubElementData1D }, {"rsnAllocationSubData2D", "(IIIIII[II)V", (void*)nAllocationSubData2D_i }, {"rsnAllocationSubData2D", "(IIIIII[FI)V", (void*)nAllocationSubData2D_f }, {"rsnAllocationRead", "(II[I)V", (void*)nAllocationRead_i }, |