aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/effects/GrSingleTextureEffect.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-01 15:40:47 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-01 15:40:47 +0000
commitc3a58f345de16c185db3a20578c7ddf52bc89d38 (patch)
tree90b83991981cce5a6e19e212911122f240aa8470 /src/gpu/effects/GrSingleTextureEffect.cpp
parent66e534da8e2b3de928f7ce132da61947a73ab7cb (diff)
Reland r6233 with fix for config conversion texture matrices.
git-svn-id: http://skia.googlecode.com/svn/trunk@6238 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/effects/GrSingleTextureEffect.cpp')
-rw-r--r--src/gpu/effects/GrSingleTextureEffect.cpp55
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));
}