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

Unified Diff: samplecode/SampleLighting.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 | « gm/dcshader.cpp ('k') | src/effects/SkAlphaThresholdFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleLighting.cpp
diff --git a/samplecode/SampleLighting.cpp b/samplecode/SampleLighting.cpp
index a002a9320f9843762dae1a492ad84a391ab10d31..53a542ec2ea833d97ecc097f6fc150fdc76bfc9f 100755
--- a/samplecode/SampleLighting.cpp
+++ b/samplecode/SampleLighting.cpp
@@ -129,38 +129,34 @@ public:
fLightDir.fX = 10000.0f;
}
- void emitCode(GrGLFPBuilder* builder,
- const GrFragmentProcessor& fp,
- const char* outputColor,
- const char* inputColor,
- const TransformedCoordsArray& coords,
- const TextureSamplerArray& samplers) override {
+ void emitCode(EmitArgs& args) override {
- GrGLFragmentBuilder* fpb = builder->getFragmentShaderBuilder();
+ GrGLFragmentBuilder* fpb = args.fBuilder->getFragmentShaderBuilder();
// add uniforms
const char* lightDirUniName = NULL;
- fLightDirUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+ fLightDirUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kVec3f_GrSLType, kDefault_GrSLPrecision,
"LightDir", &lightDirUniName);
const char* lightColorUniName = NULL;
- fLightColorUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+ fLightColorUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kVec4f_GrSLType, kDefault_GrSLPrecision,
"LightColor", &lightColorUniName);
const char* ambientColorUniName = NULL;
- fAmbientColorUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+ fAmbientColorUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kVec4f_GrSLType, kDefault_GrSLPrecision,
"AmbientColor", &ambientColorUniName);
fpb->codeAppend("vec4 diffuseColor = ");
- fpb->appendTextureLookupAndModulate(inputColor, samplers[0],
- coords[0].c_str(), coords[0].getType());
+ fpb->appendTextureLookupAndModulate(args.fInputColor, args.fSamplers[0],
+ args.fCoords[0].c_str(), args.fCoords[0].getType());
fpb->codeAppend(";");
fpb->codeAppend("vec4 normalColor = ");
- fpb->appendTextureLookup(samplers[1], coords[0].c_str(), coords[0].getType());
+ fpb->appendTextureLookup(args.fSamplers[1], args.fCoords[0].c_str(),
+ args.fCoords[0].getType());
fpb->codeAppend(";");
fpb->codeAppend("vec3 normal = normalize(2.0*(normalColor.rgb - vec3(0.5)));");
@@ -170,7 +166,7 @@ public:
fpb->codeAppendf("vec3 result = %s.rgb*diffuseColor.rgb*NdotL;", lightColorUniName);
// ambient light
fpb->codeAppendf("result += %s.rgb;", ambientColorUniName);
- fpb->codeAppendf("%s = vec4(result.rgb, diffuseColor.a);", outputColor);
+ fpb->codeAppendf("%s = vec4(result.rgb, diffuseColor.a);", args.fOutputColor);
}
void setData(const GrGLProgramDataManager& pdman, const GrProcessor& proc) override {
« no previous file with comments | « gm/dcshader.cpp ('k') | src/effects/SkAlphaThresholdFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698