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

◆ write()

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

Definition at line 164 of file raster_sparse.h.

164 {
165 // FASTLED_WARN("write: " << pt.x << "," << pt.y << " value: " <<
166 // value); mSparseGrid.insert(pt, value);
167
168 uint8_t **cached = mCache.find_value(pt);
169 if (cached) {
170 uint8_t *val = *cached;
171 if (*val < value) {
172 *val = value;
173 }
174 return;
175 }
176 if (mCache.size() <= kMaxCacheSize) {
177 // cache it.
178 uint8_t *v = mSparseGrid.find_value(pt);
179 if (v == nullptr) {
180 // FASTLED_WARN("write: " << pt.x << "," << pt.y << " value: "
181 // << value);
182 if (mSparseGrid.needs_rehash()) {
183 // mSparseGrid is about to rehash, so we need to clear the
184 // small cache because it shares pointers.
185 mCache.clear();
186 }
187
188 mSparseGrid.insert(pt, value);
189 return;
190 }
191 mCache.insert(pt, v);
192 if (*v < value) {
193 *v = value;
194 }
195 return;
196 } else {
197 // overflow, clear cache and write directly.
198 mCache.clear();
199 mSparseGrid.insert(pt, value);
200 return;
201 }
202 }
static const int kMaxCacheSize
HashMap< vec2< int >, uint8_t *, FastHashKey, EqualToKey, kMaxCacheSize > mCache
HashMapLarge mSparseGrid

References kMaxCacheSize, mCache, and mSparseGrid.

Referenced by rasterize(), and rasterize_internal().

+ Here is the caller graph for this function: