summaryrefslogtreecommitdiff
path: root/rsProgramStore.cpp
diff options
context:
space:
mode:
authorJason Sams <rjsams@android.com>2011-04-06 11:23:54 -0700
committerJason Sams <rjsams@android.com>2011-04-06 11:23:54 -0700
commit721acc495b859c6d884725a4f9b5523583dd11c7 (patch)
tree3063843924d4c9b0dce0cbe364848f4718be959e /rsProgramStore.cpp
parent8feea4e0dec48ea03bd6d32706d058b86dddc5ba (diff)
downloadrs-721acc495b859c6d884725a4f9b5523583dd11c7.tar.gz
Seperate ProgramRaster.
Cleanup ProgramRaster and ProgramStore creation. Change-Id: If25ea74355238d405340f0ccfb8117ad6e1307b7
Diffstat (limited to 'rsProgramStore.cpp')
-rw-r--r--rsProgramStore.cpp99
1 files changed, 31 insertions, 68 deletions
diff --git a/rsProgramStore.cpp b/rsProgramStore.cpp
index 087414a7..2ad65e97 100644
--- a/rsProgramStore.cpp
+++ b/rsProgramStore.cpp
@@ -21,27 +21,31 @@ using namespace android;
using namespace android::renderscript;
-ProgramStore::ProgramStore(Context *rsc) : Program(rsc) {
+ProgramStore::ProgramStore(Context *rsc,
+ bool colorMaskR, bool colorMaskG, bool colorMaskB, bool colorMaskA,
+ bool depthMask, bool ditherEnable,
+ RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc,
+ RsDepthFunc depthFunc) : Program(rsc) {
memset(&mHal, 0, sizeof(mHal));
- mHal.state.ditherEnable = true;
+ mHal.state.ditherEnable = ditherEnable;
- mHal.state.colorRWriteEnable = true;
- mHal.state.colorGWriteEnable = true;
- mHal.state.colorBWriteEnable = true;
- mHal.state.colorAWriteEnable = true;
- mHal.state.blendSrc = RS_BLEND_SRC_ONE;
- mHal.state.blendDst = RS_BLEND_DST_ZERO;
+ mHal.state.colorRWriteEnable = colorMaskR;
+ mHal.state.colorGWriteEnable = colorMaskG;
+ mHal.state.colorBWriteEnable = colorMaskB;
+ mHal.state.colorAWriteEnable = colorMaskA;
+ mHal.state.blendSrc = srcFunc;
+ mHal.state.blendDst = destFunc;
- mHal.state.depthWriteEnable = true;
- mHal.state.depthFunc = RS_DEPTH_FUNC_LESS;
+ mHal.state.depthWriteEnable = depthMask;
+ mHal.state.depthFunc = depthFunc;
}
ProgramStore::~ProgramStore() {
mRSC->mHal.funcs.store.destroy(mRSC, this);
}
-void ProgramStore::setupGL2(const Context *rsc, ProgramStoreState *state) {
+void ProgramStore::setup(const Context *rsc, ProgramStoreState *state) {
if (state->mLast.get() == this) {
return;
}
@@ -50,10 +54,6 @@ void ProgramStore::setupGL2(const Context *rsc, ProgramStoreState *state) {
rsc->mHal.funcs.store.setActive(rsc, this);
}
-void ProgramStore::setDitherEnable(bool enable) {
- mHal.state.ditherEnable = enable;
-}
-
void ProgramStore::serialize(OStream *stream) const {
}
@@ -61,43 +61,24 @@ ProgramStore *ProgramStore::createFromStream(Context *rsc, IStream *stream) {
return NULL;
}
-void ProgramStore::setDepthFunc(RsDepthFunc func) {
- mHal.state.depthFunc = func;
-}
-
-void ProgramStore::setDepthMask(bool mask) {
- mHal.state.depthWriteEnable = mask;
-}
-
-void ProgramStore::setBlendFunc(RsBlendSrcFunc src, RsBlendDstFunc dst) {
- mHal.state.blendSrc = src;
- mHal.state.blendDst = dst;
-}
-
-void ProgramStore::setColorMask(bool r, bool g, bool b, bool a) {
- mHal.state.colorRWriteEnable = r;
- mHal.state.colorGWriteEnable = g;
- mHal.state.colorBWriteEnable = b;
- mHal.state.colorAWriteEnable = a;
-}
-
void ProgramStore::init() {
mRSC->mHal.funcs.store.init(mRSC, this);
}
ProgramStoreState::ProgramStoreState() {
- mPFS = NULL;
}
ProgramStoreState::~ProgramStoreState() {
- ObjectBase::checkDelete(mPFS);
- mPFS = NULL;
}
void ProgramStoreState::init(Context *rsc) {
- ProgramStore *pfs = new ProgramStore(rsc);
- pfs->init();
- mDefault.set(pfs);
+ ProgramStore *ps = new ProgramStore(rsc,
+ true, true, true, true,
+ true, true,
+ RS_BLEND_SRC_ONE, RS_BLEND_DST_ZERO,
+ RS_DEPTH_FUNC_LESS);
+ ps->init();
+ mDefault.set(ps);
}
void ProgramStoreState::deinit(Context *rsc) {
@@ -109,38 +90,20 @@ void ProgramStoreState::deinit(Context *rsc) {
namespace android {
namespace renderscript {
-void rsi_ProgramStoreBegin(Context * rsc, RsElement in, RsElement out) {
- ObjectBase::checkDelete(rsc->mStateFragmentStore.mPFS);
- rsc->mStateFragmentStore.mPFS = new ProgramStore(rsc);
-}
-
-void rsi_ProgramStoreDepthFunc(Context *rsc, RsDepthFunc func) {
- rsc->mStateFragmentStore.mPFS->setDepthFunc(func);
-}
+RsProgramStore rsi_ProgramStoreCreate(Context *rsc,
+ bool colorMaskR, bool colorMaskG, bool colorMaskB, bool colorMaskA,
+ bool depthMask, bool ditherEnable,
+ RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc,
+ RsDepthFunc depthFunc) {
-void rsi_ProgramStoreDepthMask(Context *rsc, bool mask) {
- rsc->mStateFragmentStore.mPFS->setDepthMask(mask);
-}
-
-void rsi_ProgramStoreColorMask(Context *rsc, bool r, bool g, bool b, bool a) {
- rsc->mStateFragmentStore.mPFS->setColorMask(r, g, b, a);
-}
-
-void rsi_ProgramStoreBlendFunc(Context *rsc, RsBlendSrcFunc src, RsBlendDstFunc dst) {
- rsc->mStateFragmentStore.mPFS->setBlendFunc(src, dst);
-}
-
-RsProgramStore rsi_ProgramStoreCreate(Context *rsc) {
- ProgramStore *pfs = rsc->mStateFragmentStore.mPFS;
+ ProgramStore *pfs = new ProgramStore(rsc,
+ colorMaskR, colorMaskG, colorMaskB, colorMaskA,
+ depthMask, ditherEnable,
+ srcFunc, destFunc, depthFunc);
pfs->init();
pfs->incUserRef();
- rsc->mStateFragmentStore.mPFS = 0;
return pfs;
}
-void rsi_ProgramStoreDither(Context *rsc, bool enable) {
- rsc->mStateFragmentStore.mPFS->setDitherEnable(enable);
-}
-
}
}