Re-revert r6233.
authorbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 1 Nov 2012 15:47:55 +0000 (15:47 +0000)
committerbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 1 Nov 2012 15:47:55 +0000 (15:47 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@6239 2bbb7eff-a529-9590-31e7-b0007b416f81

29 files changed:
gm/texdata.cpp
gyp/gpu.gypi
include/gpu/GrContext.h
include/gpu/GrEffectUnitTest.h
src/effects/SkBlendImageFilter.cpp
src/effects/SkColorMatrixFilter.cpp
src/effects/gradients/SkGradientShader.cpp
src/effects/gradients/SkGradientShaderPriv.h
src/effects/gradients/SkLinearGradient.cpp
src/effects/gradients/SkRadialGradient.cpp
src/effects/gradients/SkSweepGradient.cpp
src/effects/gradients/SkTwoPointConicalGradient.cpp
src/effects/gradients/SkTwoPointRadialGradient.cpp
src/gpu/GrContext.cpp
src/gpu/GrDrawState.h
src/gpu/GrEffect.cpp
src/gpu/SkGpuDevice.cpp
src/gpu/effects/GrConfigConversionEffect.cpp
src/gpu/effects/GrConfigConversionEffect.h
src/gpu/effects/GrSingleTextureEffect.cpp
src/gpu/effects/GrSingleTextureEffect.h
src/gpu/gl/GrGLEffect.cpp
src/gpu/gl/GrGLEffect.h
src/gpu/gl/GrGLEffectMatrix.cpp [deleted file]
src/gpu/gl/GrGLEffectMatrix.h [deleted file]
src/gpu/gl/GrGLProgram.cpp
src/gpu/gl/GrGLUniformManager.cpp
src/gpu/gl/GrGLUniformManager.h
tests/GLProgramsTest.cpp

index 18c600f7226ea941892f940d28f90bb759adfedf..cc3476d1f69b354831944d602e25f2862ffcf442 100644 (file)
@@ -114,7 +114,7 @@ protected:
                 tm = vm;
                 tm.postIDiv(2*S, 2*S);
                 paint.colorStage(0)->setEffect(SkNEW_ARGS(GrSingleTextureEffect,
-                                                          (texture, tm)))->unref();
+                                                          (texture)), tm)->unref();
 
                 ctx->drawRect(paint, GrRect::MakeWH(2*S, 2*S));
 
index fae91c245e7b4428e59712902dc0b65ba5ca982f..2febe4dd2f379d2f60f44e82d5993bd05aa66cf2 100644 (file)
       '<(skia_src_path)/gpu/gl/GrGLDefines.h',
       '<(skia_src_path)/gpu/gl/GrGLEffect.cpp',
       '<(skia_src_path)/gpu/gl/GrGLEffect.h',
-      '<(skia_src_path)/gpu/gl/GrGLEffectMatrix.cpp',
-      '<(skia_src_path)/gpu/gl/GrGLEffectMatrix.h',
       '<(skia_src_path)/gpu/gl/GrGLIndexBuffer.cpp',
       '<(skia_src_path)/gpu/gl/GrGLIndexBuffer.h',
       '<(skia_src_path)/gpu/gl/GrGLInterface.cpp',
index 89cd171a5c40ddaefe024a78eeb9de42fad20b45..29ac95a918956bd893e75106f23b64cd18f71c5d 100644 (file)
@@ -928,14 +928,8 @@ private:
     // for use with textures released from an GrAutoScratchTexture.
     void addExistingTextureToCache(GrTexture* texture);
 
-    bool installPMToUPMEffect(GrTexture* texture,
-                              bool swapRAndB,
-                              const GrMatrix& matrix,
-                              GrEffectStage* stage);
-    bool installUPMToPMEffect(GrTexture* texture,
-                              bool swapRAndB,
-                              const GrMatrix& matrix,
-                              GrEffectStage* stage);
+    GrEffect* createPMToUPMEffect(GrTexture* texture, bool swapRAndB);
+    GrEffect* createUPMToPMEffect(GrTexture* texture, bool swapRAndB);
 
     typedef GrRefCnt INHERITED;
 };
index 8cc2689d915b0c63592cd9f440b19b1d4300271e..427260c664e40eb98d5aa4a308810cbe4c835710 100644 (file)
 #include "GrNoncopyable.h"
 #include "SkTArray.h"
 
-class SkMatrix;
-
 namespace GrEffectUnitTest {
 // Used to access the dummy textures in TestCreate procs.
 enum {
     kSkiaPMTextureIdx = 0,
     kAlphaTextureIdx = 1,
 };
-
-/**
- * A helper for use in GrEffect::TestCreate functions.
- */
-const SkMatrix& TestMatrix(SkRandom*);
-
 }
 
 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
@@ -64,13 +56,12 @@ private:
     static GrEffectTestFactory gTestFactory;                                        \
     static GrEffect* TestCreate(SkRandom*, GrContext*, GrTexture* dummyTextures[2])
 
-/** GrEffect subclasses should insert this macro in their implementation file. They must then
+/** GrEffect subclasses should insert this macro in their implemenation file. They must then
  *  also implement this static function:
  *      GrEffect* TestCreate(SkRandom*, GrContext*, GrTexture* dummyTextures[2]);
- * dummyTextures[] are valid textures that can optionally be used to construct GrTextureAccesses.
- * The first texture has config kSkia8888_PM_GrPixelConfig and the second has
- * kAlpha_8_GrPixelConfig. TestCreate functions are also free to create additional textures using
- * the GrContext.
+ *  dummyTextures[] are valied textures that they can optionally use for their texture accesses. The
+  * first texture has config kSkia8888_PM_GrPixelConfig and the second has kAlpha_8_GrPixelConfig.
+  * TestCreate functions are also free to create additional textures using the GrContext.
  */
 #define GR_DEFINE_EFFECT_TEST(Effect)                                               \
     GrEffectTestFactory Effect :: gTestFactory(Effect :: TestCreate)
index 9ce5726892f74f70e94a7f716bb12d373cafaf84..fb0e4d089a1b04ec2c67796dce0e73bb8d705388 100644 (file)
@@ -13,7 +13,6 @@
 #include "SkGr.h"
 #include "SkGrPixelRef.h"
 #include "gl/GrGLEffect.h"
-#include "gl/GrGLEffectMatrix.h"
 #include "GrTBackendEffectFactory.h"
 #endif
 
@@ -128,19 +127,16 @@ public:
 
     static inline EffectKey GenKey(const GrEffectStage&, const GrGLCaps&);
 
-    virtual void setData(const GrGLUniformManager&, const GrEffectStage&);
-
 private:
     typedef GrGLEffect INHERITED;
     SkBlendImageFilter::Mode fMode;
-    GrGLEffectMatrix fEffectMatrix;
 };
 
 ///////////////////////////////////////////////////////////////////////////////
 
 class GrBlendEffect : public GrSingleTextureEffect {
 public:
-    GrBlendEffect(SkBlendImageFilter::Mode mode, GrTexture* foreground, const SkMatrix&);
+    GrBlendEffect(SkBlendImageFilter::Mode mode, GrTexture* foreground);
     virtual ~GrBlendEffect();
 
     virtual bool isEqual(const GrEffect&) const SK_OVERRIDE;
@@ -213,19 +209,17 @@ GrTexture* SkBlendImageFilter::onFilterImageGPU(Proxy* proxy, GrTexture* src, co
     foregroundTexMatrix.setIDiv(foreground->width(), foreground->height());
     GrPaint paint;
     paint.colorStage(0)->setEffect(
-        SkNEW_ARGS(GrSingleTextureEffect, (background.get(), backgroundTexMatrix)))->unref();
+        SkNEW_ARGS(GrSingleTextureEffect, (background.get())), backgroundTexMatrix)->unref();
     paint.colorStage(1)->setEffect(
-        SkNEW_ARGS(GrBlendEffect, (fMode, foreground.get(), foregroundTexMatrix)))->unref();
+        SkNEW_ARGS(GrBlendEffect, (fMode, foreground.get())), foregroundTexMatrix)->unref();
     context->drawRect(paint, rect);
     return dst;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 
