Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2ea56efb authored by Jason Sams's avatar Jason Sams Committed by Android (Google) Code Review
Browse files

Merge "Remove OOB object destruction."

parents 2aed7761 d78be37d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ class BaseObj {
    {
        if (!mDestroyed) {
            if(mID != 0 && mRS.isAlive()) {
                mRS.nObjDestroyOOB(mID);
                mRS.nObjDestroy(mID);
            }
            mRS = null;
            mID = 0;
+0 −4
Original line number Diff line number Diff line
@@ -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);
+0 −9
Original line number Diff line number Diff line
@@ -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 },
+0 −1
Original line number Diff line number Diff line
@@ -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);
+0 −60
Original line number Diff line number Diff line
@@ -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<Context *>(vrsc);
    rsc->objDestroyAdd(static_cast<ObjectBase *>(obj));
}

uint32_t rsContextGetMessage(RsContext vrsc, void *data, size_t *receiveLen, size_t bufferLen, bool wait)
{
    Context * rsc = static_cast<Context *>(vrsc);
Loading