diff options
author | Chris Craik <ccraik@google.com> | 2015-02-06 23:06:43 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-02-06 23:06:44 +0000 |
commit | f7ccbfbd9811e3b1c3accd9e3e92688d31a8a2bd (patch) | |
tree | b08c13be9ce7e46c971db5437bcb94de5a5bb5ac /libs/hwui/renderstate/MeshState.cpp | |
parent | 12271e22014c2e2cd0ecdb9938ff8b618c68bc56 (diff) | |
parent | 117bdbcfa3e8306dad21e7e01fa71b00cdfa7265 (diff) | |
download | frameworks_base-f7ccbfbd9811e3b1c3accd9e3e92688d31a8a2bd.zip frameworks_base-f7ccbfbd9811e3b1c3accd9e3e92688d31a8a2bd.tar.gz frameworks_base-f7ccbfbd9811e3b1c3accd9e3e92688d31a8a2bd.tar.bz2 |
Merge "Glop ColorFilter & VertexBuffer support, initial enable"
Diffstat (limited to 'libs/hwui/renderstate/MeshState.cpp')
-rw-r--r-- | libs/hwui/renderstate/MeshState.cpp | 48 |
1 files changed, 16 insertions, 32 deletions
diff --git a/libs/hwui/renderstate/MeshState.cpp b/libs/hwui/renderstate/MeshState.cpp index 50c09c8..ce6030d 100644 --- a/libs/hwui/renderstate/MeshState.cpp +++ b/libs/hwui/renderstate/MeshState.cpp @@ -23,22 +23,20 @@ namespace android { namespace uirenderer { MeshState::MeshState() - : mCurrentPositionPointer(this) + : mCurrentIndicesBuffer(0) + , mCurrentPixelBuffer(0) + , mCurrentPositionPointer(this) , mCurrentPositionStride(0) , mCurrentTexCoordsPointer(this) , mCurrentTexCoordsStride(0) - , mTexCoordsArrayEnabled(false) { + , mTexCoordsArrayEnabled(false) + , mQuadListIndices(0) { glGenBuffers(1, &mUnitQuadBuffer); glBindBuffer(GL_ARRAY_BUFFER, mUnitQuadBuffer); glBufferData(GL_ARRAY_BUFFER, sizeof(kUnitQuadVertices), kUnitQuadVertices, GL_STATIC_DRAW); mCurrentBuffer = mUnitQuadBuffer; - mCurrentIndicesBuffer = 0; - mCurrentPixelBuffer = 0; - - mQuadListIndices = 0; - mShadowStripsIndices = 0; // position attribute always enabled glEnableVertexAttribArray(Program::kBindingPosition); @@ -50,9 +48,10 @@ MeshState::~MeshState() { glDeleteBuffers(1, &mQuadListIndices); mQuadListIndices = 0; +} - glDeleteBuffers(1, &mShadowStripsIndices); - mShadowStripsIndices = 0; +void MeshState::dump() { + ALOGD("MeshState vertices: unitQuad %d, current %d", mUnitQuadBuffer, mCurrentBuffer); } /////////////////////////////////////////////////////////////////////////////// @@ -65,18 +64,17 @@ bool MeshState::bindMeshBuffer() { bool MeshState::bindMeshBuffer(GLuint buffer) { if (!buffer) buffer = mUnitQuadBuffer; - if (mCurrentBuffer != buffer) { - glBindBuffer(GL_ARRAY_BUFFER, buffer); - mCurrentBuffer = buffer; - return true; - } - return false; + return bindMeshBufferInternal(buffer); } bool MeshState::unbindMeshBuffer() { - if (mCurrentBuffer) { - glBindBuffer(GL_ARRAY_BUFFER, 0); - mCurrentBuffer = 0; + return bindMeshBufferInternal(0); +} + +bool MeshState::bindMeshBufferInternal(GLuint buffer) { + if (mCurrentBuffer != buffer) { + glBindBuffer(GL_ARRAY_BUFFER, buffer); + mCurrentBuffer = buffer; return true; } return false; @@ -163,20 +161,6 @@ bool MeshState::bindQuadIndicesBuffer() { return bindIndicesBufferInternal(mQuadListIndices); } -bool MeshState::bindShadowIndicesBuffer() { - if (!mShadowStripsIndices) { - std::unique_ptr<uint16_t[]> shadowIndices(new uint16_t[MAX_SHADOW_INDEX_COUNT]); - ShadowTessellator::generateShadowIndices(shadowIndices.get()); - glGenBuffers(1, &mShadowStripsIndices); - bool force = bindIndicesBufferInternal(mShadowStripsIndices); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, MAX_SHADOW_INDEX_COUNT * sizeof(uint16_t), - shadowIndices.get(), GL_STATIC_DRAW); - return force; - } - - return bindIndicesBufferInternal(mShadowStripsIndices); -} - bool MeshState::unbindIndicesBuffer() { if (mCurrentIndicesBuffer) { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |