FastLED 3.10.10
Loading...
Searching...
No Matches
primitives.h File Reference
+ Include dependency graph for primitives.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  fl::gfx::detail::DiscCtx< PixelT >
 Disc context: bundles per-circle constants into a struct passed by reference. More...
 
struct  fl::gfx::detail::needs_division< Coord, typename >
 
struct  fl::gfx::detail::needs_division< Coord, typename voider< fl::bool_constant<(Coord::FRAC_BITS< 16)> >::type >
 
struct  fl::gfx::detail::PolyEdge
 Per-edge scanline state for drawPolygon (even-odd fill, band model). More...
 
struct  fl::gfx::detail::RingCtx< PixelT >
 Ring context: bundles all per-circle constants into a struct passed by reference. More...
 
struct  fl::gfx::detail::StrokeCtx< PixelT >
 Stroke line context: bundles per-line constants into a struct passed by reference. More...
 
struct  fl::gfx::detail::voider<... >
 

Namespaces

namespace  fl
 Base definition for an LED controller.
 
namespace  fl::gfx
 
namespace  fl::gfx::detail
 ============================================================================
 

Functions

template<typename Coord>
Coord fl::gfx::aaRatio (Coord num, Coord denom, Coord inv_denom) FL_NO_EXCEPT
 Compute num/denom using the best strategy for the Coord type:
 
template<typename Coord>
Coord fl::gfx::detail::aaRatioDispatch (Coord num, Coord denom, Coord, fl::true_type) FL_NO_EXCEPT
 
template<typename Coord>
Coord fl::gfx::detail::aaRatioDispatch (Coord num, Coord, Coord inv_denom, fl::false_type) FL_NO_EXCEPT
 
template<typename PixelT, bool Overwrite>
void fl::gfx::addPixelToBuffer (PixelT *pixels, int width, int height, int x, int y, const PixelT &color) FL_NO_EXCEPT
 Internal helper: add or set pixel to rectangular buffer with bounds checking Direct row-major indexing: pixels[y * width + x] Templated on Overwrite for compile-time dispatch (no per-pixel branch).
 
void fl::gfx::detail::computeBandShift (fl::i32 band, fl::u8 &shift_out, fl::u16 &inv_out) FL_NO_EXCEPT
 Precompute right-shift and reciprocal multiplier for AA division.
 
template<typename T>
fl::u8 fl::gfx::coordToU8 (T alpha) FL_NO_EXCEPT
 sqrt is provided by fl::sqrt overloads in math.h for:
 
template<>
fl::u8 fl::gfx::coordToU8< double > (double alpha) FL_NO_EXCEPT
 
template<>
fl::u8 fl::gfx::coordToU8< fl::s16x16 > (fl::s16x16 alpha) FL_NO_EXCEPT
 
template<>
fl::u8 fl::gfx::coordToU8< float > (float alpha) FL_NO_EXCEPT
 
template<>
fl::u8 fl::gfx::coordToU8< int > (int alpha) FL_NO_EXCEPT
 
template<typename PixelT, typename Coord>
void fl::gfx::drawDisc (Canvas< PixelT > &canvas, const PixelT &color, Coord cx, Coord cy, Coord r, fl::DrawMode mode=fl::DrawMode::DRAW_MODE_BLEND) FL_NO_EXCEPT
 
template<typename PixelT, typename Coord, bool Overwrite>
void fl::gfx::detail::drawDiscCore (Canvas< PixelT > &canvas, const PixelT &color, Coord cx, Coord cy, Coord r) FL_NO_EXCEPT
 
template<typename PixelT, typename Coord>
void fl::gfx::drawLine (Canvas< PixelT > &canvas, const PixelT &color, Coord x0, Coord y0, Coord x1, Coord y1, fl::DrawMode mode) FL_NO_EXCEPT
 ============================================================================
 
template<typename PixelT, typename Coord, bool Overwrite>
void fl::gfx::detail::drawLineCore (Canvas< PixelT > &canvas, const PixelT &color, Coord x0, Coord y0, Coord x1, Coord y1) FL_NO_EXCEPT
 
