FastLED 3.9.15
Loading...
Searching...
No Matches

◆ renderRingRow()

template<typename PixelT, bool Overwrite>
void fl::gfx::detail::renderRingRow ( PixelT * buf,
int w,
int py,
fl::i32 d2_row,
const RingCtx< PixelT > & g )
inline

Render one scanline of a ring using incremental d² with phase-based scanning.

Templated on Overwrite for compile-time dispatch (no per-pixel branch). Zones (left to right): outside → outer-AA → solid → inner-AA → hole → inner-AA → solid → outer-AA → outside.

Definition at line 317 of file primitives.h.

319 {
320 PixelT* ptr = &buf[py * w + g.xmin];
321 fl::i32 d2 = d2_row;
322 fl::i32 xd = g.xdelta0;
323 int px = g.xmin;
324 // Preamble: left exterior (d2 >= oo2)
325 while (px <= g.xmax && d2 >= g.oo2) {
326 d2 += xd; xd += 131072; ++ptr; ++px;
327 }
328 // Phase 1: outer-left AA fringe (oi2 <= d2 < oo2)
329 while (px <= g.xmax && d2 >= g.oi2 && d2 < g.oo2) {
330 fl::u16 diff = static_cast<fl::u16>(static_cast<fl::u32>(g.oo2 - d2) >> g.outer_shift);
331 fl::u8 br = static_cast<fl::u8>((diff * g.outer_inv) >> 8);
332 PixelT c = g.color; c.nscale8(br);
333 if (Overwrite) *ptr = c; else *ptr += c;
334 d2 += xd; xd += 131072; ++ptr; ++px;
335 }
336 // Phase 2: full-brightness band left (io2 <= d2 < oi2)
337 while (px <= g.xmax && d2 >= g.io2 && d2 < g.oi2) {
338 if (Overwrite) *ptr = g.color; else *ptr += g.color;
339 d2 += xd; xd += 131072; ++ptr; ++px;
340 }
341 // Phase 3: inner-left AA fringe (ii2 <= d2 < io2)
342 while (px <= g.xmax && d2 >= g.ii2 && d2 < g.io2) {
343 fl::u16 diff = static_cast<fl::u16>(static_cast<fl::u32>(d2 - g.ii2) >> g.inner_shift);
344 fl::u8 br = static_cast<fl::u8>((diff * g.inner_inv) >> 8);
345 PixelT c = g.color; c.nscale8(br);
346 if (Overwrite) *ptr = c; else *ptr += c;
347 d2 += xd; xd += 131072; ++ptr; ++px;
348 }
349 // Phase 4: transparent hole (d2 < ii2)
350 while (px <= g.xmax && d2 < g.ii2) {
351 d2 += xd; xd += 131072; ++ptr; ++px;
352 }
353 // Phase 5: inner-right AA fringe (ii2 <= d2 < io2)
354 while (px <= g.xmax && d2 >= g.ii2 && d2 < g.io2) {
355 fl::u16 diff = static_cast<fl::u16>(static_cast<fl::u32>(d2 - g.ii2) >> g.inner_shift);
356 fl::u8 br = static_cast<fl::u8>((diff * g.inner_inv) >> 8);
357 PixelT c = g.color; c.nscale8(br);
358 if (Overwrite) *ptr = c; else *ptr += c;
359 d2 += xd; xd += 131072; ++ptr; ++px;
360 }
361 // Phase 6: full-brightness band right (io2 <= d2 < oi2)
362 while (px <= g.xmax && d2 >= g.io2 && d2 < g.oi2) {
363 if (Overwrite) *ptr = g.color; else *ptr += g.color;
364 d2 += xd; xd += 131072; ++ptr; ++px;
365 }
366 // Phase 7: outer-right AA fringe (oi2 <= d2 < oo2)
367 while (px <= g.xmax && d2 >= g.oi2 && d2 < g.oo2) {
368 fl::u16 diff = static_cast<fl::u16>(static_cast<fl::u32>(g.oo2 - d2) >> g.outer_shift);
369 fl::u8 br = static_cast<fl::u8>((diff * g.outer_inv) >> 8);
370 PixelT c = g.color; c.nscale8(br);
371 if (Overwrite) *ptr = c; else *ptr += c;
372 d2 += xd; xd += 131072; ++ptr; ++px;
373 }
374}
unsigned char u8
Definition s16x16x4.h:132
unsigned char u8
Definition stdint.h:131

References fl::gfx::detail::RingCtx< PixelT >::color, fl::gfx::detail::RingCtx< PixelT >::ii2, fl::gfx::detail::RingCtx< PixelT >::inner_inv, fl::gfx::detail::RingCtx< PixelT >::inner_shift, fl::gfx::detail::RingCtx< PixelT >::io2, fl::gfx::detail::RingCtx< PixelT >::oi2, fl::gfx::detail::RingCtx< PixelT >::oo2, fl::gfx::detail::RingCtx< PixelT >::outer_inv, fl::gfx::detail::RingCtx< PixelT >::outer_shift, renderRingRow(), fl::gfx::detail::RingCtx< PixelT >::xdelta0, fl::gfx::detail::RingCtx< PixelT >::xmax, and fl::gfx::detail::RingCtx< PixelT >::xmin.

Referenced by drawRingCore(), and renderRingRow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: