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

◆ PixelIterator()

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

Definition at line 256 of file pixel_iterator.h.

258 : mPixelController(pc), mRgbw(rgbw), mRgbww(rgbww) {
259 // Manually build up a vtable.
260 // Wait... what? Stupid nerds trying to show off how smart they are...
261 // Why not just use a virtual function?!
262 //
263 // Before you think this then you should know that the alternative straight
264 // forward way is to have a virtual interface class that PixelController inherits from.
265 // ...and that was already tried. And if you try to do this yourself
266 // this then let me tell you what is going to happen...
267 //
268 // EVERY SINGLE PLATFORM THAT HAS A COMPILED BINARY SIZE CHECK WILL IMMEDIATELY
269 // FAIL AS THE BINARY BLOWS UP BY 10-30%!!! It doesn't matter if only one PixelController
270 // with a vtable is used, gcc seems not to de-virtualize the calls. And we really care
271 // about binary size since FastLED needs to run on those tiny little microcontrollers like
272 // the Attiny85 (and family) which are in the sub $1 range used for commercial products.
273 //
274 // So to satisfy these tight memory requirements we make the dynamic dispatch used in PixelIterator
275 // an optional zero-cost abstraction which doesn't affect the binary size for platforms that
276 // don't use it. So that's why we are using this manual construction of the vtable that is built
277 // up using template magic. If your platform has lots of memory then you'll gladly trade
278 // a sliver of memory for the convenience of having a concrete implementation of
279 // PixelController that you can use without having to make all your driver code a template.
280 //
281 // Btw, this pattern in C++ is called the "type-erasure pattern". It allows non virtual
282 // polymorphism by leveraging the C++ template system to ensure type safety.
283 typedef PixelControllerVtable<PixelControllerT> Vtable;
290 if (mLoadRawPremixed != nullptr) {
291 mRgbwConvert = mRgbw.active() ? detail::rgbw_conversion() : nullptr;
292 mRgbwwConvert = mRgbww.active() ? detail::rgbww_conversion() : nullptr;
294 }
296#if !FL_PLATFORM_HAS_TINY_MEMORY
298#endif
299 // NOTE: mLoadAndScale_APA102_HD removed - use fl::loadAndScale_APA102_HD<RGB_ORDER>() from apa102.h encoder
300 // NOTE: mLoadAndScale_WS2816_HD removed - use fl::loadAndScale_WS2816_HD<RGB_ORDER>() from ws2816.h encoder
304 mHas = &Vtable::has;
305 #if FASTLED_HD_COLOR_MIXING
306 mLoadRGBScaleAndBrightness = &Vtable::loadRGBScaleAndBrightness;
307 mGetHdScale = &Vtable::getHdScale;
308 #endif
309 }
Rgbw rgbw
loadAndScaleRGBWWUnorderedFunction mLoadAndScaleRGBWWUnordered
void advanceData() FL_NO_EXCEPT
int size() FL_NO_EXCEPT
detail::RgbwConvertFn mRgbwConvert
loadAndScaleRGBWUnorderedFunction mLoadAndScaleRGBWUnordered
loadRawPremixedFunction mLoadRawPremixed
void loadAndScaleRGB(u8 *r_out, u8 *g_out, u8 *b_out) FL_NO_EXCEPT
stepDitheringFunction mStepDithering
advanceDataFunction mAdvanceData
detail::RgbwwConvertFn mRgbwwConvert
bool has(int n) FL_NO_EXCEPT
loadAndScaleRGBWWFunction mLoadAndScaleRGBWW
loadAndScaleRGBFunction mLoadAndScaleRGB
loadAndScaleRGB16Function mLoadAndScaleRGB16
loadAndScaleRGBWFunction mLoadAndScaleRGBW
void refreshWireOrder() FL_NO_EXCEPT
Recompute the cached source channel of each wire RGB byte: this iterator's order on top of the source...
void stepDithering() FL_NO_EXCEPT
RgbwwConvertFn rgbww_conversion() FL_NO_EXCEPT
RgbwConvertFn rgbw_conversion() FL_NO_EXCEPT
Null until enable_rgbw_conversion() has run.
Definition rgbw.cpp.hpp:738
static loadRawPremixedFunction get() FL_NO_EXCEPT
static EOrder order() FL_NO_EXCEPT
static loadAndScaleRGBWWFunction orderedWW() FL_NO_EXCEPT
static loadAndScaleRGBWFunction ordered() FL_NO_EXCEPT
static loadAndScaleRGBWUnorderedFunction unordered() FL_NO_EXCEPT
static loadAndScaleRGBWWUnorderedFunction unorderedWW() FL_NO_EXCEPT
static loadAndScaleRGB16Function get() FL_NO_EXCEPT

References fl::FL_NO_EXCEPT, fl::RawPremixBinder< T, typename >::get(), fl::WideLoadBinder< T, typename >::get(), mAdvanceData, mHas, mLoadAndScaleRGB, mLoadAndScaleRGB16, mLoadAndScaleRGBW, mLoadAndScaleRGBWUnordered, mLoadAndScaleRGBWW, mLoadAndScaleRGBWWUnordered, mLoadRawPremixed, mPixelController, mRgbw, mRgbwConvert, mRgbww, mRgbwwConvert, mSize, mSourceOrder, mStepDithering, fl::RawPremixBinder< T, typename >::order(), fl::RgbwLoadBinder< T, typename >::ordered(), fl::RgbwLoadBinder< T, typename >::orderedWW(), refreshWireOrder(), rgbw, fl::detail::rgbw_conversion(), fl::detail::rgbww_conversion(), fl::RgbwLoadBinder< T, typename >::unordered(), fl::RgbwLoadBinder< T, typename >::unorderedWW(), and fl::RgbwwInvalid::value().

+ Here is the call graph for this function: