diff options
| author | Jack Palevich <jackpal@google.com> | 2009-05-28 15:53:04 -0700 |
|---|---|---|
| committer | Jack Palevich <jackpal@google.com> | 2009-05-28 15:53:04 -0700 |
| commit | ec5a20bf2b9f563f9f6a4bde4d8cbbe13598fd25 (patch) | |
| tree | 7a49a0bb4499496085cae228d92e4725e4f93143 /libs/rs | |
| parent | 63975dde40e4ee8fd08225741b31d54eff115104 (diff) | |
| download | frameworks_base-ec5a20bf2b9f563f9f6a4bde4d8cbbe13598fd25.zip frameworks_base-ec5a20bf2b9f563f9f6a4bde4d8cbbe13598fd25.tar.gz frameworks_base-ec5a20bf2b9f563f9f6a4bde4d8cbbe13598fd25.tar.bz2 | |
Delete the acc script when deleting the Renderscript rsScriptC object.
Previously we had been leaking the ACCscript object.
Diffstat (limited to 'libs/rs')
| -rw-r--r-- | libs/rs/Android.mk | 2 | ||||
| -rw-r--r-- | libs/rs/jni/RenderScript_jni.cpp | 11 | ||||
| -rw-r--r-- | libs/rs/rs.spec | 3 | ||||
| -rw-r--r-- | libs/rs/rsScriptC.cpp | 15 | ||||
| -rw-r--r-- | libs/rs/rsScriptC.h | 9 |
5 files changed, 30 insertions, 10 deletions
diff --git a/libs/rs/Android.mk b/libs/rs/Android.mk index 7ae5709..979c441 100644 --- a/libs/rs/Android.mk +++ b/libs/rs/Android.mk @@ -94,7 +94,7 @@ LOCAL_SRC_FILES:= \ rsType.cpp \ rsTriangleMesh.cpp -LOCAL_SHARED_LIBRARIES += libcutils libutils libEGL libGLESv1_CM libui +LOCAL_SHARED_LIBRARIES += libcutils libutils libEGL libGLESv1_CM libui libacc LOCAL_LDLIBS := -lpthread -ldl LOCAL_MODULE:= libRS diff --git a/libs/rs/jni/RenderScript_jni.cpp b/libs/rs/jni/RenderScript_jni.cpp index 56b4e88..50849af 100644 --- a/libs/rs/jni/RenderScript_jni.cpp +++ b/libs/rs/jni/RenderScript_jni.cpp @@ -533,6 +533,7 @@ nScriptCSetScript(JNIEnv *_env, jobject _this, jbyteArray scriptRef, jint remaining; jbyte* script_base = 0; jbyte* script_ptr; + ACCscript* script = 0; void* scriptEntry = 0; if (!scriptRef) { _exception = 1; @@ -560,19 +561,21 @@ nScriptCSetScript(JNIEnv *_env, jobject _this, jbyteArray scriptRef, script_ptr = script_base + offset; { - ACCscript* script = accCreateScript(); + script = accCreateScript(); const char* scriptSource[] = {(const char*) script_ptr}; int scriptLength[] = {length} ; accScriptSource(script, 1, scriptSource, scriptLength); accCompileScript(script); accGetScriptLabel(script, "main", (ACCvoid**) &scriptEntry); - // TBD: We currently leak the script object. We can't delete it until - // we are done with the scriptEntry. } if (scriptEntry) { - rsScriptCSetScript((void *)scriptEntry); + rsScriptCSetScript((void*) script, (void *)scriptEntry); + script = 0; } exit: + if (script) { + accDeleteScript(script); + } if (script_base) { _env->ReleasePrimitiveArrayCritical(scriptRef, script_base, _exception ? JNI_ABORT: 0); diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec index 65a4a82..98c7008 100644 --- a/libs/rs/rs.spec +++ b/libs/rs/rs.spec @@ -288,7 +288,8 @@ ScriptCSetOrtho { } ScriptCSetScript { - param void * ptr + param void * accScript + param void * codePtr } ScriptCCreate { diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp index 60339ec..2c7d884 100644 --- a/libs/rs/rsScriptC.cpp +++ b/libs/rs/rsScriptC.cpp @@ -18,17 +18,23 @@ #include "rsScriptC.h" #include "rsMatrix.h" +#include "acc/acc.h" + using namespace android; using namespace android::renderscript; ScriptC::ScriptC() { + mAccScript = NULL; mScript = NULL; } ScriptC::~ScriptC() { + if (mAccScript) { + accDeleteScript(mAccScript); + } } extern "C" void matrixLoadIdentity(void *con, rsc_Matrix *mat) @@ -394,6 +400,9 @@ ScriptCState::ScriptCState() ScriptCState::~ScriptCState() { + if (mAccScript) { + accDeleteScript(mAccScript); + } } void ScriptCState::clear() @@ -405,6 +414,7 @@ void ScriptCState::clear() mClearColor[3] = 1; mClearDepth = 1; mClearStencil = 0; + mAccScript = NULL; mScript = NULL; mIsRoot = false; mIsOrtho = true; @@ -446,9 +456,10 @@ void rsi_ScriptCAddType(Context * rsc, RsType vt) ss->mConstantBufferTypes.add(static_cast<const Type *>(vt)); } -void rsi_ScriptCSetScript(Context * rsc, void *vp) +void rsi_ScriptCSetScript(Context * rsc, void* accScript, void *vp) { ScriptCState *ss = &rsc->mScriptC; + ss->mAccScript = reinterpret_cast<ACCscript*>(accScript); ss->mScript = reinterpret_cast<rsc_RunScript>(vp); } @@ -469,6 +480,8 @@ RsScript rsi_ScriptCCreate(Context * rsc) ScriptCState *ss = &rsc->mScriptC; ScriptC *s = new ScriptC(); + s->mAccScript = ss->mAccScript; + ss->mAccScript = NULL; s->mScript = ss->mScript; s->mClearColor[0] = ss->mClearColor[0]; s->mClearColor[1] = ss->mClearColor[1]; diff --git a/libs/rs/rsScriptC.h b/libs/rs/rsScriptC.h index f35a130..c58dcf9 100644 --- a/libs/rs/rsScriptC.h +++ b/libs/rs/rsScriptC.h @@ -21,11 +21,13 @@ #include "RenderScriptEnv.h" +struct ACCscript; + // --------------------------------------------------------------------------- namespace android { namespace renderscript { - + class ScriptC : public Script { @@ -38,6 +40,7 @@ public: virtual void run(Context *, uint32_t launchID); + ACCscript* mAccScript; rsc_RunScript mScript; @@ -48,13 +51,13 @@ public: }; -class ScriptCState +class ScriptCState { public: ScriptCState(); ~ScriptCState(); - + ACCscript* mAccScript; rsc_RunScript mScript; float mClearColor[4]; float mClearDepth; |
