Isolate VertexBuilder from GrGLShaderBuilder
Adds a nested class to GrGLShaderBuilder called VertexBuilder. Now
GrGLShaderBuilder can only modify the fragment shader directly. In
order to modify the vertex shader, the client code needs to call
getVertexShader, which will return null for vertex-less shaders.
R=bsalomon@google.com
Author: cdalton@nvidia.com
Review URL: https://chromiumcodereview.appspot.com/23754003
git-svn-id: http://skia.googlecode.com/svn/trunk@11046 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp
index 5e0c4b8..cf9cb98 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp
@@ -506,9 +506,11 @@
// 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, "Conical2BCoeff",
- &fVSVaryingName, &fFSVaryingName);
+ GrGLShaderBuilder::VertexBuilder* vertexBuilder =
+ (kVec2f_GrSLType == coordsVaryingType) ? builder->getVertexBuilder() : NULL;
+ if (NULL != vertexBuilder) {
+ vertexBuilder->addVarying(kFloat_GrSLType, "Conical2BCoeff",
+ &fVSVaryingName, &fFSVaryingName);
}
// VS
@@ -522,11 +524,11 @@
// For radial gradients without perspective we can pass the linear
// part of the quadratic as a varying.
- if (kVec2f_GrSLType == coordsVaryingType) {
+ if (NULL != vertexBuilder) {
// r2Var = -2 * (r2Parm[2] * varCoord.x - r2Param[3] * r2Param[5])
- builder->vsCodeAppendf("\t%s = -2.0 * (%s * %s.x + %s * %s);\n",
- fVSVaryingName, p2.c_str(),
- vsCoordsVarying.c_str(), p3.c_str(), p5.c_str());
+ 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());
}
}
@@ -557,7 +559,7 @@
// If we we're able to interpolate the linear component,
// bVar is the varying; otherwise compute it
SkString bVar;
- if (kVec2f_GrSLType == coordsVaryingType) {
+ if (NULL != vertexBuilder) {
bVar = fFSVaryingName;
} else {
bVar = "b";