Loading libs/hwui/Glop.h +1 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,7 @@ public: } vertices; int elementCount; int vertexCount; // only used for meshes (for glDrawRangeElements) TextureVertex mappedVertices[4]; } mesh; Loading libs/hwui/GlopBuilder.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -210,6 +210,7 @@ GlopBuilder& GlopBuilder::setMeshVertexBuffer(const VertexBuffer& vertexBuffer) alphaVertex ? kAlphaVertexStride : kVertexStride }; mOutGlop->mesh.elementCount = indices ? vertexBuffer.getIndexCount() : vertexBuffer.getVertexCount(); mOutGlop->mesh.vertexCount = vertexBuffer.getVertexCount(); // used for glDrawRangeElements() return *this; } Loading libs/hwui/renderstate/RenderState.cpp +13 −3 Original line number Diff line number Diff line Loading @@ -364,18 +364,28 @@ void RenderState::render(const Glop& glop, const Matrix4& orthoMatrix) { const GLbyte* vertexData = static_cast<const GLbyte*>(vertices.position); while (elementsCount > 0) { GLsizei drawCount = std::min(elementsCount, (GLsizei) kMaxNumberOfQuads * 6); GLsizei vertexCount = (drawCount / 6) * 4; meshState().bindPositionVertexPointer(vertexData, vertices.stride); if (vertices.attribFlags & VertexAttribFlags::TextureCoord) { meshState().bindTexCoordsVertexPointer( vertexData + kMeshTextureOffset, vertices.stride); } if (mCaches->extensions().getMajorGlVersion() >= 3) { glDrawRangeElements(mesh.primitiveMode, 0, vertexCount-1, drawCount, GL_UNSIGNED_SHORT, nullptr); } else { glDrawElements(mesh.primitiveMode, drawCount, GL_UNSIGNED_SHORT, nullptr); } elementsCount -= drawCount; vertexData += (drawCount / 6) * 4 * vertices.stride; vertexData += vertexCount * vertices.stride; } } else if (indices.bufferObject || indices.indices) { if (mCaches->extensions().getMajorGlVersion() >= 3) { // use glDrawRangeElements to reduce CPU overhead (otherwise the driver has to determine the min/max index values) glDrawRangeElements(mesh.primitiveMode, 0, mesh.vertexCount-1, mesh.elementCount, GL_UNSIGNED_SHORT, indices.indices); } else { glDrawElements(mesh.primitiveMode, mesh.elementCount, GL_UNSIGNED_SHORT, indices.indices); } } else { glDrawArrays(mesh.primitiveMode, 0, mesh.elementCount); } Loading Loading
libs/hwui/Glop.h +1 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,7 @@ public: } vertices; int elementCount; int vertexCount; // only used for meshes (for glDrawRangeElements) TextureVertex mappedVertices[4]; } mesh; Loading
libs/hwui/GlopBuilder.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -210,6 +210,7 @@ GlopBuilder& GlopBuilder::setMeshVertexBuffer(const VertexBuffer& vertexBuffer) alphaVertex ? kAlphaVertexStride : kVertexStride }; mOutGlop->mesh.elementCount = indices ? vertexBuffer.getIndexCount() : vertexBuffer.getVertexCount(); mOutGlop->mesh.vertexCount = vertexBuffer.getVertexCount(); // used for glDrawRangeElements() return *this; } Loading
libs/hwui/renderstate/RenderState.cpp +13 −3 Original line number Diff line number Diff line Loading @@ -364,18 +364,28 @@ void RenderState::render(const Glop& glop, const Matrix4& orthoMatrix) { const GLbyte* vertexData = static_cast<const GLbyte*>(vertices.position); while (elementsCount > 0) { GLsizei drawCount = std::min(elementsCount, (GLsizei) kMaxNumberOfQuads * 6); GLsizei vertexCount = (drawCount / 6) * 4; meshState().bindPositionVertexPointer(vertexData, vertices.stride); if (vertices.attribFlags & VertexAttribFlags::TextureCoord) { meshState().bindTexCoordsVertexPointer( vertexData + kMeshTextureOffset, vertices.stride); } if (mCaches->extensions().getMajorGlVersion() >= 3) { glDrawRangeElements(mesh.primitiveMode, 0, vertexCount-1, drawCount, GL_UNSIGNED_SHORT, nullptr); } else { glDrawElements(mesh.primitiveMode, drawCount, GL_UNSIGNED_SHORT, nullptr); } elementsCount -= drawCount; vertexData += (drawCount / 6) * 4 * vertices.stride; vertexData += vertexCount * vertices.stride; } } else if (indices.bufferObject || indices.indices) { if (mCaches->extensions().getMajorGlVersion() >= 3) { // use glDrawRangeElements to reduce CPU overhead (otherwise the driver has to determine the min/max index values) glDrawRangeElements(mesh.primitiveMode, 0, mesh.vertexCount-1, mesh.elementCount, GL_UNSIGNED_SHORT, indices.indices); } else { glDrawElements(mesh.primitiveMode, mesh.elementCount, GL_UNSIGNED_SHORT, indices.indices); } } else { glDrawArrays(mesh.primitiveMode, 0, mesh.elementCount); } Loading