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

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

References computeBandShift(), and fl::FL_NO_EXCEPT.

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

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