FastLED 3.10.8
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 319 of file primitives.h.

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

References fl::FL_NO_EXCEPT, fl::g, and renderRingRow().

Referenced by drawRingCore(), and renderRingRow().

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