#include "include/private/base/SkAttributes.h"
#include "include/private/base/SkMath.h"
#include <cmath>
#include <cstdint>
#include <limits>
#include <type_traits>
Go to the source code of this file.
|
static constexpr int | sk_float_sgn (float x) |
|
static constexpr float | sk_float_degrees_to_radians (float degrees) |
|
static constexpr float | sk_float_radians_to_degrees (float radians) |
|
template<typename T , std::enable_if_t< std::is_floating_point_v< T >, bool > = true> |
static constexpr bool | SkIsNaN (T x) |
|
template<typename T , typename... Pack, std::enable_if_t< std::is_floating_point_v< T >, bool > = true> |
static bool | SkIsFinite (T x, Pack... values) |
|
template<typename T , std::enable_if_t< std::is_floating_point_v< T >, bool > = true> |
static bool | SkIsFinite (const T array[], int count) |
|
static constexpr int | sk_float_saturate2int (float x) |
|
static constexpr int | sk_double_saturate2int (double x) |
|
static constexpr int64_t | sk_float_saturate2int64 (float x) |
|
static constexpr float | sk_double_to_float (double x) |
|
static constexpr float | sk_float_midpoint (float a, float b) |
|
static float | sk_float_rsqrt_portable (float x) |
|
static float | sk_float_rsqrt (float x) |
|
static constexpr float | sk_ieee_float_divide (float numer, float denom) |
|
static constexpr double | sk_ieee_double_divide (double numer, double denom) |
|
bool | sk_double_nearly_zero (double a) |
|
bool | sk_doubles_nearly_equal_ulps (double a, double b, uint8_t maxUlpsDiff=16) |
|
◆ SK_CHECK_NAN
#define SK_CHECK_NAN |
( |
|
resultVal | ) |
|
◆ sk_double_ceil2int
#define sk_double_ceil2int |
( |
|
x | ) |
((int)std::ceil(x)) |
◆ sk_double_floor2int
#define sk_double_floor2int |
( |
|
x | ) |
((int)std::floor(x)) |
◆ sk_double_round
#define sk_double_round |
( |
|
x | ) |
(std::floor((x) + 0.5)) |
◆ sk_double_round2int
◆ sk_float_ceil2int
◆ sk_float_ceil2int_no_saturate
#define sk_float_ceil2int_no_saturate |
( |
|
x | ) |
((int)std::ceil(x)) |
◆ sk_float_floor2int
◆ sk_float_floor2int_no_saturate
#define sk_float_floor2int_no_saturate |
( |
|
x | ) |
((int)std::floor(x)) |
◆ sk_float_round
◆ sk_float_round2int
◆ sk_float_round2int_no_saturate
◆ sk_double_nearly_zero()
bool sk_double_nearly_zero |
( |
double |
a | ) |
|
Definition at line 54 of file SkFloatingPoint.cpp.
54 {
55 return a == 0 || fabs(
a) < std::numeric_limits<float>::epsilon();
56}
◆ sk_double_saturate2int()
static constexpr int sk_double_saturate2int |
( |
double |
x | ) |
|
|
staticconstexpr |
Return the closest int for the given double. Returns SK_MaxS32 for NaN.
Definition at line 99 of file SkFloatingPoint.h.
99 {
104}
#define SK_CHECK_NAN(resultVal)
static constexpr int32_t SK_MinS32
static constexpr int32_t SK_MaxS32
◆ sk_double_to_float()
static constexpr float sk_double_to_float |
( |
double |
x | ) |
|
|
staticconstexpr |
◆ sk_doubles_nearly_equal_ulps()
bool sk_doubles_nearly_equal_ulps |
( |
double |
a, |
|
|
double |
b, |
|
|
uint8_t |
maxUlpsDiff = 16 |
|
) |
| |
Definition at line 30 of file SkFloatingPoint.cpp.
30 {
31
32
33
34
35
36
39
40
41
42 static constexpr double ulpFactor = std::numeric_limits<double>::epsilon();
43
44
45
46
47 const double tolerance = maxMagnitude * (ulpFactor * (maxUlpsDiff + 1));
48
49
50
52}
static double magnitude(double a)
static float max(float r, float g, float b)
static float min(float r, float g, float b)
SIN Vec< N, float > abs(const Vec< N, float > &x)
◆ sk_float_degrees_to_radians()
static constexpr float sk_float_degrees_to_radians |
( |
float |
degrees | ) |
|
|
staticconstexpr |
◆ sk_float_midpoint()
static constexpr float sk_float_midpoint |
( |
float |
a, |
|
|
float |
b |
|
) |
| |
|
staticconstexpr |
Definition at line 146 of file SkFloatingPoint.h.
146 {
147
148 return static_cast<float>(0.5 * (
static_cast<double>(
a) +
b));
149}
◆ sk_float_radians_to_degrees()
static constexpr float sk_float_radians_to_degrees |
( |
float |
radians | ) |
|
|
staticconstexpr |
◆ sk_float_rsqrt()
static float sk_float_rsqrt |
( |
float |
x | ) |
|
|
inlinestatic |
Definition at line 152 of file SkFloatingPoint.h.
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
◆ sk_float_rsqrt_portable()
static float sk_float_rsqrt_portable |
( |
float |
x | ) |
|
|
inlinestatic |
◆ sk_float_saturate2int()
static constexpr int sk_float_saturate2int |
( |
float |
x | ) |
|
|
staticconstexpr |
Return the closest int for the given float. Returns SK_MaxS32FitsInFloat for NaN.
Definition at line 89 of file SkFloatingPoint.h.
89 {
94}
constexpr int SK_MinS32FitsInFloat
constexpr int SK_MaxS32FitsInFloat
◆ sk_float_saturate2int64()
static constexpr int64_t sk_float_saturate2int64 |
( |
float |
x | ) |
|
|
staticconstexpr |
Return the closest int64_t for the given float. Returns SK_MaxS64FitsInFloat for NaN.
Definition at line 109 of file SkFloatingPoint.h.
109 {
114}
constexpr int64_t SK_MinS64FitsInFloat
constexpr int64_t SK_MaxS64FitsInFloat
◆ sk_float_sgn()
static constexpr int sk_float_sgn |
( |
float |
x | ) |
|
|
staticconstexpr |
◆ sk_ieee_double_divide()
static constexpr double sk_ieee_double_divide |
( |
double |
numer, |
|
|
double |
denom |
|
) |
| |
|
staticconstexpr |
◆ sk_ieee_float_divide()
static constexpr float sk_ieee_float_divide |
( |
float |
numer, |
|
|
float |
denom |
|
) |
| |
|
staticconstexpr |
◆ SkIsFinite() [1/2]
template<typename
T , std::enable_if_t< std::is_floating_point_v<
T >, bool > = true>
static bool SkIsFinite |
( |
const T |
array[], |
|
|
int |
count |
|
) |
| |
|
inlinestatic |
◆ SkIsFinite() [2/2]
template<typename
T , typename... Pack, std::enable_if_t< std::is_floating_point_v<
T >, bool > = true>
static bool SkIsFinite |
( |
T |
x, |
|
|
Pack... |
values |
|
) |
| |
|
inlinestatic |
◆ SkIsNaN()
template<typename
T , std::enable_if_t< std::is_floating_point_v<
T >, bool > = true>
static constexpr bool SkIsNaN |
( |
T |
x | ) |
|
|
inlinestaticconstexpr |
◆ SK_DoubleNaN
constexpr double SK_DoubleNaN = std::numeric_limits<double>::quiet_NaN() |
|
inlineconstexpr |
◆ SK_DoublePI
constexpr double SK_DoublePI = 3.14159265358979323846264338327950288 |
|
inlineconstexpr |
◆ SK_FloatInfinity
constexpr float SK_FloatInfinity = std::numeric_limits<float>::infinity() |
|
inlineconstexpr |
◆ SK_FloatNaN
constexpr float SK_FloatNaN = std::numeric_limits<float>::quiet_NaN() |
|
inlineconstexpr |
◆ SK_FloatNegativeInfinity
◆ SK_FloatPI
constexpr float SK_FloatPI = 3.14159265f |
|
inlineconstexpr |
◆ SK_FloatSqrt2
constexpr float SK_FloatSqrt2 = 1.41421356f |
|
inlineconstexpr |
◆ SK_MaxS32FitsInFloat
constexpr int SK_MaxS32FitsInFloat = 2147483520 |
|
inlineconstexpr |
◆ SK_MaxS64FitsInFloat
constexpr int64_t SK_MaxS64FitsInFloat = SK_MaxS64 >> (63-24) << (63-24) |
|
inlineconstexpr |
◆ SK_MinS32FitsInFloat
◆ SK_MinS64FitsInFloat