Minimize texture binds when drawing text

When several CacheTextures are used to draw text, sort the
draw batches by texture ID to minimize state changes in the
driver.

This change also tweaks the font cache size and renames
a property that was too long to be set using setprop.

Change-Id: I0a36dfffe58c9e75dd7384592d3343c192d042b1
diff --git a/libs/hwui/FontRenderer.h b/libs/hwui/FontRenderer.h
index d0c44ef..442f4e2 100644
--- a/libs/hwui/FontRenderer.h
+++ b/libs/hwui/FontRenderer.h
@@ -28,6 +28,7 @@
 #include "font/CacheTexture.h"
 #include "font/CachedGlyphInfo.h"
 #include "font/Font.h"
+#include "utils/SortedList.h"
 #include "Matrix.h"
 #include "Properties.h"
 
@@ -180,9 +181,32 @@
 
     bool mLinearFiltering;
 
-    Vector<uint16_t*> mDrawOffsets;
-    Vector<uint32_t> mDrawCounts;
-    Vector<CacheTexture*> mDrawCacheTextures;
+    struct TextBatch {
+        TextBatch(): offset(NULL), count(0), texture(NULL) {
+        }
+
+        TextBatch(uint16_t* offset, uint32_t count, CacheTexture* texture):
+                offset(offset), count(count), texture(texture) {
+        }
+
+        static int compare(const TextBatch& lhs, const TextBatch& rhs) {
+            return lhs.texture->getTextureId() - rhs.texture->getTextureId();
+        }
+
+        friend inline int strictly_order_type(const TextBatch& lhs, const TextBatch& rhs) {
+            return compare(lhs, rhs) < 0;
+        }
+
+        friend inline int compare_type(const TextBatch& lhs, const TextBatch& rhs) {
+            return compare(lhs, rhs);
+        }
+
+        uint16_t* offset;
+        uint32_t count;
+        CacheTexture* texture;
+    };
+
+    SortedList<TextBatch> mDrawBatch;
 
     // RS constructs
     sp<RSC::RS> mRs;