diff options
author | 2016-11-02 14:47:07 -0400 | |
---|---|---|
committer | 2016-11-03 18:22:54 +0000 | |
commit | 6b059bdc40d070fe08a3ff071e45be782297ab08 (patch) | |
tree | 13cee6e84969517baf1cf2e45b25f136448320a8 /src/core | |
parent | 71d9d84d6cd38b9dc8711849952bb9e668ab33a2 (diff) |
Remove sk_linear_to_srgb_noclamp().
We've just re-noticed this can happen:
1) we have a properly premultiplied linear color;
2) we convert that to sRGB;
3) we convert that back to linear;
4) that color does not appear to be premultiplied.
Removing sk_linear_to_srgb_noclamp(), and thus always clamping to [0,1] here in linear space, does not fix this problem. However, it does help keep it from propagating too badly.
Just double-checked: the older Sk4f pipeline (SkXfermode4f, SkPM4fPriv, etc) already use sk_linear_to_srgb() exclusively, so they're already doing this same clamp.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4314
Change-Id: I6352eb0ba969eb25674e8441e43bb51e1e1c0df3
Reviewed-on: https://skia-review.googlesource.com/4314
Reviewed-by: Yuqian Li <liyuqian@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkSRGB.h | 11 |
1 files changed, 1 insertions, 10 deletions
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 <typename V> static inline V sk_linear_to_srgb_needs_trunc(const V& x) { @@ -57,15 +57,6 @@ static inline SkNx<N,int> sk_linear_to_srgb(const SkNx<N,float>& x) { return SkNx_cast<int>(sk_clamp_0_255(f)); } -template <int N> -static inline SkNx<N,int> sk_linear_to_srgb_noclamp(const SkNx<N,float>& 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<int>(f); -} - // sRGB -> linear, using math instead of table lookups, scaling better to larger SIMD vectors. template <int N> static inline SkNx<N,float> sk_linear_from_srgb_math(const SkNx<N,int>& s) { |