Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkHalf.h
Go to the documentation of this file.
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 <cstdint>
12
13// 16-bit floating point value
14// format is 1 bit sign, 5 bits exponent, 10 bits mantissa
15// only used for storage
16using SkHalf = uint16_t;
17
18static constexpr uint16_t SK_HalfNaN = 0x7c01; // a NaN value, not all possible NaN values
19static constexpr uint16_t SK_HalfInfinity = 0x7c00;
20static constexpr uint16_t SK_HalfMin = 0x0400; // 2^-14 (minimum positive normal value)
21static constexpr uint16_t SK_HalfMax = 0x7bff; // 65504 (maximum positive normal value)
22static constexpr uint16_t SK_HalfEpsilon = 0x1400; // 2^-10
23static constexpr uint16_t SK_Half1 = 0x3C00; // 1
24
25// Convert between half and single precision floating point. Vectorized functions
26// skvx::from_half and skvx::to_half are also available. Unlike skvx::to_half, this will
27// correctly handle float NaN -> half NaN.
29SkHalf SkFloatToHalf(float f);
30
31#endif
static constexpr uint16_t SK_HalfMax
Definition SkHalf.h:21
static constexpr uint16_t SK_Half1
Definition SkHalf.h:23
static constexpr uint16_t SK_HalfMin
Definition SkHalf.h:20
uint16_t SkHalf
Definition SkHalf.h:16
float SkHalfToFloat(SkHalf h)
Definition SkHalf.cpp:24
static constexpr uint16_t SK_HalfEpsilon
Definition SkHalf.h:22
static constexpr uint16_t SK_HalfInfinity
Definition SkHalf.h:19
static constexpr uint16_t SK_HalfNaN
Definition SkHalf.h:18
SkHalf SkFloatToHalf(float f)
Definition SkHalf.cpp:16
SkScalar h