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

Unified Diff: src/effects/SkMagnifierImageFilter.cpp

Issue 1457543003: Add ShaderBuilders to EmitArgs and remove gettings from ProgBuilder. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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/SkLumaColorFilter.cpp ('k') | src/effects/SkMorphologyImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkMagnifierImageFilter.cpp
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp
index 61118f502cad3a2258ec728344ef11c570150114..911294444abadd37c11a36e512ea2b1d366410a6 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -133,39 +133,39 @@ void GrGLMagnifierEffect::emitCode(EmitArgs& args) {
GrGLSLProgramBuilder::kFragment_Visibility,
kVec4f_GrSLType, kDefault_GrSLPrecision, "Bounds");
- GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
- SkString coords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
- fsBuilder->codeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str());
- fsBuilder->codeAppendf("\t\tvec2 zoom_coord = %s + %s * %s;\n",
- args.fBuilder->getUniformCStr(fOffsetVar),
- coords2D.c_str(),
- args.fBuilder->getUniformCStr(fInvZoomVar));
+ GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
+ SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
+ fragBuilder->codeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str());
+ fragBuilder->codeAppendf("\t\tvec2 zoom_coord = %s + %s * %s;\n",
+ args.fBuilder->getUniformCStr(fOffsetVar),
+ coords2D.c_str(),
+ args.fBuilder->getUniformCStr(fInvZoomVar));
const char* bounds = args.fBuilder->getUniformCStr(fBoundsVar);
- fsBuilder->codeAppendf("\t\tvec2 delta = (coord - %s.xy) * %s.zw;\n", bounds, bounds);
- fsBuilder->codeAppendf("\t\tdelta = min(delta, vec2(1.0, 1.0) - delta);\n");
- fsBuilder->codeAppendf("\t\tdelta = delta * %s;\n",
- args.fBuilder->getUniformCStr(fInvInsetVar));
-
- fsBuilder->codeAppend("\t\tfloat weight = 0.0;\n");
- fsBuilder->codeAppend("\t\tif (delta.s < 2.0 && delta.t < 2.0) {\n");
- fsBuilder->codeAppend("\t\t\tdelta = vec2(2.0, 2.0) - delta;\n");
- fsBuilder->codeAppend("\t\t\tfloat dist = length(delta);\n");
- fsBuilder->codeAppend("\t\t\tdist = max(2.0 - dist, 0.0);\n");
- fsBuilder->codeAppend("\t\t\tweight = min(dist * dist, 1.0);\n");
- fsBuilder->codeAppend("\t\t} else {\n");
- fsBuilder->codeAppend("\t\t\tvec2 delta_squared = delta * delta;\n");
- fsBuilder->codeAppend("\t\t\tweight = min(min(delta_squared.x, delta_squared.y), 1.0);\n");
- fsBuilder->codeAppend("\t\t}\n");
-
- fsBuilder->codeAppend("\t\tvec2 mix_coord = mix(coord, zoom_coord, weight);\n");
- fsBuilder->codeAppend("\t\tvec4 output_color = ");
- fsBuilder->appendTextureLookup(args.fSamplers[0], "mix_coord");
- fsBuilder->codeAppend(";\n");
-
- fsBuilder->codeAppendf("\t\t%s = output_color;", args.fOutputColor);
+ fragBuilder->codeAppendf("\t\tvec2 delta = (coord - %s.xy) * %s.zw;\n", bounds, bounds);
+ fragBuilder->codeAppendf("\t\tdelta = min(delta, vec2(1.0, 1.0) - delta);\n");
+ fragBuilder->codeAppendf("\t\tdelta = delta * %s;\n",
+ args.fBuilder->getUniformCStr(fInvInsetVar));
+
+ fragBuilder->codeAppend("\t\tfloat weight = 0.0;\n");
+ fragBuilder->codeAppend("\t\tif (delta.s < 2.0 && delta.t < 2.0) {\n");
+ fragBuilder->codeAppend("\t\t\tdelta = vec2(2.0, 2.0) - delta;\n");
+ fragBuilder->codeAppend("\t\t\tfloat dist = length(delta);\n");
+ fragBuilder->codeAppend("\t\t\tdist = max(2.0 - dist, 0.0);\n");
+ fragBuilder->codeAppend("\t\t\tweight = min(dist * dist, 1.0);\n");
+ fragBuilder->codeAppend("\t\t} else {\n");
+ fragBuilder->codeAppend("\t\t\tvec2 delta_squared = delta * delta;\n");
+ fragBuilder->codeAppend("\t\t\tweight = min(min(delta_squared.x, delta_squared.y), 1.0);\n");
+ fragBuilder->codeAppend("\t\t}\n");
+
+ fragBuilder->codeAppend("\t\tvec2 mix_coord = mix(coord, zoom_coord, weight);\n");
+ fragBuilder->codeAppend("\t\tvec4 output_color = ");
+ fragBuilder->appendTextureLookup(args.fSamplers[0], "mix_coord");
+ fragBuilder->codeAppend(";\n");
+
+ fragBuilder->codeAppendf("\t\t%s = output_color;", args.fOutputColor);
SkString modulate;
GrGLSLMulVarBy4f(&modulate, args.fOutputColor, args.fInputColor);
- fsBuilder->codeAppend(modulate.c_str());
+ fragBuilder->codeAppend(modulate.c_str());
}
void GrGLMagnifierEffect::onSetData(const GrGLSLProgramDataManager& pdman,
« no previous file with comments | « src/effects/SkLumaColorFilter.cpp ('k') | src/effects/SkMorphologyImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698