8#ifndef SkFloatingPoint_DEFINED
9#define SkFloatingPoint_DEFINED
21inline constexpr double SK_DoublePI = 3.14159265358979323846264338327950288;
24 return (0.0f <
x) - (
x < 0.0f);
38#define sk_float_round(x) (float)sk_double_round((double)(x))
40template <
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
bool> = true>
49template <
typename T,
typename...
Pack, std::enable_if_t<std::is_floating_point_v<T>,
bool> =
true>
52 prod = (prod * ... *
values);
57template <
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
bool> = true>
80#if defined(_MSC_VER) && !defined(__clang__)
81 #define SK_CHECK_NAN(resultVal) if (SkIsNaN(x)) { return resultVal; }
83 #define SK_CHECK_NAN(resultVal)
118#define sk_float_floor2int(x) sk_float_saturate2int(std::floor(x))
119#define sk_float_round2int(x) sk_float_saturate2int(sk_float_round(x))
120#define sk_float_ceil2int(x) sk_float_saturate2int(std::ceil(x))
122#define sk_float_floor2int_no_saturate(x) ((int)std::floor(x))
123#define sk_float_round2int_no_saturate(x) ((int)sk_float_round(x))
124#define sk_float_ceil2int_no_saturate(x) ((int)std::ceil(x))
126#define sk_double_round(x) (std::floor((x) + 0.5))
127#define sk_double_floor2int(x) ((int)std::floor(x))
128#define sk_double_round2int(x) ((int)std::round(x))
129#define sk_double_ceil2int(x) ((int)std::ceil(x))
136 return static_cast<float>(
x);
139inline constexpr float SK_FloatNaN = std::numeric_limits<float>::quiet_NaN();
143inline constexpr double SK_DoubleNaN = std::numeric_limits<double>::quiet_NaN();
148 return static_cast<float>(0.5 * (
static_cast<double>(
a) +
b));
156#ifdef SK_BUILD_FOR_WIN
158#pragma warning(disable : 4723)
162 return numer / denom;
167 return numer / denom;
169#ifdef SK_BUILD_FOR_WIN
170#pragma warning( pop )
#define SK_NO_SANITIZE(A)
bool sk_double_nearly_zero(double a)
static constexpr float sk_double_to_float(double x)
#define SK_CHECK_NAN(resultVal)
constexpr double SK_DoublePI
static constexpr bool SkIsNaN(T x)
constexpr float SK_FloatInfinity
constexpr int64_t SK_MinS64FitsInFloat
static bool SkIsFinite(T x, Pack... values)
static constexpr int sk_float_sgn(float x)
static constexpr int64_t sk_float_saturate2int64(float x)
constexpr int64_t SK_MaxS64FitsInFloat
constexpr int SK_MinS32FitsInFloat
constexpr float SK_FloatNaN
static float sk_float_rsqrt_portable(float x)
constexpr float SK_FloatSqrt2
constexpr int SK_MaxS32FitsInFloat
static constexpr float sk_float_degrees_to_radians(float degrees)
static constexpr double sk_ieee_double_divide(double numer, double denom)
constexpr double SK_DoubleNaN
static float sk_float_rsqrt(float x)
static constexpr int sk_double_saturate2int(double x)
static constexpr float sk_ieee_float_divide(float numer, float denom)
static constexpr float sk_float_midpoint(float a, float b)
static constexpr float sk_float_radians_to_degrees(float radians)
static constexpr int sk_float_saturate2int(float x)
constexpr float SK_FloatNegativeInfinity
bool sk_doubles_nearly_equal_ulps(double a, double b, uint8_t maxUlpsDiff=16)
constexpr float SK_FloatPI
static constexpr int64_t SK_MaxS64
static constexpr int32_t SK_MinS32
static constexpr int32_t SK_MaxS32
static void * Pack(const T &ctx, SkArenaAlloc *alloc)
SIN Vec< N, float > sqrt(const Vec< N, float > &x)