jvanverth | 9367992 | 2014-11-26 13:15:59 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SkHalf_DEFINED |
| 9 | #define SkHalf_DEFINED |
| 10 | |
| 11 | #include "SkTypes.h" |
| 12 | |
| 13 | // 16-bit floating point value |
| 14 | // format is 1 bit sign, 5 bits exponent, 10 bits mantissa |
| 15 | // only used for storage |
| 16 | typedef uint16_t SkHalf; |
| 17 | |
jvanverth | 28f9c60 | 2014-12-05 13:06:35 -0800 | [diff] [blame] | 18 | #define SK_HalfMin 0x0400 // 2^-24 (minimum positive normal value) |
| 19 | #define SK_HalfMax 0x7bff // 65504 |
| 20 | #define SK_HalfEpsilon 0x1400 // 2^-10 |
| 21 | |
jvanverth | 9367992 | 2014-11-26 13:15:59 -0800 | [diff] [blame] | 22 | // convert between half and single precision floating point |
| 23 | float SkHalfToFloat(SkHalf h); |
| 24 | SkHalf SkFloatToHalf(float f); |
| 25 | |
| 26 | #endif |