Another optimization of glyph cache uploads

Previously, cache textures were updated whenever mCurrentCacheTexuture was changed.
Since updating cache textures needs glTexSubImage2D call, frequent changing
of mCurrentCacheTexture (which can easily happen when an app uses lots of unique glyphs
even with precaching) caused many glTexSubImage2D calls and bad framerates.
This patch optimized isssueDrawCommand function. Consequently, changing mCurrentCacheTexture doesn't
cause glTexSubImage2D call any more and it will improve font rendering performance.

Change-Id: Id19d959fa0e69eeb2a39f83a57e311d7394586b2
Signed-off-by: Sangkyu Lee <geteuid@gmail.com>
diff --git a/libs/hwui/FontRenderer.h b/libs/hwui/FontRenderer.h
index 405db09..09a3c25 100644
--- a/libs/hwui/FontRenderer.h
+++ b/libs/hwui/FontRenderer.h
@@ -138,6 +138,7 @@
 
     void removeFont(const Font* font);
 
+    void updateDrawParams();
     void checkTextureUpdate();
 
     void setTextureDirty() {
@@ -155,13 +156,13 @@
     Vector<Font*> mActiveFonts;
 
     CacheTexture* mCurrentCacheTexture;
-    CacheTexture* mLastCacheTexture;
 
     bool mUploadTexture;
 
     // Pointer to vertex data to speed up frame to frame work
     float* mTextMesh;
     uint32_t mCurrentQuadIndex;
+    uint32_t mLastQuadIndex;
     uint32_t mMaxNumberOfQuads;
 
     uint32_t mIndexBufferID;
@@ -174,6 +175,10 @@
 
     bool mLinearFiltering;
 
+    Vector<uint16_t*> mDrawOffsets;
+    Vector<uint32_t> mDrawCounts;
+    Vector<CacheTexture*> mDrawCacheTextures;
+
     /** We should consider multi-threading this code or using Renderscript **/
     static void computeGaussianWeights(float* weights, int32_t radius);
     static void horizontalBlur(float* weights, int32_t radius, const uint8_t *source, uint8_t *dest,