From 40a29e8e28772b37ab0f9fe9708ecdcba24abb84 Mon Sep 17 00:00:00 2001 From: Jason Sams Date: Mon, 10 Aug 2009 14:55:26 -0700 Subject: Implement basic allocation readback. Add Get height, width to ScriptC_Lib. --- graphics/jni/android_renderscript_RenderScript.cpp | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'graphics/jni/android_renderscript_RenderScript.cpp') diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index 2c3a6cb..285fdc0 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -389,6 +389,27 @@ nAllocationSubData2D_f(JNIEnv *_env, jobject _this, jint alloc, jint xoff, jint _env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT); } +static void +nAllocationRead_i(JNIEnv *_env, jobject _this, jint alloc, jintArray data) +{ + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + jint len = _env->GetArrayLength(data); + LOG_API("nAllocationRead_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len); + jint *ptr = _env->GetIntArrayElements(data, NULL); + rsAllocationData((RsAllocation)alloc, ptr); + _env->ReleaseIntArrayElements(data, ptr, JNI_COMMIT); +} + +static void +nAllocationRead_f(JNIEnv *_env, jobject _this, jint alloc, jfloatArray data) +{ + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + jint len = _env->GetArrayLength(data); + LOG_API("nAllocationRead_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len); + jfloat *ptr = _env->GetFloatArrayElements(data, NULL); + rsAllocationData((RsAllocation)alloc, ptr); + _env->ReleaseFloatArrayElements(data, ptr, JNI_COMMIT); +} // ----------------------------------- @@ -1197,6 +1218,8 @@ static JNINativeMethod methods[] = { {"nAllocationSubData1D", "(III[F)V", (void*)nAllocationSubData1D_f }, {"nAllocationSubData2D", "(IIIII[I)V", (void*)nAllocationSubData2D_i }, {"nAllocationSubData2D", "(IIIII[F)V", (void*)nAllocationSubData2D_f }, +{"nAllocationRead", "(I[I)V", (void*)nAllocationRead_i }, +{"nAllocationRead", "(I[F)V", (void*)nAllocationRead_f }, {"nTriangleMeshDestroy", "(I)V", (void*)nTriangleMeshDestroy }, {"nTriangleMeshBegin", "(II)V", (void*)nTriangleMeshBegin }, -- cgit v1.1