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

◆ write()

void fl::XYRasterU8Sparse::write ( const vec2< u16 > & pt,
u8 value )
inline

Definition at line 175 of file raster_sparse.h.

175 {
176 // FASTLED_WARN("write: " << pt.x << "," << pt.y << " value: " <<
177 // value); mSparseGrid.insert(pt, value);
178
179 u8 **cached = mCache.find_value(pt);
180 if (cached) {
181 u8 *val = *cached;
182 if (*val < value) {
183 *val = value;
184 }
185 return;
186 }
187 if (mCache.size() <= kMaxCacheSize) {
188 // cache it.
189 u8 *v = mSparseGrid.find_value(pt);
190 if (v == nullptr) {
191 // FASTLED_WARN("write: " << pt.x << "," << pt.y << " value: "
192 // << value);
193 if (mSparseGrid.needs_rehash()) {
194 // mSparseGrid is about to rehash, so we need to clear the
195 // small cache because it shares pointers.
196 mCache.clear();
197 }
198
199 mSparseGrid.insert(pt, value);
200 return;
201 }
202 mCache.insert(pt, v);
203 if (*v < value) {
204 *v = value;
205 }
206 return;
207 } else {
208 // overflow, clear cache and write directly.
209 mCache.clear();
210 mSparseGrid.insert(pt, value);
211 return;
212 }
213 }
static const int kMaxCacheSize
HashMapLarge mSparseGrid
HashMap< vec2< u16 >, u8 *, FastHashKey, EqualToKey, kMaxCacheSize > mCache
unsigned char u8
Definition int.h:17

References kMaxCacheSize, mCache, and mSparseGrid.

Referenced by rasterize(), and rasterize_internal().

+ Here is the caller graph for this function: