Don't draw entirely transparent 9patch meshes.

Change-Id: If3e62e18b8e0dbde8a22f8ede2889b86500a4dc2
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp
index 1b21aee..e1a236c 100644
--- a/libs/hwui/FontRenderer.cpp
+++ b/libs/hwui/FontRenderer.cpp
@@ -616,8 +616,8 @@
     // Remaining capacity is measured in %
     uint32_t remainingCapacity = getRemainingCacheCapacity();
     uint32_t precacheIdx = 0;
-    while(remainingCapacity > 25 && precacheIdx < mLatinPrecache.size()) {
-        mCurrentFont->getCachedUTFChar(paint, (int32_t)mLatinPrecache[precacheIdx]);
+    while (remainingCapacity > 25 && precacheIdx < mLatinPrecache.size()) {
+        mCurrentFont->getCachedUTFChar(paint, (int32_t) mLatinPrecache[precacheIdx]);
         remainingCapacity = getRemainingCacheCapacity();
         precacheIdx ++;
     }
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 97bb73f..481e2df 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -724,11 +724,13 @@
     const Patch* mesh = mCaches.patchCache.get(bitmap->width(), bitmap->height(),
             right - left, bottom - top, xDivs, yDivs, colors, width, height, numColors);
 
-    // Specify right and bottom as +1.0f from left/top to prevent scaling since the
-    // patch mesh already defines the final size
-    drawTextureMesh(left, top, left + 1.0f, top + 1.0f, texture->id, alpha / 255.0f,
-            mode, texture->blend, &mesh->vertices[0].position[0],
-            &mesh->vertices[0].texture[0], GL_TRIANGLES, mesh->verticesCount);
+    if (mesh) {
+        // Specify right and bottom as +1.0f from left/top to prevent scaling since the
+        // patch mesh already defines the final size
+        drawTextureMesh(left, top, left + 1.0f, top + 1.0f, texture->id, alpha / 255.0f,
+                mode, texture->blend, &mesh->vertices[0].position[0],
+                &mesh->vertices[0].texture[0], GL_TRIANGLES, mesh->verticesCount);
+    }
 }
 
 void OpenGLRenderer::drawLines(float* points, int count, const SkPaint* paint) {
diff --git a/libs/hwui/PatchCache.cpp b/libs/hwui/PatchCache.cpp
index 4762d21..0fad628 100644
--- a/libs/hwui/PatchCache.cpp
+++ b/libs/hwui/PatchCache.cpp
@@ -67,6 +67,11 @@
         }
     }
 
+    // If the 9patch is made of only transparent quads
+    if (transparentQuads == (width + 1) * (height + 1)) {
+        return NULL;
+    }
+
     const PatchDescription description(bitmapWidth, bitmapHeight,
             pixelWidth, pixelHeight, width, height, transparentQuads, colorKey);