-GrBlendEffect::GrBlendEffect(SkBlendImageFilter::Mode mode,
-                             GrTexture* foreground,
-                             const SkMatrix& matrix)
-    : INHERITED(foreground, matrix), fMode(mode) {
+GrBlendEffect::GrBlendEffect(SkBlendImageFilter::Mode mode, GrTexture* foreground)
+    : INHERITED(foreground), fMode(mode) {
 }
 
 GrBlendEffect::~GrBlendEffect() {
@@ -233,7 +227,8 @@ GrBlendEffect::~GrBlendEffect() {
 
 bool GrBlendEffect::isEqual(const GrEffect& sBase) const {
     const GrBlendEffect& s = static_cast<const GrBlendEffect&>(sBase);
-    return INHERITED::isEqual(sBase) && fMode == s.fMode;
+    return INHERITED::isEqual(sBase) &&
+           fMode == s.fMode;
 }
 
 const GrBackendEffectFactory& GrBlendEffect::getFactory() const {
@@ -246,7 +241,6 @@ GrGLBlendEffect::GrGLBlendEffect(const GrBackendEffectFactory& factory,
                                  const GrEffect& effect)
     : INHERITED(factory),
       fMode(static_cast<const GrBlendEffect&>(effect).mode()) {
-    fRequiresTextureMatrix = false;
 }
 
 GrGLBlendEffect::~GrGLBlendEffect() {
@@ -254,19 +248,16 @@ GrGLBlendEffect::~GrGLBlendEffect() {
 
 void GrGLBlendEffect::emitCode(GrGLShaderBuilder* builder,
                                const GrEffectStage&,
-                               EffectKey key,
+                               EffectKey,
                                const char* vertexCoords,
                                const char* outputColor,
                                const char* inputColor,
                                const TextureSamplerArray& samplers) {
-    const char* coords;
-    GrSLType coordsType =  fEffectMatrix.emitCode(builder, key, vertexCoords, &coords);
-
     SkString* code = &builder->fFSCode;
     const char* bgColor = inputColor;
     const char* fgColor = "fgColor";
     code->appendf("\t\tvec4 %s = ", fgColor);
-    builder->appendTextureLookup(code, samplers[0], coords, coordsType);
+    builder->appendTextureLookup(code, samplers[0]);
     code->append(";\n");
     code->appendf("\t\t%s.a = 1.0 - (1.0 - %s.a) * (1.0 - %s.b);\n", outputColor, bgColor, fgColor);
     switch (fMode) {
@@ -288,16 +279,7 @@ void GrGLBlendEffect::emitCode(GrGLShaderBuilder* builder,
     }
 }
 
-void GrGLBlendEffect::setData(const GrGLUniformManager& uman, const GrEffectStage& stage) {
-    const GrBlendEffect& blend = static_cast<const GrBlendEffect&>(*stage.getEffect());
-    fEffectMatrix.setData(uman, blend.getMatrix(), stage.getCoordChangeMatrix(), blend.texture(0));
-}
-
-GrGLEffect::EffectKey GrGLBlendEffect::GenKey(const GrEffectStage& stage, const GrGLCaps&) {
-    const GrBlendEffect& blend = static_cast<const GrBlendEffect&>(*stage.getEffect());
-    EffectKey key = 
-        GrGLEffectMatrix::GenKey(blend.getMatrix(), stage.getCoordChangeMatrix(), blend.texture(0));
-    key |= (blend.mode() << GrGLEffectMatrix::kKeyBits);
-    return key;
+GrGLEffect::EffectKey GrGLBlendEffect::GenKey(const GrEffectStage& s, const GrGLCaps&) {
+    return static_cast<const GrBlendEffect&>(*s.getEffect()).mode();
 }
 #endif
index fa724cad119474a38986a84e82836097370a3c1e..58d26735a1f809e9ba664cc4c0cffdc2e1e81117 100644 (file)
@@ -350,8 +350,6 @@ public:
         : INHERITED(factory)
         , fMatrixHandle(GrGLUniformManager::kInvalidUniformHandle)
         , fVectorHandle(GrGLUniformManager::kInvalidUniformHandle) {
-            // no texture
-            fRequiresTextureMatrix = false;
         }
 
         virtual void emitCode(GrGLShaderBuilder* builder,
index 78c7e34a74b7e1e78b83a3ce8ba9b195127e640b..60eff91d65ff63d1d9bc5141df3a2be62fa09701 100644 (file)
@@ -678,9 +678,7 @@ SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
 GrGLGradientEffect::GrGLGradientEffect(const GrBackendEffectFactory& factory)
     : INHERITED(factory)
     , fCachedYCoord(GR_ScalarMax)
-    , fFSYUni(GrGLUniformManager::kInvalidUniformHandle) {
-    fRequiresTextureMatrix = false;
-}
+    , fFSYUni(GrGLUniformManager::kInvalidUniformHandle) { }
 
 GrGLGradientEffect::~GrGLGradientEffect() { }
 
@@ -690,37 +688,13 @@ void GrGLGradientEffect::emitYCoordUniform(GrGLShaderBuilder* builder) {
 }
 
 void GrGLGradientEffect::setData(const GrGLUniformManager& uman, const GrEffectStage& stage) {
-    const GrGradientEffect& e = static_cast<const GrGradientEffect&>(*stage.getEffect());
-    const GrTexture* texture = e.texture(0);
-    fEffectMatrix.setData(uman, e.getMatrix(), stage.getCoordChangeMatrix(), texture);
-
-    GrScalar yCoord = e.getYCoord();
+    GrScalar yCoord = static_cast<const GrGradientEffect&>(*stage.getEffect()).getYCoord();
     if (yCoord != fCachedYCoord) {
         uman.set1f(fFSYUni, yCoord);
         fCachedYCoord = yCoord;
     }
 }
 
-GrGLEffect::EffectKey GrGLGradientEffect::GenMatrixKey(const GrEffectStage& s) {
-    const GrGradientEffect& e = static_cast<const GrGradientEffect&>(*s.getEffect());
-    const GrTexture* texture = e.texture(0);
-    return GrGLEffectMatrix::GenKey(e.getMatrix(), s.getCoordChangeMatrix(), texture); 
-}
-
-void GrGLGradientEffect::setupMatrix(GrGLShaderBuilder* builder,
-                                     EffectKey key,
-                                     const char* vertexCoords,
-                                     const char** fsCoordName,
-                                     const char** vsVaryingName,
-                                     GrSLType* vsVaryingType) {
-    fEffectMatrix.emitCodeMakeFSCoords2D(builder,
-                                         key & kMatrixKeyMask,
-                                         vertexCoords,
-                                         fsCoordName,
-                                         vsVaryingName,
-                                         vsVaryingType);
-}
-
 void GrGLGradientEffect::emitColorLookup(GrGLShaderBuilder* builder,
                                          const char* gradientTValue,
                                          const char* outputColor,
@@ -740,7 +714,6 @@ void GrGLGradientEffect::emitColorLookup(GrGLShaderBuilder* builder,
 
 GrGradientEffect::GrGradientEffect(GrContext* ctx,
                                    const SkGradientShaderBase& shader,
-                                   const SkMatrix& matrix,
                                    SkShader::TileMode tileMode)
     : INHERITED(1) {
     // TODO: check for simple cases where we don't need a texture:
@@ -748,8 +721,6 @@ GrGradientEffect::GrGradientEffect(GrContext* ctx,
     //shader.asAGradient(&info);
     //if (info.fColorCount == 2) { ...
 
-    fMatrix = matrix;
-
     SkBitmap bitmap;
     shader.getGradientTableBitmap(&bitmap);
 
index 24379110ee0fd78474a8a4d5af8b0b6fe08d9c45..9f14e7f727bbcc33fed83ac213311e1973f44ffc 100644 (file)
@@ -193,13 +193,12 @@ private:
 #if SK_SUPPORT_GPU
 
 #include "gl/GrGLEffect.h"
-#include "gl/GrGLEffectMatrix.h"
 
 class GrEffectStage;
 class GrBackendEffectFactory;
 
 /*
- * The interpretation of the texture matrix depends on the sample mode. The
+ * The intepretation of the texture matrix depends on the sample mode. The
  * texture matrix is applied both when the texture coordinates are explicit
  * and  when vertex positions are used as texture  coordinates. In the latter
  * case the texture matrix is applied to the pre-view-matrix position
@@ -229,7 +228,6 @@ public:
 
     GrGradientEffect(GrContext* ctx,
                      const SkGradientShaderBase& shader,
-                     const SkMatrix& matrix,
                      SkShader::TileMode tileMode);
 
     virtual ~GrGradientEffect();
@@ -238,12 +236,11 @@ public:
 
     bool useAtlas() const { return SkToBool(-1 != fRow); }
     GrScalar getYCoord() const { return fYCoord; };
-    const SkMatrix& getMatrix() const { return fMatrix;}
 
     virtual bool isEqual(const GrEffect& effect) const SK_OVERRIDE {
         const GrGradientEffect& s = static_cast<const GrGradientEffect&>(effect);
         return INHERITED::isEqual(effect) && this->useAtlas() == s.useAtlas() &&
-               fYCoord == s.getYCoord() && fMatrix.cheapEqualTo(s.getMatrix());
+               fYCoord == s.getYCoord();
     }
 
 protected:
@@ -266,7 +263,6 @@ private:
     GrScalar fYCoord;
     GrTextureStripAtlas* fAtlas;
     int fRow;
-    SkMatrix fMatrix;
 
     typedef GrEffect INHERITED;
 
@@ -283,36 +279,6 @@ public:
     virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVERRIDE;
 
 protected:
-    /**
-     * Subclasses must reserve the lower kMatrixKeyBitCnt of their key for use by
-     * GrGLGradientEffect.
-     */
-    enum {
-        kMatrixKeyBitCnt = GrGLEffectMatrix::kKeyBits,
-        kMatrixKeyMask = (1 << kMatrixKeyBitCnt) - 1,
-    };
-
-    /**
-     * Subclasses must call this. It will return a value restricted to the lower kMatrixKeyBitCnt
-     * bits.
-     */
-    static EffectKey GenMatrixKey(const GrEffectStage& s);
-
-    /**
-     * Inserts code to implement the GrGradientEffect's matrix. This should be called before a
-     * subclass emits its own code. The name of the 2D coords is output via fsCoordName and already
-     * incorporates any perspective division. The caller can also optionally retrieve the name of
-     * the varying inserted in the VS and its type, which may be either vec2f or vec3f depending
-     * upon whether the matrix has perspective or not. It is not necessary to mask the key before
-     * calling.
-     */
-    void setupMatrix(GrGLShaderBuilder* builder,
-                     EffectKey key,
-                     const char* vertexCoords,
-                     const char** fsCoordName,
-                     const char** vsVaryingName = NULL,
-                     GrSLType* vsVaryingType = NULL);
-
     // Emits the uniform used as the y-coord to texture samples in derived classes. Subclasses
     // should call this method from their emitCode().
     void emitYCoordUniform(GrGLShaderBuilder* builder);
@@ -329,7 +295,6 @@ protected:
 private:
     GrScalar fCachedYCoord;
     GrGLUniformManager::UniformHandle fFSYUni;
-    GrGLEffectMatrix fEffectMatrix;
 
     typedef GrGLEffect INHERITED;
 };
index 71614505a1c5c604aec293b13bb57f2eeebded29..d9576565b5883c02c167df1c3925a7d7b68af67d 100644 (file)
@@ -495,9 +495,7 @@ public:
                           const char* inputColor,
                           const TextureSamplerArray&) SK_OVERRIDE;
 
-    static EffectKey GenKey(const GrEffectStage& stage, const GrGLCaps&) {
-        return GenMatrixKey(stage);
-    }
+    static EffectKey GenKey(const GrEffectStage&, const GrGLCaps& caps) { return 0; }
 
 private:
 
@@ -509,11 +507,8 @@ private:
 class GrLinearGradient : public GrGradientEffect {
 public:
 
-    GrLinearGradient(GrContext* ctx,
-                     const SkLinearGradient& shader,
-                     const SkMatrix& matrix,
-                     SkShader::TileMode tm)
-        : INHERITED(ctx, shader, matrix, tm) { }
+    GrLinearGradient(GrContext* ctx, const SkLinearGradient& shader, SkShader::TileMode tm)
+        : INHERITED(ctx, shader, tm) { }
     virtual ~GrLinearGradient() { }
 
     static const char* Name() { return "Linear Gradient"; }
@@ -558,18 +553,15 @@ GrEffect* GrLinearGradient::TestCreate(SkRandom* random,
 /////////////////////////////////////////////////////////////////////
 
 void GrGLLinearGradient::emitCode(GrGLShaderBuilder* builder,
-                                  const GrEffectStage& stage,
-                                  EffectKey key,
+                                  const GrEffectStage&,
+                                  EffectKey,
                                   const char* vertexCoords,
                                   const char* outputColor,
                                   const char* inputColor,
                                   const TextureSamplerArray& samplers) {
     this->emitYCoordUniform(builder);
-    const char* coords;
-    this->setupMatrix(builder, key, vertexCoords, &coords);
     SkString t;
-    t.append(coords);
-    t.append(".x");
+    t.printf("%s.x", builder->defaultTexCoordsName());
     this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, samplers[0]);
 }
 
@@ -582,7 +574,7 @@ bool SkLinearGradient::asNewEffect(GrContext* context, GrEffectStage* stage) con
         return false;
     }
     matrix.postConcat(fPtsToUnit);
-    stage->setEffect(SkNEW_ARGS(GrLinearGradient, (context, *this, matrix, fTileMode)))->unref();
+    stage->setEffect(SkNEW_ARGS(GrLinearGradient, (context, *this, fTileMode)), matrix)->unref();
     return true;
 }
 
index 02a56da5886ba3e886b1bec1a0e0809640a2ffad..a20ea35a1a99c7c3863f51495fbb231bdba7cd41 100644 (file)
@@ -490,9 +490,7 @@ public:
                           const char* inputColor,
                           const TextureSamplerArray&) SK_OVERRIDE;
 
-    static EffectKey GenKey(const GrEffectStage& stage, const GrGLCaps&) {
-        return GenMatrixKey(stage);
-    }
+    static EffectKey GenKey(const GrEffectStage&, const GrGLCaps& caps) { return 0; }
 
 private:
 
@@ -505,11 +503,8 @@ private:
 class GrRadialGradient : public GrGradientEffect {
 public:
 
-    GrRadialGradient(GrContext* ctx,
-                     const SkRadialGradient& shader,
-                     const SkMatrix& matrix,
-                     SkShader::TileMode tm)
-        : INHERITED(ctx, shader, matrix, tm) {
+    GrRadialGradient(GrContext* ctx, const SkRadialGradient& shader, SkShader::TileMode tm)
+        : INHERITED(ctx, shader, tm) {
     }
 
     virtual ~GrRadialGradient() { }
@@ -556,18 +551,15 @@ GrEffect* GrRadialGradient::TestCreate(SkRandom* random,
 /////////////////////////////////////////////////////////////////////
 
 void GrGLRadialGradient::emitCode(GrGLShaderBuilder* builder,
-                                  const GrEffectStage& stage,
-                                  EffectKey key,
+                                  const GrEffectStage&,
+                                  EffectKey,
                                   const char* vertexCoords,
                                   const char* outputColor,
                                   const char* inputColor,
                                   const TextureSamplerArray& samplers) {
     this->emitYCoordUniform(builder);
-    const char* coords;
-    this->setupMatrix(builder, key, vertexCoords, &coords);
-    SkString t("length(");
-    t.append(coords);
-    t.append(")");
+    SkString t;
+    t.printf("length(%s.xy)", builder->defaultTexCoordsName());
     this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, samplers[0]);
 }
 
@@ -581,7 +573,7 @@ bool SkRadialGradient::asNewEffect(GrContext* context, GrEffectStage* stage) con
         return false;
     }
     matrix.postConcat(fPtsToUnit);
-    stage->setEffect(SkNEW_ARGS(GrRadialGradient, (context, *this, matrix, fTileMode)))->unref();
+    stage->setEffect(SkNEW_ARGS(GrRadialGradient, (context, *this, fTileMode)), matrix)->unref();
     return true;
 }
 
index 589cf4ad14dd04e0ccbaa1b9ac6862cd53154f0f..a783e3757c1cf9074881da01624ed3405aaffecb 100644 (file)
@@ -399,9 +399,7 @@ public:
                           const char* inputColor,
                           const TextureSamplerArray&) SK_OVERRIDE;
 
-    static EffectKey GenKey(const GrEffectStage& stage, const GrGLCaps&) {
-        return GenMatrixKey(stage);
-    }
+    static EffectKey GenKey(const GrEffectStage&, const GrGLCaps& caps) { return 0; }
 
 private:
 
@@ -415,9 +413,8 @@ class GrSweepGradient : public GrGradientEffect {
 public:
 
     GrSweepGradient(GrContext* ctx,
-                    const SkSweepGradient& shader,
-                    const SkMatrix& matrix)
-    : INHERITED(ctx, shader, matrix, SkShader::kClamp_TileMode) { }
+                    const SkSweepGradient& shader)
+    : INHERITED(ctx, shader, SkShader::kClamp_TileMode) { }
     virtual ~GrSweepGradient() { }
 
     static const char* Name() { return "Sweep Gradient"; }
@@ -460,17 +457,16 @@ GrEffect* GrSweepGradient::TestCreate(SkRandom* random,
 /////////////////////////////////////////////////////////////////////
 
 void GrGLSweepGradient::emitCode(GrGLShaderBuilder* builder,
-                                 const GrEffectStage& stage,
-                                 EffectKey key,
+                                 const GrEffectStage&,
+                                 EffectKey,
                                  const char* vertexCoords,
                                  const char* outputColor,
                                  const char* inputColor,
                                  const TextureSamplerArray& samplers) {
     this->emitYCoordUniform(builder);
-    const char* coords;
-    this->setupMatrix(builder, key, vertexCoords, &coords);
     SkString t;
-    t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5", coords, coords);
+    t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5",
+        builder->defaultTexCoordsName(), builder->defaultTexCoordsName());
     this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, samplers[0]);
 }
 
@@ -482,7 +478,7 @@ bool SkSweepGradient::asNewEffect(GrContext* context, GrEffectStage* stage) cons
         return false;
     }
     matrix.postConcat(fPtsToUnit);
-    stage->setEffect(SkNEW_ARGS(GrSweepGradient, (context, *this, matrix)))->unref();
+    stage->setEffect(SkNEW_ARGS(GrSweepGradient, (context, *this)), matrix)->unref();
     return true;
 }
 
index 41292bb43a23095f1a49e44af9a2a5d70514a933..f93f660837bcef090b1f4d1758e04e26f9b32ffe 100644 (file)
@@ -371,9 +371,8 @@ public:
 
     GrConical2Gradient(GrContext* ctx,
                        const SkTwoPointConicalGradient& shader,
-                       const SkMatrix& matrix,
                        SkShader::TileMode tm)
-        : INHERITED(ctx, shader, matrix, tm)
+        : INHERITED(ctx, shader, tm)
         , fCenterX1(shader.getCenterX1())
         , fRadius0(shader.getStartRadius())
         , fDiffRadius(shader.getDiffRadius()) { }
@@ -469,17 +468,12 @@ GrGLConical2Gradient::GrGLConical2Gradient(
 }
 
 void GrGLConical2Gradient::emitCode(GrGLShaderBuilder* builder,
-                                    const GrEffectStage& stage,
-                                    EffectKey key,
+                                    const GrEffectStage&,
+                                    EffectKey,
                                     const char* vertexCoords,
                                     const char* outputColor,
                                     const char* inputColor,
                                     const TextureSamplerArray& samplers) {
-    const char* fsCoords;
-    const char* vsCoordsVarying;
-    GrSLType coordsVaryingType;
-    this->setupMatrix(builder, key, vertexCoords, &fsCoords, &vsCoordsVarying, &coordsVaryingType);
-
     this->emitYCoordUniform(builder);
     // 2 copies of uniform array, 1 for each of vertex & fragment shader,
     // to work around Xoom bug. Doesn't seem to cause performance decrease
@@ -491,7 +485,7 @@ void GrGLConical2Gradient::emitCode(GrGLShaderBuilder* builder,
 
     // For radial gradients without perspective we can pass the linear
     // part of the quadratic as a varying.
-    if (kVec2f_GrSLType == coordsVaryingType) {
+    if (!builder->defaultTextureMatrixIsPerspective()) {
         builder->addVarying(kFloat_GrSLType, "Conical2BCoeff",
                             &fVSVaryingName, &fFSVaryingName);
     }
@@ -508,11 +502,11 @@ void GrGLConical2Gradient::emitCode(GrGLShaderBuilder* builder,
 
         // For radial gradients without perspective we can pass the linear
         // part of the quadratic as a varying.
-        if (kVec2f_GrSLType == coordsVaryingType) {
+        if (!builder->defaultTextureMatrixIsPerspective()) {
             // r2Var = -2 * (r2Parm[2] * varCoord.x - r2Param[3] * r2Param[5])
             code->appendf("\t%s = -2.0 * (%s * %s.x + %s * %s);\n",
                           fVSVaryingName, p2.c_str(),
-                          vsCoordsVarying, p3.c_str(), p5.c_str());
+                          vertexCoords, p3.c_str(), p5.c_str());
         }
     }
 
@@ -544,12 +538,12 @@ void GrGLConical2Gradient::emitCode(GrGLShaderBuilder* builder,
         // If we we're able to interpolate the linear component,
         // bVar is the varying; otherwise compute it
         SkString bVar;
-        if (kVec2f_GrSLType == coordsVaryingType) {
+        if (!builder->defaultTextureMatrixIsPerspective()) {
             bVar = fFSVaryingName;
         } else {
             bVar = "b";
             code->appendf("\tfloat %s = -2.0 * (%s * %s.x + %s * %s);\n",
-                          bVar.c_str(), p2.c_str(), fsCoords,
+                          bVar.c_str(), p2.c_str(), builder->defaultTexCoordsName(),
                           p3.c_str(), p5.c_str());
         }
 
@@ -559,7 +553,7 @@ void GrGLConical2Gradient::emitCode(GrGLShaderBuilder* builder,
 
         // c = (x^2)+(y^2) - params[4]
         code->appendf("\tfloat %s = dot(%s, %s) - %s;\n", cName.c_str(),
-                      fsCoords, fsCoords,
+                      builder->defaultTexCoordsName(), builder->defaultTexCoordsName(),
                       p4.c_str());
 
         // Non-degenerate case (quadratic)
@@ -675,15 +669,7 @@ void GrGLConical2Gradient::setData(const GrGLUniformManager& uman, const GrEffec
 }
 
 GrGLEffect::EffectKey GrGLConical2Gradient::GenKey(const GrEffectStage& s, const GrGLCaps&) {
-    enum {
-        kIsDegenerate = 1 << kMatrixKeyBitCnt,
-    };
-
-    EffectKey key = GenMatrixKey(s);
-    if (static_cast<const GrConical2Gradient&>(*s.getEffect()).isDegenerate()) {
-        key |= kIsDegenerate;
-    }
-    return key;
+    return (static_cast<const GrConical2Gradient&>(*s.getEffect()).isDegenerate());
 }
 
 /////////////////////////////////////////////////////////////////////
@@ -709,7 +695,7 @@ bool SkTwoPointConicalGradient::asNewEffect(GrContext* context,
         matrix.postConcat(rot);
     }
 
-    stage->setEffect(SkNEW_ARGS(GrConical2Gradient, (context, *this, matrix, fTileMode)))->unref();
+    stage->setEffect(SkNEW_ARGS(GrConical2Gradient, (context, *this, fTileMode)), matrix)->unref();
 
     return true;
 }
index d0186291f20759d1310505420fba835d9e7cf6d9..659bce00998cce9a47f9f2779a4de3d5afe7e4d6 100644 (file)
@@ -404,11 +404,8 @@ private:
 class GrRadial2Gradient : public GrGradientEffect {
 public:
 
-    GrRadial2Gradient(GrContext* ctx,
-                      const SkTwoPointRadialGradient& shader,
-                      const SkMatrix& matrix,
-                      SkShader::TileMode tm)
-        : INHERITED(ctx, shader, matrix, tm)
+    GrRadial2Gradient(GrContext* ctx, const SkTwoPointRadialGradient& shader, SkShader::TileMode tm)
+        : INHERITED(ctx, shader, tm)
         , fCenterX1(shader.getCenterX1())
         , fRadius0(shader.getStartRadius())
         , fPosRoot(shader.getDiffRadius() < 0) { }
@@ -504,19 +501,14 @@ GrGLRadial2Gradient::GrGLRadial2Gradient(
 }
 
 void GrGLRadial2Gradient::emitCode(GrGLShaderBuilder* builder,
-                                   const GrEffectStage& stage,
-                                   EffectKey key,
+                                   const GrEffectStage&,
+                                   EffectKey,
                                    const char* vertexCoords,
                                    const char* outputColor,
                                    const char* inputColor,
                                    const TextureSamplerArray& samplers) {
 
     this->emitYCoordUniform(builder);
-    const char* fsCoords;
-    const char* vsCoordsVarying;
-    GrSLType coordsVaryingType;
-    this->setupMatrix(builder, key, vertexCoords, &fsCoords, &vsCoordsVarying, &coordsVaryingType);
-
     // 2 copies of uniform array, 1 for each of vertex & fragment shader,
     // to work around Xoom bug. Doesn't seem to cause performance decrease
     // in test apps, but need to keep an eye on it.
@@ -527,8 +519,9 @@ void GrGLRadial2Gradient::emitCode(GrGLShaderBuilder* builder,
 
     // For radial gradients without perspective we can pass the linear
     // part of the quadratic as a varying.
-    if (kVec2f_GrSLType == coordsVaryingType) {
-        builder->addVarying(kFloat_GrSLType, "Radial2BCoeff", &fVSVaryingName, &fFSVaryingName);
+    if (!builder->defaultTextureMatrixIsPerspective()) {
+        builder->addVarying(kFloat_GrSLType, "Radial2BCoeff",
+                          &fVSVaryingName, &fFSVaryingName);
     }
 
     // VS
@@ -541,11 +534,11 @@ void GrGLRadial2Gradient::emitCode(GrGLShaderBuilder* builder,
 
         // For radial gradients without perspective we can pass the linear
         // part of the quadratic as a varying.
-        if (kVec2f_GrSLType == coordsVaryingType) {
+        if (!builder->defaultTextureMatrixIsPerspective()) {
             // r2Var = 2 * (r2Parm[2] * varCoord.x - r2Param[3])
             code->appendf("\t%s = 2.0 *(%s * %s.x - %s);\n",
                           fVSVaryingName, p2.c_str(),
-                          vsCoordsVarying, p3.c_str());
+                          vertexCoords, p3.c_str());
         }
     }
 
@@ -572,19 +565,20 @@ void GrGLRadial2Gradient::emitCode(GrGLShaderBuilder* builder,
         // If we we're able to interpolate the linear component,
         // bVar is the varying; otherwise compute it
         SkString bVar;
-        if (kVec2f_GrSLType == coordsVaryingType) {
+        if (!builder->defaultTextureMatrixIsPerspective()) {
             bVar = fFSVaryingName;
         } else {
             bVar = "b";
             code->appendf("\tfloat %s = 2.0 * (%s * %s.x - %s);\n",
-                          bVar.c_str(), p2.c_str(), fsCoords, p3.c_str());
+                          bVar.c_str(), p2.c_str(),
+                          builder->defaultTexCoordsName(), p3.c_str());
         }
 
         // c = (x^2)+(y^2) - params[4]
         code->appendf("\tfloat %s = dot(%s, %s) - %s;\n",
                       cName.c_str(),
-                      fsCoords,
-                      fsCoords,
+                      builder->defaultTexCoordsName(),
+                      builder->defaultTexCoordsName(),
                       p4.c_str());
 
         // If we aren't degenerate, emit some extra code, and accept a slightly
@@ -649,15 +643,7 @@ void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman, const GrEffect
 }
 
 GrGLEffect::EffectKey GrGLRadial2Gradient::GenKey(const GrEffectStage& s, const GrGLCaps&) {
-    enum {
-        kIsDegenerate = 1 << kMatrixKeyBitCnt,
-    };
-
-    EffectKey key = GenMatrixKey(s);
-    if (static_cast<const GrRadial2Gradient&>(*s.getEffect()).isDegenerate()) {
-        key |= kIsDegenerate;
-    }
-    return key;
+    return (static_cast<const GrRadial2Gradient&>(*s.getEffect()).isDegenerate());
 }
 
 /////////////////////////////////////////////////////////////////////
@@ -681,7 +667,7 @@ bool SkTwoPointRadialGradient::asNewEffect(GrContext* context,
         matrix.postConcat(rot);
     }
 
-    stage->setEffect(SkNEW_ARGS(GrRadial2Gradient, (context, *this, matrix, fTileMode)))->unref();
+    stage->setEffect(SkNEW_ARGS(GrRadial2Gradient, (context, *this, fTileMode)), matrix)->unref();
     return true;
 }
 
index 2a39fad722a7eec4b29f8d6e495684ebfde44d7d..f7f6b0c0b7b131018558d88503c8e2b4b3e67742 100644 (file)
@@ -1307,44 +1307,35 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
         ast.set(this, desc, match);
         GrTexture* texture = ast.texture();
         if (texture) {
-            GrEffectStage stage;
-            // compute a matrix to perform the draw
-            GrMatrix textureMatrix;
-            if (flipY) {
-                textureMatrix.setTranslate(SK_Scalar1 * left,
-                                    SK_Scalar1 * (top + height));
-                textureMatrix.set(GrMatrix::kMScaleY, -GR_Scalar1);
-            } else {
-                textureMatrix.setTranslate(SK_Scalar1 *left, SK_Scalar1 *top);
-            }
-            textureMatrix.postIDiv(src->width(), src->height());
-
-            bool effectInstalled = false;
+            SkAutoTUnref<GrEffect> effect;
             if (unpremul) {
-                if (this->installPMToUPMEffect(src, swapRAndB, textureMatrix, &stage)) {
-                    effectInstalled = true;
-                    unpremul = false; // we no longer need to do this on CPU after the readback.
-                }
+                effect.reset(this->createPMToUPMEffect(src, swapRAndB));
             }
             // If we failed to create a PM->UPM effect and have no other conversions to perform then
             // there is no longer any point to using the scratch.
-            if (effectInstalled || flipY || swapRAndB) {
-                if (!effectInstalled) {
-                    SkAssertResult(GrConfigConversionEffect::InstallEffect(
-                                            src,
-                                            swapRAndB,
-                                            GrConfigConversionEffect::kNone_PMConversion,
-                                            textureMatrix,
-                                            &stage));
+            if (NULL != effect || flipY || swapRAndB) {
+                if (NULL == effect) {
+                    effect.reset(GrConfigConversionEffect::Create(src, swapRAndB));
+                    GrAssert(NULL != effect);
+                } else {
+                    unpremul = false; // we will handle the UPM conversion in the draw
                 }
                 swapRAndB = false; // we will handle the swap in the draw.
-                flipY = false; // we already incorporated the y flip in the matrix
 
                 GrDrawTarget::AutoStateRestore asr(fGpu, GrDrawTarget::kReset_ASRInit);
                 GrDrawState* drawState = fGpu->drawState();
-                *drawState->stage(0) = stage;
-
                 drawState->setRenderTarget(texture->asRenderTarget());
+                GrMatrix matrix;
+                if (flipY) {
+                    matrix.setTranslate(SK_Scalar1 * left,
+                                        SK_Scalar1 * (top + height));
+                    matrix.set(GrMatrix::kMScaleY, -GR_Scalar1);
+                    flipY = false; // the y flip will be handled in the draw
+                } else {
+                    matrix.setTranslate(SK_Scalar1 *left, SK_Scalar1 *top);
+                }
+                matrix.postIDiv(src->width(), src->height());
+                drawState->stage(0)->setEffect(effect, matrix);
                 GrRect rect = GrRect::MakeWH(GrIntToScalar(width), GrIntToScalar(height));
                 fGpu->drawSimpleRect(rect, NULL);
                 // we want to read back from the scratch's origin
@@ -1359,7 +1350,7 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
                           readConfig, buffer, rowBytes, readUpsideDown)) {
         return false;
     }
-    // Perform any conversions we weren't able to perform using a scratch texture.
+    // Perform any conversions we weren't able to perfom using a scratch texture.
     if (unpremul || swapRAndB || flipY) {
         // These are initialized to suppress a warning
         SkCanvas::Config8888 srcC8888 = SkCanvas::kNative_Premul_Config8888;
@@ -1489,7 +1480,7 @@ void GrContext::writeRenderTargetPixels(GrRenderTarget* target,
         return;
     }
 #endif
-
+    SkAutoTUnref<GrEffect> effect;
     bool swapRAndB = (fGpu->preferredReadPixelsConfig(config) == GrPixelConfigSwapRAndB(config));
 
     GrPixelConfig textureConfig;
@@ -1508,24 +1499,15 @@ void GrContext::writeRenderTargetPixels(GrRenderTarget* target,
     if (NULL == texture) {
         return;
     }
-
-    GrEffectStage stage;
-    GrMatrix textureMatrix;
-    textureMatrix.setIDiv(texture->width(), texture->height());
-
     // allocate a tmp buffer and sw convert the pixels to premul
     SkAutoSTMalloc<128 * 128, uint32_t> tmpPixels(0);
 
-    bool effectInstalled = false;
     if (kUnpremul_PixelOpsFlag & flags) {
         if (kRGBA_8888_GrPixelConfig != config && kBGRA_8888_GrPixelConfig != config) {
             return;
         }
-        effectInstalled = this->installUPMToPMEffect(texture,
-                                                     swapRAndB,
-                                                     textureMatrix,
-                                                     &stage);
-        if (!effectInstalled) {
+        effect.reset(this->createUPMToPMEffect(texture, swapRAndB));
+        if (NULL == effect) {
             SkCanvas::Config8888 srcConfig8888, dstConfig8888;
             GR_DEBUGCODE(bool success = )
             grconfig_to_config8888(config, true, &srcConfig8888);
@@ -1542,13 +1524,9 @@ void GrContext::writeRenderTargetPixels(GrRenderTarget* target,
             rowBytes = 4 * width;
         }
     }
-    if (!effectInstalled) {
-        SkAssertResult(GrConfigConversionEffect::InstallEffect(
-                                                    texture,
-                                                    swapRAndB,
-                                                    GrConfigConversionEffect::kNone_PMConversion,
-                                                    textureMatrix,
-                                                    &stage));
+    if (NULL == effect) {
+        effect.reset(GrConfigConversionEffect::Create(texture, swapRAndB));
+        GrAssert(NULL != effect);
     }
 
     this->writeTexturePixels(texture,
@@ -1558,13 +1536,15 @@ void GrContext::writeRenderTargetPixels(GrRenderTarget* target,
 
     GrDrawTarget::AutoStateRestore  asr(fGpu, GrDrawTarget::kReset_ASRInit);
     GrDrawState* drawState = fGpu->drawState();
-    *drawState->stage(0) = stage;
 
     GrMatrix matrix;
     matrix.setTranslate(GrIntToScalar(left), GrIntToScalar(top));
     drawState->setViewMatrix(matrix);
     drawState->setRenderTarget(target);
 
+    matrix.setIDiv(texture->width(), texture->height());
+    drawState->stage(0)->setEffect(effect, matrix);
+
     fGpu->drawSimpleRect(GrRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)), NULL);
 }
 ////////////////////////////////////////////////////////////////////////////////
@@ -1746,10 +1726,7 @@ void test_pm_conversions(GrContext* ctx, int* pmToUPMValue, int* upmToPMValue) {
 }
 }
 
-bool GrContext::installPMToUPMEffect(GrTexture* texture,
-                                     bool swapRAndB,
-                                     const GrMatrix& matrix,
-                                     GrEffectStage* stage) {
+GrEffect* GrContext::createPMToUPMEffect(GrTexture* texture, bool swapRAndB) {
     if (!fDidTestPMConversions) {
         test_pm_conversions(this, &fPMToUPMConversion, &fUPMToPMConversion);
         fDidTestPMConversions = true;
@@ -1757,17 +1734,13 @@ bool GrContext::installPMToUPMEffect(GrTexture* texture,
     GrConfigConversionEffect::PMConversion pmToUPM =
         static_cast<GrConfigConversionEffect::PMConversion>(fPMToUPMConversion);
     if (GrConfigConversionEffect::kNone_PMConversion != pmToUPM) {
-        GrConfigConversionEffect::InstallEffect(texture, swapRAndB, pmToUPM, matrix, stage);
-        return true;
+        return GrConfigConversionEffect::Create(texture, swapRAndB, pmToUPM);
     } else {
-        return false;
+        return NULL;
     }
 }
 
-bool GrContext::installUPMToPMEffect(GrTexture* texture,
-                                     bool swapRAndB,
-                                     const GrMatrix& matrix,
-                                     GrEffectStage* stage) {
+GrEffect* GrContext::createUPMToPMEffect(GrTexture* texture, bool swapRAndB) {
     if (!fDidTestPMConversions) {
         test_pm_conversions(this, &fPMToUPMConversion, &fUPMToPMConversion);
         fDidTestPMConversions = true;
@@ -1775,10 +1748,9 @@ bool GrContext::installUPMToPMEffect(GrTexture* texture,
     GrConfigConversionEffect::PMConversion upmToPM =
         static_cast<GrConfigConversionEffect::PMConversion>(fUPMToPMConversion);
     if (GrConfigConversionEffect::kNone_PMConversion != upmToPM) {
-        GrConfigConversionEffect::InstallEffect(texture, swapRAndB, upmToPM, matrix, stage);
-        return true;
+        return GrConfigConversionEffect::Create(texture, swapRAndB, upmToPM);
     } else {
-        return false;
+        return NULL;
     }
 }
 
@@ -1836,7 +1808,7 @@ GrTexture* GrContext::gaussianBlur(GrTexture* srcTexture,
                              i < scaleFactorY ? 0.5f : 1.0f);
 
         paint.colorStage(0)->setEffect(SkNEW_ARGS(GrSingleTextureEffect,
-                                                  (srcTexture, matrix, true)))->unref();
+                                                  (srcTexture, true)), matrix)->unref();
         this->drawRectToRect(paint, dstRect, srcRect);
         srcRect = dstRect;
         srcTexture = dstTexture;
@@ -1893,8 +1865,8 @@ GrTexture* GrContext::gaussianBlur(GrTexture* srcTexture,
         // FIXME:  This should be mitchell, not bilinear.
         matrix.setIDiv(srcTexture->width(), srcTexture->height());
         this->setRenderTarget(dstTexture->asRenderTarget());
-        paint.colorStage(0)->setEffect(SkNEW_ARGS(GrSingleTextureEffect,(srcTexture,
-                                                                         matrix, true)))->unref();
+        paint.colorStage(0)->setEffect(SkNEW_ARGS(GrSingleTextureEffect,(srcTexture, true)),
+                                       matrix)->unref();
         SkRect dstRect(srcRect);
         scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY);
         this->drawRectToRect(paint, dstRect, srcRect);
index b53944189ab5c9ea23728e8cdf865d3c4418c5e5..3c6c3a371a2aaf11802204a78d815168f4d15dd4 100644 (file)
@@ -198,16 +198,16 @@ public:
     }
     void createTextureEffect(int stageIdx, GrTexture* texture, const GrMatrix& matrix) {
         GrAssert(!this->getStage(stageIdx).getEffect());
-        GrEffect* effect = SkNEW_ARGS(GrSingleTextureEffect, (texture, matrix));
-        this->stage(stageIdx)->setEffect(effect)->unref();
+        GrEffect* effect = SkNEW_ARGS(GrSingleTextureEffect, (texture));
+        this->stage(stageIdx)->setEffect(effect, matrix)->unref();
     }
     void createTextureEffect(int stageIdx,
                              GrTexture* texture,
                              const GrMatrix& matrix,
                              const GrTextureParams& params) {
         GrAssert(!this->getStage(stageIdx).getEffect());
-        GrEffect* effect = SkNEW_ARGS(GrSingleTextureEffect, (texture, matrix, params));
-        this->stage(stageIdx)->setEffect(effect)->unref();
+        GrEffect* effect = SkNEW_ARGS(GrSingleTextureEffect, (texture, params));
+        this->stage(stageIdx)->setEffect(effect, matrix)->unref();
     }
 
 
index d470c9cc5f30de39831222b37b94828d2f2636cf..09032bf0f920e77051bc172e36882903544cb1fa 100644 (file)
@@ -20,26 +20,6 @@ SkTArray<GrEffectTestFactory*, true>* GrEffectTestFactory::GetFactories() {
 }
 #endif
 
-namespace GrEffectUnitTest {
-const SkMatrix& TestMatrix(SkRandom* random) {
-    static SkMatrix gMatrices[5];
-    static bool gOnce;
-    if (!gOnce) {
-        gMatrices[0].reset();
-        gMatrices[1].setTranslate(SkIntToScalar(-100), SkIntToScalar(100));
-        gMatrices[2].setRotate(SkIntToScalar(17));
-        gMatrices[3].setRotate(SkIntToScalar(185));
-        gMatrices[3].postTranslate(SkIntToScalar(66), SkIntToScalar(-33));
-        gMatrices[3].postScale(SkIntToScalar(2), SK_ScalarHalf);
-        gMatrices[4].setRotate(SkIntToScalar(215));
-        gMatrices[4].set(SkMatrix::kMPersp0, SkFloatToScalar(0.00013f));
-        gMatrices[4].set(SkMatrix::kMPersp1, SkFloatToScalar(-0.000039f));
-        gOnce = true;
-    }
-    return gMatrices[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gMatrices)))];
-}
-}
-
 class GrEffect_Globals {
 public:
     static GrMemoryPool* GetTLS() {
index 946d54dcc8c29e9539ebff211c5ffdf018960f78..cdccbcd049b812aa397917293fbe98ddd49b77eb 100644 (file)
@@ -608,7 +608,7 @@ inline bool skPaint2GrPaintShader(SkGpuDevice* dev,
         GrScalar sy = SkFloatToScalar(1.f / bitmap.height());
         matrix.postScale(sx, sy);
     }
-    stage->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (texture, matrix, params)))->unref();
+    stage->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (texture, params)), matrix)->unref();
 
     return true;
 }
@@ -875,7 +875,7 @@ bool drawWithGPUMaskFilter(GrContext* context, const SkPath& devPath,
             matrix.setIDiv(pathTexture->width(), pathTexture->height());
             // Blend pathTexture over blurTexture.
             context->setRenderTarget(blurTexture->asRenderTarget());
-            paint.colorStage(0)->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (pathTexture, matrix)))->unref();
+            paint.colorStage(0)->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (pathTexture)), matrix)->unref();
             if (SkMaskFilter::kInner_BlurType == blurType) {
                 // inner:  dst = dst * src
                 paint.setBlendFunc(kDC_GrBlendCoeff, kZero_GrBlendCoeff);
@@ -906,7 +906,7 @@ bool drawWithGPUMaskFilter(GrContext* context, const SkPath& devPath,
     matrix.postIDiv(blurTexture->width(), blurTexture->height());
 
     grp->coverageStage(MASK_IDX)->reset();
-    grp->coverageStage(MASK_IDX)->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (blurTexture, matrix)))->unref();
+    grp->coverageStage(MASK_IDX)->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (blurTexture)), matrix)->unref();
     context->drawRect(*grp, finalRect);
     return true;
 }
@@ -962,7 +962,7 @@ bool drawWithMaskFilter(GrContext* context, const SkPath& devPath,
     m.setTranslate(-dstM.fBounds.fLeft*SK_Scalar1, -dstM.fBounds.fTop*SK_Scalar1);
     m.postIDiv(texture->width(), texture->height());
 
-    grp->coverageStage(MASK_IDX)->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (texture, m)))->unref();
+    grp->coverageStage(MASK_IDX)->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (texture)), m)->unref();
     GrRect d;
     d.setLTRB(GrIntToScalar(dstM.fBounds.fLeft),
               GrIntToScalar(dstM.fBounds.fTop),
index 54d7285c93ed1c80968e3f0d84ecd615f76ea636..086064545e4aa0d9d00f76af43b5c41413b203a8 100644 (file)
@@ -218,27 +218,21 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
     }
 }
 
-bool GrConfigConversionEffect::InstallEffect(GrTexture* texture,
-                                             bool swapRedAndBlue,
-                                             PMConversion pmConversion,
-                                             const GrMatrix& matrix,
-                                             GrEffectStage* stage) {
+GrEffect* GrConfigConversionEffect::Create(GrTexture* texture,
+                                                bool swapRedAndBlue,
+                                                PMConversion pmConversion) {
     if (!swapRedAndBlue && kNone_PMConversion == pmConversion) {
         // If we returned a GrConfigConversionEffect that was equivalent to a GrSingleTextureEffect
         // then we may pollute our texture cache with redundant shaders. So in the case that no
         // conversions were requested we instead return a GrSingleTextureEffect.
-        stage->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (texture, matrix)), matrix)->unref();
-        return true;
+        return SkNEW_ARGS(GrSingleTextureEffect, (texture));
     } else {
         if (kRGBA_8888_GrPixelConfig != texture->config() &&
             kBGRA_8888_GrPixelConfig != texture->config() &&
             kNone_PMConversion != pmConversion) {
             // The PM conversions assume colors are 0..255
-            return false;
+            return NULL;
         }
-        stage->setEffect(SkNEW_ARGS(GrConfigConversionEffect, (texture,
-                                                               swapRedAndBlue,
-                                                               pmConversion)), matrix)->unref();
-        return true;
+        return SkNEW_ARGS(GrConfigConversionEffect, (texture, swapRedAndBlue, pmConversion));
     }
 }
index 5b531d4d58ccc288a6524b4431a489405e45274e..7c5f03fa2bccca6f913e8b5ff65012a29ac678de 100644 (file)
@@ -33,12 +33,10 @@ public:
         kPMConversionCnt
     };
 
-    // Installs an effect in the GrEffectStage to perform a config conversion.
-    static bool InstallEffect(GrTexture*,
-                              bool swapRedAndBlue,
-                              PMConversion pmConversion,
-                              const GrMatrix& matrix,
-                              GrEffectStage* stage);
+    // This will fail if the config is not 8888 and a PM conversion is requested.
+    static GrEffect* Create(GrTexture*,
+                                 bool swapRedAndBlue,
+                                 PMConversion pmConversion = kNone_PMConversion);
 
     static const char* Name() { return "Config Conversion"; }
     typedef GrGLConfigConversionEffect GLEffect;
index 0f3b614dd7be1dbb169ede47b10926c5731ebcb6..8866153962337aa8abc19fb4c7975266dd9253e4 100644 (file)
@@ -7,7 +7,6 @@
 
 #include "effects/GrSingleTextureEffect.h"
 #include "gl/GrGLEffect.h"
-#include "gl/GrGLEffectMatrix.h"
 #include "gl/GrGLSL.h"
 #include "gl/GrGLTexture.h"
 #include "GrTBackendEffectFactory.h"
@@ -17,43 +16,25 @@ class GrGLSingleTextureEffect : public GrGLEffect {
 public:
     GrGLSingleTextureEffect(const GrBackendEffectFactory& factory, const GrEffect&)
     : INHERITED (factory) {
-        fRequiresTextureMatrix = false;
     }
 
     virtual void emitCode(GrGLShaderBuilder* builder,
                           const GrEffectStage&,
-                          EffectKey key,
+                          EffectKey,
                           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],
-                                                coordName,
-                                                coordType);
+        builder->appendTextureLookupAndModulate(&builder->fFSCode, inputColor, samplers[0]);
         builder->fFSCode.append(";\n");
     }
 
-    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));
-    }
+    static inline EffectKey GenKey(const GrEffectStage&, const GrGLCaps&) { return 0; }
 
 private:
