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

Unified Diff: src/effects/SkAlphaThresholdFilter.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/GrCircleBlurFragmentProcessor.cpp ('k') | src/effects/SkArithmeticMode_gpu.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkAlphaThresholdFilter.cpp
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp
index ff5e93e0362a04dde266b29bdc79c82ceb525829..e6f1f088cbae9f1ca8775643ade00ad1f9bacaa6 100644
--- a/src/effects/SkAlphaThresholdFilter.cpp
+++ b/src/effects/SkAlphaThresholdFilter.cpp
@@ -146,40 +146,40 @@ void GrGLAlphaThresholdEffect::emitCode(EmitArgs& args) {
kFloat_GrSLType, kDefault_GrSLPrecision,
"outer_threshold");
- GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
- SkString coords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
- SkString maskCoords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 1);
-
- fsBuilder->codeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str());
- fsBuilder->codeAppendf("\t\tvec2 mask_coord = %s;\n", maskCoords2D.c_str());
- fsBuilder->codeAppend("\t\tvec4 input_color = ");
- fsBuilder->appendTextureLookup(args.fSamplers[0], "coord");
- fsBuilder->codeAppend(";\n");
- fsBuilder->codeAppend("\t\tvec4 mask_color = ");
- fsBuilder->appendTextureLookup(args.fSamplers[1], "mask_coord");
- fsBuilder->codeAppend(";\n");
-
- fsBuilder->codeAppendf("\t\tfloat inner_thresh = %s;\n",
- args.fBuilder->getUniformCStr(fInnerThresholdVar));
- fsBuilder->codeAppendf("\t\tfloat outer_thresh = %s;\n",
- args.fBuilder->getUniformCStr(fOuterThresholdVar));
- fsBuilder->codeAppend("\t\tfloat mask = mask_color.a;\n");
-
- fsBuilder->codeAppend("vec4 color = input_color;\n");
- fsBuilder->codeAppend("\t\tif (mask < 0.5) {\n"
- "\t\t\tif (color.a > outer_thresh) {\n"
- "\t\t\t\tfloat scale = outer_thresh / color.a;\n"
- "\t\t\t\tcolor.rgb *= scale;\n"
- "\t\t\t\tcolor.a = outer_thresh;\n"
- "\t\t\t}\n"
- "\t\t} else if (color.a < inner_thresh) {\n"
- "\t\t\tfloat scale = inner_thresh / max(0.001, color.a);\n"
- "\t\t\tcolor.rgb *= scale;\n"
- "\t\t\tcolor.a = inner_thresh;\n"
- "\t\t}\n");
-
- fsBuilder->codeAppendf("%s = %s;\n", args.fOutputColor,
- (GrGLSLExpr4(args.fInputColor) * GrGLSLExpr4("color")).c_str());
+ GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
+ SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
+ SkString maskCoords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 1);
+
+ fragBuilder->codeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str());
+ fragBuilder->codeAppendf("\t\tvec2 mask_coord = %s;\n", maskCoords2D.c_str());
+ fragBuilder->codeAppend("\t\tvec4 input_color = ");
+ fragBuilder->appendTextureLookup(args.fSamplers[0], "coord");
+ fragBuilder->codeAppend(";\n");
+ fragBuilder->codeAppend("\t\tvec4 mask_color = ");
+ fragBuilder->appendTextureLookup(args.fSamplers[1], "mask_coord");
+ fragBuilder->codeAppend(";\n");
+
+ fragBuilder->codeAppendf("\t\tfloat inner_thresh = %s;\n",
+ args.fBuilder->getUniformCStr(fInnerThresholdVar));
+ fragBuilder->codeAppendf("\t\tfloat outer_thresh = %s;\n",
+ args.fBuilder->getUniformCStr(fOuterThresholdVar));
+ fragBuilder->codeAppend("\t\tfloat mask = mask_color.a;\n");
+
+ fragBuilder->codeAppend("vec4 color = input_color;\n");
+ fragBuilder->codeAppend("\t\tif (mask < 0.5) {\n"
+ "\t\t\tif (color.a > outer_thresh) {\n"
+ "\t\t\t\tfloat scale = outer_thresh / color.a;\n"
+ "\t\t\t\tcolor.rgb *= scale;\n"
+ "\t\t\t\tcolor.a = outer_thresh;\n"
+ "\t\t\t}\n"
+ "\t\t} else if (color.a < inner_thresh) {\n"
+ "\t\t\tfloat scale = inner_thresh / max(0.001, color.a);\n"
+ "\t\t\tcolor.rgb *= scale;\n"
+ "\t\t\tcolor.a = inner_thresh;\n"
+ "\t\t}\n");
+
+ fragBuilder->codeAppendf("%s = %s;\n", args.fOutputColor,
+ (GrGLSLExpr4(args.fInputColor) * GrGLSLExpr4("color")).c_str());
}
void GrGLAlphaThresholdEffect::onSetData(const GrGLSLProgramDataManager& pdman,
« no previous file with comments | « src/effects/GrCircleBlurFragmentProcessor.cpp ('k') | src/effects/SkArithmeticMode_gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698