diff options
| author | Alex Sakhartchouk <alexst@google.com> | 2010-07-15 15:19:07 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-07-15 15:19:07 -0700 |
| commit | 51b7ebc652e320ee89b546f3e699ba31e9394a2c (patch) | |
| tree | ddda99e3d491b3cf7d7c505ac6a2f072485b1020 /graphics/jni/android_renderscript_RenderScript.cpp | |
| parent | c96cdc9844d60d54683fb7700fc5908fdb8ff856 (diff) | |
| parent | dfac814c18f73dd7289f9927edca3e3b6ec6bc00 (diff) | |
| download | frameworks_base-51b7ebc652e320ee89b546f3e699ba31e9394a2c.zip frameworks_base-51b7ebc652e320ee89b546f3e699ba31e9394a2c.tar.gz frameworks_base-51b7ebc652e320ee89b546f3e699ba31e9394a2c.tar.bz2 | |
Merge "Populate java objects with native data from a3d file. Remove legacy constructor from programraster Make a3d object creation synchronous"
Diffstat (limited to 'graphics/jni/android_renderscript_RenderScript.cpp')
| -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 }, |
