Index: src/gpu/effects/GrBicubicEffect.cpp |
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp |
index ba8eff3273f9da1268471c90c0de9e8c11e7c209..d9e6182e7b6367e26119bfda5d1058f0cd437812 100644 |
--- a/src/gpu/effects/GrBicubicEffect.cpp |
+++ b/src/gpu/effects/GrBicubicEffect.cpp |
@@ -72,39 +72,42 @@ void GrGLBicubicEffect::emitCode(EmitArgs& args) { |
GrGLSLShaderVar("c2", kVec4f_GrSLType), |
GrGLSLShaderVar("c3", kVec4f_GrSLType), |
}; |
- GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder(); |
- SkString coords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 0); |
- fsBuilder->emitFunction(kVec4f_GrSLType, |
- "cubicBlend", |
- SK_ARRAY_COUNT(gCubicBlendArgs), |
- gCubicBlendArgs, |
- "\tvec4 ts = vec4(1.0, t, t * t, t * t * t);\n" |
- "\tvec4 c = coefficients * ts;\n" |
- "\treturn c.x * c0 + c.y * c1 + c.z * c2 + c.w * c3;\n", |
- &cubicBlendName); |
- fsBuilder->codeAppendf("\tvec2 coord = %s - %s * vec2(0.5);\n", coords2D.c_str(), imgInc); |
+ GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
+ SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0); |
+ fragBuilder->emitFunction(kVec4f_GrSLType, |
+ "cubicBlend", |
+ SK_ARRAY_COUNT(gCubicBlendArgs), |
+ gCubicBlendArgs, |
+ "\tvec4 ts = vec4(1.0, t, t * t, t * t * t);\n" |
+ "\tvec4 c = coefficients * ts;\n" |
+ "\treturn c.x * c0 + c.y * c1 + c.z * c2 + c.w * c3;\n", |
+ &cubicBlendName); |
+ fragBuilder->codeAppendf("\tvec2 coord = %s - %s * vec2(0.5);\n", coords2D.c_str(), imgInc); |
// We unnormalize the coord in order to determine our fractional offset (f) within the texel |
// We then snap coord to a texel center and renormalize. The snap prevents cases where the |
// starting coords are near a texel boundary and accumulations of imgInc would cause us to skip/ |
// double hit a texel. |
- fsBuilder->codeAppendf("\tcoord /= %s;\n", imgInc); |
- fsBuilder->codeAppend("\tvec2 f = fract(coord);\n"); |
- fsBuilder->codeAppendf("\tcoord = (coord - f + vec2(0.5)) * %s;\n", imgInc); |
- fsBuilder->codeAppend("\tvec4 rowColors[4];\n"); |
+ fragBuilder->codeAppendf("\tcoord /= %s;\n", imgInc); |
+ fragBuilder->codeAppend("\tvec2 f = fract(coord);\n"); |
+ fragBuilder->codeAppendf("\tcoord = (coord - f + vec2(0.5)) * %s;\n", imgInc); |
+ fragBuilder->codeAppend("\tvec4 rowColors[4];\n"); |
for (int y = 0; y < 4; ++y) { |
for (int x = 0; x < 4; ++x) { |
SkString coord; |
coord.printf("coord + %s * vec2(%d, %d)", imgInc, x - 1, y - 1); |
SkString sampleVar; |
sampleVar.printf("rowColors[%d]", x); |
- fDomain.sampleTexture(fsBuilder, domain, sampleVar.c_str(), coord, args.fSamplers[0]); |
+ fDomain.sampleTexture(fragBuilder, domain, sampleVar.c_str(), coord, args.fSamplers[0]); |
} |
- fsBuilder->codeAppendf("\tvec4 s%d = %s(%s, f.x, rowColors[0], rowColors[1], rowColors[2], rowColors[3]);\n", y, cubicBlendName.c_str(), coeff); |
+ fragBuilder->codeAppendf( |
+ "\tvec4 s%d = %s(%s, f.x, rowColors[0], rowColors[1], rowColors[2], rowColors[3]);\n", |
+ y, cubicBlendName.c_str(), coeff); |
} |
SkString bicubicColor; |
bicubicColor.printf("%s(%s, f.y, s0, s1, s2, s3)", cubicBlendName.c_str(), coeff); |
- fsBuilder->codeAppendf("\t%s = %s;\n", args.fOutputColor,(GrGLSLExpr4(bicubicColor.c_str()) * |
- GrGLSLExpr4(args.fInputColor)).c_str()); |
+ fragBuilder->codeAppendf("\t%s = %s;\n", |
+ args.fOutputColor, (GrGLSLExpr4(bicubicColor.c_str()) * |
+ GrGLSLExpr4(args.fInputColor)).c_str()); |
} |
void GrGLBicubicEffect::onSetData(const GrGLSLProgramDataManager& pdman, |