Fix teardown bug found in books.
Change-Id: I9ac449b644108148b331e0c552f289bf80a07f7e
This commit is contained in:
@@ -47,7 +47,7 @@ ContextSetPriority {
|
||||
param int32_t priority
|
||||
}
|
||||
|
||||
ContextDestroy {
|
||||
ContextDestroyWorker {
|
||||
}
|
||||
|
||||
AssignName {
|
||||
|
||||
@@ -135,7 +135,6 @@ void Allocation::allocScriptMemory() {
|
||||
}
|
||||
|
||||
void Allocation::freeScriptMemory() {
|
||||
rsAssert(!(mUsageFlags & RS_ALLOCATION_USAGE_SCRIPT));
|
||||
if (mPtr) {
|
||||
free(mPtr);
|
||||
mPtr = NULL;
|
||||
|
||||
@@ -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,14 +1025,23 @@ void rsi_ContextDump(Context *rsc, int32_t bits) {
|
||||
ObjectBase::dumpAll(rsc);
|
||||
}
|
||||
|
||||
void rsi_ContextDestroy(Context *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);
|
||||
Device * dev = static_cast<Device *>(vdev);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)");
|
||||
|
||||
Reference in New Issue
Block a user