Further reduce the number of GL commands sent to the driver

Change-Id: Id922b2a166ea4573b767c27d3195e11c70320b23
diff --git a/libs/hwui/SkiaShader.cpp b/libs/hwui/SkiaShader.cpp
index 32e7533..66993a4 100644
--- a/libs/hwui/SkiaShader.cpp
+++ b/libs/hwui/SkiaShader.cpp
@@ -20,6 +20,7 @@
 
 #include <SkMatrix.h>
 
+#include "Caches.h"
 #include "SkiaShader.h"
 #include "Texture.h"
 #include "Matrix.h"
@@ -31,12 +32,6 @@
 // Support
 ///////////////////////////////////////////////////////////////////////////////
 
-static const GLenum gTextureUnitsMap[] = {
-        GL_TEXTURE0,
-        GL_TEXTURE1,
-        GL_TEXTURE2
-};
-
 static const GLint gTileModes[] = {
         GL_CLAMP_TO_EDGE,   // == SkShader::kClamp_TileMode
         GL_REPEAT,          // == SkShader::kRepeat_Mode
@@ -129,7 +124,7 @@
 void SkiaBitmapShader::setupProgram(Program* program, const mat4& modelView,
         const Snapshot& snapshot, GLuint* textureUnit) {
     GLuint textureSlot = (*textureUnit)++;
-    glActiveTexture(gTextureUnitsMap[textureSlot]);
+    Caches::getInstance().activeTexture(textureSlot);
 
     Texture* texture = mTexture;
     mTexture = NULL;
@@ -223,7 +218,7 @@
 void SkiaLinearGradientShader::setupProgram(Program* program, const mat4& modelView,
         const Snapshot& snapshot, GLuint* textureUnit) {
     GLuint textureSlot = (*textureUnit)++;
-    glActiveTexture(gTextureUnitsMap[textureSlot]);
+    Caches::getInstance().activeTexture(textureSlot);
 
     Texture* texture = mGradientCache->get(mColors, mPositions, mCount, mTileX);
 
@@ -335,7 +330,7 @@
 void SkiaSweepGradientShader::setupProgram(Program* program, const mat4& modelView,
         const Snapshot& snapshot, GLuint* textureUnit) {
     GLuint textureSlot = (*textureUnit)++;
-    glActiveTexture(gTextureUnitsMap[textureSlot]);
+    Caches::getInstance().activeTexture(textureSlot);
 
     Texture* texture = mGradientCache->get(mColors, mPositions, mCount);