Optimize FBO drawing with regions.
This optimization is currently disabled until Launcher is
modified to take advantage of it. The optimization can be
enabled by turning on RENDER_LAYERS_AS_REGIONS in the
OpenGLRenderer.h file.

Change-Id: I2fdf59d0f4dc690a3d7f712173ab8db3848b27b1
diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h
index ca22867..c019fd1 100644
--- a/libs/hwui/Caches.h
+++ b/libs/hwui/Caches.h
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef ANDROID_UI_CACHES_H
-#define ANDROID_UI_CACHES_H
+#ifndef ANDROID_HWUI_CACHES_H
+#define ANDROID_HWUI_CACHES_H
 
 #ifndef LOG_TAG
     #define LOG_TAG "OpenGLRenderer"
@@ -46,6 +46,8 @@
 
 #define REQUIRED_TEXTURE_UNITS_COUNT 3
 
+#define REGION_MESH_QUAD_COUNT 512
+
 // Generates simple and textured vertices
 #define FV(x, y, u, v) { { x, y }, { u, v } }
 
@@ -77,6 +79,7 @@
 
 class Caches: public Singleton<Caches> {
     Caches();
+    ~Caches();
 
     friend class Singleton<Caches>;
 
@@ -84,11 +87,33 @@
 
     GLuint mCurrentBuffer;
 
+    // Used to render layers
+    TextureVertex* mRegionMesh;
+    GLuint mRegionMeshIndices;
+
 public:
+    /**
+     * Binds the VBO used to render simple textured quads.
+     */
     void bindMeshBuffer();
+
+    /**
+     * Binds the specified VBO if needed.
+     */
     void bindMeshBuffer(const GLuint buffer);
+
+    /**
+     * Unbinds the VBO used to render simple textured quads.
+     */
     void unbindMeshBuffer();
 
+    /**
+     * Returns the mesh used to draw regions. Calling this method will
+     * bind a VBO of type GL_ELEMENT_ARRAY_BUFFER that contains the
+     * indices for the region mesh.
+     */
+    TextureVertex* getRegionMesh();
+
     bool blend;
     GLenum lastSrcMode;
     GLenum lastDstMode;
@@ -118,7 +143,6 @@
 }; // class Caches
 
 }; // namespace uirenderer
-
 }; // namespace android
 
-#endif // ANDROID_UI_CACHES_H
+#endif // ANDROID_HWUI_CACHES_H