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

Unified Diff: src/core/SkLightingShader.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 | « gm/dcshader.cpp ('k') | src/effects/GrCircleBlurFragmentProcessor.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkLightingShader.cpp
diff --git a/src/core/SkLightingShader.cpp b/src/core/SkLightingShader.cpp
index 7d2ab678415b2f10470066b53b5a9c258f20a074..147a7ef915cb2e98076dab4ab9df2d492c1a6472 100644
--- a/src/core/SkLightingShader.cpp
+++ b/src/core/SkLightingShader.cpp
@@ -179,7 +179,7 @@ public:
void emitCode(EmitArgs& args) override {
- GrGLSLFragmentBuilder* fpb = args.fBuilder->getFragmentShaderBuilder();
+ GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
// add uniforms
const char* lightDirUniName = nullptr;
@@ -202,33 +202,35 @@ public:
kVec2f_GrSLType, kDefault_GrSLPrecision,
"Xform", &xformUniName);
- fpb->codeAppend("vec4 diffuseColor = ");
- fpb->appendTextureLookupAndModulate(args.fInputColor, args.fSamplers[0],
+ fragBuilder->codeAppend("vec4 diffuseColor = ");
+ fragBuilder->appendTextureLookupAndModulate(args.fInputColor, args.fSamplers[0],
args.fCoords[0].c_str(),
args.fCoords[0].getType());
- fpb->codeAppend(";");
+ fragBuilder->codeAppend(";");
- fpb->codeAppend("vec4 normalColor = ");
- fpb->appendTextureLookup(args.fSamplers[1],
+ fragBuilder->codeAppend("vec4 normalColor = ");
+ fragBuilder->appendTextureLookup(args.fSamplers[1],
args.fCoords[1].c_str(),
args.fCoords[1].getType());
- fpb->codeAppend(";");
+ fragBuilder->codeAppend(";");
- fpb->codeAppend("vec3 normal = normalColor.rgb - vec3(0.5);");
+ fragBuilder->codeAppend("vec3 normal = normalColor.rgb - vec3(0.5);");
- fpb->codeAppendf("mat3 m = mat3(%s.x, -%s.y, 0.0, %s.y, %s.x, 0.0, 0.0, 0.0, 1.0);",
- xformUniName, xformUniName, xformUniName, xformUniName);
+ fragBuilder->codeAppendf(
+ "mat3 m = mat3(%s.x, -%s.y, 0.0, %s.y, %s.x, 0.0, 0.0, 0.0, 1.0);",
+ xformUniName, xformUniName, xformUniName, xformUniName);
// TODO: inverse map the light direction vectors in the vertex shader rather than
// transforming all the normals here!
- fpb->codeAppend("normal = normalize(m*normal);");
+ fragBuilder->codeAppend("normal = normalize(m*normal);");
- fpb->codeAppendf("float NdotL = clamp(dot(normal, %s), 0.0, 1.0);", lightDirUniName);
+ fragBuilder->codeAppendf("float NdotL = clamp(dot(normal, %s), 0.0, 1.0);",
+ lightDirUniName);
// diffuse light
- fpb->codeAppendf("vec3 result = %s*diffuseColor.rgb*NdotL;", lightColorUniName);
+ fragBuilder->codeAppendf("vec3 result = %s*diffuseColor.rgb*NdotL;", lightColorUniName);
// ambient light
- fpb->codeAppendf("result += %s;", ambientColorUniName);
- fpb->codeAppendf("%s = vec4(result.rgb, diffuseColor.a);", args.fOutputColor);
+ fragBuilder->codeAppendf("result += %s;", ambientColorUniName);
+ fragBuilder->codeAppendf("%s = vec4(result.rgb, diffuseColor.a);", args.fOutputColor);
}
static void GenKey(const GrProcessor& proc, const GrGLSLCaps&,
« no previous file with comments | « gm/dcshader.cpp ('k') | src/effects/GrCircleBlurFragmentProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698