-    GrGLEffectMatrix fEffectMatrix;
+
     typedef GrGLEffect INHERITED;
 };
 
@@ -62,39 +43,16 @@ private:
 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() {
@@ -118,6 +76,5 @@ GrEffect* GrSingleTextureEffect::TestCreate(SkRandom* random,
                                             GrTexture* textures[]) {
     int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
                                       GrEffectUnitTest::kAlphaTextureIdx;
-    const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random);
-    return SkNEW_ARGS(GrSingleTextureEffect, (textures[texIdx], matrix));
+    return SkNEW_ARGS(GrSingleTextureEffect, (textures[texIdx]));
 }
index 23b416d3b334f23507ff6a6cb090f369552c9083..346a6f48d8413a99c2b9bf0d12b34c1b72970906 100644 (file)
@@ -9,7 +9,6 @@
 #define GrSingleTextureEffect_DEFINED
 
 #include "GrEffect.h"
-#include "GrMatrix.h"
 
 class GrGLSingleTextureEffect;
 
@@ -19,15 +18,13 @@ class GrGLSingleTextureEffect;
 class GrSingleTextureEffect : public GrEffect {
 
 public:
-    /** These three constructors assume an identity matrix */
-    GrSingleTextureEffect(GrTexture* texture); /* unfiltered, clamp mode */
-    GrSingleTextureEffect(GrTexture* texture, bool bilerp); /* clamp mode */
-    GrSingleTextureEffect(GrTexture* texture, const GrTextureParams&);
+    /** Uses default texture params (unfiltered, clamp) */
+    GrSingleTextureEffect(GrTexture* texture);
+
+    /** Uses default tile mode (clamp) */
+    GrSingleTextureEffect(GrTexture* texture, bool bilerp);
 
-    /** These three constructors take an explicit matrix */
-    GrSingleTextureEffect(GrTexture*, const GrMatrix&); /* unfiltered, clamp mode */
-    GrSingleTextureEffect(GrTexture*, const GrMatrix&, bool bilerp); /* clamp mode */
-    GrSingleTextureEffect(GrTexture*, const GrMatrix&, const GrTextureParams&);
+    GrSingleTextureEffect(GrTexture* texture, const GrTextureParams&);
 
     virtual ~GrSingleTextureEffect();
 
@@ -35,21 +32,14 @@ public:
 
     static const char* Name() { return "Single Texture"; }
 
-    const GrMatrix& getMatrix() const { return fMatrix; }
-
     typedef GrGLSingleTextureEffect GLEffect;
 
     virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
 
-    virtual bool isEqual(const GrEffect& effect) const SK_OVERRIDE {
-        const GrSingleTextureEffect& ste = static_cast<const GrSingleTextureEffect&>(effect);
-        return INHERITED::isEqual(effect) && fMatrix.cheapEqualTo(ste.getMatrix());
-    }
 private:
     GR_DECLARE_EFFECT_TEST;
 
     GrTextureAccess fTextureAccess;
-    GrMatrix        fMatrix;
 
     typedef GrEffect INHERITED;
 };
