Remove unused texture coordinate flags.

Currently we support 5 texture stages, each with 5 possible texture coordinate attributes.
However, we only ever use one explicit texture coordinate. This change removes all but one 
(now named just "aTexCoord") of the possible explicit texture coordinates.

Review URL: https://codereview.appspot.com/7308094/


git-svn-id: http://skia.googlecode.com/svn/trunk@7737 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index a5014a6..8620c5c 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -25,19 +25,14 @@
 
 SK_CONF_DECLARE(bool, c_PrintShaders, "gpu.printShaders", false, "Print the source code for all shaders generated.");
 
+#define TEX_ATTR_NAME "aTexCoord"
 #define COL_ATTR_NAME "aColor"
 #define COV_ATTR_NAME "aCoverage"
 #define EDGE_ATTR_NAME "aEdge"
 
 namespace {
-inline void tex_attr_name(int coordIdx, SkString* s) {
-    *s = "aTexCoord";
-    s->appendS32(coordIdx);
-}
-
 inline const char* declared_color_output_name() { return "fsColorOut"; }
 inline const char* dual_source_output_name() { return "dualSourceOut"; }
-
 }
 
 void GrGLProgram::BuildDesc(const GrDrawState& drawState,
@@ -731,14 +726,10 @@
     }
 
     // add texture coordinates that are used to the list of vertex attr decls
-    SkString texCoordAttrs[GrDrawState::kMaxTexCoords];
-    for (int t = 0; t < GrDrawState::kMaxTexCoords; ++t) {
-        if (GrDrawState::VertexUsesTexCoordIdx(t, layout)) {
-            tex_attr_name(t, texCoordAttrs + t);
-            builder.fVSAttrs.push_back().set(kVec2f_GrSLType,
-                GrGLShaderVar::kAttribute_TypeModifier,
-                texCoordAttrs[t].c_str());
-        }
+    if (GrDrawState::VertexUsesTexCoords(layout)) {
+        builder.fVSAttrs.push_back().set(kVec2f_GrSLType,
+            GrGLShaderVar::kAttribute_TypeModifier,
+            TEX_ATTR_NAME);
     }
 
     ///////////////////////////////////////////////////////////////////////////
@@ -757,13 +748,11 @@
 
                 const char* inCoords;
                 // figure out what our input coords are
-                int tcIdx = GrDrawState::VertexTexCoordsForStage(s, layout);
-                if (tcIdx < 0) {
+                if (!GrDrawState::StageUsesTexCoords(layout, s)) {
                     inCoords = builder.positionAttribute().c_str();
                 } else {
                     // must have input tex coordinates if stage is enabled.
-                    GrAssert(texCoordAttrs[tcIdx].size());
-                    inCoords = texCoordAttrs[tcIdx].c_str();
+                    inCoords = TEX_ATTR_NAME;
                 }
 
                 builder.setCurrentStage(s);
@@ -853,15 +842,12 @@
 
                     const char* inCoords;
                     // figure out what our input coords are
-                    int tcIdx =
-                        GrDrawState::VertexTexCoordsForStage(s, layout);
-                    if (tcIdx < 0) {
+                    if (!GrDrawState::StageUsesTexCoords(layout, s)) {
                         inCoords = builder.positionAttribute().c_str();
                     } else {
                         // must have input tex coordinates if stage is
                         // enabled.
-                        GrAssert(texCoordAttrs[tcIdx].size());
-                        inCoords = texCoordAttrs[tcIdx].c_str();
+                        inCoords = TEX_ATTR_NAME;
                     }
 
                     // stages don't know how to deal with a scalar input. (Maybe they should. We
@@ -945,7 +931,6 @@
     }
 
     if (!this->bindOutputsAttribsAndLinkProgram(builder,
-                                                texCoordAttrs,
                                                 isColorDeclared,
                                                 dualSourceOutputWritten)) {
         return false;
@@ -959,7 +944,6 @@
 }
 
 bool GrGLProgram::bindOutputsAttribsAndLinkProgram(const GrGLShaderBuilder& builder,
-                                                   SkString texCoordAttrNames[],
                                                    bool bindColorOut,
                                                    bool bindDualSrcOut) {
     GL_CALL_RET(fProgramID, CreateProgram());
@@ -984,14 +968,7 @@
     GL_CALL(BindAttribLocation(fProgramID,
                                PositionAttributeIdx(),
                                builder.positionAttribute().c_str()));
-    for (int t = 0; t < GrDrawState::kMaxTexCoords; ++t) {
-        if (texCoordAttrNames[t].size()) {
-            GL_CALL(BindAttribLocation(fProgramID,
-                                       TexCoordAttributeIdx(t),
-                                       texCoordAttrNames[t].c_str()));
-        }
-    }
-
+    GL_CALL(BindAttribLocation(fProgramID, TexCoordAttributeIdx(), TEX_ATTR_NAME));
     GL_CALL(BindAttribLocation(fProgramID, ColorAttributeIdx(), COL_ATTR_NAME));
     GL_CALL(BindAttribLocation(fProgramID, CoverageAttributeIdx(), COV_ATTR_NAME));
     GL_CALL(BindAttribLocation(fProgramID, EdgeAttributeIdx(), EDGE_ATTR_NAME));