Removing remnants of GrGLEffect.

Bug: http://code.google.com/p/skia/issues/detail?id=264
Code review: http://codereview.appspot.com/4517073/



git-svn-id: http://skia.googlecode.com/svn/trunk@1350 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/src/GrGLEffect.h b/gpu/src/GrGLEffect.h
deleted file mode 100644
index ef00df8..0000000
--- a/gpu/src/GrGLEffect.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-    Copyright 2011 Google Inc.
-
-    Licensed under the Apache License, Version 2.0 (the "License");
-    you may not use this file except in compliance with the License.
-    You may obtain a copy of the License at
-
-         http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
- */
-
-#ifndef GrGLEffect_DEFINED
-#define GrGLEffect_DEFINED
-
-#include "GrGLInterface.h"
-#include "GrStringBuilder.h"
-
-class GrEffect;
-
-struct ShaderCodeSegments {
-    GrStringBuilder fVSUnis;
-    GrStringBuilder fVSAttrs;
-    GrStringBuilder fVaryings;
-    GrStringBuilder fFSUnis;
-    GrStringBuilder fVSCode;
-    GrStringBuilder fFSCode;
-};
-
-/**
- * This class is currently a stub.  This will be a base class for "effects", 
- * which extend the data model of GrPaint and extend the capability of
- * GrGLProgram in a modular fashion.
- */
-class GrGLEffect {
-protected:
-    GrGLEffect(GrEffect* effect) {}
-public:    
-    virtual ~GrGLEffect() {}
-    static GrGLEffect* Create(GrEffect* effect) { return NULL; }
-    void genShaderCode(ShaderCodeSegments* segments) {}
-    bool doGLSetup(GrPrimitiveType type, GrGLint program) { return true; }
-    bool doGLPost() { return true; }
-    void buildKey(GrBinHashKeyBuilder& key) const {}
-    GrGLEffect* nextEffect() { return NULL; }
-};
-
-#endif
diff --git a/gpu/src/GrGLProgram.cpp b/gpu/src/GrGLProgram.cpp
index bd95f3c..01a39b9 100644
--- a/gpu/src/GrGLProgram.cpp
+++ b/gpu/src/GrGLProgram.cpp
@@ -18,7 +18,6 @@
 
 #include "GrBinHashKey.h"
 #include "GrGLConfig.h"
-#include "GrGLEffect.h"
 #include "GrMemory.h"
 
 #include "SkXfermode.h"
@@ -140,9 +139,6 @@
 }
 
 GrGLProgram::GrGLProgram() {
-    for(int stage = 0; stage < GrDrawTarget::kNumStages; ++stage) {
-        fStageEffects[stage] = NULL;
-    }
 }
 
 GrGLProgram::~GrGLProgram() {
@@ -151,50 +147,6 @@
 void GrGLProgram::buildKey(GrBinHashKeyBuilder& key) const {
     // Add stage configuration to the key
     key.keyData(reinterpret_cast<const uint8_t*>(&fProgramDesc), sizeof(ProgramDesc));
-
-    for(int stage = 0; stage < GrDrawTarget::kNumStages; ++stage) {
-        // First pass: count effects and write the count to the key.
-        // This may seem like  we are adding redundant data to the
-        // key, but in ensures the one key cannot be a prefix of
-        // another key, or identical to the key of a different program.
-        GrGLEffect* currentEffect = fStageEffects[stage];
-        uint8_t effectCount = 0;
-        while (currentEffect) {
-            GrAssert(effectCount < 255); // overflow detection
-            ++effectCount;
-            currentEffect = currentEffect->nextEffect();
-        }
-        key.keyData(reinterpret_cast<const uint8_t*>(&effectCount), sizeof(uint8_t));
-
-        // Second pass: continue building key using the effects
-        currentEffect = fStageEffects[stage];
-        while (currentEffect) {
-            fStageEffects[stage]->buildKey(key);
-        }
-    }
-}
-
-bool GrGLProgram::doGLSetup(GrPrimitiveType type, 
-                            GrGLProgram::CachedData* programData) const {
-    for (int stage = 0; stage < GrDrawTarget::kNumStages; ++stage) {
-        GrGLEffect* effect = fStageEffects[stage];
-        if (effect) {
-            if (!effect->doGLSetup(type, programData->fProgramID)) {
-                return false;
-            }
-        }
-    }
-
-    return true;
-}
-
-void GrGLProgram::doGLPost() const {
-    for (int stage = 0; stage < GrDrawTarget::kNumStages; ++stage) {
-        GrGLEffect* effect = fStageEffects[stage];
-        if (effect) {
-            effect->doGLPost(); 
-        }    
-    }
 }
 
 // assigns modulation of two vars to an output var
@@ -1107,9 +1059,5 @@
     } else {
         segments->fFSCode.appendf("\t%s = %s(%s, %s)%s %s;\n", fsOutColor, texFunc.c_str(), samplerName.c_str(), sampleCoords.c_str(), smear, modulate.c_str());
     }
-
-    if(fStageEffects[stageNum]) {
-        fStageEffects[stageNum]->genShaderCode(segments);
-    }
 }
 
