Fix case where GrGLEffectMatrix gives back a dangling ptr for the coords var name.

R=robertphillips@google.com

Author: bsalomon@google.com

Review URL: https://chromiumcodereview.appspot.com/23706003

git-svn-id: http://skia.googlecode.com/svn/trunk@10982 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2013-08-28 15:59:13 +00:00
parent 1c028bd395
commit 7ab7ca4199
22 changed files with 71 additions and 69 deletions

View File

@ -948,13 +948,13 @@ public:
const GrTexture* backgroundTex = drawEffect.castEffect<XferEffect>().backgroundAccess().getTexture();
const char* dstColor;
if (backgroundTex) {
const char* bgCoords;
SkString bgCoords;
GrSLType bgCoordsType = fBackgroundEffectMatrix.emitCode(builder, key, &bgCoords, NULL, "BG");
dstColor = "bgColor";
builder->fsCodeAppendf("\t\tvec4 %s = ", dstColor);
builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType,
samplers[0],
bgCoords,
bgCoords.c_str(),
bgCoordsType);
builder->fsCodeAppendf(";\n");
} else {

View File

@ -351,12 +351,12 @@ void GrGLArithmeticEffect::emitCode(GrGLShaderBuilder* builder,
GrTexture* backgroundTex = drawEffect.castEffect<GrArithmeticEffect>().backgroundTexture();
const char* dstColor;
if (backgroundTex) {
const char* bgCoords;
SkString bgCoords;
GrSLType bgCoordsType = fBackgroundEffectMatrix.emitCode(builder, key, &bgCoords, NULL, "BG");
builder->fsCodeAppend("\t\tvec4 bgColor = ");
builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType,
samplers[0],
bgCoords,
bgCoords.c_str(),
bgCoordsType);
builder->fsCodeAppendf(";\n");
dstColor = "bgColor";

View File

@ -224,7 +224,7 @@ void GrGLBicubicEffect::emitCode(GrGLShaderBuilder* builder,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) {
const char* coords;
SkString coords;
fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords);
fCoefficientsUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
kMat44f_GrSLType, "Coefficients");
@ -253,7 +253,7 @@ void GrGLBicubicEffect::emitCode(GrGLShaderBuilder* builder,
"\tvec4 c = coefficients * ts;\n"
"\treturn c.x * c0 + c.y * c1 + c.z * c2 + c.w * c3;\n",
&cubicBlendName);
builder->fsCodeAppendf("\tvec2 coord = %s - %s * vec2(0.5, 0.5);\n", coords, imgInc);
builder->fsCodeAppendf("\tvec2 coord = %s - %s * vec2(0.5, 0.5);\n", coords.c_str(), imgInc);
builder->fsCodeAppendf("\tvec2 f = fract(coord / %s);\n", imgInc);
for (int y = 0; y < 4; ++y) {
for (int x = 0; x < 4; ++x) {

View File

@ -413,10 +413,10 @@ void GrGLDisplacementMapEffect::emitCode(GrGLShaderBuilder* builder,
kVec2f_GrSLType, "Scale");
const char* scaleUni = builder->getUniformCStr(fScaleUni);
const char* dCoordsIn;
SkString dCoordsIn;
GrSLType dCoordsType = fDisplacementEffectMatrix.emitCode(
builder, key, &dCoordsIn, NULL, "DISPL");
const char* cCoordsIn;
SkString cCoordsIn;
GrSLType cCoordsType = fColorEffectMatrix.emitCode(
builder, key, &cCoordsIn, NULL, "COLOR");
@ -430,7 +430,7 @@ void GrGLDisplacementMapEffect::emitCode(GrGLShaderBuilder* builder,
builder->fsCodeAppendf("\t\tvec4 %s = ", dColor);
builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType,
samplers[0],
dCoordsIn,
dCoordsIn.c_str(),
dCoordsType);
builder->fsCodeAppend(";\n");
@ -439,7 +439,7 @@ void GrGLDisplacementMapEffect::emitCode(GrGLShaderBuilder* builder,
dColor, dColor, nearZero, dColor, dColor);
builder->fsCodeAppendf("\t\tvec2 %s = %s + %s*(%s.",
cCoords, cCoordsIn, scaleUni, dColor);
cCoords, cCoordsIn.c_str(), scaleUni, dColor);
switch (fXChannelSelector) {
case SkDisplacementMapEffect::kR_ChannelSelectorType:

View File

@ -1204,7 +1204,7 @@ void GrGLLightingEffect::emitCode(GrGLShaderBuilder* builder,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) {
const char* coords;
SkString coords;
fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords);
fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
@ -1267,7 +1267,7 @@ void GrGLLightingEffect::emitCode(GrGLShaderBuilder* builder,
interiorNormalBody.c_str(),
&interiorNormalName);
builder->fsCodeAppendf("\t\tvec2 coord = %s;\n", coords);
builder->fsCodeAppendf("\t\tvec2 coord = %s;\n", coords.c_str());
builder->fsCodeAppend("\t\tfloat m[9];\n");
const char* imgInc = builder->getUniformCStr(fImageIncrementUni);

View File

@ -127,7 +127,7 @@ void GrGLMagnifierEffect::emitCode(GrGLShaderBuilder* builder,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) {
const char* coords;
SkString coords;
fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords);
fOffsetVar = builder->addUniform(
GrGLShaderBuilder::kFragment_ShaderType |
@ -142,10 +142,10 @@ void GrGLMagnifierEffect::emitCode(GrGLShaderBuilder* builder,
GrGLShaderBuilder::kVertex_ShaderType,
kVec2f_GrSLType, "uInset");
builder->fsCodeAppendf("\t\tvec2 coord = %s;\n", coords);
builder->fsCodeAppendf("\t\tvec2 coord = %s;\n", coords.c_str());
builder->fsCodeAppendf("\t\tvec2 zoom_coord = %s + %s / %s;\n",
builder->getUniformCStr(fOffsetVar),
coords,
coords.c_str(),
builder->getUniformCStr(fZoomVar));
builder->fsCodeAppend("\t\tvec2 delta = min(coord, vec2(1.0, 1.0) - coord);\n");

View File

@ -385,7 +385,7 @@ void GrGLMatrixConvolutionEffect::emitCode(GrGLShaderBuilder* builder,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) {
const char* coords;
SkString coords;
fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords);
fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
kVec2f_GrSLType, "ImageIncrement");
@ -407,7 +407,7 @@ void GrGLMatrixConvolutionEffect::emitCode(GrGLShaderBuilder* builder,
int kHeight = fKernelSize.height();
builder->fsCodeAppend("\t\tvec4 sum = vec4(0, 0, 0, 0);\n");
builder->fsCodeAppendf("\t\tvec2 coord = %s - %s * %s;\n", coords, target, imgInc);
builder->fsCodeAppendf("\t\tvec2 coord = %s - %s * %s;\n", coords.c_str(), target, imgInc);
builder->fsCodeAppendf("\t\tfor (int y = 0; y < %d; y++) {\n", kHeight);
builder->fsCodeAppendf("\t\t\tfor (int x = 0; x < %d; x++) {\n", kWidth);
builder->fsCodeAppendf("\t\t\t\tfloat k = %s[y * %d + x];\n", kernel, kWidth);
@ -426,7 +426,7 @@ void GrGLMatrixConvolutionEffect::emitCode(GrGLShaderBuilder* builder,
builder->fsCodeAppendf("\t\t%s.rgb = clamp(%s.rgb, 0.0, %s.a);\n", outputColor, outputColor, outputColor);
} else {
builder->fsCodeAppend("\t\tvec4 c = ");
appendTextureLookup(builder, samplers[0], coords, fTileMode);
appendTextureLookup(builder, samplers[0], coords.c_str(), fTileMode);
builder->fsCodeAppend(";\n");
builder->fsCodeAppendf("\t\t%s.a = c.a;\n", outputColor);
builder->fsCodeAppendf("\t\t%s.rgb = sum.rgb * %s + %s;\n", outputColor, gain, bias);

View File

@ -324,7 +324,7 @@ void GrGLMorphologyEffect::emitCode(GrGLShaderBuilder* builder,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) {
const char* coords;
SkString coords;
fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords);
fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
kVec2f_GrSLType, "ImageIncrement");
@ -346,7 +346,7 @@ void GrGLMorphologyEffect::emitCode(GrGLShaderBuilder* builder,
}
const char* imgInc = builder->getUniformCStr(fImageIncrementUni);
builder->fsCodeAppendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords, fRadius, imgInc);
builder->fsCodeAppendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords.c_str(), fRadius, imgInc);
builder->fsCodeAppendf("\t\tfor (int i = 0; i < %d; i++) {\n", this->width());
builder->fsCodeAppendf("\t\t\t%s = %s(%s, ", outputColor, func, outputColor);
builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, samplers[0], "coord");

View File

@ -749,7 +749,7 @@ void GrGLSimplexNoise::emitCode(GrGLShaderBuilder* builder,
const TextureSamplerArray&) {
sk_ignore_unused_variable(inputColor);
const char* vCoords;
SkString vCoords;
fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &vCoords);
fSeedUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
@ -904,7 +904,7 @@ void GrGLSimplexNoise::emitCode(GrGLShaderBuilder* builder,
// There are rounding errors if the floor operation is not performed here
builder->fsCodeAppendf(
"\t\tvec3 %s = vec3(floor((%s*vec3(%s, 1.0)).xy) * vec2(0.66) * %s, 0.0);\n",
noiseVecIni, invMatrixUni, vCoords, baseFrequencyUni);
noiseVecIni, invMatrixUni, vCoords.c_str(), baseFrequencyUni);
// Perturb the texcoords with three components of noise
builder->fsCodeAppendf("\t\t%s += 0.1 * vec3(%s(%s + vec3( 0.0, 0.0, %s)),"
@ -965,7 +965,7 @@ void GrGLPerlinNoise::emitCode(GrGLShaderBuilder* builder,
const TextureSamplerArray& samplers) {
sk_ignore_unused_variable(inputColor);
const char* vCoords;
SkString vCoords;
fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &vCoords);
fInvMatrixUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
@ -1148,7 +1148,7 @@ void GrGLPerlinNoise::emitCode(GrGLShaderBuilder* builder,
// There are rounding errors if the floor operation is not performed here
builder->fsCodeAppendf("\n\t\tvec2 %s = floor((%s * vec3(%s, 1.0)).xy) * %s;",
noiseVec, invMatrixUni, vCoords, baseFrequencyUni);
noiseVec, invMatrixUni, vCoords.c_str(), baseFrequencyUni);
// Clear the color accumulator
builder->fsCodeAppendf("\n\t\t%s = vec4(0.0);", outputColor);

View File

@ -857,8 +857,8 @@ GrGLEffect::EffectKey GrGLGradientEffect::GenMatrixKey(const GrDrawEffect& drawE
void GrGLGradientEffect::setupMatrix(GrGLShaderBuilder* builder,
EffectKey key,
const char** fsCoordName,
const char** vsVaryingName,
SkString* fsCoordName,
SkString* vsVaryingName,
GrSLType* vsVaryingType) {
fEffectMatrix.emitCodeMakeFSCoords2D(builder,
key & kMatrixKeyMask,

View File

@ -317,8 +317,8 @@ protected:
*/
void setupMatrix(GrGLShaderBuilder* builder,
EffectKey key,
const char** fsCoordName,
const char** vsVaryingName = NULL,
SkString* fsCoordName,
SkString* vsVaryingName = NULL,
GrSLType* vsVaryingType = NULL);
// Emits the uniform used as the y-coord to texture samples in derived classes. Subclasses

View File

@ -525,7 +525,7 @@ void GrGLLinearGradient::emitCode(GrGLShaderBuilder* builder,
const char* inputColor,
const TextureSamplerArray& samplers) {
this->emitYCoordUniform(builder);
const char* coords;
SkString coords;
this->setupMatrix(builder, key, &coords);
SkString t;
t.append(coords);

View File

@ -559,7 +559,7 @@ void GrGLRadialGradient::emitCode(GrGLShaderBuilder* builder,
const char* inputColor,
const TextureSamplerArray& samplers) {
this->emitYCoordUniform(builder);
const char* coords;
SkString coords;
this->setupMatrix(builder, key, &coords);
SkString t("length(");
t.append(coords);

View File

@ -473,10 +473,10 @@ void GrGLSweepGradient::emitCode(GrGLShaderBuilder* builder,
const char* inputColor,
const TextureSamplerArray& samplers) {
this->emitYCoordUniform(builder);
const char* coords;
SkString coords;
this->setupMatrix(builder, key, &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", coords.c_str(), coords.c_str());
this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, samplers[0]);
}

View File

@ -490,8 +490,8 @@ void GrGLConical2Gradient::emitCode(GrGLShaderBuilder* builder,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) {
const char* fsCoords;
const char* vsCoordsVarying;
SkString fsCoords;
SkString vsCoordsVarying;
GrSLType coordsVaryingType;
this->setupMatrix(builder, key, &fsCoords, &vsCoordsVarying, &coordsVaryingType);
@ -526,7 +526,7 @@ void GrGLConical2Gradient::emitCode(GrGLShaderBuilder* builder,
// 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, p3.c_str(), p5.c_str());
vsCoordsVarying.c_str(), p3.c_str(), p5.c_str());
}
}
@ -562,7 +562,7 @@ void GrGLConical2Gradient::emitCode(GrGLShaderBuilder* builder,
} else {
bVar = "b";
builder->fsCodeAppendf("\tfloat %s = -2.0 * (%s * %s.x + %s * %s);\n",
bVar.c_str(), p2.c_str(), fsCoords,
bVar.c_str(), p2.c_str(), fsCoords.c_str(),
p3.c_str(), p5.c_str());
}
@ -572,7 +572,7 @@ void GrGLConical2Gradient::emitCode(GrGLShaderBuilder* builder,
// c = (x^2)+(y^2) - params[4]
builder->fsCodeAppendf("\tfloat %s = dot(%s, %s) - %s;\n", cName.c_str(),
fsCoords, fsCoords,
fsCoords.c_str(), fsCoords.c_str(),
p4.c_str());
// Non-degenerate case (quadratic)

View File

@ -533,8 +533,8 @@ void GrGLRadial2Gradient::emitCode(GrGLShaderBuilder* builder,
const TextureSamplerArray& samplers) {
this->emitYCoordUniform(builder);
const char* fsCoords;
const char* vsCoordsVarying;
SkString fsCoords;
SkString vsCoordsVarying;
GrSLType coordsVaryingType;
this->setupMatrix(builder, key, &fsCoords, &vsCoordsVarying, &coordsVaryingType);
@ -565,7 +565,7 @@ void GrGLRadial2Gradient::emitCode(GrGLShaderBuilder* builder,
// r2Var = 2 * (r2Parm[2] * varCoord.x - r2Param[3])
builder->vsCodeAppendf("\t%s = 2.0 *(%s * %s.x - %s);\n",
fVSVaryingName, p2.c_str(),
vsCoordsVarying, p3.c_str());
vsCoordsVarying.c_str(), p3.c_str());
}
}
@ -596,14 +596,14 @@ void GrGLRadial2Gradient::emitCode(GrGLShaderBuilder* builder,
} else {
bVar = "b";
builder->fsCodeAppendf("\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(), fsCoords.c_str(), p3.c_str());
}
// c = (x^2)+(y^2) - params[4]
builder->fsCodeAppendf("\tfloat %s = dot(%s, %s) - %s;\n",
cName.c_str(),
fsCoords,
fsCoords,
fsCoords.c_str(),
fsCoords.c_str(),
p4.c_str());
// If we aren't degenerate, emit some extra code, and accept a slightly

View File

@ -30,12 +30,12 @@ public:
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) SK_OVERRIDE {
const char* coords;
SkString coords;
GrSLType coordsType = fEffectMatrix.emitCode(builder, key, &coords);
builder->fsCodeAppendf("\t\t%s = ", outputColor);
builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType,
samplers[0],
coords,
coords.c_str(),
coordsType);
builder->fsCodeAppend(";\n");
if (GrConfigConversionEffect::kNone_PMConversion == fPMConversion) {

View File

@ -62,7 +62,7 @@ void GrGLConvolutionEffect::emitCode(GrGLShaderBuilder* builder,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) {
const char* coords;
SkString coords;
fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords);
fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
kVec2f_GrSLType, "ImageIncrement");
@ -79,7 +79,7 @@ void GrGLConvolutionEffect::emitCode(GrGLShaderBuilder* builder,
const GrGLShaderVar& kernel = builder->getUniformVariable(fKernelUni);
const char* imgInc = builder->getUniformCStr(fImageIncrementUni);
builder->fsCodeAppendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords, fRadius, imgInc);
builder->fsCodeAppendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords.c_str(), fRadius, imgInc);
// Manually unroll loop because some drivers don't; yields 20-30% speedup.
for (int i = 0; i < width; i++) {

View File

@ -31,14 +31,16 @@ public:
const char* inputColor,
const TextureSamplerArray& samplers) SK_OVERRIDE {
const GrSimpleTextureEffect& ste = drawEffect.castEffect<GrSimpleTextureEffect>();
const char* fsCoordName;
SkString fsCoordName;
GrSLType fsCoordSLType;
if (GrEffect::kCustom_CoordsType == ste.coordsType()) {
SkASSERT(ste.getMatrix().isIdentity());
SkASSERT(1 == ste.numVertexAttribs());
fsCoordSLType = kVec2f_GrSLType;
const char* vsVaryingName;
builder->addVarying(kVec2f_GrSLType, "textureCoords", &vsVaryingName, &fsCoordName);
const char* fsVaryingNamePtr;
builder->addVarying(kVec2f_GrSLType, "textureCoords", &vsVaryingName, &fsVaryingNamePtr);
fsCoordName = fsVaryingNamePtr;
const char* attrName =
builder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0])->c_str();
builder->vsCodeAppendf("\t%s = %s;\n", vsVaryingName, attrName);
@ -49,7 +51,7 @@ public:
builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_ShaderType,
inputColor,
samplers[0],
fsCoordName,
fsCoordName.c_str(),
fsCoordSLType);
builder->fsCodeAppend(";\n");
}

View File

@ -50,7 +50,7 @@ void GrGLTextureDomainEffect::emitCode(GrGLShaderBuilder* builder,
const TextureSamplerArray& samplers) {
const GrTextureDomainEffect& texDom = drawEffect.castEffect<GrTextureDomainEffect>();
const char* coords;
SkString coords;
fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords);
const char* domain;
fNameUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
@ -58,7 +58,7 @@ void GrGLTextureDomainEffect::emitCode(GrGLShaderBuilder* builder,
if (GrTextureDomainEffect::kClamp_WrapMode == texDom.wrapMode()) {
builder->fsCodeAppendf("\tvec2 clampCoord = clamp(%s, %s.xy, %s.zw);\n",
coords, domain, domain);
coords.c_str(), domain, domain);
builder->fsCodeAppendf("\t%s = ", outputColor);
builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_ShaderType,
@ -81,24 +81,24 @@ void GrGLTextureDomainEffect::emitCode(GrGLShaderBuilder* builder,
builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_ShaderType,
inputColor,
samplers[0],
coords);
coords.c_str());
builder->fsCodeAppend(";\n");
builder->fsCodeAppendf("\tfloat x = abs(2.0*(%s.x - %s.x)/(%s.z - %s.x) - 1.0);\n",
coords, domain, domain, domain);
coords.c_str(), domain, domain, domain);
builder->fsCodeAppendf("\tfloat y = abs(2.0*(%s.y - %s.y)/(%s.w - %s.y) - 1.0);\n",
coords, domain, domain, domain);
coords.c_str(), domain, domain, domain);
builder->fsCodeAppend("\tfloat blend = step(1.0, max(x, y));\n");
builder->fsCodeAppendf("\t%s = mix(inside, outside, blend);\n", outputColor);
} else {
builder->fsCodeAppend("\tbvec4 outside;\n");
builder->fsCodeAppendf("\toutside.xy = lessThan(%s, %s.xy);\n", coords, domain);
builder->fsCodeAppendf("\toutside.zw = greaterThan(%s, %s.zw);\n", coords, domain);
builder->fsCodeAppendf("\toutside.xy = lessThan(%s, %s.xy);\n", coords.c_str(), domain);
builder->fsCodeAppendf("\toutside.zw = greaterThan(%s, %s.zw);\n", coords.c_str(), domain);
builder->fsCodeAppendf("\t%s = any(outside) ? vec4(0.0, 0.0, 0.0, 0.0) : ", outputColor);
builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_ShaderType,
inputColor,
samplers[0],
coords);
coords.c_str());
builder->fsCodeAppend(";\n");
}
}

