| Flutter Impeller |

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 }

## ◆ ONLY_ON_SAME_TYPES()

impeller::saturated::ONLY_ON_SAME_TYPES | ( | T | ,
|  | U |
| ) |  |

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))

Definition at line 87 of file saturated_math.h.

Referenced by Array4Near(), ColorBufferNear(), ColorNear(), ColorsNear(), impeller::Vector3::Combine(), impeller::ComponentChoose(), impeller::ComputeCubicSubdivisions(), impeller::TypographerContextSTB::CreateGlyphAtlas(), impeller::CubicPathBoundingPopulateValues(), impeller::VertexWriter::EndContour(), impeller::GlyphAtlas::GetGlyphCount(), impeller::TRect< Scalar >::Intersection(), impeller::skia_conversions::IsNearlySimpleRRect(), impeller::Color::Lerp(), impeller::Color::MakeRGBA8(), MatrixNear(), impeller::NearEqual(), NumberNear(), PointNear(), QuaternionNear(), RectNear(), impeller::GaussianBlurFilterContents::ScaleSigma(), SizeNear(), SolidVerticesNear(), impeller::testing::swap_nan(), impeller::testing::TEST(), impeller::testing::TEST_P(), TextureVerticesNear(), impeller::Color::ToR8G8B8A8(), impeller::TRect< Scalar >::Union(), Vector3Near(), and Vector4Near().

## ◆ 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.

Referenced by impeller::scene::TimelineResolver::GetTimelineKey(), and impeller::testing::TEST_P().

## ◆ is_signed_integral_v

template<typename T >

constexpr bool impeller::saturated::is_signed_integral_v
| inline constexpr

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.

impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::saturated::lower
SI lower
Definition: saturated_math.h:72
impeller::saturated::distance
SI distance
Definition: saturated_math.h:57
impeller::saturated::b
SI b
Definition: saturated_math.h:87