Optimize state changes

Change-Id: Iae59bc8dfd6427d0967472462cc1994987092827
diff --git a/libs/hwui/Program.cpp b/libs/hwui/Program.cpp
index cb2a5fd..cbea843 100644
--- a/libs/hwui/Program.cpp
+++ b/libs/hwui/Program.cpp
@@ -26,7 +26,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 // TODO: Program instance should be created from a factory method
-Program::Program(const char* vertex, const char* fragment) {
+Program::Program(const ProgramDescription& description, const char* vertex, const char* fragment) {
     mInitialized = false;
     mHasColorUniform = false;
     mUse = false;
@@ -43,6 +43,12 @@
             glAttachShader(mProgramId, mFragmentShader);
 
             position = bindAttrib("position", kBindingPosition);
+            if (description.hasTexture || description.hasExternalTexture) {
+                texCoords = bindAttrib("texCoords", kBindingTexCoords);
+            } else {
+                texCoords = -1;
+            }
+
             glLinkProgram(mProgramId);
 
             GLint status;