template<typename PixelT, typename Coord, int N>
void fl::gfx::drawPolygon (Canvas< PixelT > &canvas, const PixelT &color, const PolyPoint< Coord >(&pts)[N], fl::DrawMode mode) FL_NO_EXCEPT
 
template<typename PixelT, typename Coord, int N, int MAXN = FL_GFX_POLYGON_DEFAULT_MAXN, int CHUNK = FL_GFX_POLYGON_DEFAULT_CHUNK, PolyFill Fill = PolyFill::Exact>
void fl::gfx::drawPolygon (Canvas< PixelT > &canvas, const PixelT &color, const PolyPoint< Coord >(&pts)[N], fl::DrawMode mode=fl::DrawMode::DRAW_MODE_BLEND) FL_NO_EXCEPT
 
template<typename PixelT, typename Coord>
void fl::gfx::drawPolygon (Canvas< PixelT > &canvas, const PixelT &color, fl::span< const PolyPoint< Coord > > pts, fl::DrawMode mode) FL_NO_EXCEPT
 
template<typename PixelT, typename Coord, int MAXN = FL_GFX_POLYGON_DEFAULT_MAXN, int CHUNK = FL_GFX_POLYGON_DEFAULT_CHUNK, PolyFill Fill = PolyFill::Exact>
void fl::gfx::drawPolygon (Canvas< PixelT > &canvas, const PixelT &color, fl::span< const PolyPoint< Coord > > pts, fl::DrawMode mode=fl::DrawMode::DRAW_MODE_BLEND) FL_NO_EXCEPT
 Fill selects the polygon backend (PolyFill::Exact by default; PolyFill::ABuffer for the faster 8x4 A-buffer kernel, which ignores CHUNK).
 
template<typename PixelT, typename Coord, bool Overwrite, int MAXN, int CHUNK>
void fl::gfx::detail::drawPolygonCore (Canvas< PixelT > &canvas, const PixelT &color, fl::span< const PolyPoint< Coord > > pts) FL_NO_EXCEPT
 
template<typename PixelT, typename Coord>
void fl::gfx::drawRing (Canvas< PixelT > &canvas, const PixelT &color, Coord cx, Coord cy, Coord r, Coord thickness, fl::DrawMode mode=fl::DrawMode::DRAW_MODE_BLEND) FL_NO_EXCEPT
 
template<typename PixelT, typename Coord, bool Overwrite>
void fl::gfx::detail::drawRingCore (Canvas< PixelT > &canvas, const PixelT &color, Coord cx, Coord cy, Coord r, Coord thickness) FL_NO_EXCEPT
 
template<typename PixelT, typename Coord>
void fl::gfx::drawStrokeLine (Canvas< PixelT > &canvas, const PixelT &color, Coord x0, Coord y0, Coord x1, Coord y1, Coord thickness, LineCap cap, fl::DrawMode mode=fl::DrawMode::DRAW_MODE_BLEND) FL_NO_EXCEPT
 
template<typename PixelT, typename Coord, bool Overwrite>
void fl::gfx::detail::drawStrokeLineCore (Canvas< PixelT > &canvas, const PixelT &color, Coord x0, Coord y0, Coord x1, Coord y1, Coord thickness, LineCap cap) FL_NO_EXCEPT
 
fl::i32 fl::gfx::detail::floorDiv16I32 (fl::i32 v) FL_NO_EXCEPT
 Floor(v / 65536) for i32.
 
fl::i64 fl::gfx::detail::floorDiv16I64 (fl::i64 v) FL_NO_EXCEPT
 Same for i64 (line crossings can exceed i32 for steep short edges).
 
fl::i64 fl::gfx::detail::floorDivI64 (fl::i64 a, fl::i64 b) FL_NO_EXCEPT
 Floor-divide a by positive b (rounds toward -inf).
 
template<typename T>
T fl::gfx::fromFrac (int p, int q) FL_NO_EXCEPT
 Convert rational p/q to Coord without float.
 
template<>
fl::s16x16 fl::gfx::fromFrac< fl::s16x16 > (int p, int q) FL_NO_EXCEPT
 
