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

Unified Diff: src/effects/SkAlphaThresholdFilter.cpp

Issue 1251173002: Added GrGLFragmentProcessor::EmitArgs struct for use with emitCode() (Closed) Base URL: https://skia.googlesource.com/skia@composeshader_gpu
Patch Set: Created 5 years, 5 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 | « samplecode/SampleLighting.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 55e113efe17cee20b7c98f245521c19816908290..c9d72bb67305dff45d7d3591bf667333bd1a5865 100644
--- a/src/effects/SkAlphaThresholdFilter.cpp
+++ b/src/effects/SkAlphaThresholdFilter.cpp
@@ -128,12 +128,7 @@ class GrGLAlphaThresholdEffect : public GrGLFragmentProcessor {
public:
GrGLAlphaThresholdEffect(const GrFragmentProcessor&) {}
- virtual void emitCode(GrGLFPBuilder*,
- const GrFragmentProcessor&,
- const char* outputColor,
- const char* inputColor,
- const TransformedCoordsArray&,
- const TextureSamplerArray&) override;
+ virtual void emitCode(EmitArgs&) override;
void setData(const GrGLProgramDataManager&, const GrProcessor&) override;
@@ -145,38 +140,33 @@ private:
typedef GrGLFragmentProcessor INHERITED;
};
-void GrGLAlphaThresholdEffect::emitCode(GrGLFPBuilder* builder,
- const GrFragmentProcessor&,
- const char* outputColor,
- const char* inputColor,
- const TransformedCoordsArray& coords,
- const TextureSamplerArray& samplers) {
- fInnerThresholdVar = builder->addUniform(
+void GrGLAlphaThresholdEffect::emitCode(EmitArgs& args) {
+ fInnerThresholdVar = args.fBuilder->addUniform(
GrGLProgramBuilder::kFragment_Visibility,
kFloat_GrSLType, kDefault_GrSLPrecision,
"inner_threshold");
- fOuterThresholdVar = builder->addUniform(
+ fOuterThresholdVar = args.fBuilder->addUniform(
GrGLProgramBuilder::kFragment_Visibility,
kFloat_GrSLType, kDefault_GrSLPrecision,
"outer_threshold");
- GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
- SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0);
- SkString maskCoords2D = fsBuilder->ensureFSCoords2D(coords, 1);
+ GrGLFragmentBuilder* 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(samplers[0], "coord");
+ fsBuilder->appendTextureLookup(args.fSamplers[0], "coord");
fsBuilder->codeAppend(";\n");
fsBuilder->codeAppend("\t\tvec4 mask_color = ");
- fsBuilder->appendTextureLookup(samplers[1], "mask_coord");
+ fsBuilder->appendTextureLookup(args.fSamplers[1], "mask_coord");
fsBuilder->codeAppend(";\n");
fsBuilder->codeAppendf("\t\tfloat inner_thresh = %s;\n",
- builder->getUniformCStr(fInnerThresholdVar));
+ args.fBuilder->getUniformCStr(fInnerThresholdVar));
fsBuilder->codeAppendf("\t\tfloat outer_thresh = %s;\n",
- builder->getUniformCStr(fOuterThresholdVar));
+ args.fBuilder->getUniformCStr(fOuterThresholdVar));
fsBuilder->codeAppend("\t\tfloat mask = mask_color.a;\n");
fsBuilder->codeAppend("vec4 color = input_color;\n");
@@ -192,8 +182,8 @@ void GrGLAlphaThresholdEffect::emitCode(GrGLFPBuilder* builder,
"\t\t\tcolor.a = inner_thresh;\n"
"\t\t}\n");
- fsBuilder->codeAppendf("%s = %s;\n", outputColor,
- (GrGLSLExpr4(inputColor) * GrGLSLExpr4("color")).c_str());
+ fsBuilder->codeAppendf("%s = %s;\n", args.fOutputColor,
+ (GrGLSLExpr4(args.fInputColor) * GrGLSLExpr4("color")).c_str());
}
void GrGLAlphaThresholdEffect::setData(const GrGLProgramDataManager& pdman,
« no previous file with comments | « samplecode/SampleLighting.cpp ('k') | src/effects/SkArithmeticMode_gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698