Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
impeller::saturated Namespace Reference

Functions

 ONLY_ON_SIGNED_INT (SI) Add(SI location
 
 ONLY_ON_FLOAT (FP) Add(FP location
 
 ONLY_ON_SIGNED_INT_RET (SI, Scalar) AverageScalar(SI a
 
 ONLY_ON_SAME_TYPES (T, U) Cast(T v)
 
 ONLY_ON_FLOAT_TO_SIGNED_INT (FP, SI) Cast(FP v)
 
 ONLY_ON_DIFFERING_FLOAT (FP1, FP2) Cast(FP1 v)
 

Variables

template<typename T >
constexpr bool is_signed_integral_v
 
SI distance
 
SI lower
 
SI b
 

Function Documentation

◆ ONLY_ON_DIFFERING_FLOAT()

impeller::saturated::ONLY_ON_DIFFERING_FLOAT ( FP1  ,
FP2   
)

Definition at line 122 of file saturated_math.h.

122 {
123 if (std::isfinite(v)) {
124 // Avoid truncation to inf/-inf.
125 return std::clamp(static_cast<FP2>(v), //
126 std::numeric_limits<FP2>::lowest(),
127 std::numeric_limits<FP2>::max());
128 } else {
129 return static_cast<FP2>(v);
130 }
131}

◆ ONLY_ON_FLOAT()

impeller::saturated::ONLY_ON_FLOAT ( FP  )

◆ ONLY_ON_FLOAT_TO_SIGNED_INT()

impeller::saturated::ONLY_ON_FLOAT_TO_SIGNED_INT ( FP  ,
SI   
)

Definition at line 113 of file saturated_math.h.

113 {
114 if (v <= static_cast<FP>(std::numeric_limits<SI>::min())) {
115 return std::numeric_limits<SI>::min();
116 } else if (v >= static_cast<FP>(std::numeric_limits<SI>::max())) {
117 return std::numeric_limits<SI>::max();
118 }
119 return static_cast<SI>(v);
120}
#define SI

◆ ONLY_ON_SAME_TYPES()

impeller::saturated::ONLY_ON_SAME_TYPES ( T  ,
 
)

Definition at line 109 of file saturated_math.h.

109 {
110 return v;
111}

◆ ONLY_ON_SIGNED_INT()

impeller::saturated::ONLY_ON_SIGNED_INT ( SI  )

◆ ONLY_ON_SIGNED_INT_RET()

impeller::saturated::ONLY_ON_SIGNED_INT_RET ( SI  ,
Scalar   
)

Variable Documentation

◆ b

FP impeller::saturated::b
Initial value:
{
return static_cast<Scalar>(std::scalbn(a, -1) + std::scalbn(b, -1))
static bool b
struct MyStruct a[10]
float Scalar
Definition scalar.h:18

Definition at line 87 of file saturated_math.h.

◆ distance

FP impeller::saturated::distance
Initial value:
{
if (location >= 0) {
if (distance > std::numeric_limits<SI>::max() - location) {
return std::numeric_limits<SI>::max();
}
} else if (distance < std::numeric_limits<SI>::min() - location) {
return std::numeric_limits<SI>::min();
}
return location + distance

Definition at line 57 of file saturated_math.h.

57 {
58 if (location >= 0) {
59 if (distance > std::numeric_limits<SI>::max() - location) {
60 return std::numeric_limits<SI>::max();
61 }
62 } else if (distance < std::numeric_limits<SI>::min() - location) {
63 return std::numeric_limits<SI>::min();
64 }

◆ is_signed_integral_v

template<typename T >
constexpr bool impeller::saturated::is_signed_integral_v
inlineconstexpr
Initial value:
=
std::is_integral_v<T> && std::is_signed_v<T>

Definition at line 21 of file saturated_math.h.

◆ lower

FP impeller::saturated::lower
Initial value:
{
if (upper >= 0) {
if (lower < 0 && upper > std::numeric_limits<SI>::max() + lower) {
return std::numeric_limits<SI>::max();
}
} else if (lower > 0 && upper < std::numeric_limits<SI>::min() + lower) {
return std::numeric_limits<SI>::min();
}
return upper - lower

Definition at line 72 of file saturated_math.h.

72 {
73 if (upper >= 0) {
74 if (lower < 0 && upper > std::numeric_limits<SI>::max() + lower) {
75 return std::numeric_limits<SI>::max();
76 }
77 } else if (lower > 0 && upper < std::numeric_limits<SI>::min() + lower) {
78 return std::numeric_limits<SI>::min();
79 }