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

◆ write()

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

Definition at line 169 of file raster_sparse.h.

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