Fix issues from recent glyph caching change

There were 2 issues remaining after a recent change to support
glyph caching from multiple textures:
- memory in the GPU for all textures was being allocated automatically.
This is now lazy, being allocated only when those textures are first
needed.
- filtering (applied when a rendered object is transformed) was ignoring
the new multiple-texture structure. Filtering should be applied correctly
whenever we change textures.

Change-Id: I5c8eb8d46c73cd01782a353fc79b11cacc2146ab
diff --git a/libs/hwui/FontRenderer.h b/libs/hwui/FontRenderer.h
index b34fdfa..9f32747 100644
--- a/libs/hwui/FontRenderer.h
+++ b/libs/hwui/FontRenderer.h
@@ -59,7 +59,8 @@
 public:
     CacheTexture(){}
     CacheTexture(uint8_t* texture, GLuint textureId, uint16_t width, uint16_t height) :
-        mTexture(texture), mTextureId(textureId), mWidth(width), mHeight(height) {}
+        mTexture(texture), mTextureId(textureId), mWidth(width), mHeight(height),
+        mLinearFiltering(false) {}
     ~CacheTexture() {
         if (mTexture != NULL) {
             delete[] mTexture;
@@ -73,6 +74,7 @@
     GLuint mTextureId;
     uint16_t mWidth;
     uint16_t mHeight;
+    bool mLinearFiltering;
 };
 
 class CacheTextureLine {
@@ -249,7 +251,8 @@
 
     GLuint getTexture(bool linearFiltering = false) {
         checkInit();
-        if (linearFiltering != mLinearFiltering) {
+        if (linearFiltering != mCurrentCacheTexture->mLinearFiltering) {
+            mCurrentCacheTexture->mLinearFiltering = linearFiltering;
             mLinearFiltering = linearFiltering;
             const GLenum filtering = linearFiltering ? GL_LINEAR : GL_NEAREST;
 
@@ -282,7 +285,7 @@
 
     const uint8_t* mGammaTable;
 
-    uint8_t* allocateTextureMemory(int width, int height);
+    void allocateTextureMemory(CacheTexture* cacheTexture);
     void initTextTexture();
     CacheTexture *createCacheTexture(int width, int height, bool allocate);
     void cacheBitmap(const SkGlyph& glyph, CachedGlyphInfo* cachedGlyph,
@@ -318,7 +321,6 @@
     CacheTexture* mCacheTexture256;
     CacheTexture* mCacheTexture512;
 
-
     void checkTextureUpdate();
     bool mUploadTexture;