diff --git a/src/core/SkSRGB.h b/src/core/SkSRGB.h index a12ce9615d..82a9e90f49 100644 --- a/src/core/SkSRGB.h +++ b/src/core/SkSRGB.h @@ -29,7 +29,7 @@ static inline V sk_clamp_0_255(const V& x) { return V::Min(V::Max(x, 0.0f), 255.0f); } -// This should probably only be called from sk_linear_to_srgb() or sk_linear_to_srgb_noclamp(). +// This should probably only be called from sk_linear_to_srgb(). // It generally doesn't make sense to work with sRGB floats. template static inline V sk_linear_to_srgb_needs_trunc(const V& x) { @@ -57,15 +57,6 @@ static inline SkNx sk_linear_to_srgb(const SkNx& x) { return SkNx_cast(sk_clamp_0_255(f)); } -template -static inline SkNx sk_linear_to_srgb_noclamp(const SkNx& x) { - auto f = sk_linear_to_srgb_needs_trunc(x); - for (int i = 0; i < 4; i++) { - SkASSERTF(0.0f <= f[i] && f[i] < 256.0f, "f[%d] was %g, outside [0,256)\n", i, f[i]); - } - return SkNx_cast(f); -} - // sRGB -> linear, using math instead of table lookups, scaling better to larger SIMD vectors. template static inline SkNx sk_linear_from_srgb_math(const SkNx& s) { diff --git a/src/opts/SkRasterPipeline_opts.h b/src/opts/SkRasterPipeline_opts.h index 950264efb1..bd42632b4b 100644 --- a/src/opts/SkRasterPipeline_opts.h +++ b/src/opts/SkRasterPipeline_opts.h @@ -405,10 +405,10 @@ STAGE(load_s_srgb, true) { STAGE(store_srgb, false) { auto ptr = *(uint32_t**)ctx + x; - store(tail, ( sk_linear_to_srgb_noclamp(r) << SK_R32_SHIFT - | sk_linear_to_srgb_noclamp(g) << SK_G32_SHIFT - | sk_linear_to_srgb_noclamp(b) << SK_B32_SHIFT - | SkNx_cast(255.0f * a + 0.5f) << SK_A32_SHIFT ), (int*)ptr); + store(tail, ( sk_linear_to_srgb(r) << SK_R32_SHIFT + | sk_linear_to_srgb(g) << SK_G32_SHIFT + | sk_linear_to_srgb(b) << SK_B32_SHIFT + | SkNx_cast(0.5f + 255.0f * a) << SK_A32_SHIFT), (int*)ptr); } RGBA_XFERMODE(clear) { return 0.0f; }