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

Unified Diff: src/effects/SkMagnifierImageFilter.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/SkLightingImageFilter.cpp ('k') | src/effects/SkMatrixConvolutionImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkMagnifierImageFilter.cpp
===================================================================
--- src/effects/SkMagnifierImageFilter.cpp (revision 8005)
+++ src/effects/SkMagnifierImageFilter.cpp (working copy)
@@ -148,36 +148,36 @@
GrGLShaderBuilder::kVertex_ShaderType,
kVec2f_GrSLType, "uInset");
- SkString* code = &builder->fFSCode;
+ builder->fsCodeAppendf("\t\tvec2 coord = %s;\n", coords);
+ builder->fsCodeAppendf("\t\tvec2 zoom_coord = %s + %s / %s;\n",
+ builder->getUniformCStr(fOffsetVar),
+ coords,
+ builder->getUniformCStr(fZoomVar));
- code->appendf("\t\tvec2 coord = %s;\n", coords);
- code->appendf("\t\tvec2 zoom_coord = %s + %s / %s;\n",
- builder->getUniformCStr(fOffsetVar),
- coords,
- builder->getUniformCStr(fZoomVar));
+ builder->fsCodeAppend("\t\tvec2 delta = min(coord, vec2(1.0, 1.0) - coord);\n");
- code->appendf("\t\tvec2 delta = min(coord, vec2(1.0, 1.0) - coord);\n");
+ builder->fsCodeAppendf("\t\tdelta = delta / %s;\n", builder->getUniformCStr(fInsetVar));
- code->appendf("\t\tdelta = delta / %s;\n", builder->getUniformCStr(fInsetVar));
+ builder->fsCodeAppend("\t\tfloat weight = 0.0;\n");
+ builder->fsCodeAppend("\t\tif (delta.s < 2.0 && delta.t < 2.0) {\n");
+ builder->fsCodeAppend("\t\t\tdelta = vec2(2.0, 2.0) - delta;\n");
+ builder->fsCodeAppend("\t\t\tfloat dist = length(delta);\n");
+ builder->fsCodeAppend("\t\t\tdist = max(2.0 - dist, 0.0);\n");
+ builder->fsCodeAppend("\t\t\tweight = min(dist * dist, 1.0);\n");
+ builder->fsCodeAppend("\t\t} else {\n");
+ builder->fsCodeAppend("\t\t\tvec2 delta_squared = delta * delta;\n");
+ builder->fsCodeAppend("\t\t\tweight = min(min(delta_squared.s, delta_squared.y), 1.0);\n");
+ builder->fsCodeAppend("\t\t}\n");
- code->appendf("\t\tfloat weight = 0.0;\n");
- code->appendf("\t\tif (delta.s < 2.0 && delta.t < 2.0) {\n");
- code->appendf("\t\t\tdelta = vec2(2.0, 2.0) - delta;\n");
- code->appendf("\t\t\tfloat dist = length(delta);\n");
- code->appendf("\t\t\tdist = max(2.0 - dist, 0.0);\n");
- code->appendf("\t\t\tweight = min(dist * dist, 1.0);\n");
- code->appendf("\t\t} else {\n");
- code->appendf("\t\t\tvec2 delta_squared = delta * delta;\n");
- code->appendf("\t\t\tweight = min(min(delta_squared.s, delta_squared.y), 1.0);\n");
- code->appendf("\t\t}\n");
+ builder->fsCodeAppend("\t\tvec2 mix_coord = mix(coord, zoom_coord, weight);\n");
+ builder->fsCodeAppend("\t\tvec4 output_color = ");
+ builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, samplers[0], "mix_coord");
+ builder->fsCodeAppend(";\n");
- code->appendf("\t\tvec2 mix_coord = mix(coord, zoom_coord, weight);\n");
- code->appendf("\t\tvec4 output_color = ");
- builder->appendTextureLookup(code, samplers[0], "mix_coord");
- code->append(";\n");
-
- code->appendf("\t\t%s = output_color;", outputColor);
- GrGLSLMulVarBy4f(code, 2, outputColor, inputColor);
+ builder->fsCodeAppendf("\t\t%s = output_color;", outputColor);
+ SkString modulate;
+ GrGLSLMulVarBy4f(&modulate, 2, outputColor, inputColor);
+ builder->fsCodeAppend(modulate.c_str());
}
void GrGLMagnifierEffect::setData(const GrGLUniformManager& uman,
« no previous file with comments | « src/effects/SkLightingImageFilter.cpp ('k') | src/effects/SkMatrixConvolutionImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698