diff options
author | Jason Sams <rjsams@android.com> | 2010-11-22 16:20:16 -0800 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2010-11-22 16:20:16 -0800 |
commit | add9d9633205f76cc34f04368b8482c2c369ba63 (patch) | |
tree | cc360ce8783627e98c05f764d99c70dc29cc5b87 /libs/rs/rsContext.cpp | |
parent | 83d97c8c7ddff9374f876bef48758414a7775cb1 (diff) | |
download | frameworks_base-add9d9633205f76cc34f04368b8482c2c369ba63.zip frameworks_base-add9d9633205f76cc34f04368b8482c2c369ba63.tar.gz frameworks_base-add9d9633205f76cc34f04368b8482c2c369ba63.tar.bz2 |
More error checks
Change-Id: Id2b9ab7a76bbdf2ed745f5e36e552dc9b101982f
Diffstat (limited to 'libs/rs/rsContext.cpp')
-rw-r--r-- | libs/rs/rsContext.cpp | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index 840a10e..35db332 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -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; -} - } } |