summaryrefslogtreecommitdiffstats
path: root/graphics/jni
diff options
context:
space:
mode:
authorJason Sams <rjsams@android.com>2009-12-23 14:35:29 -0800
committerJason Sams <rjsams@android.com>2009-12-23 14:35:29 -0800
commit718cd1f322ee5b62b6a49cb36195bcb18a5ab711 (patch)
treef2f8c9db5a8141eafa2f1547634d7586fdc6ef04 /graphics/jni
parentceedafacdb87307234c84196a12eeb6e657d6220 (diff)
downloadframeworks_base-718cd1f322ee5b62b6a49cb36195bcb18a5ab711.zip
frameworks_base-718cd1f322ee5b62b6a49cb36195bcb18a5ab711.tar.gz
frameworks_base-718cd1f322ee5b62b6a49cb36195bcb18a5ab711.tar.bz2
Element restructuring. Add support for new basic Element types including the RS objects and vectors(2-4). In theory this paves the way for maintaining type info for RS objects, passing elements for GLSL uiforms/attribs/varyings, and supporting nested structures.
This will break some apps, checkings for other projects will follow to unbreak them.
Diffstat (limited to 'graphics/jni')
-rw-r--r--graphics/jni/android_renderscript_RenderScript.cpp84
1 files changed, 42 insertions, 42 deletions
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp
index 6ae93a7..f4e752f 100644
--- a/graphics/jni/android_renderscript_RenderScript.cpp
+++ b/graphics/jni/android_renderscript_RenderScript.cpp
@@ -247,36 +247,39 @@ static void nContextDeinitToClient(JNIEnv *_env, jobject _this)
}
-static void
-nElementBegin(JNIEnv *_env, jobject _this)
+static jint
+nElementCreate(JNIEnv *_env, jobject _this, jint type, jint kind, jboolean norm, jint size)
{
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
- LOG_API("nElementBegin, con(%p)", con);
- rsElementBegin(con);
+ LOG_API("nElementCreate, con(%p), type(%i), kind(%i), norm(%i), size(%i)", con, type, kind, norm, size);
+ return (jint)rsElementCreate(con, (RsDataType)type, (RsDataKind)kind, norm, size);
}
-
-static void
-nElementAdd(JNIEnv *_env, jobject _this, jint kind, jint type, jboolean norm, jint bits, jstring name)
+static jint
+nElementCreate2(JNIEnv *_env, jobject _this, jintArray _ids, jobjectArray _names)
{
+ int fieldCount = _env->GetArrayLength(_ids);
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
- const char* n = NULL;
- if (name) {
- n = _env->GetStringUTFChars(name, NULL);
+ LOG_API("nElementCreate, con(%p), type(%i), kind(%i), norm(%i), size(%i)", con, type, kind, norm, size);
+
+ jint *ids = _env->GetIntArrayElements(_ids, NULL);
+ const char ** nameArray = (const char **)calloc(fieldCount, sizeof(char *));
+ size_t* sizeArray = (size_t*)calloc(fieldCount, sizeof(size_t));
+
+ for (int ct=0; ct < fieldCount; ct++) {
+ jstring s = (jstring)_env->GetObjectArrayElement(_names, ct);
+ nameArray[ct] = _env->GetStringUTFChars(s, NULL);
+ sizeArray[ct] = _env->GetStringUTFLength(s);
}
- LOG_API("nElementAdd, con(%p), kind(%i), type(%i), norm(%i), bits(%i)", con, kind, type, norm, bits);
- rsElementAdd(con, (RsDataKind)kind, (RsDataType)type, norm != 0, (size_t)bits, n);
- if (n) {
- _env->ReleaseStringUTFChars(name, n);
+ jint id = (jint)rsElementCreate2(con, fieldCount, (RsElement *)ids, nameArray, sizeArray);
+ for (int ct=0; ct < fieldCount; ct++) {
+ jstring s = (jstring)_env->GetObjectArrayElement(_names, ct);
+ _env->ReleaseStringUTFChars(s, nameArray[ct]);
}
-}
-
-static jint
-nElementCreate(JNIEnv *_env, jobject _this)
-{
- RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
- LOG_API("nElementCreate, con(%p)", con);
- return (jint)rsElementCreate(con);
+ _env->ReleaseIntArrayElements(_ids, ids, JNI_ABORT);
+ free(nameArray);
+ free(sizeArray);
+ return (jint)id;
}
// -----------------------------------
@@ -395,26 +398,24 @@ nTypeSetupFields(JNIEnv *_env, jobject _this, jobject _type, jintArray _types, j
tfc[ct].bits = fBits[ct];
switch(fType[ct]) {
- case RS_TYPE_FLOAT:
+ case RS_TYPE_FLOAT_32:
tfc[ct].ptr = SF_LoadFloat;
tfc[ct].readPtr = SF_SaveFloat;
break;
- case RS_TYPE_UNSIGNED:
- case RS_TYPE_SIGNED:
- switch(tfc[ct].bits) {
- case 32:
- tfc[ct].ptr = SF_LoadInt;
- tfc[ct].readPtr = SF_SaveInt;
- break;
- case 16:
- tfc[ct].ptr = SF_LoadShort;
- tfc[ct].readPtr = SF_SaveShort;
- break;
- case 8:
- tfc[ct].ptr = SF_LoadByte;
- tfc[ct].readPtr = SF_SaveByte;
- break;
- }
+ case RS_TYPE_UNSIGNED_32:
+ case RS_TYPE_SIGNED_32:
+ tfc[ct].ptr = SF_LoadInt;
+ tfc[ct].readPtr = SF_SaveInt;
+ break;
+ case RS_TYPE_UNSIGNED_16:
+ case RS_TYPE_SIGNED_16:
+ tfc[ct].ptr = SF_LoadShort;
+ tfc[ct].readPtr = SF_SaveShort;
+ break;
+ case RS_TYPE_UNSIGNED_8:
+ case RS_TYPE_SIGNED_8:
+ tfc[ct].ptr = SF_LoadByte;
+ tfc[ct].readPtr = SF_SaveByte;
break;
}
tc->size += 4;
@@ -1367,9 +1368,8 @@ static JNINativeMethod methods[] = {
{"nFileOpen", "([B)I", (void*)nFileOpen },
-{"nElementBegin", "()V", (void*)nElementBegin },
-{"nElementAdd", "(IIZILjava/lang/String;)V", (void*)nElementAdd },
-{"nElementCreate", "()I", (void*)nElementCreate },
+{"nElementCreate", "(IIZI)I", (void*)nElementCreate },
+{"nElementCreate2", "([I[Ljava/lang/String;)I", (void*)nElementCreate2 },
{"nTypeBegin", "(I)V", (void*)nTypeBegin },
{"nTypeAdd", "(II)V", (void*)nTypeAdd },