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

◆ computeBandShift()

void fl::gfx::detail::computeBandShift ( fl::i32 band,
fl::u8 & shift_out,
fl::u16 & inv_out )
inline

Precompute right-shift and reciprocal multiplier for AA division.

Converts 32-bit AA division: (diff * 255u) / band (~60 cycles on AVR) into a multiply-by-reciprocal: ((diff >> shift) * inv) >> 8 (~14 cycles on AVR) where inv = round(255 * 256 / scaled).

Definition at line 209 of file primitives.h.

209 {
210 fl::u8 sh = 0;
211 fl::u32 tmp = static_cast<fl::u32>(band);
212 while (tmp > 255u) { tmp >>= 1; ++sh; }
213 shift_out = sh;
214 // Reciprocal: (255 * 256 + scaled/2) / scaled — rounds to nearest
215 fl::u8 scaled = static_cast<fl::u8>(tmp);
216 inv_out = static_cast<fl::u16>((65280u + (scaled >> 1)) / scaled);
217}
unsigned char u8
Definition s16x16x4.h:132

References computeBandShift().

Referenced by computeBandShift(), drawDiscCore(), drawRingCore(), and drawStrokeLineCore().

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