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();
+}
+