diff options
author | fmenozzi <fmenozzi@google.com> | 2016-08-16 09:24:52 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-16 09:24:52 -0700 |
commit | af23ee538b5a007c2c9ca12ae6e54b2e0ed29876 (patch) | |
tree | eb0c956db4a9c8531274f0b8e80d9b498d87cec5 /src/effects | |
parent | 80e96088bc608d6935b24ff623b9025b38da576e (diff) |
Reducing number of calls to GLSL mix() from two to one reduces frame render time by 21%
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2247113003
Review-Url: https://codereview.chromium.org/2247113003
Diffstat (limited to 'src/effects')
-rw-r--r-- | src/effects/gradients/SkGradientShader.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp index 457b89dcf5..6ffe56b9d4 100644 --- a/src/effects/gradients/SkGradientShader.cpp +++ b/src/effects/gradients/SkGradientShader.cpp @@ -1116,12 +1116,14 @@ void GrGradientEffect::GLSLProcessor::emitColor(GrGLSLFPFragmentBuilder* fragBui if (SkShader::kClamp_TileMode == ge.fTileMode) { fragBuilder->codeAppendf("relative_t += step(1.0, %s);", t); } - fragBuilder->codeAppendf("vec4 colorTemp = mix(%s[0], %s[1], relative_t);", colors, - colors); + + fragBuilder->codeAppendf("vec4 start = %s[0];", colors); + fragBuilder->codeAppendf("vec4 end = %s[1];", colors); fragBuilder->codeAppendf("if (clamp_t >= 0.5) {"); - fragBuilder->codeAppendf(" colorTemp = mix(%s[2], %s[3], relative_t);", colors, - colors); + fragBuilder->codeAppendf(" start = %s[2];", colors); + fragBuilder->codeAppendf(" end = %s[3];", colors); fragBuilder->codeAppendf("}"); + fragBuilder->codeAppendf("vec4 colorTemp = mix(start, end, relative_t);"); if (GrGradientEffect::kAfterInterp_PremulType == ge.getPremulType()) { fragBuilder->codeAppend("colorTemp.rgb *= colorTemp.a;"); |