FastLED 3.10.8
Loading...
Searching...
No Matches

◆ renderDiscRow()

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

Render one scanline of a disc using incremental d².

Templated on Overwrite for compile-time dispatch (no per-pixel branch). Uses (n+1)² = n² + 2n + 1 identity — zero multiplies in the inner loop.

Definition at line 280 of file primitives.h.

282 {
283 PixelT* ptr = &buf[py * w + f.xmin];
284 fl::i32 d2 = d2_row;
285 fl::i32 xd = f.xdelta0;
286 int px = f.xmin;
287 // Phase 1: Skip outside pixels (left, d2 decreasing)
288 while (px <= f.xmax && d2 >= f.rout2) {
289 d2 += xd; xd += 131072; ++ptr; ++px;
290 }
291 // Phase 2: Outer AA fringe (left)
292 while (px <= f.xmax && d2 >= f.rin2 && d2 < f.rout2) {
293 fl::u16 diff = static_cast<fl::u16>(static_cast<fl::u32>(f.rout2 - d2) >> f.band_shift);
294 fl::u8 br = static_cast<fl::u8>((diff * f.band_inv) >> 8);
295 PixelT c = f.color; c.nscale8(br);
296 if (Overwrite) *ptr = c; else *ptr += c;
297 d2 += xd; xd += 131072; ++ptr; ++px;
298 }
299 // Phase 3: Full brightness interior (d2 hits minimum, then increases)
300 while (px <= f.xmax && d2 < f.rin2) {
301 if (Overwrite) *ptr = f.color; else *ptr += f.color;
302 d2 += xd; xd += 131072; ++ptr; ++px;
303 }
304 // Phase 4: Outer AA fringe (right, d2 increasing)
305 while (px <= f.xmax && d2 < f.rout2) {
306 fl::u16 diff = static_cast<fl::u16>(static_cast<fl::u32>(f.rout2 - d2) >> f.band_shift);
307 fl::u8 br = static_cast<fl::u8>((diff * f.band_inv) >> 8);
308 PixelT c = f.color; c.nscale8(br);
309 if (Overwrite) *ptr = c; else *ptr += c;
310 d2 += xd; xd += 131072; ++ptr; ++px;
311 }
312}
unsigned char u8
Definition stdint.h:131

References fl::FL_NO_EXCEPT, and renderDiscRow().

Referenced by drawDiscCore(), and renderDiscRow().

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