diff options
Diffstat (limited to 'graphics/jni/android_renderscript_RenderScript.cpp')
-rw-r--r-- | graphics/jni/android_renderscript_RenderScript.cpp | 436 |
1 files changed, 305 insertions, 131 deletions
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index 45cc72e..8968dfb 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -85,6 +85,14 @@ static void nInitElements(JNIEnv *_env, jobject _this, jint a8, jint rgba4444, j // --------------------------------------------------------------------------- static void +nContextFinish(JNIEnv *_env, jobject _this) +{ + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + LOG_API("nContextFinish, con(%p)", con); + rsContextFinish(con); +} + +static void nAssignName(JNIEnv *_env, jobject _this, jint obj, jbyteArray str) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); @@ -96,6 +104,17 @@ nAssignName(JNIEnv *_env, jobject _this, jint obj, jbyteArray str) _env->ReleasePrimitiveArrayCritical(str, cptr, JNI_ABORT); } +static jstring +nGetName(JNIEnv *_env, jobject _this, jint obj) +{ + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + LOG_API("nGetName, con(%p), obj(%p)", con, (void *)obj); + + const char *name = NULL; + rsGetName(con, (void *)obj, &name); + return _env->NewStringUTF(name); +} + static void nObjDestroy(JNIEnv *_env, jobject _this, jint obj) { @@ -289,6 +308,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 @@ -315,6 +374,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); @@ -700,6 +779,78 @@ 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 +nFileA3DCreateFromAssetStream(JNIEnv *_env, jobject _this, jint native_asset) +{ + LOGV("______nFileA3D %u", (uint32_t) native_asset); + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + + Asset* asset = reinterpret_cast<Asset*>(native_asset); + + jint id = (jint)rsFileA3DCreateFromAssetStream(con, asset->getBuffer(false), asset->getLength()); + return id; +} + +static int +nFileA3DGetNumIndexEntries(JNIEnv *_env, jobject _this, jint fileA3D) +{ + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + + int32_t numEntries = 0; + rsFileA3DGetNumIndexEntries(con, &numEntries, (RsFile)fileA3D); + return numEntries; +} + +static void +nFileA3DGetIndexEntries(JNIEnv *_env, jobject _this, jint fileA3D, jint numEntries, jintArray _ids, jobjectArray _entries) +{ + LOGV("______nFileA3D %u", (uint32_t) fileA3D); + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + + RsFileIndexEntry *fileEntries = (RsFileIndexEntry*)malloc((uint32_t)numEntries * sizeof(RsFileIndexEntry)); + + rsFileA3DGetIndexEntries(con, fileEntries, (uint32_t)numEntries, (RsFile)fileA3D); + + for(jint i = 0; i < numEntries; i ++) { + _env->SetObjectArrayElement(_entries, i, _env->NewStringUTF(fileEntries[i].objectName)); + _env->SetIntArrayRegion(_ids, i, 1, (const jint*)&fileEntries[i].classID); + } + + free(fileEntries); +} + +static int +nFileA3DGetEntryByIndex(JNIEnv *_env, jobject _this, jint fileA3D, jint index) +{ + LOGV("______nFileA3D %u", (uint32_t) fileA3D); + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + + jint id = (jint)rsFileA3DGetEntryByIndex(con, (uint32_t)index, (RsFile)fileA3D); + return id; +} + +// ----------------------------------- + +static int +nFontCreateFromFile(JNIEnv *_env, jobject _this, jstring fileName, jint fontSize, jint dpi) +{ + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + const char* fileNameUTF = _env->GetStringUTFChars(fileName, NULL); + + jint id = (jint)rsFontCreateFromFile(con, fileNameUTF, fontSize, dpi); + return id; +} + // ----------------------------------- @@ -854,29 +1005,33 @@ nScriptBindAllocation(JNIEnv *_env, jobject _this, jint script, jint alloc, jint } static void -nScriptSetClearColor(JNIEnv *_env, jobject _this, jint script, jfloat r, jfloat g, jfloat b, jfloat a) +nScriptSetVarI(JNIEnv *_env, jobject _this, jint script, jint slot, jint val) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nScriptSetClearColor, con(%p), s(%p), r(%f), g(%f), b(%f), a(%f)", con, (void *)script, r, g, b, a); - rsScriptSetClearColor(con, (RsScript)script, r, g, b, a); + LOG_API("nScriptSetVarI, con(%p), s(%p), slot(%i), val(%i), b(%f), a(%f)", con, (void *)script, slot, val); + rsScriptSetVarI(con, (RsScript)script, slot, val); } static void -nScriptSetClearDepth(JNIEnv *_env, jobject _this, jint script, jfloat d) +nScriptSetVarF(JNIEnv *_env, jobject _this, jint script, jint slot, float val) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nScriptCSetClearDepth, con(%p), s(%p), depth(%f)", con, (void *)script, d); - rsScriptSetClearDepth(con, (RsScript)script, d); + LOG_API("nScriptSetVarI, con(%p), s(%p), slot(%i), val(%i), b(%f), a(%f)", con, (void *)script, slot, val); + rsScriptSetVarF(con, (RsScript)script, slot, val); } static void -nScriptSetClearStencil(JNIEnv *_env, jobject _this, jint script, jint stencil) +nScriptSetVarV(JNIEnv *_env, jobject _this, jint script, jint slot, jbyteArray data) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nScriptCSetClearStencil, con(%p), s(%p), stencil(%i)", con, (void *)script, stencil); - rsScriptSetClearStencil(con, (RsScript)script, stencil); + LOG_API("nScriptSetVarV, con(%p), s(%p), slot(%i)", con, (void *)script, slot); + jint len = _env->GetArrayLength(data); + jbyte *ptr = _env->GetByteArrayElements(data, NULL); + rsScriptSetVarV(con, (RsScript)script, slot, ptr, len); + _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); } + static void nScriptSetTimeZone(JNIEnv *_env, jobject _this, jint script, jbyteArray timeZone) { @@ -895,36 +1050,6 @@ nScriptSetTimeZone(JNIEnv *_env, jobject _this, jint script, jbyteArray timeZone } static void -nScriptSetType(JNIEnv *_env, jobject _this, jint type, jboolean writable, jstring _str, jint slot) -{ - RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nScriptCAddType, con(%p), type(%p), writable(%i), slot(%i)", con, (RsType)type, writable, slot); - const char* n = NULL; - if (_str) { - n = _env->GetStringUTFChars(_str, NULL); - } - rsScriptSetType(con, (RsType)type, slot, writable, n); - if (n) { - _env->ReleaseStringUTFChars(_str, n); - } -} - -static void -nScriptSetInvoke(JNIEnv *_env, jobject _this, jstring _str, jint slot) -{ - RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nScriptSetInvoke, con(%p)", con); - const char* n = NULL; - if (_str) { - n = _env->GetStringUTFChars(_str, NULL); - } - rsScriptSetInvoke(con, n, slot); - if (n) { - _env->ReleaseStringUTFChars(_str, n); - } -} - -static void nScriptInvoke(JNIEnv *_env, jobject _this, jint obj, jint slot) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); @@ -933,13 +1058,17 @@ nScriptInvoke(JNIEnv *_env, jobject _this, jint obj, jint slot) } static void -nScriptSetRoot(JNIEnv *_env, jobject _this, jboolean isRoot) +nScriptInvokeV(JNIEnv *_env, jobject _this, jint script, jint slot, jbyteArray data) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nScriptCSetRoot, con(%p), isRoot(%i)", con, isRoot); - rsScriptSetRoot(con, isRoot); + LOG_API("nScriptInvokeV, con(%p), s(%p), slot(%i)", con, (void *)script, slot); + jint len = _env->GetArrayLength(data); + jbyte *ptr = _env->GetByteArrayElements(data, NULL); + rsScriptInvokeV(con, (RsScript)script, slot, ptr, len); + _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); } + // ----------------------------------- static void @@ -1002,83 +1131,63 @@ nScriptCCreate(JNIEnv *_env, jobject _this) return (jint)rsScriptCCreate(con); } -static void -nScriptCAddDefineI32(JNIEnv *_env, jobject _this, jstring name, jint value) -{ - RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - const char* n = _env->GetStringUTFChars(name, NULL); - LOG_API("nScriptCAddDefineI32, con(%p) name(%s) value(%d)", con, n, value); - rsScriptCSetDefineI32(con, n, value); - _env->ReleaseStringUTFChars(name, n); -} - -static void -nScriptCAddDefineF(JNIEnv *_env, jobject _this, jstring name, jfloat value) -{ - RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - const char* n = _env->GetStringUTFChars(name, NULL); - LOG_API("nScriptCAddDefineF, con(%p) name(%s) value(%f)", con, n, value); - rsScriptCSetDefineF(con, n, value); - _env->ReleaseStringUTFChars(name, n); -} - // --------------------------------------------------------------------------- static void -nProgramFragmentStoreBegin(JNIEnv *_env, jobject _this, jint in, jint out) +nProgramStoreBegin(JNIEnv *_env, jobject _this, jint in, jint out) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nProgramFragmentStoreBegin, con(%p), in(%p), out(%p)", con, (RsElement)in, (RsElement)out); - rsProgramFragmentStoreBegin(con, (RsElement)in, (RsElement)out); + LOG_API("nProgramStoreBegin, con(%p), in(%p), out(%p)", con, (RsElement)in, (RsElement)out); + rsProgramStoreBegin(con, (RsElement)in, (RsElement)out); } static void -nProgramFragmentStoreDepthFunc(JNIEnv *_env, jobject _this, jint func) +nProgramStoreDepthFunc(JNIEnv *_env, jobject _this, jint func) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nProgramFragmentStoreDepthFunc, con(%p), func(%i)", con, func); - rsProgramFragmentStoreDepthFunc(con, (RsDepthFunc)func); + LOG_API("nProgramStoreDepthFunc, con(%p), func(%i)", con, func); + rsProgramStoreDepthFunc(con, (RsDepthFunc)func); } static void -nProgramFragmentStoreDepthMask(JNIEnv *_env, jobject _this, jboolean enable) +nProgramStoreDepthMask(JNIEnv *_env, jobject _this, jboolean enable) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nProgramFragmentStoreDepthMask, con(%p), enable(%i)", con, enable); - rsProgramFragmentStoreDepthMask(con, enable); + LOG_API("nProgramStoreDepthMask, con(%p), enable(%i)", con, enable); + rsProgramStoreDepthMask(con, enable); } static void -nProgramFragmentStoreColorMask(JNIEnv *_env, jobject _this, jboolean r, jboolean g, jboolean b, jboolean a) +nProgramStoreColorMask(JNIEnv *_env, jobject _this, jboolean r, jboolean g, jboolean b, jboolean a) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nProgramFragmentStoreColorMask, con(%p), r(%i), g(%i), b(%i), a(%i)", con, r, g, b, a); - rsProgramFragmentStoreColorMask(con, r, g, b, a); + LOG_API("nProgramStoreColorMask, con(%p), r(%i), g(%i), b(%i), a(%i)", con, r, g, b, a); + rsProgramStoreColorMask(con, r, g, b, a); } static void -nProgramFragmentStoreBlendFunc(JNIEnv *_env, jobject _this, int src, int dst) +nProgramStoreBlendFunc(JNIEnv *_env, jobject _this, int src, int dst) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nProgramFragmentStoreBlendFunc, con(%p), src(%i), dst(%i)", con, src, dst); - rsProgramFragmentStoreBlendFunc(con, (RsBlendSrcFunc)src, (RsBlendDstFunc)dst); + LOG_API("nProgramStoreBlendFunc, con(%p), src(%i), dst(%i)", con, src, dst); + rsProgramStoreBlendFunc(con, (RsBlendSrcFunc)src, (RsBlendDstFunc)dst); } static void -nProgramFragmentStoreDither(JNIEnv *_env, jobject _this, jboolean enable) +nProgramStoreDither(JNIEnv *_env, jobject _this, jboolean enable) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nProgramFragmentStoreDither, con(%p), enable(%i)", con, enable); - rsProgramFragmentStoreDither(con, enable); + LOG_API("nProgramStoreDither, con(%p), enable(%i)", con, enable); + rsProgramStoreDither(con, enable); } static jint -nProgramFragmentStoreCreate(JNIEnv *_env, jobject _this) +nProgramStoreCreate(JNIEnv *_env, jobject _this) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nProgramFragmentStoreCreate, con(%p)", con); + LOG_API("nProgramStoreCreate, con(%p)", con); - return (jint)rsProgramFragmentStoreCreate(con); + return (jint)rsProgramStoreCreate(con); } // --------------------------------------------------------------------------- @@ -1171,29 +1280,28 @@ nProgramVertexCreate2(JNIEnv *_env, jobject _this, jstring shader, jintArray par // --------------------------------------------------------------------------- static jint -nProgramRasterCreate(JNIEnv *_env, jobject _this, jint in, jint out, - jboolean pointSmooth, jboolean lineSmooth, jboolean pointSprite) +nProgramRasterCreate(JNIEnv *_env, jobject _this, jboolean pointSmooth, jboolean lineSmooth, jboolean pointSprite) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nProgramRasterCreate, con(%p), in(%p), out(%p), pointSmooth(%i), lineSmooth(%i), pointSprite(%i)", - con, (RsElement)in, (RsElement)out, pointSmooth, lineSmooth, pointSprite); - return (jint)rsProgramRasterCreate(con, (RsElement)in, (RsElement)out, pointSmooth, lineSmooth, pointSprite); + LOG_API("nProgramRasterCreate, con(%p), pointSmooth(%i), lineSmooth(%i), pointSprite(%i)", + con, pointSmooth, lineSmooth, pointSprite); + return (jint)rsProgramRasterCreate(con, pointSmooth, lineSmooth, pointSprite); } static void -nProgramRasterSetPointSize(JNIEnv *_env, jobject _this, jint vpr, jfloat v) +nProgramRasterSetLineWidth(JNIEnv *_env, jobject _this, jint vpr, jfloat v) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nProgramRasterSetPointSize, con(%p), vpf(%p), value(%f)", con, (RsProgramRaster)vpr, v); - rsProgramRasterSetPointSize(con, (RsProgramFragment)vpr, v); + LOG_API("nProgramRasterSetLineWidth, con(%p), vpf(%p), value(%f)", con, (RsProgramRaster)vpr, v); + rsProgramRasterSetLineWidth(con, (RsProgramRaster)vpr, v); } static void -nProgramRasterSetLineWidth(JNIEnv *_env, jobject _this, jint vpr, jfloat v) +nProgramRasterSetCullMode(JNIEnv *_env, jobject _this, jint vpr, jint v) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nProgramRasterSetLineWidth, con(%p), vpf(%p), value(%f)", con, (RsProgramRaster)vpr, v); - rsProgramRasterSetLineWidth(con, (RsProgramFragment)vpr, v); + LOG_API("nProgramRasterSetCullMode, con(%p), vpf(%p), value(%i)", con, (RsProgramRaster)vpr, v); + rsProgramRasterSetCullMode(con, (RsProgramRaster)vpr, (RsCullMode)v); } @@ -1208,11 +1316,11 @@ nContextBindRootScript(JNIEnv *_env, jobject _this, jint script) } static void -nContextBindProgramFragmentStore(JNIEnv *_env, jobject _this, jint pfs) +nContextBindProgramStore(JNIEnv *_env, jobject _this, jint pfs) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nContextBindProgramFragmentStore, con(%p), pfs(%p)", con, (RsProgramFragmentStore)pfs); - rsContextBindProgramFragmentStore(con, (RsProgramFragmentStore)pfs); + LOG_API("nContextBindProgramStore, con(%p), pfs(%p)", con, (RsProgramStore)pfs); + rsContextBindProgramStore(con, (RsProgramStore)pfs); } static void @@ -1319,32 +1427,84 @@ nLightSetPosition(JNIEnv *_env, jobject _this, jint light, float x, float y, flo // --------------------------------------------------------------------------- static jint -nSimpleMeshCreate(JNIEnv *_env, jobject _this, jint batchID, jint indexID, jintArray vtxIDs, jint primID) +nMeshCreate(JNIEnv *_env, jobject _this, jint vtxCount, jint idxCount) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - jint len = _env->GetArrayLength(vtxIDs); - LOG_API("nSimpleMeshCreate, con(%p), batchID(%i), indexID(%i), vtxIDs.len(%i), primID(%i)", - con, batchID, indexID, len, primID); - jint *ptr = _env->GetIntArrayElements(vtxIDs, NULL); - int id = (int)rsSimpleMeshCreate(con, (void *)batchID, (void *)indexID, (void **)ptr, len, primID); - _env->ReleaseIntArrayElements(vtxIDs, ptr, 0/*JNI_ABORT*/); + LOG_API("nMeshCreate, con(%p), vtxCount(%i), idxCount(%i)", con, vtxCount, idxCount); + int id = (int)rsMeshCreate(con, vtxCount, idxCount); return id; } static void -nSimpleMeshBindVertex(JNIEnv *_env, jobject _this, jint s, jint alloc, jint slot) +nMeshBindVertex(JNIEnv *_env, jobject _this, jint mesh, jint alloc, jint slot) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nSimpleMeshBindVertex, con(%p), SimpleMesh(%p), Alloc(%p), slot(%i)", con, (RsSimpleMesh)s, (RsAllocation)alloc, slot); - rsSimpleMeshBindVertex(con, (RsSimpleMesh)s, (RsAllocation)alloc, slot); + LOG_API("nMeshBindVertex, con(%p), Mesh(%p), Alloc(%p), slot(%i)", con, (RsMesh)mesh, (RsAllocation)alloc, slot); + rsMeshBindVertex(con, (RsMesh)mesh, (RsAllocation)alloc, slot); } static void -nSimpleMeshBindIndex(JNIEnv *_env, jobject _this, jint s, jint alloc) +nMeshBindIndex(JNIEnv *_env, jobject _this, jint mesh, jint alloc, jint primID, jint slot) +{ + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + LOG_API("nMeshBindIndex, con(%p), Mesh(%p), Alloc(%p)", con, (RsMesh)mesh, (RsAllocation)alloc); + rsMeshBindIndex(con, (RsMesh)mesh, (RsAllocation)alloc, primID, slot); +} + +static jint +nMeshGetVertexBufferCount(JNIEnv *_env, jobject _this, jint mesh) +{ + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + LOG_API("nMeshGetVertexBufferCount, con(%p), Mesh(%p)", con, (RsMesh)mesh); + jint vtxCount = 0; + rsMeshGetVertexBufferCount(con, (RsMesh)mesh, &vtxCount); + return vtxCount; +} + +static jint +nMeshGetIndexCount(JNIEnv *_env, jobject _this, jint mesh) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nSimpleMeshBindIndex, con(%p), SimpleMesh(%p), Alloc(%p)", con, (RsSimpleMesh)s, (RsAllocation)alloc); - rsSimpleMeshBindIndex(con, (RsSimpleMesh)s, (RsAllocation)alloc); + LOG_API("nMeshGetIndexCount, con(%p), Mesh(%p)", con, (RsMesh)mesh); + jint idxCount = 0; + rsMeshGetIndexCount(con, (RsMesh)mesh, &idxCount); + return idxCount; +} + +static void +nMeshGetVertices(JNIEnv *_env, jobject _this, jint mesh, jintArray _ids, int numVtxIDs) +{ + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + LOG_API("nMeshGetVertices, con(%p), Mesh(%p)", con, (RsMesh)mesh); + + RsAllocation *allocs = (RsAllocation*)malloc((uint32_t)numVtxIDs * sizeof(RsAllocation)); + rsMeshGetVertices(con, (RsMesh)mesh, allocs, (uint32_t)numVtxIDs); + + for(jint i = 0; i < numVtxIDs; i ++) { + _env->SetIntArrayRegion(_ids, i, 1, (const jint*)&allocs[i]); + } + + free(allocs); +} + +static void +nMeshGetIndices(JNIEnv *_env, jobject _this, jint mesh, jintArray _idxIds, jintArray _primitives, int numIndices) +{ + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + LOG_API("nMeshGetVertices, con(%p), Mesh(%p)", con, (RsMesh)mesh); + + RsAllocation *allocs = (RsAllocation*)malloc((uint32_t)numIndices * sizeof(RsAllocation)); + uint32_t *prims= (uint32_t*)malloc((uint32_t)numIndices * sizeof(uint32_t)); + + rsMeshGetIndices(con, (RsMesh)mesh, allocs, prims, (uint32_t)numIndices); + + for(jint i = 0; i < numIndices; i ++) { + _env->SetIntArrayRegion(_idxIds, i, 1, (const jint*)&allocs[i]); + _env->SetIntArrayRegion(_primitives, i, 1, (const jint*)&prims[i]); + } + + free(allocs); + free(prims); } // --------------------------------------------------------------------------- @@ -1361,6 +1521,7 @@ static JNINativeMethod methods[] = { {"nDeviceSetConfig", "(III)V", (void*)nDeviceSetConfig }, {"nContextCreate", "(II)I", (void*)nContextCreate }, {"nContextCreateGL", "(IIZ)I", (void*)nContextCreateGL }, +{"nContextFinish", "()V", (void*)nContextFinish }, {"nContextSetPriority", "(I)V", (void*)nContextSetPriority }, {"nContextSetSurface", "(IILandroid/view/Surface;)V", (void*)nContextSetSurface }, {"nContextDestroy", "(I)V", (void*)nContextDestroy }, @@ -1368,6 +1529,7 @@ static JNINativeMethod methods[] = { {"nContextPause", "()V", (void*)nContextPause }, {"nContextResume", "()V", (void*)nContextResume }, {"nAssignName", "(I[B)V", (void*)nAssignName }, +{"nGetName", "(I)Ljava/lang/String;", (void*)nGetName }, {"nObjDestroy", "(I)V", (void*)nObjDestroy }, {"nObjDestroyOOB", "(I)V", (void*)nObjDestroyOOB }, {"nContextGetMessage", "([IZ)I", (void*)nContextGetMessage }, @@ -1375,15 +1537,24 @@ static JNINativeMethod methods[] = { {"nContextDeinitToClient", "()V", (void*)nContextDeinitToClient }, {"nFileOpen", "([B)I", (void*)nFileOpen }, +{"nFileA3DCreateFromAssetStream", "(I)I", (void*)nFileA3DCreateFromAssetStream }, +{"nFileA3DGetNumIndexEntries", "(I)I", (void*)nFileA3DGetNumIndexEntries }, +{"nFileA3DGetIndexEntries", "(II[I[Ljava/lang/String;)V", (void*)nFileA3DGetIndexEntries }, +{"nFileA3DGetEntryByIndex", "(II)I", (void*)nFileA3DGetEntryByIndex }, + +{"nFontCreateFromFile", "(Ljava/lang/String;II)I", (void*)nFontCreateFromFile }, {"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 }, @@ -1402,6 +1573,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 }, @@ -1420,28 +1592,24 @@ static JNINativeMethod methods[] = { {"nAdapter2DCreate", "()I", (void*)nAdapter2DCreate }, {"nScriptBindAllocation", "(III)V", (void*)nScriptBindAllocation }, -{"nScriptSetClearColor", "(IFFFF)V", (void*)nScriptSetClearColor }, -{"nScriptSetClearDepth", "(IF)V", (void*)nScriptSetClearDepth }, -{"nScriptSetClearStencil", "(II)V", (void*)nScriptSetClearStencil }, {"nScriptSetTimeZone", "(I[B)V", (void*)nScriptSetTimeZone }, -{"nScriptSetType", "(IZLjava/lang/String;I)V", (void*)nScriptSetType }, -{"nScriptSetRoot", "(Z)V", (void*)nScriptSetRoot }, -{"nScriptSetInvokable", "(Ljava/lang/String;I)V", (void*)nScriptSetInvoke }, {"nScriptInvoke", "(II)V", (void*)nScriptInvoke }, +{"nScriptInvokeV", "(II[B)V", (void*)nScriptInvokeV }, +{"nScriptSetVarI", "(III)V", (void*)nScriptSetVarI }, +{"nScriptSetVarF", "(IIF)V", (void*)nScriptSetVarF }, +{"nScriptSetVarV", "(II[B)V", (void*)nScriptSetVarV }, {"nScriptCBegin", "()V", (void*)nScriptCBegin }, {"nScriptCSetScript", "([BII)V", (void*)nScriptCSetScript }, {"nScriptCCreate", "()I", (void*)nScriptCCreate }, -{"nScriptCAddDefineI32", "(Ljava/lang/String;I)V", (void*)nScriptCAddDefineI32 }, -{"nScriptCAddDefineF", "(Ljava/lang/String;F)V", (void*)nScriptCAddDefineF }, -{"nProgramFragmentStoreBegin", "(II)V", (void*)nProgramFragmentStoreBegin }, -{"nProgramFragmentStoreDepthFunc", "(I)V", (void*)nProgramFragmentStoreDepthFunc }, -{"nProgramFragmentStoreDepthMask", "(Z)V", (void*)nProgramFragmentStoreDepthMask }, -{"nProgramFragmentStoreColorMask", "(ZZZZ)V", (void*)nProgramFragmentStoreColorMask }, -{"nProgramFragmentStoreBlendFunc", "(II)V", (void*)nProgramFragmentStoreBlendFunc }, -{"nProgramFragmentStoreDither", "(Z)V", (void*)nProgramFragmentStoreDither }, -{"nProgramFragmentStoreCreate", "()I", (void*)nProgramFragmentStoreCreate }, +{"nProgramStoreBegin", "(II)V", (void*)nProgramStoreBegin }, +{"nProgramStoreDepthFunc", "(I)V", (void*)nProgramStoreDepthFunc }, +{"nProgramStoreDepthMask", "(Z)V", (void*)nProgramStoreDepthMask }, +{"nProgramStoreColorMask", "(ZZZZ)V", (void*)nProgramStoreColorMask }, +{"nProgramStoreBlendFunc", "(II)V", (void*)nProgramStoreBlendFunc }, +{"nProgramStoreDither", "(Z)V", (void*)nProgramStoreDither }, +{"nProgramStoreCreate", "()I", (void*)nProgramStoreCreate }, {"nProgramBindConstants", "(III)V", (void*)nProgramBindConstants }, {"nProgramBindTexture", "(III)V", (void*)nProgramBindTexture }, @@ -1450,9 +1618,9 @@ static JNINativeMethod methods[] = { {"nProgramFragmentCreate", "([I)I", (void*)nProgramFragmentCreate }, {"nProgramFragmentCreate2", "(Ljava/lang/String;[I)I", (void*)nProgramFragmentCreate2 }, -{"nProgramRasterCreate", "(IIZZZ)I", (void*)nProgramRasterCreate }, -{"nProgramRasterSetPointSize", "(IF)V", (void*)nProgramRasterSetPointSize }, +{"nProgramRasterCreate", "(ZZZ)I", (void*)nProgramRasterCreate }, {"nProgramRasterSetLineWidth", "(IF)V", (void*)nProgramRasterSetLineWidth }, +{"nProgramRasterSetCullMode", "(II)V", (void*)nProgramRasterSetCullMode }, {"nProgramVertexCreate", "(Z)I", (void*)nProgramVertexCreate }, {"nProgramVertexCreate2", "(Ljava/lang/String;[I)I", (void*)nProgramVertexCreate2 }, @@ -1465,7 +1633,7 @@ static JNINativeMethod methods[] = { {"nLightSetPosition", "(IFFF)V", (void*)nLightSetPosition }, {"nContextBindRootScript", "(I)V", (void*)nContextBindRootScript }, -{"nContextBindProgramFragmentStore","(I)V", (void*)nContextBindProgramFragmentStore }, +{"nContextBindProgramStore", "(I)V", (void*)nContextBindProgramStore }, {"nContextBindProgramFragment", "(I)V", (void*)nContextBindProgramFragment }, {"nContextBindProgramVertex", "(I)V", (void*)nContextBindProgramVertex }, {"nContextBindProgramRaster", "(I)V", (void*)nContextBindProgramRaster }, @@ -1474,9 +1642,14 @@ static JNINativeMethod methods[] = { {"nSamplerSet", "(II)V", (void*)nSamplerSet }, {"nSamplerCreate", "()I", (void*)nSamplerCreate }, -{"nSimpleMeshCreate", "(II[II)I", (void*)nSimpleMeshCreate }, -{"nSimpleMeshBindVertex", "(III)V", (void*)nSimpleMeshBindVertex }, -{"nSimpleMeshBindIndex", "(II)V", (void*)nSimpleMeshBindIndex }, +{"nMeshCreate", "(II)I", (void*)nMeshCreate }, +{"nMeshBindVertex", "(III)V", (void*)nMeshBindVertex }, +{"nMeshBindIndex", "(IIII)V", (void*)nMeshBindIndex }, + +{"nMeshGetVertexBufferCount", "(I)I", (void*)nMeshGetVertexBufferCount }, +{"nMeshGetIndexCount", "(I)I", (void*)nMeshGetIndexCount }, +{"nMeshGetVertices", "(I[II)V", (void*)nMeshGetVertices }, +{"nMeshGetIndices", "(I[I[II)V", (void*)nMeshGetIndices }, }; @@ -1510,3 +1683,4 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) bail: return result; } + |