diff options
Diffstat (limited to 'cpp/RenderScript.cpp')
| -rw-r--r-- | cpp/RenderScript.cpp | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/cpp/RenderScript.cpp b/cpp/RenderScript.cpp index 889f27b5..3160b4d6 100644 --- a/cpp/RenderScript.cpp +++ b/cpp/RenderScript.cpp @@ -19,6 +19,7 @@ #include <utils/Log.h> #include <malloc.h> #include <string.h> +#include <pthread.h> #include "RenderScript.h" #include "rs.h" @@ -26,10 +27,10 @@ using namespace android; using namespace renderscriptCpp; -bool RenderScript::gInitialized = false; -pthread_mutex_t RenderScript::gInitMutex = PTHREAD_MUTEX_INITIALIZER; +bool RS::gInitialized = false; +pthread_mutex_t RS::gInitMutex = PTHREAD_MUTEX_INITIALIZER; -RenderScript::RenderScript() { +RS::RS() { mDev = NULL; mContext = NULL; mErrorFunc = NULL; @@ -39,7 +40,7 @@ RenderScript::RenderScript() { memset(&mElements, 0, sizeof(mElements)); } -RenderScript::~RenderScript() { +RS::~RS() { mMessageRun = false; rsContextDeinitToClient(mContext); @@ -53,7 +54,11 @@ RenderScript::~RenderScript() { mDev = NULL; } -bool RenderScript::init(int targetApi) { +bool RS::init() { + return RS::init(RS_VERSION); +} + +bool RS::init(int targetApi) { mDev = rsDeviceCreate(); if (mDev == 0) { ALOGE("Device creation failed"); @@ -66,12 +71,11 @@ bool RenderScript::init(int targetApi) { return false; } - pid_t mNativeMessageThreadId; int status = pthread_create(&mMessageThreadId, NULL, threadProc, this); if (status) { - ALOGE("Failed to start RenderScript message thread."); + ALOGE("Failed to start RS message thread."); return false; } // Wait for the message thread to be active. @@ -82,15 +86,15 @@ bool RenderScript::init(int targetApi) { return true; } -void RenderScript::throwError(const char *err) const { +void RS::throwError(const char *err) const { ALOGE("RS CPP error: %s", err); int * v = NULL; v[0] = 0; } -void * RenderScript::threadProc(void *vrsc) { - RenderScript *rs = static_cast<RenderScript *>(vrsc); +void * RS::threadProc(void *vrsc) { + RS *rs = static_cast<RS *>(vrsc); size_t rbuf_size = 256; void * rbuf = malloc(rbuf_size); @@ -110,7 +114,7 @@ void * RenderScript::threadProc(void *vrsc) { rbuf = realloc(rbuf, rbuf_size); } if (!rbuf) { - ALOGE("RenderScript::message handler realloc error %zu", rbuf_size); + ALOGE("RS::message handler realloc error %zu", rbuf_size); // No clean way to recover now? } rsContextGetMessage(rs->mContext, rbuf, rbuf_size, &receiveLen, sizeof(receiveLen), @@ -139,30 +143,21 @@ void * RenderScript::threadProc(void *vrsc) { break; default: - ALOGE("RenderScript unknown message type %i", r); + ALOGE("RS unknown message type %i", r); } } if (rbuf) { free(rbuf); } - ALOGE("RenderScript Message thread exiting."); + ALOGE("RS Message thread exiting."); return NULL; } -void RenderScript::setErrorHandler(ErrorHandlerFunc_t func) { +void RS::setErrorHandler(ErrorHandlerFunc_t func) { mErrorFunc = func; } -void RenderScript::setMessageHandler(MessageHandlerFunc_t func) { +void RS::setMessageHandler(MessageHandlerFunc_t func) { mMessageFunc = func; } - -void RenderScript::contextDump() { -} - -void RenderScript::finish() { - -} - - |
