Create GL implementation for GrSingleTextureEffect, use it instead of GrPaint::setTexture()
or GrDrawState::setTexture() in GrContext.cpp

http://codereview.appspot.com/6399053/



git-svn-id: http://skia.googlecode.com/svn/trunk@4677 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/effects/GrSingleTextureEffect.cpp b/src/gpu/effects/GrSingleTextureEffect.cpp
index a373ebe..d8b90a1 100644
--- a/src/gpu/effects/GrSingleTextureEffect.cpp
+++ b/src/gpu/effects/GrSingleTextureEffect.cpp
@@ -6,8 +6,39 @@
  */
 
 #include "effects/GrSingleTextureEffect.h"
+#include "gl/GrGLProgramStage.h"
+#include "gl/GrGLSL.h"
+#include "gl/GrGLTexture.h"
+#include "GrProgramStageFactory.h"
 #include "GrTexture.h"
 
+// For brevity, and these definitions are likely to move to a different class soon.
+typedef GrGLShaderBuilder::UniformHandle UniformHandle;
+static const UniformHandle kInvalidUniformHandle = GrGLShaderBuilder::kInvalidUniformHandle;
+
+class GrGLSingleTextureEffect : public GrGLProgramStage {
+public:
+    GrGLSingleTextureEffect(const GrProgramStageFactory& factory,
+                            const GrCustomStage& stage) : INHERITED (factory) { }
+
+    virtual void emitVS(GrGLShaderBuilder* builder,
+                        const char* vertexCoords) SK_OVERRIDE { }
+    virtual void emitFS(GrGLShaderBuilder* builder,
+                        const char* outputColor,
+                        const char* inputColor,
+                        const char* samplerName) SK_OVERRIDE {
+        builder->emitDefaultFetch(outputColor, samplerName);
+    }
+
+    static inline StageKey GenKey(const GrCustomStage&) { return 0; }
+
+private:
+
+    typedef GrGLProgramStage INHERITED;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+
 GrSingleTextureEffect::GrSingleTextureEffect(GrTexture* texture)
     : fTexture (texture) {
     SkSafeRef(fTexture);
@@ -26,4 +57,8 @@
     return fTexture;
 }
 
+const GrProgramStageFactory& GrSingleTextureEffect::getFactory() const {
+    return GrTProgramStageFactory<GrSingleTextureEffect>::getInstance();
+}
+
 
diff --git a/src/gpu/effects/GrSingleTextureEffect.h b/src/gpu/effects/GrSingleTextureEffect.h
index 9a6bd1c..c49dac8 100644
--- a/src/gpu/effects/GrSingleTextureEffect.h
+++ b/src/gpu/effects/GrSingleTextureEffect.h
@@ -10,6 +10,11 @@
 
 #include "GrCustomStage.h"
 
+class GrGLSingleTextureEffect;
+
+/**
+ * An effect that merely blits a single texture; commonly used as a base class.
+ */
 class GrSingleTextureEffect : public GrCustomStage {
 
 public:
@@ -19,6 +24,12 @@
     virtual unsigned int numTextures() const SK_OVERRIDE;
     virtual GrTexture* texture(unsigned int index) const SK_OVERRIDE;
 
+    static const char* Name() { return "Single Texture"; }
+
+    typedef GrGLSingleTextureEffect GLProgramStage;
+
+    virtual const GrProgramStageFactory& getFactory() const SK_OVERRIDE;
+
 private:
     GrTexture* fTexture;