aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-02 18:23:45 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-02 18:23:45 +0000
commitb1456d70100d309c852906fafab006fae63de53e (patch)
treee6a40306b395cd5a03a5739aa41b89e9bd403fab
parent9313ca4bde606a18f29214eea8b8e47312b8fd9c (diff)
Make GrGLConfigConversionEffect use GrGLEffectMatrix
Review URL: https://codereview.appspot.com/6815074 git-svn-id: http://skia.googlecode.com/svn/trunk@6268 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--src/gpu/effects/GrConfigConversionEffect.cpp58
-rw-r--r--src/gpu/effects/GrConfigConversionEffect.h3
2 files changed, 48 insertions, 13 deletions
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index 7ccea74963..a2aad29400 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -6,8 +6,11 @@
*/
#include "GrConfigConversionEffect.h"
+#include "GrContext.h"
#include "GrTBackendEffectFactory.h"
#include "gl/GrGLEffect.h"
+#include "gl/GrGLEffectMatrix.h"
+#include "SkMatrix.h"
class GrGLConfigConversionEffect : public GrGLEffect {
public:
@@ -16,17 +19,20 @@ public:
const GrConfigConversionEffect& effect = static_cast<const GrConfigConversionEffect&>(s);
fSwapRedAndBlue = effect.swapsRedAndBlue();
fPMConversion = effect.pmConversion();
+ 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* coords;
+ GrSLType coordsType = fEffectMatrix.emitCode(builder, key, vertexCoords, &coords);
builder->fFSCode.appendf("\t\t%s = ", outputColor);
- builder->appendTextureLookup(&builder->fFSCode, samplers[0]);
+ builder->appendTextureLookup(&builder->fFSCode, samplers[0], coords, coordsType);
builder->fFSCode.append(";\n");
if (GrConfigConversionEffect::kNone_PMConversion == fPMConversion) {
GrAssert(fSwapRedAndBlue);
@@ -60,15 +66,32 @@ public:
GrGLSLMulVarBy4f(&builder->fFSCode, 2, outputColor, inputColor);
}
+ void setData(const GrGLUniformManager& uman, const GrEffectStage& stage) {
+ const GrConfigConversionEffect& effect =
+ static_cast<const GrConfigConversionEffect&>(*stage.getEffect());
+ fEffectMatrix.setData(uman,
+ effect.getMatrix(),
+ stage.getCoordChangeMatrix(),
+ effect.texture(0));
+ }
+
static inline EffectKey GenKey(const GrEffectStage& s, const GrGLCaps&) {
const GrConfigConversionEffect& effect =
static_cast<const GrConfigConversionEffect&>(*s.getEffect());
- return static_cast<int>(effect.swapsRedAndBlue()) | (effect.pmConversion() << 1);
+ EffectKey key = static_cast<EffectKey>(effect.swapsRedAndBlue()) |
+ (effect.pmConversion() << 1);
+ key <<= GrGLEffectMatrix::kKeyBits;
+ EffectKey matrixKey = GrGLEffectMatrix::GenKey(effect.getMatrix(),
+ s.getCoordChangeMatrix(),
+ effect.texture(0));
+ GrAssert(!(matrixKey & key));
+ return matrixKey | key;
}
private:
bool fSwapRedAndBlue;
GrConfigConversionEffect::PMConversion fPMConversion;
+ GrGLEffectMatrix fEffectMatrix;
typedef GrGLEffect INHERITED;
@@ -78,8 +101,9 @@ private:
GrConfigConversionEffect::GrConfigConversionEffect(GrTexture* texture,
bool swapRedAndBlue,
- PMConversion pmConversion)
- : GrSingleTextureEffect(texture)
+ PMConversion pmConversion,
+ const SkMatrix& matrix)
+ : GrSingleTextureEffect(texture, matrix)
, fSwapRedAndBlue(swapRedAndBlue)
, fPMConversion(pmConversion) {
GrAssert(kRGBA_8888_GrPixelConfig == texture->config() ||
@@ -111,8 +135,10 @@ GrEffect* GrConfigConversionEffect::TestCreate(SkRandom* random,
} else {
swapRB = random->nextBool();
}
- return SkNEW_ARGS(GrConfigConversionEffect,
- (textures[GrEffectUnitTest::kSkiaPMTextureIdx], swapRB, pmConv));
+ return SkNEW_ARGS(GrConfigConversionEffect, (textures[GrEffectUnitTest::kSkiaPMTextureIdx],
+ swapRB,
+ pmConv,
+ GrEffectUnitTest::TestMatrix(random)));
}
///////////////////////////////////////////////////////////////////////////////
@@ -179,13 +205,21 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
// We then verify that two reads produced the same values.
GrPaint paint;
-
SkAutoTUnref<GrEffect> pmToUPMEffect1(SkNEW_ARGS(GrConfigConversionEffect,
- (dataTex, false, *pmToUPMRule)));
+ (dataTex,
+ false,
+ *pmToUPMRule,
+ SkMatrix::I())));
SkAutoTUnref<GrEffect> upmToPMEffect(SkNEW_ARGS(GrConfigConversionEffect,
- (readTex, false, *upmToPMRule)));
+ (readTex,
+ false,
+ *upmToPMRule,
+ SkMatrix::I())));
SkAutoTUnref<GrEffect> pmToUPMEffect2(SkNEW_ARGS(GrConfigConversionEffect,
- (tempTex, false, *pmToUPMRule)));
+ (tempTex,
+ false,
+ *pmToUPMRule,
+ SkMatrix::I())));
context->setRenderTarget(readTex->asRenderTarget());
paint.colorStage(0)->setEffect(pmToUPMEffect1);
@@ -238,7 +272,7 @@ bool GrConfigConversionEffect::InstallEffect(GrTexture* texture,
}
stage->setEffect(SkNEW_ARGS(GrConfigConversionEffect, (texture,
swapRedAndBlue,
- pmConversion)), matrix)->unref();
+ pmConversion, matrix)))->unref();
return true;
}
}
diff --git a/src/gpu/effects/GrConfigConversionEffect.h b/src/gpu/effects/GrConfigConversionEffect.h
index 6a10c25e97..48c776ccf4 100644
--- a/src/gpu/effects/GrConfigConversionEffect.h
+++ b/src/gpu/effects/GrConfigConversionEffect.h
@@ -61,7 +61,8 @@ public:
private:
GrConfigConversionEffect(GrTexture*,
bool swapRedAndBlue,
- PMConversion pmConversion);
+ PMConversion pmConversion,
+ const SkMatrix& matrix);
bool fSwapRedAndBlue;
PMConversion fPMConversion;