Introduce Caches::bindTexture() to reduce glBindTexture calls

Change-Id: Ic345422567c020c0a9035ff51dcf2ae2a1fc59f4
diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h
index 54e4138..bd31ec3 100644
--- a/libs/hwui/Caches.h
+++ b/libs/hwui/Caches.h
@@ -55,6 +55,7 @@
 // Globals
 ///////////////////////////////////////////////////////////////////////////////
 
+// GL ES 2.0 defines that at least 16 texture units must be supported
 #define REQUIRED_TEXTURE_UNITS_COUNT 3
 
 #define REGION_MESH_QUAD_COUNT 512
@@ -79,6 +80,7 @@
 static const GLsizei gVertexAALengthOffset = 3 * sizeof(float);
 static const GLsizei gMeshCount = 4;
 
+// Must define as many texture units as specified by REQUIRED_TEXTURE_UNITS_COUNT
 static const GLenum gTextureUnits[] = {
     GL_TEXTURE0,
     GL_TEXTURE1,
@@ -223,6 +225,22 @@
     void activeTexture(GLuint textureUnit);
 
     /**
+     * Binds the specified texture as a GL_TEXTURE_2D texture.
+     */
+    void bindTexture(GLuint texture);
+
+    /**
+     * Binds the specified texture..
+     */
+    void bindTexture(GLenum target, GLuint texture);
+
+    /**
+     * Signals that the cache of bound textures should be cleared.
+     * Other users of the context may have altered which textures are bound.
+     */
+    void resetBoundTextures();
+
+    /**
      * Sets the scissor for the current surface.
      */
     bool setScissor(GLint x, GLint y, GLint width, GLint height);
@@ -363,6 +381,8 @@
     bool mInitialized;
 
     uint32_t mFunctorsCount;
+
+    GLuint mBoundTextures[REQUIRED_TEXTURE_UNITS_COUNT];
 }; // class Caches
 
 }; // namespace uirenderer