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

◆ write()

void fl::XYRasterSparse_RGB8::write ( const vec2< u16 > & pt,
const CRGB & color )
inline

Definition at line 344 of file raster_sparse.h.

344 {
345 CRGB **cached = mCache.find_value(pt);
346 if (cached) {
347 CRGB *val = *cached;
348 // For CRGB, we'll replace the existing color (blend could be added later)
349 *val = color;
350 return;
351 }
352 if (mCache.size() <= kMaxCacheSize) {
353 // cache it.
354 CRGB *v = mSparseGrid.find_value(pt);
355 if (v == nullptr) {
356 if (mSparseGrid.needs_rehash()) {
357 // mSparseGrid is about to rehash, so we need to clear the
358 // small cache because it shares pointers.
359 mCache.clear();
360 }
361 mSparseGrid.insert(pt, color);
362 return;
363 }
364 mCache.insert(pt, v);
365 *v = color;
366 return;
367 } else {
368 // overflow, clear cache and write directly.
369 mCache.clear();
370 mSparseGrid.insert(pt, color);
371 return;
372 }
373 }
unordered_map< vec2< u16 >, CRGB *, FastHashKey, EqualToKey, kMaxCacheSize > mCache
static const int kMaxCacheSize
fl::CRGB CRGB
Definition video.h:15

References kMaxCacheSize, mCache, and mSparseGrid.

Referenced by rasterize().

+ Here is the caller graph for this function: