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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 55 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
56 | 56 |
57 static inline Sk4f Sk4f_fromL32(uint32_t src) { | 57 static inline Sk4f Sk4f_fromL32(uint32_t src) { |
58 return to_4f(src) * Sk4f(1.0f/255); | 58 return to_4f(src) * Sk4f(1.0f/255); |
59 } | 59 } |
60 | 60 |
61 static inline Sk4f Sk4f_fromS32(uint32_t src) { | 61 static inline Sk4f Sk4f_fromS32(uint32_t src) { |
62 return srgb_to_linear(to_4f(src) * Sk4f(1.0f/255)); | 62 return srgb_to_linear(to_4f(src) * Sk4f(1.0f/255)); |
63 } | 63 } |
64 | 64 |
| 65 // Color handling: |
| 66 // SkColor has an ordering of (b, g, r, a) if cast to an Sk4f, so the code swi
zzles r and b to |
| 67 // produce the needed (r, g, b, a) ordering. |
| 68 static inline Sk4f Sk4f_from_SkColor(SkColor color) { |
| 69 return swizzle_rb(gTreatSkColorAsSRGB ? Sk4f_fromS32(color) : Sk4f_fromL32(c
olor)); |
| 70 } |
| 71 |
65 static inline uint32_t Sk4f_toL32(const Sk4f& x4) { | 72 static inline uint32_t Sk4f_toL32(const Sk4f& x4) { |
66 return to_4b(x4 * Sk4f(255) + Sk4f(0.5f)); | 73 return to_4b(x4 * Sk4f(255) + Sk4f(0.5f)); |
67 } | 74 } |
68 | 75 |
69 static inline uint32_t Sk4f_toS32(const Sk4f& x4) { | 76 static inline uint32_t Sk4f_toS32(const Sk4f& x4) { |
70 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)); |
71 } | 78 } |
72 | 79 |
73 #endif | 80 #endif |
OLD | NEW |