diff options
| author | Jason Sams <rjsams@android.com> | 2010-05-19 17:22:57 -0700 |
|---|---|---|
| committer | Jason Sams <rjsams@android.com> | 2010-05-19 17:23:08 -0700 |
| commit | d79b2e9f8b0fa43f6734aaa5e9d0d389d5da5109 (patch) | |
| tree | e2eb06363ce3d83f447bac87e385835a4314d7ac /libs/rs/rsScriptC.cpp | |
| parent | d52498a64ff0bef28cd48ed28acd84a680a1d9b5 (diff) | |
| download | frameworks_base-d79b2e9f8b0fa43f6734aaa5e9d0d389d5da5109.zip frameworks_base-d79b2e9f8b0fa43f6734aaa5e9d0d389d5da5109.tar.gz frameworks_base-d79b2e9f8b0fa43f6734aaa5e9d0d389d5da5109.tar.bz2 | |
Begin naming cleanup for renderscript runtime.
Prefix functions with "rs" or "rsg".
Change-Id: I4435b486831bfab1ea473ccfad435b404e68f1c9
Diffstat (limited to 'libs/rs/rsScriptC.cpp')
| -rw-r--r-- | libs/rs/rsScriptC.cpp | 63 |
1 files changed, 57 insertions, 6 deletions
diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp index 1cf8f97..3217e64 100644 --- a/libs/rs/rsScriptC.cpp +++ b/libs/rs/rsScriptC.cpp @@ -87,6 +87,21 @@ const Allocation *ScriptC::ptrToAllocation(const void *ptr) const return NULL; } +void ScriptC::setTLS() +{ + Context::ScriptTLSStruct * tls = (Context::ScriptTLSStruct *) + pthread_getspecific(Context::gThreadTLSKey); + rsAssert(tls); + tls->mScript = this; +} + +void ScriptC::clearTLS() +{ + Context::ScriptTLSStruct * tls = (Context::ScriptTLSStruct *) + pthread_getspecific(Context::gThreadTLSKey); + rsAssert(tls); + tls->mScript = NULL; +} uint32_t ScriptC::run(Context *rsc, uint32_t launchIndex) { @@ -95,10 +110,6 @@ uint32_t ScriptC::run(Context *rsc, uint32_t launchIndex) return 0; } - Context::ScriptTLSStruct * tls = - (Context::ScriptTLSStruct *)pthread_getspecific(Context::gThreadTLSKey); - rsAssert(tls); - if (mEnviroment.mFragmentStore.get()) { rsc->setFragmentStore(mEnviroment.mFragmentStore.get()); } @@ -119,14 +130,54 @@ uint32_t ScriptC::run(Context *rsc, uint32_t launchIndex) setupScript(); uint32_t ret = 0; - tls->mScript = this; + setTLS(); //LOGE("ScriptC::run %p", mProgram.mRoot); ret = mProgram.mRoot(); - tls->mScript = NULL; + clearTLS(); //LOGE("ScriptC::run ret %i", ret); return ret; } +void ScriptC::Invoke(Context *rsc, uint32_t slot, const void *data, uint32_t len) +{ + //LOGE("rsi_ScriptInvoke %i", slot); + if ((slot >= mEnviroment.mInvokeFunctionCount) || + (mEnviroment.mInvokeFunctions[slot] == NULL)) { + rsc->setError(RS_ERROR_BAD_SCRIPT, "Calling invoke on bad script"); + return; + } + setupScript(); + setTLS(); + + const uint32_t * dPtr = (const uint32_t *)data; + switch(len) { + case 0: + mEnviroment.mInvokeFunctions[slot](); + break; + case 4: + ((void (*)(uint32_t)) + mEnviroment.mInvokeFunctions[slot])(dPtr[0]); + break; + case 8: + ((void (*)(uint32_t, uint32_t)) + mEnviroment.mInvokeFunctions[slot])(dPtr[0], dPtr[1]); + break; + case 12: + ((void (*)(uint32_t, uint32_t, uint32_t)) + mEnviroment.mInvokeFunctions[slot])(dPtr[0], dPtr[1], dPtr[2]); + break; + case 16: + ((void (*)(uint32_t, uint32_t, uint32_t, uint32_t)) + mEnviroment.mInvokeFunctions[slot])(dPtr[0], dPtr[1], dPtr[2], dPtr[3]); + break; + case 20: + ((void (*)(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t)) + mEnviroment.mInvokeFunctions[slot])(dPtr[0], dPtr[1], dPtr[2], dPtr[3], dPtr[4]); + break; + } + clearTLS(); +} + ScriptCState::ScriptCState() { mScript = NULL; |