template<typename T>
T fl::gfx::fromInt (int n) FL_NO_EXCEPT
 Convert an integer to Coord without float intermediate.
 
template<>
fl::s16x16 fl::gfx::fromInt< fl::s16x16 > (int n) FL_NO_EXCEPT
 
template<typename T>
T fl::gfx::halfOf (T val) FL_NO_EXCEPT
 Divide Coord by 2 using shift (avoids expensive division on embedded).
 
template<>
double fl::gfx::halfOf< double > (double val)
 
template<>
fl::s16x16 fl::gfx::halfOf< fl::s16x16 > (fl::s16x16 val) FL_NO_EXCEPT
 
template<>
float fl::gfx::halfOf< float > (float val)
 
template<>
int fl::gfx::halfOf< int > (int val) FL_NO_EXCEPT
 
void fl::gfx::detail::polyAdd128 (fl::u64 &hi, fl::u64 &lo, fl::u64 ahi, fl::u64 alo) FL_NO_EXCEPT
 128-bit add: (hi, lo) += (ahi, alo).
 
int fl::gfx::detail::polyClz32 (fl::u32 v) FL_NO_EXCEPT
 Count leading zeros of a non-zero 32-bit value (branch form: portable to MSVC where __builtin_clz is unavailable, and branch-free on x86).
 
int fl::gfx::detail::polyColClamped (fl::i64 v, int width) FL_NO_EXCEPT
 Pixel column floor(v / 65536) of a row-extent bound v = x +/- hw, clamped to [-1, width].
 
