diff options
Diffstat (limited to 'src/gpu/effects/GrSingleTextureEffect.cpp')
-rw-r--r-- | src/gpu/effects/GrSingleTextureEffect.cpp | 55 |
1 files changed, 49 insertions, 6 deletions
diff --git a/src/gpu/effects/GrSingleTextureEffect.cpp b/src/gpu/effects/GrSingleTextureEffect.cpp index 8866153962..0f3b614dd7 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 @@ class GrGLSingleTextureEffect : public GrGLEffect { 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)); + } -private: + 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 @@ 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() { @@ -76,5 +118,6 @@ GrEffect* GrSingleTextureEffect::TestCreate(SkRandom* random, 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)); } |