Reland r6233 with fix for config conversion texture matrices.

git-svn-id: http://skia.googlecode.com/svn/trunk@6238 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/effects/GrSingleTextureEffect.cpp b/src/gpu/effects/GrSingleTextureEffect.cpp
index 8866153..0f3b614 100644
--- a/src/gpu/effects/GrSingleTextureEffect.cpp
+++ b/src/gpu/effects/GrSingleTextureEffect.cpp
@@ -7,6 +7,7 @@
 
 #include "effects/GrSingleTextureEffect.h"
 #include "gl/GrGLEffect.h"
+#include "gl/GrGLEffectMatrix.h"
 #include "gl/GrGLSL.h"
 #include "gl/GrGLTexture.h"
 #include "GrTBackendEffectFactory.h"
@@ -16,25 +17,43 @@
 public:
     GrGLSingleTextureEffect(const GrBackendEffectFactory& factory, const GrEffect&)
     : INHERITED (factory) {
+        fRequiresTextureMatrix = false;
     }
 
     virtual void emitCode(GrGLShaderBuilder* builder,
                           const GrEffectStage&,
-                          EffectKey,
+                          EffectKey key,
                           const char* vertexCoords,
                           const char* outputColor,
                           const char* inputColor,
                           const TextureSamplerArray& samplers) SK_OVERRIDE {
-
+        const char* coordName;
+        GrSLType coordType = fEffectMatrix.emitCode(builder, key, vertexCoords, &coordName);
         builder->fFSCode.appendf("\t%s = ", outputColor);
-        builder->appendTextureLookupAndModulate(&builder->fFSCode, inputColor, samplers[0]);
+        builder->appendTextureLookupAndModulate(&builder->fFSCode,
+                                                inputColor,
+                                                samplers[0],
+                                                coordName,
+                                                coordType);
         builder->fFSCode.append(";\n");
     }
 
-    static inline EffectKey GenKey(const GrEffectStage&, const GrGLCaps&) { return 0; }
+    static inline EffectKey GenKey(const GrEffectStage& stage, const GrGLCaps&) {
+        const GrSingleTextureEffect& ste =
+            static_cast<const GrSingleTextureEffect&>(*stage.getEffect());
+        return GrGLEffectMatrix::GenKey(ste.getMatrix(),
+                                        stage.getCoordChangeMatrix(),
+                                        ste.texture(0));
+    }
+
+    virtual void setData(const GrGLUniformManager& uman, const GrEffectStage& stage) SK_OVERRIDE {
+        const GrSingleTextureEffect& ste =
+            static_cast<const GrSingleTextureEffect&>(*stage.getEffect());
+        fEffectMatrix.setData(uman, ste.getMatrix(), stage.getCoordChangeMatrix(), ste.texture(0));
+    }
 
 private:
-
+    GrGLEffectMatrix fEffectMatrix;
     typedef GrGLEffect INHERITED;
 };
 
@@ -43,16 +62,39 @@
 GrSingleTextureEffect::GrSingleTextureEffect(GrTexture* texture)
     : INHERITED(1)
     , fTextureAccess(texture) {
+    fMatrix.reset();
 }
 
 GrSingleTextureEffect::GrSingleTextureEffect(GrTexture* texture, bool bilerp)
     : INHERITED(1)
     , fTextureAccess(texture, bilerp) {
+    fMatrix.reset();
 }
 
 GrSingleTextureEffect::GrSingleTextureEffect(GrTexture* texture, const GrTextureParams& params)
     : INHERITED(1)
     , fTextureAccess(texture, params) {
+    fMatrix.reset();
+}
+
+GrSingleTextureEffect::GrSingleTextureEffect(GrTexture* texture, const GrMatrix& m)
+    : INHERITED(1)
+    , fTextureAccess(texture)
+    , fMatrix(m) {
+}
+
+GrSingleTextureEffect::GrSingleTextureEffect(GrTexture* texture, const GrMatrix& m, bool bilerp)
+    : INHERITED(1)
+    , fTextureAccess(texture, bilerp)
+    , fMatrix(m) {
+}
+
+GrSingleTextureEffect::GrSingleTextureEffect(GrTexture* texture,
+                                             const GrMatrix& m,
+                                             const GrTextureParams& params)
+    : INHERITED(1)
+    , fTextureAccess(texture, params)
+    , fMatrix(m) {
 }
 
 GrSingleTextureEffect::~GrSingleTextureEffect() {
@@ -76,5 +118,6 @@
                                             GrTexture* textures[]) {
     int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
                                       GrEffectUnitTest::kAlphaTextureIdx;
-    return SkNEW_ARGS(GrSingleTextureEffect, (textures[texIdx]));
+    const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random);
+    return SkNEW_ARGS(GrSingleTextureEffect, (textures[texIdx], matrix));
 }