From 2e35e8a45c9ff04b88d7a98b381ce56e565d8402 Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Fri, 18 Nov 2016 15:47:22 -0500 Subject: mirror tiling GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=5064 CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot Change-Id: I9d48ba73e145701245e5ec4f32c8c360da6baddd Reviewed-on: https://skia-review.googlesource.com/5064 Reviewed-by: Herb Derby Commit-Queue: Mike Klein --- src/opts/SkNx_sse.h | 1 + src/opts/SkRasterPipeline_opts.h | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src/opts') diff --git a/src/opts/SkNx_sse.h b/src/opts/SkNx_sse.h index c1f4b2c1c5..fa9f4cde1f 100644 --- a/src/opts/SkNx_sse.h +++ b/src/opts/SkNx_sse.h @@ -610,6 +610,7 @@ public: AI SkNx rsqrt() const { return _mm256_rsqrt_ps(fVec); } AI SkNx invert() const { return _mm256_rcp_ps (fVec); } + AI SkNx abs() const { return _mm256_andnot_ps(_mm256_set1_ps(-0.0f), fVec); } AI SkNx floor() const { return _mm256_floor_ps(fVec); } AI float operator[](int k) const { diff --git a/src/opts/SkRasterPipeline_opts.h b/src/opts/SkRasterPipeline_opts.h index d9760cbafa..ee957e147b 100644 --- a/src/opts/SkRasterPipeline_opts.h +++ b/src/opts/SkRasterPipeline_opts.h @@ -697,21 +697,25 @@ SI SkNf clamp(const SkNf& v, float limit) { SI SkNf repeat(const SkNf& v, float limit) { SkNf result = v - (v/limit).floor()*limit; - // For small negative v, (v/limit).floor()*limit can dominate v in the subtraction, // which leaves result == limit. We want result < limit, so clamp it one ULP. result = SkNf::Min(result, nextafterf(limit, 0)); - return assert_in_tile(result, limit); } +SI SkNf mirror(const SkNf& v, float l/*imit*/) { + SkNf result = ((v - l) - ((v - l) / (2*l)).floor()*(2*l) - l).abs(); + // Same deal as repeat. + result = SkNf::Min(result, nextafterf(l, 0)); + return assert_in_tile(result, l); +} + STAGE(clamp_x, true) { r = clamp (r, *(const int*)ctx); } STAGE(clamp_y, true) { g = clamp (g, *(const int*)ctx); } STAGE(repeat_x, true) { r = repeat(r, *(const int*)ctx); } STAGE(repeat_y, true) { g = repeat(g, *(const int*)ctx); } - -STAGE(mirror_x, true) {} // TODO -STAGE(mirror_y, true) {} // TODO +STAGE(mirror_x, true) { r = mirror(r, *(const int*)ctx); } +STAGE(mirror_y, true) { g = mirror(g, *(const int*)ctx); } struct NearestCtx { -- cgit v1.2.3