aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects/gradients
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-01 15:47:55 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-01 15:47:55 +0000
commit115b06f3d51902a122621e897360ba80153527b3 (patch)
tree82a6e178b304838e1a5e26d77c9476c547128f6e /src/effects/gradients
parentc3a58f345de16c185db3a20578c7ddf52bc89d38 (diff)
Re-revert r6233.
git-svn-id: http://skia.googlecode.com/svn/trunk@6239 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/effects/gradients')
-rw-r--r--src/effects/gradients/SkGradientShader.cpp33
-rw-r--r--src/effects/gradients/SkGradientShaderPriv.h39
-rw-r--r--src/effects/gradients/SkLinearGradient.cpp22
-rw-r--r--src/effects/gradients/SkRadialGradient.cpp24
-rw-r--r--src/effects/gradients/SkSweepGradient.cpp20
-rw-r--r--src/effects/gradients/SkTwoPointConicalGradient.cpp36
-rw-r--r--src/effects/gradients/SkTwoPointRadialGradient.cpp46
7 files changed, 54 insertions, 166 deletions
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index 78c7e34a74..60eff91d65 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -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);
diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h
index 24379110ee..9f14e7f727 100644
--- a/src/effects/gradients/SkGradientShaderPriv.h
+++ b/src/effects/gradients/SkGradientShaderPriv.h
@@ -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;
};
diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp
index 71614505a1..d9576565b5 100644
--- a/src/effects/gradients/SkLinearGradient.cpp
+++ b/src/effects/gradients/SkLinearGradient.cpp
@@ -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;
}
diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp
index 02a56da588..a20ea35a1a 100644
--- a/src/effects/gradients/SkRadialGradient.cpp
+++ b/src/effects/gradients/SkRadialGradient.cpp
@@ -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;
}
diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp
index 589cf4ad14..a783e3757c 100644
--- a/src/effects/gradients/SkSweepGradient.cpp
+++ b/src/effects/gradients/SkSweepGradient.cpp
@@ -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;
}
diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp
index 41292bb43a..f93f660837 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp
@@ -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;
}
diff --git a/src/effects/gradients/SkTwoPointRadialGradient.cpp b/src/effects/gradients/SkTwoPointRadialGradient.cpp
index d0186291f2..659bce0099 100644
--- a/src/effects/gradients/SkTwoPointRadialGradient.cpp
+++ b/src/effects/gradients/SkTwoPointRadialGradient.cpp
@@ -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;
}