From 34335c5a8dcb7192c366775fcb6bff4fa9a96aff Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Tue, 8 Aug 2017 13:00:30 -0400 Subject: 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 Reviewed-by: Brian Salomon --- src/shaders/gradients/SkGradientShader.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'src/shaders/gradients') 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; } -- cgit v1.2.3