From 03750a067e818ca7fbd0f590e2ff6a8fded21e6c Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Mon, 18 Oct 2010 14:06:08 -0700 Subject: Use VBOs to render most geometries. Change-Id: I4360dc4fe5693ab425450c107282b2c22db4dca7 --- libs/hwui/Patch.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'libs/hwui/Patch.cpp') diff --git a/libs/hwui/Patch.cpp b/libs/hwui/Patch.cpp index 560decf15d38..c2ebee0405d4 100644 --- a/libs/hwui/Patch.cpp +++ b/libs/hwui/Patch.cpp @@ -19,12 +19,16 @@ #include #include +#include #include "Patch.h" +#include "Caches.h" namespace android { namespace uirenderer { +class Caches; + /////////////////////////////////////////////////////////////////////////////// // Constructors/destructor /////////////////////////////////////////////////////////////////////////////// @@ -32,11 +36,14 @@ namespace uirenderer { Patch::Patch(const uint32_t xCount, const uint32_t yCount, const int8_t emptyQuads) { // 2 triangles per patch, 3 vertices per triangle verticesCount = ((xCount + 1) * (yCount + 1) - emptyQuads) * 2 * 3; - vertices = new TextureVertex[verticesCount]; + mVertices = new TextureVertex[verticesCount]; + + glGenBuffers(1, &meshBuffer); } Patch::~Patch() { - delete[] vertices; + delete[] mVertices; + glDeleteBuffers(1, &meshBuffer); } /////////////////////////////////////////////////////////////////////////////// @@ -77,7 +84,7 @@ void Patch::updateVertices(const float bitmapWidth, const float bitmapHeight, stretchY = yStretch / yStretchTex; } - TextureVertex* vertex = vertices; + TextureVertex* vertex = mVertices; uint32_t quadCount = 0; float previousStepY = 0.0f; @@ -108,6 +115,10 @@ void Patch::updateVertices(const float bitmapWidth, const float bitmapHeight, generateRow(vertex, y1, bottom - top, v1, 1.0f, xDivs, width, stretchX, right - left, bitmapWidth, quadCount, colorKey); + + Caches::getInstance().bindMeshBuffer(meshBuffer); + glBufferData(GL_ARRAY_BUFFER, sizeof(TextureVertex) * verticesCount, + mVertices, GL_STATIC_DRAW); } inline void Patch::generateRow(TextureVertex*& vertex, float y1, float y2, float v1, float v2, -- cgit v1.2.3-59-g8ed1b