Revert "Add a requiresVertexShader method to GrGLEffect"

This reverts commit 1a30a3af805b7ea688d4a0f0bfe373c204085a27. We're
going to take a different direction for vertexless shaders.

R=bsalomon@google.com

Author: cdalton@nvidia.com

Review URL: https://codereview.chromium.org/23464082

git-svn-id: http://skia.googlecode.com/svn/trunk@11521 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/gl/GrGLShaderBuilder.cpp b/src/gpu/gl/GrGLShaderBuilder.cpp
index f73520c..d11394a 100644
--- a/src/gpu/gl/GrGLShaderBuilder.cpp
+++ b/src/gpu/gl/GrGLShaderBuilder.cpp
@@ -94,7 +94,7 @@
 GrGLShaderBuilder::GrGLShaderBuilder(const GrGLContextInfo& ctxInfo,
                                      GrGLUniformManager& uniformManager,
                                      const GrGLProgramDesc& desc,
-                                     bool hasVertexShaderEffects)
+                                     bool needsVertexShader)
     : fUniforms(kVarsPerBlock)
     , fCtxInfo(ctxInfo)
     , fUniformManager(uniformManager)
@@ -106,8 +106,9 @@
 
     const GrGLProgramDesc::KeyHeader& header = desc.getHeader();
 
-    // TODO: go vertexless when possible.
-    fVertexBuilder.reset(SkNEW_ARGS(VertexBuilder, (this, desc)));
+    if (needsVertexShader) {
+        fVertexBuilder.reset(SkNEW_ARGS(VertexBuilder, (this, desc)));
+    }
 
     // Emit code to read the dst copy textue if necessary.
     if (kNoDstRead_DstReadKey != header.fDstReadKey &&
@@ -216,7 +217,7 @@
 
 const char* GrGLShaderBuilder::dstColor() {
     if (fCodeStage.inStageCode()) {
-        const GrEffectRef& effect = *fCodeStage.effect();
+        const GrEffectRef& effect = *fCodeStage.effectStage()->getEffect();
         if (!effect->willReadDstColor()) {
             GrDebugCrash("GrGLEffect asked for dst color but its generating GrEffect "
                          "did not request access.");
@@ -362,7 +363,7 @@
 
 const char* GrGLShaderBuilder::fragmentPosition() {
     if (fCodeStage.inStageCode()) {
-        const GrEffectRef& effect = *fCodeStage.effect();
+        const GrEffectRef& effect = *fCodeStage.effectStage()->getEffect();
         if (!effect->willReadFragmentPosition()) {
             GrDebugCrash("GrGLEffect asked for frag position but its generating GrEffect "
                          "did not request access.");
@@ -499,23 +500,24 @@
 }
 
 void GrGLShaderBuilder::emitEffects(
-                        GrGLEffect* const glEffects[],
-                        const GrDrawEffect drawEffects[],
+                        const GrEffectStage* effectStages[],
                         const GrBackendEffectFactory::EffectKey effectKeys[],
                         int effectCnt,
                         SkString* fsInOutColor,
                         GrSLConstantVec* fsInOutColorKnownValue,
-                        SkTArray<GrGLUniformManager::UniformHandle, true>* effectSamplerHandles[]) {
+                        SkTArray<GrGLUniformManager::UniformHandle, true>* effectSamplerHandles[],
+                        GrGLEffect* glEffects[]) {
     bool effectEmitted = false;
 
     SkString inColor = *fsInOutColor;
     SkString outColor;
 
     for (int e = 0; e < effectCnt; ++e) {
-        const GrDrawEffect& drawEffect = drawEffects[e];
-        const GrEffectRef& effect = *drawEffect.effect();
+        SkASSERT(NULL != effectStages[e] && NULL != effectStages[e]->getEffect());
+        const GrEffectStage& stage = *effectStages[e];
+        const GrEffectRef& effect = *stage.getEffect();
 
-        CodeStage::AutoStageRestore csar(&fCodeStage, &effect);
+        CodeStage::AutoStageRestore csar(&fCodeStage, &stage);
 
         int numTextures = effect->numTextures();
         SkSTArray<8, GrGLShaderBuilder::TextureSampler> textureSamplers;
@@ -524,9 +526,11 @@
             textureSamplers[t].init(this, &effect->textureAccess(t), t);
             effectSamplerHandles[e]->push_back(textureSamplers[t].fSamplerUniform);
         }
+        GrDrawEffect drawEffect(stage, fVertexBuilder.get()
+                                       && fVertexBuilder->hasExplicitLocalCoords());
 
-        int numAttributes = drawEffect.getVertexAttribIndexCount();
-        const int* attributeIndices = drawEffect.getVertexAttribIndices();
+        int numAttributes = stage.getVertexAttribIndexCount();
+        const int* attributeIndices = stage.getVertexAttribIndices();
         SkSTArray<GrEffect::kMaxVertexAttribs, SkString> attributeNames;
         for (int a = 0; a < numAttributes; ++a) {
             // TODO: Make addAttribute mangle the name.
@@ -538,6 +542,8 @@
                                                attributeName);
         }
 
+        glEffects[e] = effect->getFactory().createGLInstance(drawEffect);
+
         if (kZeros_GrSLConstantVec == *fsInOutColorKnownValue) {
             // Effects have no way to communicate zeros, they treat an empty string as ones.
             this->nameVariable(&inColor, '\0', "input");