Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Unified Diff: src/effects/SkTableColorFilter.cpp

Issue 12547012: Make GrGLEffects use an interface to append their code. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/SkMorphologyImageFilter.cpp ('k') | src/effects/gradients/SkGradientShader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkTableColorFilter.cpp
===================================================================
--- src/effects/SkTableColorFilter.cpp (revision 8005)
+++ src/effects/SkTableColorFilter.cpp (working copy)
@@ -289,39 +289,38 @@
static const float kColorScaleFactor = 255.0f / 256.0f;
static const float kColorOffsetFactor = 1.0f / 512.0f;
- SkString* code = &builder->fFSCode;
if (NULL == inputColor) {
// the input color is solid white (all ones).
static const float kMaxValue = kColorScaleFactor + kColorOffsetFactor;
- code->appendf("\t\tvec4 coord = vec4(%f, %f, %f, %f);\n",
- kMaxValue, kMaxValue, kMaxValue, kMaxValue);
+ builder->fsCodeAppendf("\t\tvec4 coord = vec4(%f, %f, %f, %f);\n",
+ kMaxValue, kMaxValue, kMaxValue, kMaxValue);
} else {
- code->appendf("\t\tfloat nonZeroAlpha = max(%s.a, .0001);\n", inputColor);
- code->appendf("\t\tvec4 coord = vec4(%s.rgb / nonZeroAlpha, nonZeroAlpha);\n", inputColor);
- code->appendf("\t\tcoord = coord * %f + vec4(%f, %f, %f, %f);\n",
- kColorScaleFactor,
- kColorOffsetFactor, kColorOffsetFactor,
- kColorOffsetFactor, kColorOffsetFactor);
+ builder->fsCodeAppendf("\t\tfloat nonZeroAlpha = max(%s.a, .0001);\n", inputColor);
+ builder->fsCodeAppendf("\t\tvec4 coord = vec4(%s.rgb / nonZeroAlpha, nonZeroAlpha);\n", inputColor);
+ builder->fsCodeAppendf("\t\tcoord = coord * %f + vec4(%f, %f, %f, %f);\n",
+ kColorScaleFactor,
+ kColorOffsetFactor, kColorOffsetFactor,
+ kColorOffsetFactor, kColorOffsetFactor);
}
- code->appendf("\t\t%s.a = ", outputColor);
- builder->appendTextureLookup(code, samplers[0], "vec2(coord.a, 0.125)");
- code->append(";\n");
+ builder->fsCodeAppendf("\t\t%s.a = ", outputColor);
+ builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, samplers[0], "vec2(coord.a, 0.125)");
+ builder->fsCodeAppend(";\n");
- code->appendf("\t\t%s.r = ", outputColor);
- builder->appendTextureLookup(code, samplers[0], "vec2(coord.r, 0.375)");
- code->append(";\n");
+ builder->fsCodeAppendf("\t\t%s.r = ", outputColor);
+ builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, samplers[0], "vec2(coord.r, 0.375)");
+ builder->fsCodeAppend(";\n");
- code->appendf("\t\t%s.g = ", outputColor);
- builder->appendTextureLookup(code, samplers[0], "vec2(coord.g, 0.625)");
- code->append(";\n");
+ builder->fsCodeAppendf("\t\t%s.g = ", outputColor);
+ builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, samplers[0], "vec2(coord.g, 0.625)");
+ builder->fsCodeAppend(";\n");
- code->appendf("\t\t%s.b = ", outputColor);
- builder->appendTextureLookup(code, samplers[0], "vec2(coord.b, 0.875)");
- code->append(";\n");
+ builder->fsCodeAppendf("\t\t%s.b = ", outputColor);
+ builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, samplers[0], "vec2(coord.b, 0.875)");
+ builder->fsCodeAppend(";\n");
- code->appendf("\t\t%s.rgb *= %s.a;\n", outputColor, outputColor);
+ builder->fsCodeAppendf("\t\t%s.rgb *= %s.a;\n", outputColor, outputColor);
}
GrGLEffect::EffectKey GLColorTableEffect::GenKey(const GrEffectStage&, const GrGLCaps&) {
« no previous file with comments | « src/effects/SkMorphologyImageFilter.cpp ('k') | src/effects/gradients/SkGradientShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698