Enforce maximum texture size.

When an app tries to render a bitmap or path larger than the GPU's maximum
texture size, the drawing command is ignored and a warning is logged. This
change also makes texture drawing more robust by catching potential errors
during texture creation.

This change also fixes a crash in the FontRenderer. The destructor would
sometimes try to free an uninitialized array.

Change-Id: I95ae0939c52192d97b340aa02417bf6d0c962c57
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index db8c863..5d30b1a 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -436,6 +436,7 @@
     }
 
     const Texture* texture = mTextureCache.get(bitmap);
+    if (!texture) return;
     const AutoTexture autoCleanup(texture);
 
     drawTextureRect(left, top, right, bottom, texture, paint);
@@ -451,6 +452,7 @@
     }
 
     const Texture* texture = mTextureCache.get(bitmap);
+    if (!texture) return;
     const AutoTexture autoCleanup(texture);
 
     drawTextureRect(r.left, r.top, r.right, r.bottom, texture, paint);
@@ -465,6 +467,7 @@
     }
 
     const Texture* texture = mTextureCache.get(bitmap);
+    if (!texture) return;
     const AutoTexture autoCleanup(texture);
 
     const float width = texture->width;
@@ -489,6 +492,7 @@
     }
 
     const Texture* texture = mTextureCache.get(bitmap);
+    if (!texture) return;
     const AutoTexture autoCleanup(texture);
 
     int alpha;
@@ -617,6 +621,7 @@
     glActiveTexture(gTextureUnits[textureUnit]);
 
     const PathTexture* texture = mPathCache.get(path, paint);
+    if (!texture) return;
     const AutoTexture autoCleanup(texture);
 
     int alpha;