Index: src/effects/SkMorphologyImageFilter.cpp |
=================================================================== |
--- src/effects/SkMorphologyImageFilter.cpp (revision 8005) |
+++ src/effects/SkMorphologyImageFilter.cpp (working copy) |
@@ -324,16 +324,14 @@ |
fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, |
kVec2f_GrSLType, "ImageIncrement"); |
- SkString* code = &builder->fFSCode; |
- |
const char* func; |
switch (fType) { |
case GrMorphologyEffect::kErode_MorphologyType: |
- code->appendf("\t\t%s = vec4(1, 1, 1, 1);\n", outputColor); |
+ builder->fsCodeAppendf("\t\t%s = vec4(1, 1, 1, 1);\n", outputColor); |
func = "min"; |
break; |
case GrMorphologyEffect::kDilate_MorphologyType: |
- code->appendf("\t\t%s = vec4(0, 0, 0, 0);\n", outputColor); |
+ builder->fsCodeAppendf("\t\t%s = vec4(0, 0, 0, 0);\n", outputColor); |
func = "max"; |
break; |
default: |
@@ -343,14 +341,16 @@ |
} |
const char* imgInc = builder->getUniformCStr(fImageIncrementUni); |
- code->appendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords, fRadius, imgInc); |
- code->appendf("\t\tfor (int i = 0; i < %d; i++) {\n", this->width()); |
- code->appendf("\t\t\t%s = %s(%s, ", outputColor, func, outputColor); |
- builder->appendTextureLookup(&builder->fFSCode, samplers[0], "coord"); |
- code->appendf(");\n"); |
- code->appendf("\t\t\tcoord += %s;\n", imgInc); |
- code->appendf("\t\t}\n"); |
- GrGLSLMulVarBy4f(code, 2, outputColor, inputColor); |
+ builder->fsCodeAppendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords, 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"); |
+ builder->fsCodeAppend(");\n"); |
+ builder->fsCodeAppendf("\t\t\tcoord += %s;\n", imgInc); |
+ builder->fsCodeAppend("\t\t}\n"); |
+ SkString modulate; |
+ GrGLSLMulVarBy4f(&modulate, 2, outputColor, inputColor); |
+ builder->fsCodeAppend(modulate.c_str()); |
} |
GrGLEffect::EffectKey GrGLMorphologyEffect::GenKey(const GrEffectStage& s, const GrGLCaps&) { |