diff --git a/gpu/src/GrGLProgram.h b/gpu/src/GrGLProgram.h
index 64d7088..e02d15b 100644
--- a/gpu/src/GrGLProgram.h
+++ b/gpu/src/GrGLProgram.h
@@ -24,8 +24,15 @@
 #include "SkXfermode.h"
 
 class GrBinHashKeyBuilder;
-class GrGLEffect;
-struct ShaderCodeSegments;
+
+struct ShaderCodeSegments {
+    GrStringBuilder fVSUnis;
+    GrStringBuilder fVSAttrs;
+    GrStringBuilder fVaryings;
+    GrStringBuilder fFSUnis;
+    GrStringBuilder fVSCode;
+    GrStringBuilder fFSCode;
+};
 
 /**
  * This class manages a GPU program and records per-program information.
@@ -58,18 +65,6 @@
      */
     bool genProgram(CachedData* programData) const;
 
-    /**
-     *  Routine that is called before rendering. Sets-up all the state and
-     *  other initializations required for the Gpu Program to run.
-     */
-    bool doGLSetup(GrPrimitiveType type, CachedData* programData) const;
-
-    /**
-     *  Routine that is called after rendering. Performs state restoration.
-     *  May perform secondary render passes.
-     */
-    void doGLPost() const;
-
     static int PositionAttributeIdx() { return 0; }
     static int TexCoordAttributeIdx(int tcIdx) { return 1 + tcIdx; }
     static int ColorAttributeIdx() { return 1 + GrDrawTarget::kMaxTexCoords; }
@@ -177,36 +172,15 @@
     class CachedData : public ::GrNoncopyable {
     public:
         CachedData() {
-            GR_DEBUGCODE(fEffectUniCount = 0;)
-            fEffectUniLocationsExtended = NULL;
         }
 
         ~CachedData() {
-            GrFree(fEffectUniLocationsExtended);
         }
 
         void copyAndTakeOwnership(CachedData& other) {
             memcpy(this, &other, sizeof(*this));
-            other.fEffectUniLocationsExtended = NULL; // ownership transfer
-            GR_DEBUGCODE(other.fEffectUniCount = 0;)
         }
 
-        void setEffectUniformCount(size_t effectUniforms) {
-            GR_DEBUGCODE(fEffectUniCount = effectUniforms;)
-            GrFree(fEffectUniLocationsExtended);
-            if (effectUniforms > kUniLocationPreAllocSize) {
-                fEffectUniLocationsExtended = (GrGLint*)GrMalloc(sizeof(GrGLint)*(effectUniforms-kUniLocationPreAllocSize));
-            } else {
-                fEffectUniLocationsExtended = NULL;
-            }
-        }
-
-        GrGLint&  effectUniLocation(size_t index) {
-            GrAssert(index < fEffectUniCount);
-            return (index < kUniLocationPreAllocSize) ? 
-                fEffectUniLocations[index] :
-                fEffectUniLocationsExtended[index - kUniLocationPreAllocSize];
-        }
 
     public:
 
@@ -236,13 +210,8 @@
             kUniLocationPreAllocSize = 8
         };
 
-        GrGLint     fEffectUniLocations[kUniLocationPreAllocSize];
-        GrGLint*    fEffectUniLocationsExtended;
-        GR_DEBUGCODE(size_t fEffectUniCount;)
     }; // CachedData
 
-    GrGLEffect* fStageEffects[GrDrawTarget::kNumStages];
-
 private:
     enum {
         kUseUniform = 2000
diff --git a/gpu/src/GrGpuGLShaders.cpp b/gpu/src/GrGpuGLShaders.cpp
index bcf29ae..08845a9 100644
--- a/gpu/src/GrGpuGLShaders.cpp
+++ b/gpu/src/GrGpuGLShaders.cpp
@@ -15,7 +15,6 @@
  */
 
 #include "GrBinHashKey.h"
-#include "GrGLEffect.h"
 #include "GrGLProgram.h"
 #include "GrGpuGLShaders.h"
 #include "GrGpuVertex.h"
@@ -534,10 +533,6 @@
         fHWProgramID = fProgramData->fProgramID;
     }
 
-    if (!fCurrentProgram.doGLSetup(type, fProgramData)) {
-        return false;
-    }
-
     this->flushColor();
 
     GrMatrix* currViewMatrix;
@@ -568,7 +563,6 @@
 }
 
 void GrGpuGLShaders::postDraw() {
-    fCurrentProgram.doGLPost();
 }
 
 void GrGpuGLShaders::setupGeometry(int* startVertex,
@@ -774,18 +768,10 @@
             } else {
                 stage.fModulation = GrGLProgram::ProgramDesc::StageDesc::kColor_Modulation;
             }
-
-            if (fCurrDrawState.fEffects[s]) {
-                fCurrentProgram.fStageEffects[s] = GrGLEffect::Create(fCurrDrawState.fEffects[s]);
-            } else {
-                delete fCurrentProgram.fStageEffects[s];
-                fCurrentProgram.fStageEffects[s] = NULL;
-            }
         } else {
             stage.fOptFlags     = 0;
             stage.fCoordMapping = (GrGLProgram::ProgramDesc::StageDesc::CoordMapping)0;
             stage.fModulation   = (GrGLProgram::ProgramDesc::StageDesc::Modulation)0;
-            fCurrentProgram.fStageEffects[s] = NULL;
         }
     }
 }