From d78be37d81f6c1aba75180c7608753a027a881ee Mon Sep 17 00:00:00 2001 From: Jason Sams Date: Tue, 17 Aug 2010 19:28:29 -0700 Subject: [PATCH] Remove OOB object destruction. Change-Id: Icaa06aca4a701ec663c124d3141d9dbb633d7dc1 --- .../java/android/renderscript/BaseObj.java | 2 +- .../android/renderscript/RenderScript.java | 4 -- .../jni/android_renderscript_RenderScript.cpp | 9 --- libs/rs/RenderScript.h | 1 - libs/rs/rsContext.cpp | 60 ------------------- libs/rs/rsContext.h | 11 ---- 6 files changed, 1 insertion(+), 86 deletions(-) diff --git a/graphics/java/android/renderscript/BaseObj.java b/graphics/java/android/renderscript/BaseObj.java index 5dce18f49b1a9..3198e3fdb2295 100644 --- a/graphics/java/android/renderscript/BaseObj.java +++ b/graphics/java/android/renderscript/BaseObj.java @@ -62,7 +62,7 @@ class BaseObj { { if (!mDestroyed) { if(mID != 0 && mRS.isAlive()) { - mRS.nObjDestroyOOB(mID); + mRS.nObjDestroy(mID); } mRS = null; mID = 0; diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index e42f9f66ee9fc..d82e5242dccb4 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -143,10 +143,6 @@ public class RenderScript { synchronized void nObjDestroy(int id) { rsnObjDestroy(mContext, id); } - native void rsnObjDestroyOOB(int con, int id); - synchronized void nObjDestroyOOB(int id) { - rsnObjDestroyOOB(mContext, id); - } native int rsnFileOpen(int con, byte[] name); synchronized int nFileOpen(byte[] name) { return rsnFileOpen(mContext, name); diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index 3b85fddb37766..3624678fd7ad6 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -117,14 +117,6 @@ nObjDestroy(JNIEnv *_env, jobject _this, RsContext con, jint obj) rsObjDestroy(con, (void *)obj); } -static void -nObjDestroyOOB(JNIEnv *_env, jobject _this, RsContext con, jint obj) -{ - // This function only differs from nObjDestroy in that it calls the - // special Out Of Band version of ObjDestroy which is thread safe. - LOG_API("nObjDestroyOOB, con(%p) obj(%p)", con, (void *)obj); - rsObjDestroyOOB(con, (void *)obj); -} static jint nFileOpen(JNIEnv *_env, jobject _this, RsContext con, jbyteArray str) @@ -1377,7 +1369,6 @@ static JNINativeMethod methods[] = { {"rsnAssignName", "(II[B)V", (void*)nAssignName }, {"rsnGetName", "(II)Ljava/lang/String;", (void*)nGetName }, {"rsnObjDestroy", "(II)V", (void*)nObjDestroy }, -{"rsnObjDestroyOOB", "(II)V", (void*)nObjDestroyOOB }, {"rsnFileOpen", "(I[B)I", (void*)nFileOpen }, {"rsnFileA3DCreateFromAssetStream", "(II)I", (void*)nFileA3DCreateFromAssetStream }, diff --git a/libs/rs/RenderScript.h b/libs/rs/RenderScript.h index 6636fef57d359..3406287f2789a 100644 --- a/libs/rs/RenderScript.h +++ b/libs/rs/RenderScript.h @@ -63,7 +63,6 @@ void rsDeviceSetConfig(RsDevice, RsDeviceParam, int32_t value); RsContext rsContextCreate(RsDevice, uint32_t version); RsContext rsContextCreateGL(RsDevice, uint32_t version, bool useDepth); void rsContextDestroy(RsContext); -void rsObjDestroyOOB(RsContext, void *); uint32_t rsContextGetMessage(RsContext, void *data, size_t *receiveLen, size_t bufferLen, bool wait); void rsContextInitToClient(RsContext); diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index 2a94651fb13f0..1a7c5ad69afa5 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -340,9 +340,6 @@ void * Context::threadProc(void *vrsc) rsc->timerPrint(); rsc->timerReset(); } - if (rsc->mObjDestroy.mNeedToEmpty) { - rsc->objDestroyOOBRun(); - } if (rsc->mThreadPriority > 0 && targetTime) { int32_t t = (targetTime - (int32_t)(rsc->mTimeMSLastScript + rsc->mTimeMSLastSwap)) * 1000; if (t > 0) { @@ -367,9 +364,6 @@ void * Context::threadProc(void *vrsc) } ObjectBase::zeroAllUserRef(rsc); - rsc->mObjDestroy.mNeedToEmpty = true; - rsc->objDestroyOOBRun(); - if (rsc->mIsGraphicsContext) { pthread_mutex_lock(&gInitMutex); rsc->deinitEGL(); @@ -488,7 +482,6 @@ Context::Context(Device *dev, bool isGraphics, bool useDepth) mWndSurface = NULL; - objDestroyOOBInit(); timerInit(); timerSet(RS_TIMER_INTERNAL); @@ -534,8 +527,6 @@ Context::~Context() mIO.shutdown(); int status = pthread_join(mThreadId, &res); - mObjDestroy.mNeedToEmpty = true; - objDestroyOOBRun(); // Global structure cleanup. pthread_mutex_lock(&gInitMutex); @@ -548,8 +539,6 @@ Context::~Context() mDev = NULL; } pthread_mutex_unlock(&gInitMutex); - - objDestroyOOBDestroy(); } void Context::setSurface(uint32_t w, uint32_t h, ANativeWindow *sur) @@ -721,49 +710,6 @@ void Context::removeName(ObjectBase *obj) } } -bool Context::objDestroyOOBInit() -{ - if (!mObjDestroy.mMutex.init()) { - LOGE("Context::ObjDestroyOOBInit mutex init failure"); - return false; - } - return true; -} - -void Context::objDestroyOOBRun() -{ - if (mObjDestroy.mNeedToEmpty) { - if (!mObjDestroy.mMutex.lock()) { - LOGE("Context::ObjDestroyOOBRun: error locking for OOBRun."); - return; - } - - for (size_t ct = 0; ct < mObjDestroy.mDestroyList.size(); ct++) { - mObjDestroy.mDestroyList[ct]->decUserRef(); - } - mObjDestroy.mDestroyList.clear(); - mObjDestroy.mNeedToEmpty = false; - mObjDestroy.mMutex.unlock(); - } -} - -void Context::objDestroyOOBDestroy() -{ - rsAssert(!mObjDestroy.mNeedToEmpty); -} - -void Context::objDestroyAdd(ObjectBase *obj) -{ - if (!mObjDestroy.mMutex.lock()) { - LOGE("Context::ObjDestroyOOBRun: error locking for OOBRun."); - return; - } - - mObjDestroy.mNeedToEmpty = true; - mObjDestroy.mDestroyList.add(obj); - mObjDestroy.mMutex.unlock(); -} - uint32_t Context::getMessageToClient(void *data, size_t *receiveLen, size_t bufferLen, bool wait) { //LOGE("getMessageToClient %i %i", bufferLen, wait); @@ -1003,12 +949,6 @@ void rsContextDestroy(RsContext vrsc) delete rsc; } -void rsObjDestroyOOB(RsContext vrsc, void *obj) -{ - Context * rsc = static_cast(vrsc); - rsc->objDestroyAdd(static_cast(obj)); -} - uint32_t rsContextGetMessage(RsContext vrsc, void *data, size_t *receiveLen, size_t bufferLen, bool wait) { Context * rsc = static_cast(vrsc); diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h index 2da3ab5133fbf..6d1a41d342c22 100644 --- a/libs/rs/rsContext.h +++ b/libs/rs/rsContext.h @@ -137,7 +137,6 @@ public: ThreadIO mIO; - void objDestroyAdd(ObjectBase *); // Timers enum Timers { @@ -248,16 +247,6 @@ protected: ObjectBaseRef mRaster; ObjectBaseRef mFont; - struct ObjDestroyOOB { - Mutex mMutex; - Vector mDestroyList; - bool mNeedToEmpty; - }; - ObjDestroyOOB mObjDestroy; - bool objDestroyOOBInit(); - void objDestroyOOBRun(); - void objDestroyOOBDestroy(); - void displayDebugStats(); private: