Flutter Engine
The Flutter Engine
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(),
128 } else {
129 return static_cast<FP2>(v);
130 }
131}
static unsigned clamp(SkFixed fx, int max)
static float max(float r, float g, float b)
Definition: hsl.cpp:49
SINT bool isfinite(const Vec< N, T > &v)
Definition: SkVx.h:1003

◆ 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())) {
116 } else if (v >= static_cast<FP>(std::numeric_limits<SI>::max())) {
118 }
119 return static_cast<SI>(v);
120}
#define SI
Definition: Transform_inl.h:94
static float min(float r, float g, float b)
Definition: hsl.cpp:48

◆ 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) {
}
} else if (distance < std::numeric_limits<SI>::min() - location) {
}
return location + distance

Definition at line 57 of file saturated_math.h.

◆ 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) {
}
} else if (lower > 0 && upper < std::numeric_limits<SI>::min() + lower) {
}
return upper - lower

Definition at line 72 of file saturated_math.h.