index 5e0875b71cbbdc0ab3ed81b9a3983d51218581c2..0bbf1f7ccbfb45a7c9c2b04b47e5a73252bb3715 100644 (file)
@@ -10,8 +10,6 @@
 
 GrGLEffect::GrGLEffect(const GrBackendEffectFactory& factory)
     : fFactory(factory) {
-
-    fRequiresTextureMatrix = true;
 }
 
 GrGLEffect::~GrGLEffect() {
index 0fd5722cb8a4071f1536ced2c728c5315b70f3c6..30b8455a68d16ee0692c27bd434662542b2b32bf 100644 (file)
@@ -51,9 +51,7 @@ public:
 
         @param builder      Interface used to emit code in the shaders.
         @param stage        The effect stage that generated this program stage.
-        @param key          The key that was computed by GenKey() from the generating GrEffect.
-                            Only the bits indicated by GrBackendEffectFactory::kEffectKeyBits are
-                            guaranteed to match the value produced by GenKey();
+        @param key          The key that was computed by EffectKey() from the generating GrEffect.
         @param vertexCoords A vec2 of texture coordinates in the VS, which may be altered. This will
                             be removed soon and stages will be responsible for computing their own
                             coords.
@@ -87,14 +85,7 @@ public:
 
     static EffectKey GenTextureKey(const GrEffect&, const GrGLCaps&);
 
-    bool requiresTextureMatrix() const { return fRequiresTextureMatrix; }
-
-
 protected:
-    // HACK: This is a temporary field that allows GrGLEffect subclasses to opt into the new
-    // shader gen where a texture matrix is not automatically inserted. It defaults to true and is
-    // set to false in a subclass to opt into the new behavior.
-    bool fRequiresTextureMatrix;
 
     const GrBackendEffectFactory& fFactory;
 };
