diff options
Diffstat (limited to 'libs/rs/rsScript.cpp')
| -rw-r--r-- | libs/rs/rsScript.cpp | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/libs/rs/rsScript.cpp b/libs/rs/rsScript.cpp index afee2a3..f62c72e 100644 --- a/libs/rs/rsScript.cpp +++ b/libs/rs/rsScript.cpp @@ -21,6 +21,7 @@ using namespace android::renderscript; Script::Script(Context *rsc) : ObjectBase(rsc) { memset(&mEnviroment, 0, sizeof(mEnviroment)); + memset(&mHal, 0, sizeof(mHal)); mSlots = NULL; mTypes = NULL; @@ -37,48 +38,38 @@ Script::~Script() { } } -void Script::initSlots() { - if (mEnviroment.mFieldCount > 0) { - mSlots = new ObjectBaseRef<Allocation>[mEnviroment.mFieldCount]; - mTypes = new ObjectBaseRef<const Type>[mEnviroment.mFieldCount]; - } -} - void Script::setSlot(uint32_t slot, Allocation *a) { - if (slot >= mEnviroment.mFieldCount) { + //LOGE("setSlot %i %p", slot, a); + if (slot >= mHal.info.exportedVariableCount) { LOGE("Script::setSlot unable to set allocation, invalid slot index"); return; } mSlots[slot].set(a); + if (a != NULL) { + mRSC->mHal.funcs.script.setGlobalBind(mRSC, this, slot, a->getPtr()); + } else { + mRSC->mHal.funcs.script.setGlobalBind(mRSC, this, slot, NULL); + } } -void Script::setVar(uint32_t slot, const void *val, uint32_t len) { - int32_t *destPtr = ((int32_t **)mEnviroment.mFieldAddress)[slot]; - if (destPtr) { - //LOGE("setVar f1 %f", ((const float *)destPtr)[0]); - //LOGE("setVar %p %i", destPtr, len); - memcpy(destPtr, val, len); - //LOGE("setVar f2 %f", ((const float *)destPtr)[0]); - } else { - //if (rsc->props.mLogScripts) { - LOGV("Calling setVar on slot = %i which is null", slot); - //} +void Script::setVar(uint32_t slot, const void *val, size_t len) { + //LOGE("setVar %i %p %i", slot, val, len); + if (slot >= mHal.info.exportedVariableCount) { + LOGE("Script::setVar unable to set allocation, invalid slot index"); + return; } + mRSC->mHal.funcs.script.setGlobalVar(mRSC, this, slot, (void *)val, len); } void Script::setVarObj(uint32_t slot, ObjectBase *val) { - ObjectBase **destPtr = ((ObjectBase ***)mEnviroment.mFieldAddress)[slot]; - - if (destPtr) { - if (val != NULL) { - val->incSysRef(); - } - if (*destPtr) { - (*destPtr)->decSysRef(); - } - *destPtr = val; + //LOGE("setVarObj %i %p", slot, val); + if (slot >= mHal.info.exportedVariableCount) { + LOGE("Script::setVarObj unable to set allocation, invalid slot index"); + return; } + //LOGE("setvarobj %i %p", slot, val); + mRSC->mHal.funcs.script.setGlobalObj(mRSC, this, slot, val); } namespace android { @@ -91,11 +82,21 @@ void rsi_ScriptBindAllocation(Context * rsc, RsScript vs, RsAllocation va, uint3 //LOGE("rsi_ScriptBindAllocation %i %p %p", slot, a, a->getPtr()); } -void rsi_ScriptSetTimeZone(Context * rsc, RsScript vs, const char * timeZone, uint32_t length) { +void rsi_ScriptSetTimeZone(Context * rsc, RsScript vs, const char * timeZone, size_t length) { Script *s = static_cast<Script *>(vs); s->mEnviroment.mTimeZone = timeZone; } +void rsi_ScriptForEach(Context *rsc, RsScript vs, uint32_t slot, + RsAllocation vain, RsAllocation vaout, + const void *params, size_t paramLen) { + Script *s = static_cast<Script *>(vs); + s->runForEach(rsc, + static_cast<const Allocation *>(vain), static_cast<Allocation *>(vaout), + params, paramLen); + +} + void rsi_ScriptInvoke(Context *rsc, RsScript vs, uint32_t slot) { Script *s = static_cast<Script *>(vs); s->Invoke(rsc, slot, NULL, 0); @@ -107,7 +108,7 @@ void rsi_ScriptInvokeData(Context *rsc, RsScript vs, uint32_t slot, void *data) s->Invoke(rsc, slot, NULL, 0); } -void rsi_ScriptInvokeV(Context *rsc, RsScript vs, uint32_t slot, const void *data, uint32_t len) { +void rsi_ScriptInvokeV(Context *rsc, RsScript vs, uint32_t slot, const void *data, size_t len) { Script *s = static_cast<Script *>(vs); s->Invoke(rsc, slot, data, len); } @@ -138,7 +139,7 @@ void rsi_ScriptSetVarD(Context *rsc, RsScript vs, uint32_t slot, double value) { s->setVar(slot, &value, sizeof(value)); } -void rsi_ScriptSetVarV(Context *rsc, RsScript vs, uint32_t slot, const void *data, uint32_t len) { +void rsi_ScriptSetVarV(Context *rsc, RsScript vs, uint32_t slot, const void *data, size_t len) { Script *s = static_cast<Script *>(vs); s->setVar(slot, data, len); } |
