Delete the acc script when deleting the Renderscript rsScriptC object.
Previously we had been leaking the ACCscript object.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -288,7 +288,8 @@ ScriptCSetOrtho {
|
||||
}
|
||||
|
||||
ScriptCSetScript {
|
||||
param void * ptr
|
||||
param void * accScript
|
||||
param void * codePtr
|
||||
}
|
||||
|
||||
ScriptCCreate {
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user