diff options
author | Florin Malita <fmalita@chromium.org> | 2017-08-08 13:00:30 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-08-08 17:20:50 +0000 |
commit | 34335c5a8dcb7192c366775fcb6bff4fa9a96aff (patch) | |
tree | e3a11c80824ac82e18491c5437ad7b651ccc233a /src/shaders/gradients | |
parent | b81a8b9c74c69ebbe9eafa5100baf599aa22d9fd (diff) |
Streamline GrGradientEffect mirror tiling
Using the same branch-less method as raster pipeline.
Change-Id: Iaaa36330dbf49961bdfc288cad031d891d8ff589
Reviewed-on: https://skia-review.googlesource.com/31280
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/shaders/gradients')
-rw-r--r-- | src/shaders/gradients/SkGradientShader.cpp | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/src/shaders/gradients/SkGradientShader.cpp b/src/shaders/gradients/SkGradientShader.cpp index 4fcfa36d85..186f683dca 100644 --- a/src/shaders/gradients/SkGradientShader.cpp +++ b/src/shaders/gradients/SkGradientShader.cpp @@ -1567,16 +1567,8 @@ void GrGradientEffect::GLSLProcessor::emitAnalyticalColor(GrGLSLFPFragmentBuilde } break; case SkShader::kMirror_TileMode: - fragBuilder->codeAppendf("float clamp_t = %s;", t); - // TODO: Is this conditional really useful? Since the client requested kMirror, - // t is likely outside [0,1] most of the time so we might as well always fall through. - fragBuilder->codeAppendf("if (%s < 0.0 || %s > 1.0) {", t, t); - fragBuilder->codeAppendf(" if (mod(floor(%s), 2.0) == 0.0) {", t); - fragBuilder->codeAppendf(" clamp_t = fract(%s);", t); - fragBuilder->codeAppendf(" } else {"); - fragBuilder->codeAppendf(" clamp_t = 1.0 - fract(%s);", t); - fragBuilder->codeAppendf(" }"); - fragBuilder->codeAppendf("}"); + fragBuilder->codeAppendf("float t_1 = %s - 1.0;", t); + fragBuilder->codeAppendf("float clamp_t = abs(t_1 - 2.0 * floor(t_1 * 0.5) - 1.0);"); break; } |