| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 } | 48 } |
| 49 | 49 |
| 50 | 50 |
| 51 // SkColor handling: | 51 // SkColor handling: |
| 52 // SkColor has an ordering of (b, g, r, a) if cast to an Sk4f, so the code swi
zzles r and b to | 52 // SkColor has an ordering of (b, g, r, a) if cast to an Sk4f, so the code swi
zzles r and b to |
| 53 // produce the needed (r, g, b, a) ordering. | 53 // produce the needed (r, g, b, a) ordering. |
| 54 static inline Sk4f Sk4f_from_SkColor(SkColor color) { | 54 static inline Sk4f Sk4f_from_SkColor(SkColor color) { |
| 55 return swizzle_rb(Sk4f_fromS32(color)); | 55 return swizzle_rb(Sk4f_fromS32(color)); |
| 56 } | 56 } |
| 57 | 57 |
| 58 static inline void assert_unit(float x) { |
| 59 SkASSERT(0 <= x && x <= 1); |
| 60 } |
| 61 |
| 62 static inline float exact_srgb_to_linear(float srgb) { |
| 63 assert_unit(srgb); |
| 64 float linear; |
| 65 if (srgb <= 0.04045) { |
| 66 linear = srgb / 12.92f; |
| 67 } else { |
| 68 linear = powf((srgb + 0.055f) / 1.055f, 2.4f); |
| 69 } |
| 70 assert_unit(linear); |
| 71 return linear; |
| 72 } |
| 73 |
| 58 #endif | 74 #endif |
| OLD | NEW |