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

Unified Diff: src/effects/gradients/SkGradientShader.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/SkTableColorFilter.cpp ('k') | src/effects/gradients/SkGradientShaderPriv.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/gradients/SkGradientShader.cpp
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index f11d0787b9916198cfd7841972dff27c17fcaa6d..8c944bae5516e80cf7f38ea6251081691c3a09a5 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -1027,61 +1027,61 @@ uint32_t GrGLGradientEffect::GenBaseGradientKey(const GrProcessor& processor) {
}
void GrGLGradientEffect::emitColor(GrGLSLFPBuilder* builder,
+ GrGLSLFragmentBuilder* fragBuilder,
const GrGradientEffect& ge,
const char* gradientTValue,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) {
- GrGLSLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
if (SkGradientShaderBase::kTwo_GpuColorType == ge.getColorType()){
- fsBuilder->codeAppendf("\tvec4 colorTemp = mix(%s, %s, clamp(%s, 0.0, 1.0));\n",
- builder->getUniformVariable(fColorStartUni).c_str(),
- builder->getUniformVariable(fColorEndUni).c_str(),
- gradientTValue);
+ fragBuilder->codeAppendf("\tvec4 colorTemp = mix(%s, %s, clamp(%s, 0.0, 1.0));\n",
+ builder->getUniformVariable(fColorStartUni).c_str(),
+ builder->getUniformVariable(fColorEndUni).c_str(),
+ gradientTValue);
// Note that we could skip this step if both colors are known to be opaque. Two
// considerations:
// The gradient SkShader reporting opaque is more restrictive than necessary in the two pt
// case. Make sure the key reflects this optimization (and note that it can use the same
// shader as thekBeforeIterp case). This same optimization applies to the 3 color case below.
if (GrGradientEffect::kAfterInterp_PremulType == ge.getPremulType()) {
- fsBuilder->codeAppend("\tcolorTemp.rgb *= colorTemp.a;\n");
+ fragBuilder->codeAppend("\tcolorTemp.rgb *= colorTemp.a;\n");
}
- fsBuilder->codeAppendf("\t%s = %s;\n", outputColor,
- (GrGLSLExpr4(inputColor) * GrGLSLExpr4("colorTemp")).c_str());
+ fragBuilder->codeAppendf("\t%s = %s;\n", outputColor,
+ (GrGLSLExpr4(inputColor) * GrGLSLExpr4("colorTemp")).c_str());
} else if (SkGradientShaderBase::kThree_GpuColorType == ge.getColorType()) {
- fsBuilder->codeAppendf("\tfloat oneMinus2t = 1.0 - (2.0 * (%s));\n",
- gradientTValue);
- fsBuilder->codeAppendf("\tvec4 colorTemp = clamp(oneMinus2t, 0.0, 1.0) * %s;\n",
- builder->getUniformVariable(fColorStartUni).c_str());
+ fragBuilder->codeAppendf("\tfloat oneMinus2t = 1.0 - (2.0 * (%s));\n",
+ gradientTValue);
+ fragBuilder->codeAppendf("\tvec4 colorTemp = clamp(oneMinus2t, 0.0, 1.0) * %s;\n",
+ builder->getUniformVariable(fColorStartUni).c_str());
if (!builder->glslCaps()->canUseMinAndAbsTogether()) {
// The Tegra3 compiler will sometimes never return if we have
// min(abs(oneMinus2t), 1.0), or do the abs first in a separate expression.
- fsBuilder->codeAppend("\tfloat minAbs = abs(oneMinus2t);\n");
- fsBuilder->codeAppend("\tminAbs = minAbs > 1.0 ? 1.0 : minAbs;\n");
- fsBuilder->codeAppendf("\tcolorTemp += (1.0 - minAbs) * %s;\n",
- builder->getUniformVariable(fColorMidUni).c_str());
+ fragBuilder->codeAppend("\tfloat minAbs = abs(oneMinus2t);\n");
+ fragBuilder->codeAppend("\tminAbs = minAbs > 1.0 ? 1.0 : minAbs;\n");
+ fragBuilder->codeAppendf("\tcolorTemp += (1.0 - minAbs) * %s;\n",
+ builder->getUniformVariable(fColorMidUni).c_str());
} else {
- fsBuilder->codeAppendf("\tcolorTemp += (1.0 - min(abs(oneMinus2t), 1.0)) * %s;\n",
- builder->getUniformVariable(fColorMidUni).c_str());
+ fragBuilder->codeAppendf("\tcolorTemp += (1.0 - min(abs(oneMinus2t), 1.0)) * %s;\n",
+ builder->getUniformVariable(fColorMidUni).c_str());
}
- fsBuilder->codeAppendf("\tcolorTemp += clamp(-oneMinus2t, 0.0, 1.0) * %s;\n",
- builder->getUniformVariable(fColorEndUni).c_str());
+ fragBuilder->codeAppendf("\tcolorTemp += clamp(-oneMinus2t, 0.0, 1.0) * %s;\n",
+ builder->getUniformVariable(fColorEndUni).c_str());
if (GrGradientEffect::kAfterInterp_PremulType == ge.getPremulType()) {
- fsBuilder->codeAppend("\tcolorTemp.rgb *= colorTemp.a;\n");
+ fragBuilder->codeAppend("\tcolorTemp.rgb *= colorTemp.a;\n");
}
- fsBuilder->codeAppendf("\t%s = %s;\n", outputColor,
- (GrGLSLExpr4(inputColor) * GrGLSLExpr4("colorTemp")).c_str());
+ fragBuilder->codeAppendf("\t%s = %s;\n", outputColor,
+ (GrGLSLExpr4(inputColor) * GrGLSLExpr4("colorTemp")).c_str());
} else {
- fsBuilder->codeAppendf("\tvec2 coord = vec2(%s, %s);\n",
- gradientTValue,
- builder->getUniformVariable(fFSYUni).c_str());
- fsBuilder->codeAppendf("\t%s = ", outputColor);
- fsBuilder->appendTextureLookupAndModulate(inputColor,
- samplers[0],
- "coord");
- fsBuilder->codeAppend(";\n");
+ fragBuilder->codeAppendf("\tvec2 coord = vec2(%s, %s);\n",
+ gradientTValue,
+ builder->getUniformVariable(fFSYUni).c_str());
+ fragBuilder->codeAppendf("\t%s = ", outputColor);
+ fragBuilder->appendTextureLookupAndModulate(inputColor,
+ samplers[0],
+ "coord");
+ fragBuilder->codeAppend(";\n");
}
}
« no previous file with comments | « src/effects/SkTableColorFilter.cpp ('k') | src/effects/gradients/SkGradientShaderPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698