From abddea0d8c05103dfb3ea63744f178b4ef4075c9 Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Fri, 20 Jan 2017 11:45:01 -0500 Subject: [PATCH] Just clamp to limit-epsilon. I think the -0.5f was an implementation detail of Herb's bilerp that we don't need here. It happened to also be clamping us to something less than limit (limit-0.5), so we do need to replace that with a little nudge to keep us on tile. Change-Id: I4ebd32e0ad38c724a17dc8bc35d9ea228eeeca32 Reviewed-on: https://skia-review.googlesource.com/7338 Commit-Queue: Mike Klein Reviewed-by: Herb Derby Reviewed-by: Florin Malita --- src/effects/gradients/SkLinearGradient.cpp | 5 +---- src/opts/SkRasterPipeline_opts.h | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp index 91c0e20955..aab1ac787a 100644 --- a/src/effects/gradients/SkLinearGradient.cpp +++ b/src/effects/gradients/SkLinearGradient.cpp @@ -129,10 +129,7 @@ bool SkLinearGradient::onAppendStages(SkRasterPipeline* p, SkColorSpace* cs, SkA auto* limit = alloc->make(1.0f); switch (fTileMode) { - case kClamp_TileMode: - *limit += 0.5f; // why is clamp_x offsetting its limit? - p->append(SkRasterPipeline::clamp_x, limit); - break; + case kClamp_TileMode: p->append(SkRasterPipeline:: clamp_x, limit); break; case kMirror_TileMode: p->append(SkRasterPipeline::mirror_x, limit); break; case kRepeat_TileMode: p->append(SkRasterPipeline::repeat_x, limit); break; } diff --git a/src/opts/SkRasterPipeline_opts.h b/src/opts/SkRasterPipeline_opts.h index 2376c10e35..aa66d73034 100644 --- a/src/opts/SkRasterPipeline_opts.h +++ b/src/opts/SkRasterPipeline_opts.h @@ -872,7 +872,7 @@ SI SkNf assert_in_tile(const SkNf& v, float limit) { } SI SkNf clamp(const SkNf& v, float limit) { - SkNf result = SkNf::Max(0, SkNf::Min(v, limit - 0.5f)); + SkNf result = SkNf::Max(0, SkNf::Min(v, nextafterf(limit, 0))); return assert_in_tile(result, limit); } SI SkNf repeat(const SkNf& v, float limit) {