FastLED 3.9.15
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 278 of file primitives.h.

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

References fl::gfx::detail::DiscCtx< PixelT >::band_inv, fl::gfx::detail::DiscCtx< PixelT >::band_shift, fl::gfx::detail::DiscCtx< PixelT >::color, renderDiscRow(), fl::gfx::detail::DiscCtx< PixelT >::rin2, fl::gfx::detail::DiscCtx< PixelT >::rout2, fl::gfx::detail::DiscCtx< PixelT >::xdelta0, fl::gfx::detail::DiscCtx< PixelT >::xmax, and fl::gfx::detail::DiscCtx< PixelT >::xmin.

Referenced by drawDiscCore(), and renderDiscRow().

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