FL_NO_INLINE fl::i32 fl::gfx::detail::polyDivRoundT28 (fl::u64 mhi, fl::u64 mlo, fl::u64 dv) FL_NO_EXCEPT
 T = round_half_up(M / dv) clamped to kPolyOne, for M = (mhi, mlo) and 0 < dv < 2^63 (polyLineT28's quotient step).
 
fl::i32 fl::gfx::detail::polyLineT28 (fl::i32 B, fl::i32 D, fl::i64 u, fl::i32 ta, fl::i32 tb) FL_NO_EXCEPT
 Exact left-of-line coverage of one pixel for one polygon edge.
 
void fl::gfx::detail::polyMul128 (fl::u64 a, fl::u64 b, fl::u64 &hi, fl::u64 &lo) FL_NO_EXCEPT
 Multiply two unsigned values < 2^48, returning the 128-bit product as a (hi, lo) u64 pair.
 
void fl::gfx::detail::polySortBand (fl::u8 *idx, fl::i64 *keys, const PolyEdge *edges, int nc, fl::i32 mid) FL_NO_EXCEPT
 Sort a band's active edges (idx[0..nc)) by the committed implementation's midpoint key: the FLOORED Q16.16 crossing at the band midpoint, key_e = floor((2*dy_e*x_e + B_e*mid) / (2*dy_e)), mid = a + b with a stable insertion sort (equal keys keep edge-index order).
 
int fl::gfx::detail::polyTopBit128 (fl::u32 m3, fl::u32 m2, fl::u32 m1, fl::u32 m0) FL_NO_EXCEPT
 Index (0..127) of the highest set bit of a 128-bit value held in four 32-bit lanes (m3 most significant), or -1 when the value is zero.
 
template<typename PixelT, bool Overwrite>
void fl::gfx::detail::renderDiscRow (PixelT *buf, int w, int py, fl::i32 d2_row, const DiscCtx< PixelT > &f) FL_NO_EXCEPT
 Render one scanline of a disc using incremental d².
 
template<typename PixelT, bool Overwrite>
void fl::gfx::detail::renderRingRow (PixelT *buf, int w, int py, fl::i32 d2_row, const RingCtx< PixelT > &g) FL_NO_EXCEPT
 Render one scanline of a ring using incremental d² with phase-based scanning.
 
template<typename PixelT, bool Overwrite>
void fl::gfx::detail::renderStrokeRow (PixelT *buf, int w, int py, fl::i32 cross_start, fl::i32 dot_start, const StrokeCtx< PixelT > &sc) FL_NO_EXCEPT
 Render one scanline of a stroke line using phase-based scanning.
 
template<typename Coord>
fl::i32 fl::gfx::detail::toFixed8 (Coord val) FL_NO_EXCEPT
 Convert any Coord type to 8.8 fixed-point (fl::i32).
 
template<>
fl::i32 fl::gfx::detail::toFixed8< double > (double val) FL_NO_EXCEPT
 
template<>
fl::i32 fl::gfx::detail::toFixed8< fl::s16x16 > (fl::s16x16 val) FL_NO_EXCEPT
 
template<>
fl::i32 fl::gfx::detail::toFixed8< float > (float val) FL_NO_EXCEPT
 
template<>
fl::i32 fl::gfx::detail::toFixed8< int > (int val) FL_NO_EXCEPT
 
template<typename T>
int fl::gfx::toInt (const T &val) FL_NO_EXCEPT
 Helper to convert any coordinate type to int Supports: s16x16 (via to_int()), float, int, and other arithmetic types.
 
template<>
int fl::gfx::toInt< double > (const double &val) FL_NO_EXCEPT
 
template<>
int fl::gfx::toInt< float > (const float &val) FL_NO_EXCEPT
 
template<>
int fl::gfx::toInt< int > (const int &val) FL_NO_EXCEPT
 
template<typename Coord>
fl::i32 fl::gfx::detail::toQ16 (Coord val) FL_NO_EXCEPT
 Convert any Coord type to Q16.16 raw i32 for integer inner loops.
 
template<>
fl::i32 fl::gfx::detail::toQ16< double > (double val) FL_NO_EXCEPT
 
template<>
fl::i32 fl::gfx::detail::toQ16< fl::s16x16 > (fl::s16x16 val) FL_NO_EXCEPT
 
template<>
fl::i32 fl::gfx::detail::toQ16< float > (float val) FL_NO_EXCEPT
 
template<>
fl::i32 fl::gfx::detail::toQ16< int > (int val) FL_NO_EXCEPT
 
template<typename Coord>
fl::i32 fl::gfx::detail::toQ16Clamped (Coord val) FL_NO_EXCEPT
 Convert any Coord type to Q16.16, clamped to ±8191 px (NaN -> 0).
 

Variables

static const fl::i32 fl::gfx::detail::kPolyOne = 1L << 28
 Full-pixel coverage in T units (see polyLineT28).
 
static const fl::i32 fl::gfx::detail::kPolyQ16Max = 8191L << 16
 Maximum |vertex coordinate| accepted by drawPolygon, in Q16.16 units.
 

Class Documentation

◆ fl::gfx::detail::DiscCtx

struct fl::gfx::detail::DiscCtx
Class Members
u16 band_inv
u8 band_shift
PixelT color
i32 rin2
i32 rout2
i32 xdelta0
int xmax
int xmin

◆ fl::gfx::detail::PolyEdge

struct fl::gfx::detail::PolyEdge
Class Members
i32 B
i32 dy
i64 hw
int py0
int py1
i32 rem
i64 step
i32 t
i64 x
i32 ybot
i32 ytop

◆ fl::gfx::detail::RingCtx

struct fl::gfx::detail::RingCtx
Class Members
PixelT color
i32 ii2
u16 inner_inv
u8 inner_shift
i32 io2
i32 oi2
i32 oo2
u16 outer_inv
u8 outer_shift
i32 xdelta0
int xmax
int xmin

◆ fl::gfx::detail::StrokeCtx

struct fl::gfx::detail::StrokeCtx
Class Members
u16 aa_inv
u8 aa_shift
LineCap cap
u16 cap_inv
u8 cap_shift
PixelT color
i32 dot_ext_q
i32 dx_q
i32 dy_q
i32 len2_q
i32 r_max2_8
i32 threshold_q
i32 x0_8
i32 x1_8
int xmax
int xmin
i32 y0_8
i32 y1_8

◆ fl::gfx::detail::voider

struct fl::gfx::detail::voider
Class Members
typedef void type