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

◆ write()

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

Definition at line 166 of file raster_sparse.h.

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

References kMaxCacheSize, mCache, mSparseGrid, and fl::type_rank< T >::value.

Referenced by rasterize(), and rasterize_internal().

+ Here is the caller graph for this function: