diff options
| author | Alex Sakhartchouk <alexst@google.com> | 2010-07-15 11:33:03 -0700 |
|---|---|---|
| committer | Alex Sakhartchouk <alexst@google.com> | 2010-07-15 14:02:54 -0700 |
| commit | dfac814c18f73dd7289f9927edca3e3b6ec6bc00 (patch) | |
| tree | 386ca04866a3e7be79ae621582222a8f2b09ceda /graphics/jni | |
| parent | 506821b406181ff9b9a10c2fc078d16b79a8cf92 (diff) | |
| download | frameworks_base-dfac814c18f73dd7289f9927edca3e3b6ec6bc00.zip frameworks_base-dfac814c18f73dd7289f9927edca3e3b6ec6bc00.tar.gz frameworks_base-dfac814c18f73dd7289f9927edca3e3b6ec6bc00.tar.bz2 | |
Populate java objects with native data from a3d file.
Remove legacy constructor from programraster
Make a3d object creation synchronous
Change-Id: Ic7d7547cf6eee6f9a7c6e3ee12cd104e80056a7b
Diffstat (limited to 'graphics/jni')
| -rw-r--r-- | graphics/jni/android_renderscript_RenderScript.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index 13360c3..888c76a 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -297,6 +297,46 @@ nElementCreate2(JNIEnv *_env, jobject _this, jintArray _ids, jobjectArray _names return (jint)id; } +static void +nElementGetNativeData(JNIEnv *_env, jobject _this, jint id, jintArray _elementData) +{ + int dataSize = _env->GetArrayLength(_elementData); + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + LOG_API("nElementGetNativeData, con(%p)", con); + + // we will pack mType; mKind; mNormalized; mVectorSize; NumSubElements + assert(dataSize == 5); + + uint32_t elementData[5]; + rsElementGetNativeData(con, (RsElement)id, elementData, dataSize); + + for(jint i = 0; i < dataSize; i ++) { + _env->SetIntArrayRegion(_elementData, i, 1, (const jint*)&elementData[i]); + } +} + + +static void +nElementGetSubElements(JNIEnv *_env, jobject _this, jint id, jintArray _IDs, jobjectArray _names) +{ + int dataSize = _env->GetArrayLength(_IDs); + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + LOG_API("nElementGetSubElements, con(%p)", con); + + uint32_t *ids = (uint32_t *)malloc((uint32_t)dataSize * sizeof(uint32_t)); + const char **names = (const char **)malloc((uint32_t)dataSize * sizeof(const char *)); + + rsElementGetSubElements(con, (RsElement)id, ids, names, (uint32_t)dataSize); + + for(jint i = 0; i < dataSize; i ++) { + _env->SetObjectArrayElement(_names, i, _env->NewStringUTF(names[i])); + _env->SetIntArrayRegion(_IDs, i, 1, (const jint*)&ids[i]); + } + + free(ids); + free(names); +} + // ----------------------------------- static void @@ -323,6 +363,26 @@ nTypeCreate(JNIEnv *_env, jobject _this) return (jint)rsTypeCreate(con); } +static void +nTypeGetNativeData(JNIEnv *_env, jobject _this, jint id, jintArray _typeData) +{ + // We are packing 6 items: mDimX; mDimY; mDimZ; + // mDimLOD; mDimFaces; mElement; into typeData + int elementCount = _env->GetArrayLength(_typeData); + + assert(elementCount == 6); + + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + LOG_API("nTypeCreate, con(%p)", con); + + uint32_t typeData[6]; + rsTypeGetNativeData(con, (RsType)id, typeData, 6); + + for(jint i = 0; i < elementCount; i ++) { + _env->SetIntArrayRegion(_typeData, i, 1, (const jint*)&typeData[i]); + } +} + static void * SF_LoadInt(JNIEnv *_env, jobject _obj, jfieldID _field, void *buffer) { ((int32_t *)buffer)[0] = _env->GetIntField(_obj, _field); @@ -708,6 +768,14 @@ nAllocationSubReadFromObject(JNIEnv *_env, jobject _this, jint alloc, jobject _t free(bufAlloc); } +static jint +nAllocationGetType(JNIEnv *_env, jobject _this, jint a) +{ + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + LOG_API("nAllocationGetType, con(%p), a(%p)", con, (RsAllocation)a); + return (jint) rsAllocationGetType(con, (RsAllocation)a); +} + // ----------------------------------- static int @@ -1466,12 +1534,15 @@ static JNINativeMethod methods[] = { {"nElementCreate", "(IIZI)I", (void*)nElementCreate }, {"nElementCreate2", "([I[Ljava/lang/String;)I", (void*)nElementCreate2 }, +{"nElementGetNativeData", "(I[I)V", (void*)nElementGetNativeData }, +{"nElementGetSubElements", "(I[I[Ljava/lang/String;)V", (void*)nElementGetSubElements }, {"nTypeBegin", "(I)V", (void*)nTypeBegin }, {"nTypeAdd", "(II)V", (void*)nTypeAdd }, {"nTypeCreate", "()I", (void*)nTypeCreate }, {"nTypeFinalDestroy", "(Landroid/renderscript/Type;)V", (void*)nTypeFinalDestroy }, {"nTypeSetupFields", "(Landroid/renderscript/Type;[I[I[Ljava/lang/reflect/Field;)V", (void*)nTypeSetupFields }, +{"nTypeGetNativeData", "(I[I)V", (void*)nTypeGetNativeData }, {"nAllocationCreateTyped", "(I)I", (void*)nAllocationCreateTyped }, {"nAllocationCreateFromBitmap", "(IZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmap }, @@ -1490,6 +1561,7 @@ static JNINativeMethod methods[] = { {"nAllocationRead", "(I[F)V", (void*)nAllocationRead_f }, {"nAllocationSubDataFromObject", "(ILandroid/renderscript/Type;ILjava/lang/Object;)V", (void*)nAllocationSubDataFromObject }, {"nAllocationSubReadFromObject", "(ILandroid/renderscript/Type;ILjava/lang/Object;)V", (void*)nAllocationSubReadFromObject }, +{"nAllocationGetType", "(I)I", (void*)nAllocationGetType}, {"nAdapter1DBindAllocation", "(II)V", (void*)nAdapter1DBindAllocation }, {"nAdapter1DSetConstraint", "(III)V", (void*)nAdapter1DSetConstraint }, |
