diff options
author | 2017-11-01 15:43:52 -0400 | |
---|---|---|
committer | 2017-11-01 20:22:30 +0000 | |
commit | 79363b604e376a3c0f70009ed1017edc6d29cdfb (patch) | |
tree | 7acd6d0cf00cce49034e7433ac2d3ec63f719c4c /src/core/SkSRGB.h | |
parent | 3c2359397a3c586a9a49266e1d0a6990558debdd (diff) |
Streamline legacy gradient color conversion
To produce colors for interpolation in legacy mode, we currently do
something like
SkColor c = Sk4f_toS32(swizzle_rb(Sk4f::Load(c4f)));
color4f = swizzle_rb(SkNx_cast<float>(Sk4b::Load(&c)) * (1/255.0f));
Let's see if we can streamline some of that.
Change-Id: I423b5aa8c2df8d115cc236d5f0a2e79923a9c2cc
Reviewed-on: https://skia-review.googlesource.com/66142
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src/core/SkSRGB.h')
-rw-r--r-- | src/core/SkSRGB.h | 15 |
1 files changed, 0 insertions, 15 deletions
diff --git a/src/core/SkSRGB.h b/src/core/SkSRGB.h index 9166ee9a2e..de078a5528 100644 --- a/src/core/SkSRGB.h +++ b/src/core/SkSRGB.h @@ -49,19 +49,4 @@ static inline Sk4i sk_linear_to_srgb(const Sk4f& x) { return SkNx_cast<int>(Sk4f::Min(Sk4f::Max(s, 0.0f), 255.0f)); } -// [0.0f, 1.0f] -> [0.0f, 1.0f]. Correct after rounding. -static inline Sk4f sk_linear_to_srgb_needs_round(const Sk4f& x) { - // Tuned to round trip each sRGB byte after rounding. - auto rsqrt = x.rsqrt(), - sqrt = rsqrt.invert(), - ftrt = rsqrt.rsqrt(); - - auto lo = 12.46f * x; - - auto hi = Sk4f::Min(1.0f, SkNx_fma(Sk4f{+0.411192f}, ftrt, - SkNx_fma(Sk4f{+0.689206f}, sqrt, - Sk4f{-0.0988f}))); - return (x < 0.0043f).thenElse(lo, hi); -} - #endif//SkSRGB_DEFINED |