OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkPM4fPriv_DEFINED | 8 #ifndef SkPM4fPriv_DEFINED |
9 #define SkPM4fPriv_DEFINED | 9 #define SkPM4fPriv_DEFINED |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 static inline Sk4f to_4f_rgba(uint32_t b4) { | 35 static inline Sk4f to_4f_rgba(uint32_t b4) { |
36 return swizzle_rb_if_bgra(to_4f(b4)); | 36 return swizzle_rb_if_bgra(to_4f(b4)); |
37 } | 37 } |
38 | 38 |
39 static inline Sk4f srgb_to_linear(const Sk4f& s4) { | 39 static inline Sk4f srgb_to_linear(const Sk4f& s4) { |
40 return set_alpha(s4 * s4, get_alpha(s4)); | 40 return set_alpha(s4 * s4, get_alpha(s4)); |
41 } | 41 } |
42 | 42 |
43 static inline Sk4f linear_to_srgb(const Sk4f& l4) { | 43 static inline Sk4f linear_to_srgb(const Sk4f& l4) { |
44 return set_alpha(l4.sqrt(), get_alpha(l4)); | 44 return set_alpha(l4.rsqrt().invert(), get_alpha(l4)); |
45 } | 45 } |
46 | 46 |
47 static inline float srgb_to_linear(float x) { | 47 static inline float srgb_to_linear(float x) { |
48 return x * x; | 48 return x * x; |
49 } | 49 } |
50 | 50 |
51 static inline float linear_to_srgb(float x) { | 51 static inline float linear_to_srgb(float x) { |
52 return sqrtf(x); | 52 return sqrtf(x); |
53 } | 53 } |
54 | 54 |
(...skipping 16 matching lines...) Expand all Loading... |
71 | 71 |
72 static inline uint32_t Sk4f_toL32(const Sk4f& x4) { | 72 static inline uint32_t Sk4f_toL32(const Sk4f& x4) { |
73 return to_4b(x4 * Sk4f(255) + Sk4f(0.5f)); | 73 return to_4b(x4 * Sk4f(255) + Sk4f(0.5f)); |
74 } | 74 } |
75 | 75 |
76 static inline uint32_t Sk4f_toS32(const Sk4f& x4) { | 76 static inline uint32_t Sk4f_toS32(const Sk4f& x4) { |
77 return to_4b(linear_to_srgb(x4) * Sk4f(255) + Sk4f(0.5f)); | 77 return to_4b(linear_to_srgb(x4) * Sk4f(255) + Sk4f(0.5f)); |
78 } | 78 } |
79 | 79 |
80 #endif | 80 #endif |
OLD | NEW |