diff options
author | Jason Sams <rjsams@android.com> | 2010-11-08 17:06:46 -0800 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2010-11-08 17:19:31 -0800 |
commit | 1c41517124a90fcfdb95dc069fc492c6fcf1ff25 (patch) | |
tree | 43a463cfe40b0cf7e96ca9045075e31390d1e60e /graphics/jni | |
parent | 553a53ef9ff789dff8b5a74dfea4d6f37feeb263 (diff) | |
download | frameworks_base-1c41517124a90fcfdb95dc069fc492c6fcf1ff25.zip frameworks_base-1c41517124a90fcfdb95dc069fc492c6fcf1ff25.tar.gz frameworks_base-1c41517124a90fcfdb95dc069fc492c6fcf1ff25.tar.bz2 |
Handle user message ID 0
Pass RS runtime errors back to java.
throw exceptions for runtime errors.
Change-Id: Ifcf16cbbf9b98137971dced5076f8a5563eb016c
Diffstat (limited to 'graphics/jni')
-rw-r--r-- | graphics/jni/android_renderscript_RenderScript.cpp | 58 |
1 files changed, 45 insertions, 13 deletions
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index 77cbc10..dd84848 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -223,19 +223,48 @@ nContextResume(JNIEnv *_env, jobject _this, RsContext con) rsContextResume(con); } -static jint -nContextGetMessage(JNIEnv *_env, jobject _this, RsContext con, jintArray data, jboolean wait) + +static jstring +nContextGetErrorMessage(JNIEnv *_env, jobject _this, RsContext con) +{ + LOG_API("nContextGetErrorMessage, con(%p)", con); + char buf[1024]; + + size_t receiveLen; + uint32_t subID; + int id = rsContextGetMessage(con, buf, &receiveLen, &subID, sizeof(buf), true); + if (!id && receiveLen) { + LOGV("message receive buffer too small. %i", receiveLen); + } + return _env->NewStringUTF(buf); +} + +static void +nContextGetUserMessage(JNIEnv *_env, jobject _this, RsContext con, jintArray data) { jint len = _env->GetArrayLength(data); LOG_API("nContextGetMessage, con(%p), len(%i)", con, len); jint *ptr = _env->GetIntArrayElements(data, NULL); size_t receiveLen; - int id = rsContextGetMessage(con, ptr, &receiveLen, len * 4, wait); + uint32_t subID; + int id = rsContextGetMessage(con, ptr, &receiveLen, &subID, len * 4, true); if (!id && receiveLen) { LOGV("message receive buffer too small. %i", receiveLen); - *ptr = (jint)receiveLen; } _env->ReleaseIntArrayElements(data, ptr, 0); +} + +static jint +nContextPeekMessage(JNIEnv *_env, jobject _this, RsContext con, jintArray auxData, jboolean wait) +{ + LOG_API("nContextPeekMessage, con(%p)", con); + jint *auxDataPtr = _env->GetIntArrayElements(auxData, NULL); + size_t receiveLen; + uint32_t subID; + int id = rsContextPeekMessage(con, &receiveLen, &subID, wait); + auxDataPtr[0] = (jint)subID; + auxDataPtr[1] = (jint)receiveLen; + _env->ReleaseIntArrayElements(auxData, auxDataPtr, 0); return id; } @@ -1218,15 +1247,18 @@ nMeshGetIndices(JNIEnv *_env, jobject _this, RsContext con, jint mesh, jintArray static const char *classPathName = "android/renderscript/RenderScript"; static JNINativeMethod methods[] = { -{"_nInit", "()V", (void*)_nInit }, -{"nInitElements", "(IIII)V", (void*)nInitElements }, - -{"nDeviceCreate", "()I", (void*)nDeviceCreate }, -{"nDeviceDestroy", "(I)V", (void*)nDeviceDestroy }, -{"nDeviceSetConfig", "(III)V", (void*)nDeviceSetConfig }, -{"nContextGetMessage", "(I[IZ)I", (void*)nContextGetMessage }, -{"nContextInitToClient", "(I)V", (void*)nContextInitToClient }, -{"nContextDeinitToClient", "(I)V", (void*)nContextDeinitToClient }, +{"_nInit", "()V", (void*)_nInit }, +{"nInitElements", "(IIII)V", (void*)nInitElements }, + +{"nDeviceCreate", "()I", (void*)nDeviceCreate }, +{"nDeviceDestroy", "(I)V", (void*)nDeviceDestroy }, +{"nDeviceSetConfig", "(III)V", (void*)nDeviceSetConfig }, +{"nContextGetUserMessage", "(I[I)V", (void*)nContextGetUserMessage }, +{"nContextGetErrorMessage", "(I)Ljava/lang/String;", (void*)nContextGetErrorMessage }, +{"nContextPeekMessage", "(I[IZ)I", (void*)nContextPeekMessage }, + +{"nContextInitToClient", "(I)V", (void*)nContextInitToClient }, +{"nContextDeinitToClient", "(I)V", (void*)nContextDeinitToClient }, // All methods below are thread protected in java. |