View File

@ -45,8 +45,8 @@ GrGLEffect::EffectKey GrGLEffectMatrix::GenKey(const SkMatrix& effectMatrix,
GrSLType GrGLEffectMatrix::emitCode(GrGLShaderBuilder* builder,
EffectKey key,
const char** fsCoordName,
const char** vsCoordName,
SkString* fsCoordName,
SkString* vsCoordName,
const char* suffix) {
GrSLType varyingType = kVoid_GrSLType;
const char* uniName;
@ -152,11 +152,11 @@ GrSLType GrGLEffectMatrix::emitCode(GrGLShaderBuilder* builder,
*/
void GrGLEffectMatrix::emitCodeMakeFSCoords2D(GrGLShaderBuilder* builder,
EffectKey key,
const char** fsCoordName,
const char** vsVaryingName,
SkString* fsCoordName,
SkString* vsVaryingName,
GrSLType* vsVaryingType,
const char* suffix) {
const char* fsVaryingName;
SkString fsVaryingName;
GrSLType varyingType = this->emitCode(builder,
key,
@ -173,7 +173,7 @@ void GrGLEffectMatrix::emitCodeMakeFSCoords2D(GrGLShaderBuilder* builder,
coordName = suffixedCoordName.c_str();
}
builder->fsCodeAppendf("\tvec2 %s = %s.xy / %s.z;",
coordName, fsVaryingName, fsVaryingName);
coordName, fsVaryingName.c_str(), fsVaryingName.c_str());
if (NULL != fsCoordName) {
*fsCoordName = coordName;
}

View File

@ -84,12 +84,12 @@ public:
* are returned as output parameters and the type of the varying is the return value. The suffix
* is an optional parameter that can be used to make all variables emitted by the object
* unique within a stage. It is only necessary if multiple GrGLEffectMatrix objects are used by
* a GrGLEffect.
* a single GrGLEffect.
*/
GrSLType emitCode(GrGLShaderBuilder*,
EffectKey,
const char** fsCoordName, /* optional */
const char** vsCoordName = NULL,
SkString* fsCoordName, /* optional */
SkString* vsCoordName = NULL,
const char* suffix = NULL);
/**
@ -98,8 +98,8 @@ public:
*/
void emitCodeMakeFSCoords2D(GrGLShaderBuilder*,
EffectKey,
const char** fsCoordName, /* optional */
const char** vsVaryingName = NULL,
SkString* fsCoordName, /* optional */
SkString* vsVaryingName = NULL,
GrSLType* vsVaryingType = NULL,
const char* suffix = NULL);
/**