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

◆ PixelIterator()

template<typename PixelControllerT>
fl::PixelIterator::PixelIterator ( PixelControllerT * pc,
Rgbw rgbw,
Rgbww rgbww = RgbwwInvalid::value() )
inline

Definition at line 124 of file pixel_iterator.h.

126 : mPixelController(pc), mRgbw(rgbw), mRgbww(rgbww) {
127 // Manually build up a vtable.
128 // Wait... what? Stupid nerds trying to show off how smart they are...
129 // Why not just use a virtual function?!
130 //
131 // Before you think this then you should know that the alternative straight
132 // forward way is to have a virtual interface class that PixelController inherits from.
133 // ...and that was already tried. And if you try to do this yourself
134 // this then let me tell you what is going to happen...
135 //
136 // EVERY SINGLE PLATFORM THAT HAS A COMPILED BINARY SIZE CHECK WILL IMMEDIATELY
137 // FAIL AS THE BINARY BLOWS UP BY 10-30%!!! It doesn't matter if only one PixelController
138 // with a vtable is used, gcc seems not to de-virtualize the calls. And we really care
139 // about binary size since FastLED needs to run on those tiny little microcontrollers like
140 // the Attiny85 (and family) which are in the sub $1 range used for commercial products.
141 //
142 // So to satisfy these tight memory requirements we make the dynamic dispatch used in PixelIterator
143 // an optional zero-cost abstraction which doesn't affect the binary size for platforms that
144 // don't use it. So that's why we are using this manual construction of the vtable that is built
145 // up using template magic. If your platform has lots of memory then you'll gladly trade
146 // a sliver of memory for the convenience of having a concrete implementation of
147 // PixelController that you can use without having to make all your driver code a template.
148 //
149 // Btw, this pattern in C++ is called the "type-erasure pattern". It allows non virtual
150 // polymorphism by leveraging the C++ template system to ensure type safety.
151 typedef PixelControllerVtable<PixelControllerT> Vtable;
155 // NOTE: mLoadAndScale_APA102_HD removed - use fl::loadAndScale_APA102_HD<RGB_ORDER>() from apa102.h encoder
156 // NOTE: mLoadAndScale_WS2816_HD removed - use fl::loadAndScale_WS2816_HD<RGB_ORDER>() from ws2816.h encoder
160 mHas = &Vtable::has;
161 #if FASTLED_HD_COLOR_MIXING
162 mLoadRGBScaleAndBrightness = &Vtable::loadRGBScaleAndBrightness;
163 mGetHdScale = &Vtable::getHdScale;
164 #endif
165 }
Rgbw rgbw
int size() FL_NOEXCEPT
stepDitheringFunction mStepDithering
void loadAndScaleRGBWW(u8 *b0_out, u8 *b1_out, u8 *b2_out, u8 *b3_out, u8 *b4_out) FL_NOEXCEPT
advanceDataFunction mAdvanceData
bool has(int n) FL_NOEXCEPT
void loadAndScaleRGBW(u8 *b0_out, u8 *b1_out, u8 *b2_out, u8 *w_out) FL_NOEXCEPT
void advanceData() FL_NOEXCEPT
loadAndScaleRGBWWFunction mLoadAndScaleRGBWW
loadAndScaleRGBFunction mLoadAndScaleRGB
void loadAndScaleRGB(u8 *r_out, u8 *g_out, u8 *b_out) FL_NOEXCEPT
void stepDithering() FL_NOEXCEPT
loadAndScaleRGBWFunction mLoadAndScaleRGBW

References FL_NOEXCEPT, mAdvanceData, mHas, mLoadAndScaleRGB, mLoadAndScaleRGBW, mLoadAndScaleRGBWW, mPixelController, mRgbw, mRgbww, mSize, mStepDithering, rgbw, and fl::RgbwwInvalid::value().

+ Here is the call graph for this function: