diff options
author | Jason Sams <rjsams@android.com> | 2009-08-20 16:10:36 -0700 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2009-08-20 16:11:03 -0700 |
commit | 25ffcdc9d7e32c9c1eeb2b48cc2f17d1353e9fae (patch) | |
tree | 37bac4daba3c96307217faea840754cdbd9d5cba /libs/rs | |
parent | ac81c42971ddcd0726c4f2050fd82942914d0e1c (diff) | |
download | frameworks_base-25ffcdc9d7e32c9c1eeb2b48cc2f17d1353e9fae.zip frameworks_base-25ffcdc9d7e32c9c1eeb2b48cc2f17d1353e9fae.tar.gz frameworks_base-25ffcdc9d7e32c9c1eeb2b48cc2f17d1353e9fae.tar.bz2 |
Point Sprites
Diffstat (limited to 'libs/rs')
-rw-r--r-- | libs/rs/RenderScript.h | 3 | ||||
-rw-r--r-- | libs/rs/rs.spec | 15 | ||||
-rw-r--r-- | libs/rs/rsComponent.cpp | 2 | ||||
-rw-r--r-- | libs/rs/rsComponent.h | 4 | ||||
-rw-r--r-- | libs/rs/rsProgramFragment.cpp | 34 | ||||
-rw-r--r-- | libs/rs/rsProgramFragment.h | 3 | ||||
-rw-r--r-- | libs/rs/rsSampler.cpp | 1 | ||||
-rw-r--r-- | libs/rs/rsTriangleMesh.cpp | 17 | ||||
-rw-r--r-- | libs/rs/rsType.cpp | 14 | ||||
-rw-r--r-- | libs/rs/rsType.h | 1 |
10 files changed, 50 insertions, 44 deletions
diff --git a/libs/rs/RenderScript.h b/libs/rs/RenderScript.h index e4cf00f..2f60c9f 100644 --- a/libs/rs/RenderScript.h +++ b/libs/rs/RenderScript.h @@ -80,7 +80,8 @@ enum RsDataKind { RS_KIND_NX, RS_KIND_NY, RS_KIND_NZ, - RS_KIND_INDEX + RS_KIND_INDEX, + RS_KIND_POINT_SIZE }; enum RsElementPredefined { diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec index 1a81021..e275f27 100644 --- a/libs/rs/rs.spec +++ b/libs/rs/rs.spec @@ -361,6 +361,7 @@ ProgramFragmentStoreCreate { ProgramFragmentBegin { param RsElement in param RsElement out + param bool pointSpriteEnable } ProgramFragmentBindTexture { @@ -375,19 +376,11 @@ ProgramFragmentBindSampler { param RsSampler s } -ProgramFragmentSetType { - param uint32_t slot - param RsType t - } - -ProgramFragmentSetEnvMode { - param uint32_t slot - param RsTexEnvMode env - } - -ProgramFragmentSetTexEnable { +ProgramFragmentSetSlot { param uint32_t slot param bool enable + param RsTexEnvMode env + param RsType t } ProgramFragmentCreate { diff --git a/libs/rs/rsComponent.cpp b/libs/rs/rsComponent.cpp index b88710c..4a043f3 100644 --- a/libs/rs/rsComponent.cpp +++ b/libs/rs/rsComponent.cpp @@ -24,7 +24,7 @@ using namespace android::renderscript; Component::Component() { mType = FLOAT; - mKind = NONE; + mKind = USER; mIsNormalized = false; mBits = 0; } diff --git a/libs/rs/rsComponent.h b/libs/rs/rsComponent.h index 6342f1b..5856524 100644 --- a/libs/rs/rsComponent.h +++ b/libs/rs/rsComponent.h @@ -34,13 +34,13 @@ public: }; enum DataKind { - NONE, + USER, RED, GREEN, BLUE, ALPHA, LUMINANCE, INTENSITY, X, Y, Z, W, S, T, Q, R, NX, NY, NZ, INDEX, - USER + POINT_SIZE }; diff --git a/libs/rs/rsProgramFragment.cpp b/libs/rs/rsProgramFragment.cpp index 9df07bf..4ef6835 100644 --- a/libs/rs/rsProgramFragment.cpp +++ b/libs/rs/rsProgramFragment.cpp @@ -24,7 +24,7 @@ using namespace android; using namespace android::renderscript; -ProgramFragment::ProgramFragment(Element *in, Element *out) : +ProgramFragment::ProgramFragment(Element *in, Element *out, bool pointSpriteEnable) : Program(in, out) { for (uint32_t ct=0; ct < MAX_TEXTURE; ct++) { @@ -32,6 +32,7 @@ ProgramFragment::ProgramFragment(Element *in, Element *out) : mTextureDimensions[ct] = 2; } mTextureEnableMask = 0; + mPointSpriteEnable = pointSpriteEnable; mEnvModes[1] = RS_TEX_ENV_MODE_DECAL; } @@ -54,6 +55,7 @@ void ProgramFragment::setupGL(ProgramFragmentState *state) } glEnable(GL_TEXTURE_2D); + //glTexEnvi(GL_POINT_SPRITE_OES, GL_COORD_REPLACE_OES, mPointSpriteEnable); glBindTexture(GL_TEXTURE_2D, mTextures[ct]->getTextureID()); switch(mEnvModes[ct]) { @@ -94,7 +96,6 @@ void ProgramFragment::setupGL(ProgramFragmentState *state) glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); } } - glActiveTexture(GL_TEXTURE0); mDirty = false; } @@ -178,7 +179,7 @@ ProgramFragmentState::~ProgramFragmentState() void ProgramFragmentState::init(Context *rsc, int32_t w, int32_t h) { - ProgramFragment *pf = new ProgramFragment(NULL, NULL); + ProgramFragment *pf = new ProgramFragment(NULL, NULL, false); mDefault.set(pf); } @@ -186,10 +187,10 @@ void ProgramFragmentState::init(Context *rsc, int32_t w, int32_t h) namespace android { namespace renderscript { -void rsi_ProgramFragmentBegin(Context * rsc, RsElement in, RsElement out) +void rsi_ProgramFragmentBegin(Context * rsc, RsElement in, RsElement out, bool pointSpriteEnable) { delete rsc->mStateFragment.mPF; - rsc->mStateFragment.mPF = new ProgramFragment((Element *)in, (Element *)out); + rsc->mStateFragment.mPF = new ProgramFragment((Element *)in, (Element *)out, pointSpriteEnable); } void rsi_ProgramFragmentBindTexture(Context *rsc, RsProgramFragment vpf, uint32_t slot, RsAllocation a) @@ -204,27 +205,20 @@ void rsi_ProgramFragmentBindSampler(Context *rsc, RsProgramFragment vpf, uint32_ pf->bindSampler(slot, static_cast<Sampler *>(s)); } -void rsi_ProgramFragmentSetType(Context *rsc, uint32_t slot, RsType vt) +void rsi_ProgramFragmentSetSlot(Context *rsc, uint32_t slot, bool enable, RsTexEnvMode env, RsType vt) { const Type *t = static_cast<const Type *>(vt); - uint32_t dim = 1; - if (t->getDimY()) { - dim ++; - if (t->getDimZ()) { + if (t) { + uint32_t dim = 1; + if (t->getDimY()) { dim ++; + if (t->getDimZ()) { + dim ++; + } } + rsc->mStateFragment.mPF->setType(slot, t->getElement(), dim); } - - rsc->mStateFragment.mPF->setType(slot, t->getElement(), dim); -} - -void rsi_ProgramFragmentSetEnvMode(Context *rsc, uint32_t slot, RsTexEnvMode env) -{ rsc->mStateFragment.mPF->setEnvMode(slot, env); -} - -void rsi_ProgramFragmentSetTexEnable(Context *rsc, uint32_t slot, bool enable) -{ rsc->mStateFragment.mPF->setTexEnable(slot, enable); } diff --git a/libs/rs/rsProgramFragment.h b/libs/rs/rsProgramFragment.h index 57fb6a5..bd45342 100644 --- a/libs/rs/rsProgramFragment.h +++ b/libs/rs/rsProgramFragment.h @@ -32,7 +32,7 @@ public: - ProgramFragment(Element *in, Element *out); + ProgramFragment(Element *in, Element *out, bool pointSpriteEnable); virtual ~ProgramFragment(); virtual void setupGL(ProgramFragmentState *); @@ -64,6 +64,7 @@ protected: // Hacks to create a program for now RsTexEnvMode mEnvModes[MAX_TEXTURE]; uint32_t mTextureEnableMask; + bool mPointSpriteEnable; }; class ProgramFragmentState diff --git a/libs/rs/rsSampler.cpp b/libs/rs/rsSampler.cpp index c14c371..332d532 100644 --- a/libs/rs/rsSampler.cpp +++ b/libs/rs/rsSampler.cpp @@ -143,6 +143,7 @@ RsSampler rsi_SamplerCreate(Context *rsc) ss->mWrapS, ss->mWrapT, ss->mWrapR); + s->incRef(); return s; } diff --git a/libs/rs/rsTriangleMesh.cpp b/libs/rs/rsTriangleMesh.cpp index 8c7bc92..99f8adb 100644 --- a/libs/rs/rsTriangleMesh.cpp +++ b/libs/rs/rsTriangleMesh.cpp @@ -199,6 +199,7 @@ RsTriangleMesh rsi_TriangleMeshCreate(Context *rsc) memcpy(tm->mIndexData, tmc->mIndexData.array(), tm->mIndexDataSize); tm->analyzeElement(); + tm->incRef(); return tm; } @@ -248,16 +249,16 @@ void rsi_TriangleMeshRenderRange(Context *rsc, RsTriangleMesh vtm, uint32_t firs glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, tm->mBufferObjects[1]); glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(tm->mSizeCoord, - GL_FLOAT, - tm->mVertexElement->getSizeBytes(), + glVertexPointer(tm->mSizeCoord, + GL_FLOAT, + tm->mVertexElement->getSizeBytes(), (void *)tm->mVertexElement->getComponentOffsetBytes(tm->mOffsetCoord)); if (tm->mSizeTex) { glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glTexCoordPointer(tm->mSizeTex, - GL_FLOAT, - tm->mVertexElement->getSizeBytes(), + glTexCoordPointer(tm->mSizeTex, + GL_FLOAT, + tm->mVertexElement->getSizeBytes(), (void *)tm->mVertexElement->getComponentOffsetBytes(tm->mOffsetTex)); } else { glDisableClientState(GL_TEXTURE_COORD_ARRAY); @@ -265,8 +266,8 @@ void rsi_TriangleMeshRenderRange(Context *rsc, RsTriangleMesh vtm, uint32_t firs if (tm->mSizeNorm) { glEnableClientState(GL_NORMAL_ARRAY); - glNormalPointer(GL_FLOAT, - tm->mVertexElement->getSizeBytes(), + glNormalPointer(GL_FLOAT, + tm->mVertexElement->getSizeBytes(), (void *)tm->mVertexElement->getComponentOffsetBytes(tm->mOffsetNorm)); } else { glDisableClientState(GL_NORMAL_ARRAY); diff --git a/libs/rs/rsType.cpp b/libs/rs/rsType.cpp index a40a152..5a9090e 100644 --- a/libs/rs/rsType.cpp +++ b/libs/rs/rsType.cpp @@ -230,6 +230,13 @@ void Type::makeGLComponents() mGL.mTex[texNum].size = 4; break; + case Component::POINT_SIZE: + rsAssert(!mGL.mPointSize.size); + mGL.mPointSize.size = 1; + mGL.mPointSize.offset = mElement->getComponentOffsetBytes(ct); + mGL.mPointSize.type = c->getGLType(); + break; + default: break; } @@ -280,6 +287,13 @@ void Type::enableGLVertexBuffer() const } glClientActiveTexture(GL_TEXTURE0); + if (mGL.mPointSize.size) { + glEnableClientState(GL_POINT_SIZE_ARRAY_OES); + glPointSizePointerOES(mGL.mPointSize.type, + stride, + (void *)mGL.mPointSize.offset); + } + } diff --git a/libs/rs/rsType.h b/libs/rs/rsType.h index 60d75d7..6c39a4c 100644 --- a/libs/rs/rsType.h +++ b/libs/rs/rsType.h @@ -118,6 +118,7 @@ protected: VertexComponent_t mNorm; VertexComponent_t mColor; VertexComponent_t mTex[RS_MAX_TEXTURE]; + VertexComponent_t mPointSize; }; GLState_t mGL; void makeGLComponents(); |