Loading graphics/java/android/renderscript/BaseObj.java +6 −1 Original line number Diff line number Diff line Loading @@ -60,8 +60,13 @@ class BaseObj { protected void finalize() throws Throwable { if (!mDestroyed) { if(mID != 0) { mRS.nObjDestroyOOB(mID); } mID = 0; mDestroyed = true; Log.v(RenderScript.LOG_TAG, getClass() + " finalized without having released the RS reference."); getClass() + " auto finalizing object without having released the RS reference."); } super.finalize(); } Loading graphics/java/android/renderscript/RenderScript.java +1 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ public class RenderScript { native void nAssignName(int obj, byte[] name); native void nObjDestroy(int id); native void nObjDestroyOOB(int id); native int nFileOpen(byte[] name); native void nElementBegin(); Loading graphics/jni/android_renderscript_RenderScript.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,15 @@ nObjDestroy(JNIEnv *_env, jobject _this, jint obj) rsObjDestroy(con, (void *)obj); } static void nObjDestroyOOB(JNIEnv *_env, jobject _this, jint obj) { // This function only differs from nObjDestroy in that it calls the // special Out Of Band version of ObjDestroy which is thread safe. RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); LOG_API("nObjDestroyOOB, con(%p) obj(%p)", con, (void *)obj); rsObjDestroyOOB(con, (void *)obj); } static jint nFileOpen(JNIEnv *_env, jobject _this, jbyteArray str) Loading Loading @@ -1217,6 +1226,7 @@ static JNINativeMethod methods[] = { {"nContextDestroy", "(I)V", (void*)nContextDestroy }, {"nAssignName", "(I[B)V", (void*)nAssignName }, {"nObjDestroy", "(I)V", (void*)nObjDestroy }, {"nObjDestroyOOB", "(I)V", (void*)nObjDestroyOOB }, {"nFileOpen", "([B)I", (void*)nFileOpen }, Loading libs/rs/RenderScript.h +1 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ void rsDeviceDestroy(RsDevice); RsContext rsContextCreate(RsDevice, void *, uint32_t version); void rsContextDestroy(RsContext); void rsObjDestroyOOB(RsContext, void *); #define RS_MAX_TEXTURE 2 Loading libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java +8 −10 Original line number Diff line number Diff line Loading @@ -67,8 +67,6 @@ public class FountainRS { private RenderScript mRS; private Allocation mIntAlloc; private Allocation mPartAlloc; private Script mScript; private SimpleMesh mSM; private SomeData mSD; private Type mSDType; Loading @@ -94,9 +92,9 @@ public class FountainRS { mSM = smb.create(); mSM.setName("PartMesh"); mPartAlloc = mSM.createVertexAllocation(vtxSlot); mPartAlloc.setName("PartBuffer"); mSM.bindVertexAllocation(mPartAlloc, 0); Allocation partAlloc = mSM.createVertexAllocation(vtxSlot); partAlloc.setName("PartBuffer"); mSM.bindVertexAllocation(partAlloc, 0); // All setup of named objects should be done by this point // because we are about to compile the script. Loading @@ -104,12 +102,12 @@ public class FountainRS { sb.setScript(mRes, R.raw.fountain); sb.setRoot(true); sb.setType(mSDType, "Control", 0); mScript = sb.create(); mScript.setClearColor(0.0f, 0.0f, 0.0f, 1.0f); Script script = sb.create(); script.setClearColor(0.0f, 0.0f, 0.0f, 1.0f); mScript.bindAllocation(mIntAlloc, 0); mScript.bindAllocation(mPartAlloc, 1); mRS.contextBindRootScript(mScript); script.bindAllocation(mIntAlloc, 0); script.bindAllocation(partAlloc, 1); mRS.contextBindRootScript(script); } } Loading Loading
graphics/java/android/renderscript/BaseObj.java +6 −1 Original line number Diff line number Diff line Loading @@ -60,8 +60,13 @@ class BaseObj { protected void finalize() throws Throwable { if (!mDestroyed) { if(mID != 0) { mRS.nObjDestroyOOB(mID); } mID = 0; mDestroyed = true; Log.v(RenderScript.LOG_TAG, getClass() + " finalized without having released the RS reference."); getClass() + " auto finalizing object without having released the RS reference."); } super.finalize(); } Loading
graphics/java/android/renderscript/RenderScript.java +1 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ public class RenderScript { native void nAssignName(int obj, byte[] name); native void nObjDestroy(int id); native void nObjDestroyOOB(int id); native int nFileOpen(byte[] name); native void nElementBegin(); Loading
graphics/jni/android_renderscript_RenderScript.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,15 @@ nObjDestroy(JNIEnv *_env, jobject _this, jint obj) rsObjDestroy(con, (void *)obj); } static void nObjDestroyOOB(JNIEnv *_env, jobject _this, jint obj) { // This function only differs from nObjDestroy in that it calls the // special Out Of Band version of ObjDestroy which is thread safe. RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); LOG_API("nObjDestroyOOB, con(%p) obj(%p)", con, (void *)obj); rsObjDestroyOOB(con, (void *)obj); } static jint nFileOpen(JNIEnv *_env, jobject _this, jbyteArray str) Loading Loading @@ -1217,6 +1226,7 @@ static JNINativeMethod methods[] = { {"nContextDestroy", "(I)V", (void*)nContextDestroy }, {"nAssignName", "(I[B)V", (void*)nAssignName }, {"nObjDestroy", "(I)V", (void*)nObjDestroy }, {"nObjDestroyOOB", "(I)V", (void*)nObjDestroyOOB }, {"nFileOpen", "([B)I", (void*)nFileOpen }, Loading
libs/rs/RenderScript.h +1 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ void rsDeviceDestroy(RsDevice); RsContext rsContextCreate(RsDevice, void *, uint32_t version); void rsContextDestroy(RsContext); void rsObjDestroyOOB(RsContext, void *); #define RS_MAX_TEXTURE 2 Loading
libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java +8 −10 Original line number Diff line number Diff line Loading @@ -67,8 +67,6 @@ public class FountainRS { private RenderScript mRS; private Allocation mIntAlloc; private Allocation mPartAlloc; private Script mScript; private SimpleMesh mSM; private SomeData mSD; private Type mSDType; Loading @@ -94,9 +92,9 @@ public class FountainRS { mSM = smb.create(); mSM.setName("PartMesh"); mPartAlloc = mSM.createVertexAllocation(vtxSlot); mPartAlloc.setName("PartBuffer"); mSM.bindVertexAllocation(mPartAlloc, 0); Allocation partAlloc = mSM.createVertexAllocation(vtxSlot); partAlloc.setName("PartBuffer"); mSM.bindVertexAllocation(partAlloc, 0); // All setup of named objects should be done by this point // because we are about to compile the script. Loading @@ -104,12 +102,12 @@ public class FountainRS { sb.setScript(mRes, R.raw.fountain); sb.setRoot(true); sb.setType(mSDType, "Control", 0); mScript = sb.create(); mScript.setClearColor(0.0f, 0.0f, 0.0f, 1.0f); Script script = sb.create(); script.setClearColor(0.0f, 0.0f, 0.0f, 1.0f); mScript.bindAllocation(mIntAlloc, 0); mScript.bindAllocation(mPartAlloc, 1); mRS.contextBindRootScript(mScript); script.bindAllocation(mIntAlloc, 0); script.bindAllocation(partAlloc, 1); mRS.contextBindRootScript(script); } } Loading