Make GPU coord transforms automatic
Adds a GrCoordTransform class and updates the framework to handle
coord transforms similar to how it handles textures with
GrTextureAccess. Renames GrGLEffectMatrix to GrGLCoordTransform and
slightly repurposes it to be used by the framework instead of effects.
R=bsalomon@google.com, robertphillips@google.com
Review URL: https://codereview.chromium.org/24853002
git-svn-id: http://skia.googlecode.com/svn/trunk@11569 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp
index 6315565..0a5e29b 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp
@@ -347,6 +347,7 @@
EffectKey,
const char* outputColor,
const char* inputColor,
+ const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
@@ -488,12 +489,8 @@
EffectKey key,
const char* outputColor,
const char* inputColor,
+ const TransformedCoordsArray& coords,
const TextureSamplerArray& samplers) {
- SkString fsCoords;
- SkString vsCoordsVarying;
- GrSLType coordsVaryingType;
- this->setupMatrix(builder, key, &fsCoords, &vsCoordsVarying, &coordsVaryingType);
-
this->emitUniforms(builder, key);
// 2 copies of uniform array, 1 for each of vertex & fragment shader,
// to work around Xoom bug. Doesn't seem to cause performance decrease
@@ -506,7 +503,7 @@
// For radial gradients without perspective we can pass the linear
// part of the quadratic as a varying.
GrGLShaderBuilder::VertexBuilder* vertexBuilder =
- (kVec2f_GrSLType == coordsVaryingType) ? builder->getVertexBuilder() : NULL;
+ (kVec2f_GrSLType == coords[0].type()) ? builder->getVertexBuilder() : NULL;
if (NULL != vertexBuilder) {
vertexBuilder->addVarying(kFloat_GrSLType, "Conical2BCoeff",
&fVSVaryingName, &fFSVaryingName);
@@ -527,13 +524,13 @@
// r2Var = -2 * (r2Parm[2] * varCoord.x - r2Param[3] * r2Param[5])
vertexBuilder->vsCodeAppendf("\t%s = -2.0 * (%s * %s.x + %s * %s);\n",
fVSVaryingName, p2.c_str(),
- vsCoordsVarying.c_str(), p3.c_str(), p5.c_str());
+ coords[0].getVSName().c_str(), p3.c_str(), p5.c_str());
}
}
// FS
{
-
+ SkString coords2D = builder->ensureFSCoords2D(coords, 0);
SkString cName("c");
SkString ac4Name("ac4");
SkString dName("d");
@@ -563,7 +560,7 @@
} else {
bVar = "b";
builder->fsCodeAppendf("\tfloat %s = -2.0 * (%s * %s.x + %s * %s);\n",
- bVar.c_str(), p2.c_str(), fsCoords.c_str(),
+ bVar.c_str(), p2.c_str(), coords2D.c_str(),
p3.c_str(), p5.c_str());
}
@@ -573,7 +570,7 @@
// c = (x^2)+(y^2) - params[4]
builder->fsCodeAppendf("\tfloat %s = dot(%s, %s) - %s;\n", cName.c_str(),
- fsCoords.c_str(), fsCoords.c_str(),
+ coords2D.c_str(), coords2D.c_str(),
p4.c_str());
// Non-degenerate case (quadratic)