Index: src/effects/gradients/SkGradientShader.cpp |
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp |
index be6fdb036d4a50e52c2a54b3e2ebc1425afeb16c..74355b8a0b8a7faee3938585e41c3acf6b1f9402 100644 |
--- a/src/effects/gradients/SkGradientShader.cpp |
+++ b/src/effects/gradients/SkGradientShader.cpp |
@@ -825,8 +825,7 @@ SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
GrGLGradientEffect::GrGLGradientEffect(const GrBackendEffectFactory& factory) |
: INHERITED(factory) |
- , fCachedYCoord(SK_ScalarMax) |
- , fEffectMatrix(kCoordsType) { |
+ , fCachedYCoord(SK_ScalarMax) { |
} |
GrGLGradientEffect::~GrGLGradientEffect() { } |
@@ -883,7 +882,6 @@ void GrGLGradientEffect::setData(const GrGLUniformManager& uman, |
if (GrGradientEffect::kTwo_ColorType == e.getColorType()){ |
- fEffectMatrix.setData(uman, e.getMatrix(), drawEffect, NULL); |
if (GrGradientEffect::kBeforeInterp_PremulType == e.getPremulType()) { |
set_mul_color_uni(uman, fColorStartUni, e.getColors(0)); |
set_mul_color_uni(uman, fColorEndUni, e.getColors(1)); |
@@ -894,7 +892,6 @@ void GrGLGradientEffect::setData(const GrGLUniformManager& uman, |
} else if (GrGradientEffect::kThree_ColorType == e.getColorType()){ |
- fEffectMatrix.setData(uman, e.getMatrix(), drawEffect, NULL); |
if (GrGradientEffect::kBeforeInterp_PremulType == e.getPremulType()) { |
set_mul_color_uni(uman, fColorStartUni, e.getColors(0)); |
set_mul_color_uni(uman, fColorMidUni, e.getColors(1)); |
@@ -905,8 +902,6 @@ void GrGLGradientEffect::setData(const GrGLUniformManager& uman, |
set_color_uni(uman, fColorEndUni, e.getColors(2)); |
} |
} else { |
- const GrTexture* texture = e.texture(0); |
- fEffectMatrix.setData(uman, e.getMatrix(), drawEffect, texture); |
SkScalar yCoord = e.getYCoord(); |
if (yCoord != fCachedYCoord) { |
@@ -919,13 +914,8 @@ void GrGLGradientEffect::setData(const GrGLUniformManager& uman, |
GrGLEffect::EffectKey GrGLGradientEffect::GenBaseGradientKey(const GrDrawEffect& drawEffect) { |
const GrGradientEffect& e = drawEffect.castEffect<GrGradientEffect>(); |
- const GrTexture* texture = NULL; |
- if (GrGradientEffect::kTexture_ColorType == e.getColorType()){ |
- texture = e.texture(0); |
- } |
- |
- EffectKey key = GrGLEffectMatrix::GenKey(e.getMatrix(), drawEffect, kCoordsType, texture); |
+ EffectKey key = 0; |
if (GrGradientEffect::kTwo_ColorType == e.getColorType()) { |
key |= kTwoColorKey; |
@@ -940,18 +930,6 @@ GrGLEffect::EffectKey GrGLGradientEffect::GenBaseGradientKey(const GrDrawEffect& |
return key; |
} |
-void GrGLGradientEffect::setupMatrix(GrGLShaderBuilder* builder, |
- EffectKey key, |
- SkString* fsCoordName, |
- SkString* vsVaryingName, |
- GrSLType* vsVaryingType) { |
- fEffectMatrix.emitCodeMakeFSCoords2D(builder, |
- key & kMatrixKeyMask, |
- fsCoordName, |
- vsVaryingName, |
- vsVaryingType); |
-} |
- |
void GrGLGradientEffect::emitColor(GrGLShaderBuilder* builder, |
const char* gradientTValue, |
EffectKey key, |
@@ -1023,8 +1001,6 @@ GrGradientEffect::GrGradientEffect(GrContext* ctx, |
const SkMatrix& matrix, |
SkShader::TileMode tileMode) { |
- |
- fMatrix = matrix; |
fIsOpaque = shader.isOpaque(); |
SkShader::GradientInfo info; |
@@ -1055,6 +1031,7 @@ GrGradientEffect::GrGradientEffect(GrContext* ctx, |
} else { |
fPremulType = kAfterInterp_PremulType; |
} |
+ fCoordTransform.reset(kCoordSet, matrix); |
} else { |
// doesn't matter how this is set, just be consistent because it is part of the effect key. |
fPremulType = kBeforeInterp_PremulType; |
@@ -1080,9 +1057,11 @@ GrGradientEffect::GrGradientEffect(GrContext* ctx, |
if (-1 != fRow) { |
fYCoord = fAtlas->getYOffset(fRow) + SK_ScalarHalf * |
fAtlas->getVerticalScaleFactor(); |
+ fCoordTransform.reset(kCoordSet, matrix, fAtlas->getTexture()); |
fTextureAccess.reset(fAtlas->getTexture(), params); |
} else { |
GrTexture* texture = GrLockAndRefCachedBitmapTexture(ctx, bitmap, ¶ms); |
+ fCoordTransform.reset(kCoordSet, matrix, texture); |
fTextureAccess.reset(texture, params); |
fYCoord = SK_ScalarHalf; |
@@ -1093,6 +1072,7 @@ GrGradientEffect::GrGradientEffect(GrContext* ctx, |
} |
this->addTextureAccess(&fTextureAccess); |
} |
+ this->addCoordTransform(&fCoordTransform); |
} |
GrGradientEffect::~GrGradientEffect() { |
@@ -1124,7 +1104,7 @@ bool GrGradientEffect::onIsEqual(const GrEffect& effect) const { |
s.fTextureAccess.getParams().getTileModeX() && |
this->useAtlas() == s.useAtlas() && |
fYCoord == s.getYCoord() && |
- fMatrix.cheapEqualTo(s.getMatrix()); |
+ fCoordTransform.getMatrix().cheapEqualTo(s.fCoordTransform.getMatrix()); |
} |
return false; |