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

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

Merge "More error checks"

parents 077b6ed3 add9d963
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -685,6 +685,8 @@ public class RenderScript {
        public static final int RS_MESSAGE_TO_CLIENT_ERROR = 3;
        public static final int RS_MESSAGE_TO_CLIENT_USER = 4;

        public static final int RS_ERROR_FATAL_UNKNOWN = 0x1000;

        MessageThread(RenderScript rs) {
            super("RSMessageThread");
            mRS = rs;
@@ -722,6 +724,10 @@ public class RenderScript {
                if (msg == RS_MESSAGE_TO_CLIENT_ERROR) {
                    String e = mRS.nContextGetErrorMessage(mRS.mContext);

                    if (subID >= RS_ERROR_FATAL_UNKNOWN) {
                        throw new RSRuntimeException("Fatal error " + subID + ", details: " + e);
                    }

                    if(mRS.mErrorCallback != null) {
                        mRS.mErrorCallback.mErrorMessage = e;
                        mRS.mErrorCallback.mErrorNum = subID;
+10 −5
Original line number Diff line number Diff line
@@ -236,11 +236,16 @@ enum RsPrimitive {
};

enum RsError {
    RS_ERROR_NONE,
    RS_ERROR_BAD_SHADER,
    RS_ERROR_BAD_SCRIPT,
    RS_ERROR_BAD_VALUE,
    RS_ERROR_OUT_OF_MEMORY
    RS_ERROR_NONE = 0,
    RS_ERROR_BAD_SHADER = 1,
    RS_ERROR_BAD_SCRIPT = 2,
    RS_ERROR_BAD_VALUE = 3,
    RS_ERROR_OUT_OF_MEMORY = 4,
    RS_ERROR_DRIVER = 5,

    RS_ERROR_FATAL_UNKNOWN = 0x1000,
    RS_ERROR_FATAL_DRIVER = 0x1001,
    RS_ERROR_FATAL_PROGRAM_LINK = 0x1002
};

enum RsAnimationInterpolation {
+0 −5
Original line number Diff line number Diff line
@@ -43,11 +43,6 @@ ContextDump {
	param int32_t bits
}

ContextGetError {
	param RsError *err
	ret const char *
	}

ContextSetPriority {
	param int32_t priority
	}
+22 −23
Original line number Diff line number Diff line
@@ -287,10 +287,27 @@ uint32_t Context::runScript(Script *s) {
    return ret;
}

void Context::checkError(const char *msg) const {
void Context::checkError(const char *msg, bool isFatal) const {

    GLenum err = glGetError();
    if (err != GL_NO_ERROR) {
        LOGE("%p, GL Error, 0x%x, from %s", this, err, msg);
        char buf[1024];
        snprintf(buf, sizeof(buf), "GL Error = 0x%08x, from: %s", err, msg);

        if (isFatal) {
            setError(RS_ERROR_FATAL_DRIVER, buf);
        } else {
            switch (err) {
            case GL_OUT_OF_MEMORY:
                setError(RS_ERROR_OUT_OF_MEMORY, buf);
                break;
            default:
                setError(RS_ERROR_DRIVER, buf);
                break;
            }
        }

        LOGE("%p, %s", this, buf);
    }
}

@@ -597,7 +614,6 @@ Context::Context() {
    mPaused = false;
    mObjHead = NULL;
    mError = RS_ERROR_NONE;
    mErrorMsg = NULL;
}

Context * Context::createContext(Device *dev, const RsSurfaceConfig *sc) {
@@ -861,7 +877,8 @@ RsMessageToClientType Context::getMessageToClient(void *data, size_t *receiveLen
    return RS_MESSAGE_TO_CLIENT_RESIZE;
}

bool Context::sendMessageToClient(const void *data, RsMessageToClientType cmdID, uint32_t subID, size_t len, bool waitForSpace) {
bool Context::sendMessageToClient(const void *data, RsMessageToClientType cmdID,
                                  uint32_t subID, size_t len, bool waitForSpace) const {
    //LOGE("sendMessageToClient %i %i %i %i", cmdID, subID, len, waitForSpace);
    if (cmdID == 0) {
        LOGE("Attempting to send invalid command 0 to client.");
@@ -894,18 +911,8 @@ void Context::deinitToClient() {
    mIO.mToClient.shutdown();
}

const char * Context::getError(RsError *err) {
    *err = mError;
    mError = RS_ERROR_NONE;
    if (*err != RS_ERROR_NONE) {
        return mErrorMsg;
    }
    return NULL;
}

void Context::setError(RsError e, const char *msg) {
void Context::setError(RsError e, const char *msg) const {
    mError = e;
    mErrorMsg = msg;
    sendMessageToClient(msg, RS_MESSAGE_TO_CLIENT_ERROR, e, strlen(msg) + 1, true);
}

@@ -1012,14 +1019,6 @@ void rsi_ContextDump(Context *rsc, int32_t bits) {
    ObjectBase::dumpAll(rsc);
}

const char* rsi_ContextGetError(Context *rsc, RsError *e) {
    const char *msg = rsc->getError(e);
    if (*e != RS_ERROR_NONE) {
        LOGE("RS Error %i %s", *e, msg);
    }
    return msg;
}

}
}

+5 −7
Original line number Diff line number Diff line
@@ -144,7 +144,7 @@ public:

    RsMessageToClientType peekMessageToClient(size_t *receiveLen, uint32_t *subID, bool wait);
    RsMessageToClientType getMessageToClient(void *data, size_t *receiveLen, uint32_t *subID, size_t bufferLen, bool wait);
    bool sendMessageToClient(const void *data, RsMessageToClientType cmdID, uint32_t subID, size_t len, bool waitForSpace);
    bool sendMessageToClient(const void *data, RsMessageToClientType cmdID, uint32_t subID, size_t len, bool waitForSpace) const;
    uint32_t runScript(Script *s);

    void initToClient();
@@ -169,7 +169,7 @@ public:
    uint32_t getWidth() const {return mWidth;}
    uint32_t getHeight() const {return mHeight;}

    ThreadIO mIO;
    mutable ThreadIO mIO;

    // Timers
    enum Timers {
@@ -197,9 +197,8 @@ public:
    } props;

    void dumpDebug() const;
    void checkError(const char *) const;
    const char * getError(RsError *);
    void setError(RsError e, const char *msg = NULL);
    void checkError(const char *, bool isFatal = false) const;
    void setError(RsError e, const char *msg = NULL) const;

    mutable const ObjectBase * mObjHead;

@@ -259,8 +258,7 @@ protected:
    bool mRunning;
    bool mExit;
    bool mPaused;
    RsError mError;
    const char *mErrorMsg;
    mutable RsError mError;

    pthread_t mThreadId;
    pid_t mNativeThreadId;
Loading