summaryrefslogtreecommitdiff
path: root/libs/hwui/FontRenderer.cpp
diff options
context:
space:
mode:
author Romain Guy <romainguy@google.com> 2011-12-13 13:11:32 -0800
committer Romain Guy <romainguy@google.com> 2011-12-13 13:11:32 -0800
commit15bc6437f8b4cf10dba55c7638d349e7b9563f4f (patch)
tree18e054e26a43a757fec54387571ae2d1aadbea1c /libs/hwui/FontRenderer.cpp
parent5009f65c9a676b64869e638e08ec0294e20d7e6e (diff)
Reduce the number of GL commands generated by the UI
This optimization along with the previous one lets us render an application like Gmail using only 30% of the number of GL commands previously required Change-Id: Ifee63edaf495e04490b5abd5433bb9a07bc327a8
Diffstat (limited to 'libs/hwui/FontRenderer.cpp')
-rw-r--r--libs/hwui/FontRenderer.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp
index f04ea6f3cfb4..102aea69f748 100644
--- a/libs/hwui/FontRenderer.cpp
+++ b/libs/hwui/FontRenderer.cpp
@@ -22,6 +22,7 @@
#include <utils/Log.h>
+#include "Caches.h"
#include "Debug.h"
#include "FontRenderer.h"
@@ -536,9 +537,8 @@ void FontRenderer::initVertexArrayBuffers() {
}
glGenBuffers(1, &mIndexBufferID);
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBufferID);
+ Caches::getInstance().bindIndicesBuffer(mIndexBufferID);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexBufferSizeBytes, indexBufferData, GL_STATIC_DRAW);
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
free(indexBufferData);
@@ -597,7 +597,18 @@ void FontRenderer::checkTextureUpdate() {
void FontRenderer::issueDrawCommand() {
checkTextureUpdate();
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBufferID);
+ Caches& caches = Caches::getInstance();
+ if (!mDrawn) {
+ float* buffer = mTextMeshPtr;
+ int offset = 2;
+
+ bool force = caches.unbindMeshBuffer();
+ caches.bindPositionVertexPointer(force, caches.currentProgram->position, buffer);
+ caches.bindTexCoordsVertexPointer(force, caches.currentProgram->texCoords,
+ buffer + offset);
+ }
+
+ caches.bindIndicesBuffer(mIndexBufferID);
glDrawElements(GL_TRIANGLES, mCurrentQuadIndex * 6, GL_UNSIGNED_SHORT, NULL);
mDrawn = true;