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

Unified Diff: src/effects/SkTableColorFilter.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 | « src/effects/SkPerlinNoiseShader.cpp ('k') | src/effects/gradients/SkLinearGradient.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkTableColorFilter.cpp
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index 11fdb89061239dc0ff4d4d4c219720fd5a700355..8314f30c43297229db2278dd65033671a86ce6ed 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -379,12 +379,7 @@ class GLColorTableEffect : public GrGLFragmentProcessor {
public:
GLColorTableEffect(const GrProcessor&);
- 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;
@@ -417,28 +412,24 @@ void GLColorTableEffect::setData(const GrGLProgramDataManager& pdm, const GrProc
pdm.set4fv(fRGBAYValuesUni, 1, rgbaYValues);
}
-void GLColorTableEffect::emitCode(GrGLFPBuilder* builder,
- const GrFragmentProcessor&,
- const char* outputColor,
- const char* inputColor,
- const TransformedCoordsArray&,
- const TextureSamplerArray& samplers) {
+void GLColorTableEffect::emitCode(EmitArgs& args) {
const char* yoffsets;
- fRGBAYValuesUni = builder->addUniform(GrGLFPBuilder::kFragment_Visibility,
+ fRGBAYValuesUni = args.fBuilder->addUniform(GrGLFPBuilder::kFragment_Visibility,
kVec4f_GrSLType, kDefault_GrSLPrecision,
"yoffsets", &yoffsets);
static const float kColorScaleFactor = 255.0f / 256.0f;
static const float kColorOffsetFactor = 1.0f / 512.0f;
- GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
- if (NULL == inputColor) {
+ GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+ if (NULL == args.fInputColor) {
// the input color is solid white (all ones).
static const float kMaxValue = kColorScaleFactor + kColorOffsetFactor;
fsBuilder->codeAppendf("\t\tvec4 coord = vec4(%f, %f, %f, %f);\n",
kMaxValue, kMaxValue, kMaxValue, kMaxValue);
} else {
- fsBuilder->codeAppendf("\t\tfloat nonZeroAlpha = max(%s.a, .0001);\n", inputColor);
- fsBuilder->codeAppendf("\t\tvec4 coord = vec4(%s.rgb / nonZeroAlpha, nonZeroAlpha);\n", inputColor);
+ fsBuilder->codeAppendf("\t\tfloat nonZeroAlpha = max(%s.a, .0001);\n", args.fInputColor);
+ fsBuilder->codeAppendf("\t\tvec4 coord = vec4(%s.rgb / nonZeroAlpha, nonZeroAlpha);\n",
+ args.fInputColor);
fsBuilder->codeAppendf("\t\tcoord = coord * %f + vec4(%f, %f, %f, %f);\n",
kColorScaleFactor,
kColorOffsetFactor, kColorOffsetFactor,
@@ -447,27 +438,27 @@ void GLColorTableEffect::emitCode(GrGLFPBuilder* builder,
SkString coord;
- fsBuilder->codeAppendf("\t\t%s.a = ", outputColor);
+ fsBuilder->codeAppendf("\t\t%s.a = ", args.fOutputColor);
coord.printf("vec2(coord.a, %s.a)", yoffsets);
- fsBuilder->appendTextureLookup(samplers[0], coord.c_str());
+ fsBuilder->appendTextureLookup(args.fSamplers[0], coord.c_str());
fsBuilder->codeAppend(";\n");
- fsBuilder->codeAppendf("\t\t%s.r = ", outputColor);
+ fsBuilder->codeAppendf("\t\t%s.r = ", args.fOutputColor);
coord.printf("vec2(coord.r, %s.r)", yoffsets);
- fsBuilder->appendTextureLookup(samplers[0], coord.c_str());
+ fsBuilder->appendTextureLookup(args.fSamplers[0], coord.c_str());
fsBuilder->codeAppend(";\n");
- fsBuilder->codeAppendf("\t\t%s.g = ", outputColor);
+ fsBuilder->codeAppendf("\t\t%s.g = ", args.fOutputColor);
coord.printf("vec2(coord.g, %s.g)", yoffsets);
- fsBuilder->appendTextureLookup(samplers[0], coord.c_str());
+ fsBuilder->appendTextureLookup(args.fSamplers[0], coord.c_str());
fsBuilder->codeAppend(";\n");
- fsBuilder->codeAppendf("\t\t%s.b = ", outputColor);
+ fsBuilder->codeAppendf("\t\t%s.b = ", args.fOutputColor);
coord.printf("vec2(coord.b, %s.b)", yoffsets);
- fsBuilder->appendTextureLookup(samplers[0], coord.c_str());
+ fsBuilder->appendTextureLookup(args.fSamplers[0], coord.c_str());
fsBuilder->codeAppend(";\n");
- fsBuilder->codeAppendf("\t\t%s.rgb *= %s.a;\n", outputColor, outputColor);
+ fsBuilder->codeAppendf("\t\t%s.rgb *= %s.a;\n", args.fOutputColor, args.fOutputColor);
}
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/effects/SkPerlinNoiseShader.cpp ('k') | src/effects/gradients/SkLinearGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698