diff --git a/src/gpu/gl/GrGLEffectMatrix.cpp b/src/gpu/gl/GrGLEffectMatrix.cpp
deleted file mode 100644 (file)
index 0db87f9..0000000
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "GrGLEffectMatrix.h"
-#include "GrTexture.h"
-
-GrGLEffect::EffectKey GrGLEffectMatrix::GenKey(const SkMatrix& effectMatrix,
-                                               const SkMatrix& coordChangeMatrix,
-                                               const GrTexture* texture) {
-    SkMatrix::TypeMask type0 = effectMatrix.getType();
-    SkMatrix::TypeMask type1 = coordChangeMatrix.getType();
-
-    static const int kNonTransMask = SkMatrix::kAffine_Mask |
-                                     SkMatrix::kScale_Mask  |
-                                     SkMatrix::kPerspective_Mask;
-    int combinedTypes = type0 | type1;
-
-    bool reverseY = (NULL != texture) && GrSurface::kBottomLeft_Origin == texture->origin();
-
-    if (SkMatrix::kPerspective_Mask & combinedTypes) {
-        return kGeneral_Key;
-    } else if ((kNonTransMask & combinedTypes) || reverseY) {
-        return kNoPersp_Key;
-    } else if (kTrans_Key & combinedTypes) {
-        return kTrans_Key;
-    } else {
-        GrAssert(effectMatrix.isIdentity() && coordChangeMatrix.isIdentity());
-        return kIdentity_Key;
-    }
-}
-
-GrSLType GrGLEffectMatrix::emitCode(GrGLShaderBuilder* builder,
-                                    EffectKey key,
-                                    const char* vertexCoords,
-                                    const char** fsCoordName,
-                                    const char** vsCoordName,
-                                    const char* suffix) {
-    GrSLType varyingType;
-    const char* uniName;
-    key &= kKeyMask;
-    switch (key) {
-        case kIdentity_Key:
-            fUniType = kVoid_GrSLType;
-            varyingType = kVec2f_GrSLType;
-            break;
-        case kTrans_Key:
-            fUniType = kVec2f_GrSLType;
-            uniName = "StageTranslate";
-            varyingType = kVec2f_GrSLType;
-            break;
-        case kNoPersp_Key:
-            fUniType = kMat33f_GrSLType;
-            uniName = "StageMatrix";
-            varyingType = kVec2f_GrSLType;
-            break;
-        case kGeneral_Key:
-            fUniType = kMat33f_GrSLType;
-            uniName = "StageMatrix";
-            varyingType = kVec3f_GrSLType;
-            break;
-        default:
-            GrCrash("Unexpected key.");
-    }
-    SkString suffixedUniName;
-    if (NULL != suffix) {
-        suffixedUniName.append(uniName);
-        suffixedUniName.append(suffix);
-        uniName = suffixedUniName.c_str();
-    }
-    if (kVoid_GrSLType != fUniType) {
-        fUni = builder->addUniform(GrGLShaderBuilder::kVertex_ShaderType,
-                                   fUniType,
-                                   uniName,
-                                   &uniName);
-    }
-
-    const char* varyingName = "StageCoord";
-    SkString suffixedVaryingName;
-    if (NULL != suffix) {
-        suffixedVaryingName.append(varyingName);
-        suffixedVaryingName.append(suffix);
-        varyingName = suffixedVaryingName.c_str();
-    }
-    const char* vsVaryingName;
-    const char* fsVaryingName;
-    builder->addVarying(varyingType, varyingName, &vsVaryingName, &fsVaryingName);
-
-    // varying = matrix * vertex-coords (logically)
-    switch (fUniType) {
-        case kVoid_GrSLType:
-            GrAssert(kVec2f_GrSLType == varyingType);
-            builder->fVSCode.appendf("\t%s = %s;\n", vsVaryingName, vertexCoords);
-            break;
-        case kVec2f_GrSLType:
-            GrAssert(kVec2f_GrSLType == varyingType);
-            builder->fVSCode.appendf("\t%s = %s + %s;\n", vsVaryingName, uniName, vertexCoords);
-            break;
-        case kMat33f_GrSLType: {
-            GrAssert(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyingType);
-            if (kVec2f_GrSLType == varyingType) {
-                builder->fVSCode.appendf("\t%s = (%s * vec3(%s, 1)).xy;\n",
-                                         vsVaryingName, uniName, vertexCoords);
-            } else {
-                builder->fVSCode.appendf("\t%s = %s * vec3(%s, 1);\n",
-                                         vsVaryingName, uniName, vertexCoords);
-            }
-            break;
-        }
-        default:
-            GrCrash("Unexpected uniform type.");
-    }
-    if (NULL != vsCoordName) {
-        *vsCoordName = vsVaryingName;
-    }
-    if (NULL != fsCoordName) {
-        *fsCoordName = fsVaryingName;
-    }
-    return varyingType;
-}
-
-/**
-    * This is similar to emitCode except that it performs perspective division in the FS if the
-    * texture coordinates have a w coordinate. The fsCoordName always refers to a vec2f.
-    */
-void GrGLEffectMatrix::emitCodeMakeFSCoords2D(GrGLShaderBuilder* builder,
-                                              EffectKey key,
-                                              const char* vertexCoords,
-                                              const char** fsCoordName,
-                                              const char** vsVaryingName,
-                                              GrSLType* vsVaryingType,
-                                              const char* suffix) {
-    const char* fsVaryingName;
-        
-    GrSLType varyingType = this->emitCode(builder,
-                                          key,
-                                          vertexCoords,
-                                          &fsVaryingName,
-                                          vsVaryingName,
-                                          suffix);
-    if (kVec3f_GrSLType == varyingType) {
-
-        const char* coordName = "coords2D";
-        SkString suffixedCoordName;
-        if (NULL != suffix) {
-            suffixedCoordName.append(coordName);
-            suffixedCoordName.append(suffix);
-            coordName = suffixedCoordName.c_str();
-        }
-        builder->fFSCode.appendf("\tvec2 %s = %s.xy / %s.z;",
-                                    coordName, fsVaryingName, fsVaryingName);
-        if (NULL != fsCoordName) {
-            *fsCoordName = coordName;
-        }
-    } else if(NULL != fsCoordName) {
-        *fsCoordName = fsVaryingName;
-    }
-    if (NULL != vsVaryingType) {
-        *vsVaryingType = varyingType;
-    }
-}
-
-void GrGLEffectMatrix::setData(const GrGLUniformManager& uniformManager,
-                              const SkMatrix& matrix,
-                              const SkMatrix& coordChangeMatrix,
-                              const GrTexture* texture) {
-    GrAssert((GrGLUniformManager::kInvalidUniformHandle == fUni) ==
-                (kVoid_GrSLType == fUniType));
-    switch (fUniType) {
-        case kVoid_GrSLType:
-            GrAssert(matrix.isIdentity());
-            GrAssert(coordChangeMatrix.isIdentity());
-            GrAssert(NULL == texture || GrSurface::kTopLeft_Origin == texture->origin());
-            return;
-        case kVec2f_GrSLType: {
-            GrAssert(SkMatrix::kTranslate_Mask == (matrix.getType() | coordChangeMatrix.getType()));
-            GrAssert(NULL == texture || GrSurface::kTopLeft_Origin == texture->origin());
-            SkScalar tx = matrix[SkMatrix::kMTransX] + coordChangeMatrix[SkMatrix::kMTransX];
-            SkScalar ty = matrix[SkMatrix::kMTransY] + coordChangeMatrix[SkMatrix::kMTransY];
-            if (fPrevMatrix.get(SkMatrix::kMTransX) != tx ||
-                fPrevMatrix.get(SkMatrix::kMTransY) != ty) {
-                uniformManager.set2f(fUni, tx, ty);
-                fPrevMatrix.set(SkMatrix::kMTransX, tx);
-                fPrevMatrix.set(SkMatrix::kMTransY, ty);
-            }
-            break;
-        }
-        case kMat33f_GrSLType: {
-            SkMatrix combined;
-            combined.setConcat(matrix, coordChangeMatrix);
-            if (NULL != texture && GrSurface::kBottomLeft_Origin == texture->origin()) {
-                // combined.postScale(1,-1);
-                // combined.postTranslate(0,1);
-                combined.set(SkMatrix::kMSkewY,
-                    combined[SkMatrix::kMPersp0] - combined[SkMatrix::kMSkewY]);
-                combined.set(SkMatrix::kMScaleY,
-                    combined[SkMatrix::kMPersp1] - combined[SkMatrix::kMScaleY]);
-                combined.set(SkMatrix::kMTransY,
-                    combined[SkMatrix::kMPersp2] - combined[SkMatrix::kMTransY]);
-            }
-            if (!fPrevMatrix.cheapEqualTo(combined)) {
-                uniformManager.setSkMatrix(fUni, combined);
-                fPrevMatrix = combined;
-            }
-            break;
-        }
-        default:
-            GrCrash("Unexpected uniform type.");
-    }
-}
diff --git a/src/gpu/gl/GrGLEffectMatrix.h b/src/gpu/gl/GrGLEffectMatrix.h
deleted file mode 100644 (file)
index 9e45f3e..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrGLEffectMatrix_DEFINED
-#define GrGLEffectMatrix_DEFINED
-
-#include "GrGLEffect.h"
-#include "SkMatrix.h"
-
-class GrTexture;
-class SkRandom;
-
-/**
- * This is a helper to implement a texture matrix in a GrGLEffect.
- */
-class GrGLEffectMatrix {
-public:
-    typedef GrGLEffect::EffectKey EffectKey;
-    /**
-     * The matrix uses kKeyBits of the effect's EffectKey. A GrGLEffect may place these bits at an
-     * arbitrary shift in its final key. However, when GrGLEffectMatrix::emitCode*() code is called
-     * the relevant bits must be in the lower kKeyBits of the key parameter.
-     */
-    enum {
-        kKeyBits = 2,
-        kKeyMask = (1 << kKeyBits) - 1,
-    };
-
-    GrGLEffectMatrix() : fUni(GrGLUniformManager::kInvalidUniformHandle) {
-        fPrevMatrix = SkMatrix::InvalidMatrix();
-    }
-
-    /**
-     * Generates the key for the portion of the code emitted by this class's emitCode() function.
-     * Pass a texture to make GrGLEffectMatrix automatically adjust for the texture's origin. Pass
-     * NULL when not using the EffectMatrix for a texture lookups, or if the GrGLEffect subclass
-     * wants to handle origin adjustments in some other manner. coordChangeMatrix is the matrix
-     * from GrEffectStage.
-     */
-    static EffectKey GenKey(const SkMatrix& effectMatrix,
-                            const SkMatrix& coordChangeMatrix,
-                            const GrTexture*);
-
-    /**
-     * Emits code to implement the matrix in the VS. A varying is added as an output of the VS and
-     * input to the FS. The varying may be either a vec2f or vec3f depending upon whether
-     * perspective interpolation is required or not. The names of the varying in the VS and FS are
-     * are returned as output parameters and the type of the varying is the return value. The suffix
-     * is an optional parameter that can be used to make all variables emitted by the object
-     * unique within a stage. It is only necessary if multiple GrGLEffectMatrix objects are used by
-     * a GrGLEffect.
-     */
-    GrSLType emitCode(GrGLShaderBuilder*,
-                      EffectKey,
-                      const char* vertexCoords,
-                      const char** fsCoordName, /* optional */
-                      const char** vsCoordName = NULL,
-                      const char* suffix = NULL);
-
-    /**
-     * This is similar to emitCode except that it performs perspective division in the FS if the
-     * texture coordinates have a w coordinate. The fsCoordName always refers to a vec2f.
-     */
-    void emitCodeMakeFSCoords2D(GrGLShaderBuilder*,
-                                EffectKey,
-                                const char* vertexCoords,
-                                const char** fsCoordName, /* optional */
-                                const char** vsVaryingName = NULL,
-                                GrSLType* vsVaryingType = NULL,
-                                const char* suffix = NULL);
-    /**
-     * Call from a GrGLEffect's subclass to update the texture matrix. The matrix,
-     * coordChangeMatrix, and texture params should match those used with GenKey.
-     */
-    void setData(const GrGLUniformManager& uniformManager,
-                 const SkMatrix& effectMatrix,
-                 const SkMatrix& coordChangeMatrix,
-                 const GrTexture*);
-
-private:
-    enum {
-        kIdentity_Key   = 0,
-        kTrans_Key      = 1,
-        kNoPersp_Key    = 2,
-        kGeneral_Key    = 3,
-    };
-
-    GrGLUniformManager::UniformHandle fUni;
-    GrSLType                          fUniType;
-    SkMatrix                          fPrevMatrix;
-};
-
-#endif
\ No newline at end of file
index 120bd1e3addda4a85bbcaddd9dd8a3335da46a04..cd16d9e24fdec42cffee468071e12785bf87e0fa 100644 (file)
@@ -909,64 +909,57 @@ GrGLEffect* GrGLProgram::GenStageCode(const GrEffectStage& stage,
 
     /// Vertex Shader Stuff
 
-    const char* vertexCoords;
-
-    // Has the effect not yet been updated to insert its own texture matrix if necessary.
-    if (glEffect->requiresTextureMatrix()) {
-        // Decide whether we need a matrix to transform texture coords and whether the varying needs
-        // a perspective coord.
-        const char* matName = NULL;
-        GrSLType texCoordVaryingType;
-        if (desc.fOptFlags & StageDesc::kIdentityMatrix_OptFlagBit) {
-            texCoordVaryingType = kVec2f_GrSLType;
-        } else {
-            uniforms->fTextureMatrixUni = builder->addUniform(GrGLShaderBuilder::kVertex_ShaderType,
-                                                              kMat33f_GrSLType, "TexM", &matName);
-            builder->getUniformVariable(uniforms->fTextureMatrixUni);
+    // decide whether we need a matrix to transform texture coords and whether the varying needs a
+    // perspective coord.
+    const char* matName = NULL;
+    GrSLType texCoordVaryingType;
+    if (desc.fOptFlags & StageDesc::kIdentityMatrix_OptFlagBit) {
+        texCoordVaryingType = kVec2f_GrSLType;
+    } else {
+        uniforms->fTextureMatrixUni = builder->addUniform(GrGLShaderBuilder::kVertex_ShaderType,
+                                                         kMat33f_GrSLType, "TexM", &matName);
+        builder->getUniformVariable(uniforms->fTextureMatrixUni);
 
-            if (desc.fOptFlags & StageDesc::kNoPerspective_OptFlagBit) {
-                texCoordVaryingType = kVec2f_GrSLType;
-            } else {
-                texCoordVaryingType = kVec3f_GrSLType;
-            }
-        }
-        const char *varyingVSName, *varyingFSName;
-        builder->addVarying(texCoordVaryingType,
-                            "Stage",
-                            &varyingVSName,
-                            &varyingFSName);
-        builder->setupTextureAccess(varyingFSName, texCoordVaryingType);
-
-        if (!matName) {
-            GrAssert(kVec2f_GrSLType == texCoordVaryingType);
-            builder->fVSCode.appendf("\t%s = %s;\n", varyingVSName, vsInCoord);
+        if (desc.fOptFlags & StageDesc::kNoPerspective_OptFlagBit) {
+            texCoordVaryingType = kVec2f_GrSLType;
         } else {
-            // varying = texMatrix * texCoord
-            builder->fVSCode.appendf("\t%s = (%s * vec3(%s, 1))%s;\n",
-                                     varyingVSName, matName, vsInCoord,
-                                     vector_all_coords(GrSLTypeToVecLength(texCoordVaryingType)));
+            texCoordVaryingType = kVec3f_GrSLType;
         }
-        vertexCoords = varyingVSName;
-    } else {
-        vertexCoords = vsInCoord;
     }
+    const char *varyingVSName, *varyingFSName;
+    builder->addVarying(texCoordVaryingType,
+                        "Stage",
+                        &varyingVSName,
+                        &varyingFSName);
+    builder->setupTextureAccess(varyingFSName, texCoordVaryingType);
 
-    // setup texture samplers for gl effect
     int numTextures = effect->numTextures();
     SkSTArray<8, GrGLShaderBuilder::TextureSampler> textureSamplers;
+
     textureSamplers.push_back_n(numTextures);
+
     for (int i = 0; i < numTextures; ++i) {
         textureSamplers[i].init(builder, &effect->textureAccess(i));
         uniforms->fSamplerUniforms.push_back(textureSamplers[i].fSamplerUniform);
     }
 
+    if (!matName) {
+        GrAssert(kVec2f_GrSLType == texCoordVaryingType);
+        builder->fVSCode.appendf("\t%s = %s;\n", varyingVSName, vsInCoord);
+    } else {
+        // varying = texMatrix * texCoord
+        builder->fVSCode.appendf("\t%s = (%s * vec3(%s, 1))%s;\n",
+                                  varyingVSName, matName, vsInCoord,
+                                  vector_all_coords(GrSLTypeToVecLength(texCoordVaryingType)));
+    }
+
     // Enclose custom code in a block to avoid namespace conflicts
     builder->fVSCode.appendf("\t{ // %s\n", glEffect->name());
     builder->fFSCode.appendf("\t{ // %s \n", glEffect->name());
     glEffect->emitCode(builder,
                        stage,
                        desc.fEffectKey,
-                       vertexCoords,
+                       varyingVSName,
                        fsOutColor,
                        fsInColor,
                        textureSamplers);
index 7a92d25b2898ef85b8a0199a294de5fc560fa2d3..684ef8c37ea03d1f751e825ac92f977aa0af674e 100644 (file)
@@ -8,7 +8,6 @@
 #include "gl/GrGLShaderBuilder.h"
 #include "gl/GrGLProgram.h"
 #include "gl/GrGLUniformHandle.h"
-#include "SkMatrix.h"
 
 #define ASSERT_ARRAY_UPLOAD_IN_BOUNDS(UNI, OFFSET, COUNT) \
          GrAssert(offset + arrayCount <= uni.fArrayCount || \
@@ -232,23 +231,6 @@ void GrGLUniformManager::setMatrix4fv(UniformHandle u,
     }
 }
 
-void GrGLUniformManager::setSkMatrix(UniformHandle u, const SkMatrix& matrix) const {
-    GR_STATIC_ASSERT(SK_SCALAR_IS_FLOAT);
-    GrGLfloat mt[] = {
-        matrix.get(SkMatrix::kMScaleX),
-        matrix.get(SkMatrix::kMSkewY),
-        matrix.get(SkMatrix::kMPersp0),
-        matrix.get(SkMatrix::kMSkewX),
-        matrix.get(SkMatrix::kMScaleY),
-        matrix.get(SkMatrix::kMPersp1),
-        matrix.get(SkMatrix::kMTransX),
-        matrix.get(SkMatrix::kMTransY),
-        matrix.get(SkMatrix::kMPersp2),
-    };
-    this->setMatrix3f(u, mt);
-}
-
-
 void GrGLUniformManager::getUniformLocations(GrGLuint programID, const BuilderUniformArray& uniforms) {
     GrAssert(uniforms.count() == fUniforms.count());
     int count = fUniforms.count();
index 8f435d3037ed456707602cec64382a0d3f2b2d23..e9856c6ea3b6b62779c758abbe9c6cab0b92258c 100644 (file)
@@ -15,7 +15,6 @@
 #include "SkTArray.h"
 
 class GrGLContextInfo;
-class SkMatrix;
 
 /** Manages a program's uniforms.
 */
@@ -48,9 +47,6 @@ public:
     void setMatrix3fv(UniformHandle, int offset, int arrayCount, const GrGLfloat matrices[]) const;
     void setMatrix4fv(UniformHandle, int offset, int arrayCount, const GrGLfloat matrices[]) const;
 
-    // convenience method for uploading a SkMatrix to a 3x3 matrix uniform
-    void setSkMatrix(UniformHandle, const SkMatrix&) const;
-
     struct BuilderUniform {
         GrGLShaderVar fVariable;
         uint32_t      fVisibility;
index 6812d2790d8f17516421b5aa07ac9336aa3a378d..9c001fbbd8f5b41b2dc615aef57413011da14cf8 100644 (file)
@@ -184,11 +184,7 @@ void forceLinking();
 void forceLinking() {
     SkLightingImageFilter::CreateDistantLitDiffuse(SkPoint3(0,0,0), 0, 0, 0);
     SkMagnifierImageFilter mag(SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1);
-    GrConfigConversionEffect::InstallEffect(NULL,
-                                            false,
-                                            GrConfigConversionEffect::kNone_PMConversion,
-                                            GrMatrix::I(),
-                                            &GrEffectStage());
+    GrConfigConversionEffect::Create(NULL, false);
     SkScalar matrix[20];
     SkColorMatrixFilter cmf(matrix);
 }