diff options
| author | 2009-08-12 17:54:11 -0700 | |
|---|---|---|
| committer | 2009-08-12 17:54:11 -0700 | |
| commit | 43ee06857bb7f99446d1d84f8789016c5d105558 (patch) | |
| tree | cc88d57d27c7ea1c1d0a9e21a49f3fc16908e1cc /libs/rs/rsScriptC.cpp | |
| parent | a9f1dd021f8f6ee777bc4d27913bd40c42e753af (diff) | |
Implement reflecting Java objects into the ACC enviroment.
Diffstat (limited to 'libs/rs/rsScriptC.cpp')
| -rw-r--r-- | libs/rs/rsScriptC.cpp | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp index 3343db51af93..652283d38ad7 100644 --- a/libs/rs/rsScriptC.cpp +++ b/libs/rs/rsScriptC.cpp @@ -19,7 +19,6 @@ #include "rsMatrix.h" #include "acc/acc.h" -#include "utils/String8.h" #include "utils/Timers.h" #include <GLES/gl.h> @@ -91,7 +90,10 @@ void ScriptCState::clear() { memset(&mProgram, 0, sizeof(mProgram)); - mConstantBufferTypes.clear(); + mConstantTypeCount = 0; + for (uint32_t ct=0; ct < MAX_SCRIPT_BANKS; ct++) { + mConstantBufferTypes[ct].clear(); + } memset(&mEnviroment, 0, sizeof(mEnviroment)); mEnviroment.mClearColor[0] = 0; @@ -127,6 +129,7 @@ void ScriptCState::runCompiler(Context *rsc) appendDecls(&tmp); rsc->appendVarDefines(&tmp); appendVarDefines(&tmp); + appendTypes(&tmp); tmp.append("#line 1\n"); const char* scriptSource[] = {tmp.string(), mProgram.mScriptText}; @@ -242,6 +245,31 @@ void ScriptCState::appendVarDefines(String8 *str) } } +void ScriptCState::appendTypes(String8 *str) +{ + char buf[256]; + + for (size_t ct=0; ct < mConstantTypeCount; ct++) { + const Type *t = mConstantBufferTypes[ct].get(); + const Element *e = t->getElement(); + + if (!t->getName()) { + continue; + } + for (size_t ct2=0; ct2 < e->getComponentCount(); ct2++) { + const Component *c = e->getComponent(ct2); + str->append("#define OFFSETOF_"); + str->append(t->getName()); + str->append("_"); + str->append(c->getComponentName()); + sprintf(buf, " %i\n", ct2); + str->append(buf); + } + + } + +} + namespace android { namespace renderscript { @@ -255,7 +283,10 @@ void rsi_ScriptCBegin(Context * rsc) void rsi_ScriptCAddType(Context * rsc, RsType vt) { ScriptCState *ss = &rsc->mScriptC; - ss->mConstantBufferTypes.add(static_cast<const Type *>(vt)); + const Type *t = static_cast<const Type *>(vt); + + ss->mConstantBufferTypes[ss->mConstantTypeCount].set(t); + ss->mConstantTypeCount ++; } void rsi_ScriptCSetScript(Context * rsc, void *vp) |