diff options
| author | 2010-12-24 14:38:39 -0800 | |
|---|---|---|
| committer | 2010-12-24 14:42:54 -0800 | |
| commit | 5c68a712dacf8cf0a419f1b743474a3b4290d024 (patch) | |
| tree | 92653c54d1666735087415086c3215abc62016aa | |
| parent | bccc78ffa57cb259010c25630055eef95c0e0c2c (diff) | |
Fix teardown bug found in books.
Change-Id: I9ac449b644108148b331e0c552f289bf80a07f7e
| -rw-r--r-- | libs/rs/rs.spec | 2 | ||||
| -rw-r--r-- | libs/rs/rsAllocation.cpp | 1 | ||||
| -rw-r--r-- | libs/rs/rsContext.cpp | 47 | ||||
| -rw-r--r-- | libs/rs/rsContext.h | 1 | ||||
| -rw-r--r-- | libs/rs/rsScriptC.cpp | 4 |
5 files changed, 35 insertions, 20 deletions
diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec index 021ff92cf7fd..a5810d4e0746 100644 --- a/libs/rs/rs.spec +++ b/libs/rs/rs.spec @@ -47,7 +47,7 @@ ContextSetPriority { param int32_t priority } -ContextDestroy { +ContextDestroyWorker { } AssignName { diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp index 77e80320b372..ec1f684467ef 100644 --- a/libs/rs/rsAllocation.cpp +++ b/libs/rs/rsAllocation.cpp @@ -135,7 +135,6 @@ void Allocation::allocScriptMemory() { } void Allocation::freeScriptMemory() { - rsAssert(!(mUsageFlags & RS_ALLOCATION_USAGE_SCRIPT)); if (mPtr) { free(mPtr); mPtr = NULL; diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index 2988950d532a..22c73fec491c 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -509,20 +509,6 @@ void * Context::threadProc(void *vrsc) { } LOGV("%p, RS Thread exiting", rsc); - if (rsc->mIsGraphicsContext) { - rsc->mRaster.clear(); - rsc->mFragment.clear(); - rsc->mVertex.clear(); - rsc->mFragmentStore.clear(); - rsc->mFont.clear(); - rsc->mRootScript.clear(); - rsc->mStateRaster.deinit(rsc); - rsc->mStateVertex.deinit(rsc); - rsc->mStateFragment.deinit(rsc); - rsc->mStateFragmentStore.deinit(rsc); - rsc->mStateFont.deinit(rsc); - } - ObjectBase::zeroAllUserRef(rsc); if (rsc->mIsGraphicsContext) { pthread_mutex_lock(&gInitMutex); @@ -535,6 +521,25 @@ void * Context::threadProc(void *vrsc) { return NULL; } +void Context::destroyWorkerThreadResources() { + LOGV("destroyWorkerThreadResources 1"); + if (mIsGraphicsContext) { + mRaster.clear(); + mFragment.clear(); + mVertex.clear(); + mFragmentStore.clear(); + mFont.clear(); + mRootScript.clear(); + mStateRaster.deinit(this); + mStateVertex.deinit(this); + mStateFragment.deinit(this); + mStateFragmentStore.deinit(this); + mStateFont.deinit(this); + } + ObjectBase::zeroAllUserRef(this); + LOGV("destroyWorkerThreadResources 2"); +} + void * Context::helperThreadProc(void *vrsc) { Context *rsc = static_cast<Context *>(vrsc); uint32_t idx = (uint32_t)android_atomic_inc(&rsc->mWorkers.mLaunchCount); @@ -725,6 +730,7 @@ Context::~Context() { mDev = NULL; } pthread_mutex_unlock(&gInitMutex); + LOGV("Context::~Context done"); } void Context::setSurface(uint32_t w, uint32_t h, ANativeWindow *sur) { @@ -1019,13 +1025,22 @@ void rsi_ContextDump(Context *rsc, int32_t bits) { ObjectBase::dumpAll(rsc); } -void rsi_ContextDestroy(Context *rsc) { - delete rsc; +void rsi_ContextDestroyWorker(Context *rsc) { + LOGE("rsi_ContextDestroyWorker 1"); + rsc->destroyWorkerThreadResources();; + LOGE("rsi_ContextDestroyWorker 2"); } } } +void rsContextDestroy(RsContext vcon) { + LOGV("rsContextDestroy %p", vcon); + Context *rsc = static_cast<Context *>(vcon); + rsContextDestroyWorker(rsc); + delete rsc; + LOGV("rsContextDestroy 2 %p", vcon); +} RsContext rsContextCreate(RsDevice vdev, uint32_t version) { LOGV("rsContextCreate %p", vdev); diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h index 49ee676b8442..3c402c42ea5a 100644 --- a/libs/rs/rsContext.h +++ b/libs/rs/rsContext.h @@ -137,6 +137,7 @@ public: void resume(); void setSurface(uint32_t w, uint32_t h, ANativeWindow *sur); void setPriority(int32_t p); + void destroyWorkerThreadResources(); void assignName(ObjectBase *obj, const char *name, uint32_t len); void removeName(ObjectBase *obj); diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp index 64eb7d269c27..ef06033bf56a 100644 --- a/libs/rs/rsScriptC.cpp +++ b/libs/rs/rsScriptC.cpp @@ -37,13 +37,13 @@ using namespace android::renderscript; ScriptC::ScriptC(Context *rsc) : Script(rsc) { - LOGD(">>>> ScriptC ctor called, obj=%x", this); + LOGD(">>>> ScriptC ctor called, obj=%p", this); mBccScript = NULL; memset(&mProgram, 0, sizeof(mProgram)); } ScriptC::~ScriptC() { - LOGD(">>>> ~ScriptC()"); + LOGD(">>>> ~ScriptC() mBccScript = %p", mBccScript); if (mBccScript) { bccDeleteScript(mBccScript); LOGD(">>>> ~ScriptC(mBCCScript)"); |