Hooks up the GrCustomStage/GrGLProgramStageFactory/GrGLProgramStage
classes from r3726 so they can be used. Does not implement any actual
effect stages.

Has one large known bug: if custom stages are provided, GrSamplerState
comparisons will break; this should preserve correct drawing, but decrease
performance - among other things, we'll break draw batching. To fix this
we'll need a RTTI system for GrCustomState objects, and we'll need to change
the GrSamplerState comparison from a memcmp to something that also does a
deep type-sensitive compare of any GrCustomState objects present.

http://codereview.appspot.com/6074043/



git-svn-id: http://skia.googlecode.com/svn/trunk@3742 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index 0d8c39a..73bfa94 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -19,6 +19,7 @@
 #include "SkXfermode.h"
 
 class GrBinHashKeyBuilder;
+class GrGLProgramStage;
 
 struct ShaderCodeSegments;
 
@@ -49,6 +50,7 @@
      *  but in a separate cacheable container.
      */
     bool genProgram(const GrGLContextInfo& gl,
+                    GrCustomStage** customStages,
                     CachedData* programData) const;
 
      /**
@@ -180,6 +182,10 @@
             uint8_t fCoordMapping;  // casts to enum CoordMapping
             uint8_t fKernelWidth;
 
+            /** Non-zero if user-supplied code will write the stage's
+                contribution to the fragment shader. */
+            uint16_t fCustomStageKey;
+
             GR_STATIC_ASSERT((InConfigFlags)(uint8_t)kInConfigBitMask ==
                              kInConfigBitMask);
 
@@ -305,10 +311,12 @@
     class CachedData : public ::GrNoncopyable {
     public:
         CachedData() {
+            for (int i = 0; i < GrDrawState::kNumStages; ++i) {
+                fCustomStage[i] = NULL;
+            }
         }
 
-        ~CachedData() {
-        }
+        ~CachedData();
 
         void copyAndTakeOwnership(CachedData& other) {
             memcpy(this, &other, sizeof(*this));
@@ -340,6 +348,8 @@
         bool                        fRadial2PosRoot[GrDrawState::kNumStages];
         GrRect                      fTextureDomain[GrDrawState::kNumStages];
 
+        GrGLProgramStage*           fCustomStage[GrDrawState::kNumStages];
+
     private:
         enum Constants {
             kUniLocationPreAllocSize = 8
@@ -366,7 +376,8 @@
                       const char* fsOutColor,
                       const char* vsInCoord,
                       ShaderCodeSegments* segments,
-                      StageUniLocations* locations) const;
+                      StageUniLocations* locations,
+                      GrGLProgramStage* override) const;
 
     void genGeometryShader(const GrGLContextInfo& gl,
                            ShaderCodeSegments* segments) const;