Blender V5.3
cache.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#undef DEBUG_MESSAGES
10
11#include <cstdlib> /* for qsort */
12#include <memory.h>
13#include <mutex>
14
16#include "MEM_guardedalloc.h"
17
18#include "BLI_ghash.hh"
19#include "BLI_mempool.hh"
20#include "BLI_string.hh"
21
22#include "IMB_cache.hh"
23
24#include "IMB_imbuf.hh"
25#include "IMB_imbuf_types.hh"
26
27namespace blender {
28
29#ifdef DEBUG_MESSAGES
30# if defined __GNUC__
31# define PRINT(format, args...) printf(format, ##args)
32# else
33# define PRINT(format, ...) printf(__VA_ARGS__)
34# endif
35#else
36# define PRINT(format, ...)
37#endif
38
39static MEM_CacheLimiterC *limitor = nullptr;
40
41/* Image buffers managed by a ImBufCache might be using their own caches (used by color
42 * management). In practice this means that, for example, freeing ImBufCache used by MovieClip
43 * will request freeing ImBufCache owned by ImBuf. Freeing ImBufCache needs to be thread-safe,
44 * so regular mutex will not work here, hence the recursive lock. */
45static std::recursive_mutex limitor_lock;
46
70
75
81 /* Indicates that #ibuf is null, because there was an error during load. */
83};
84
85static uint imbufcache_hashhash(const void *keyv)
86{
87 const ImBufCacheKey *key = static_cast<const ImBufCacheKey *>(keyv);
88
89 return key->cache_owner->hashfp(key->userkey);
90}
91
92static bool imbufcache_hashcmp(const void *av, const void *bv)
93{
94 const ImBufCacheKey *a = static_cast<const ImBufCacheKey *>(av);
95 const ImBufCacheKey *b = static_cast<const ImBufCacheKey *>(bv);
96
97 return a->cache_owner->cmpfp(a->userkey, b->userkey);
98}
99
100static void imbufcache_keyfree(void *val)
101{
102 ImBufCacheKey *key = static_cast<ImBufCacheKey *>(val);
103
105
107}
108
109static void imbufcache_valfree(void *val)
110{
111 ImBufCacheItem *item = static_cast<ImBufCacheItem *>(val);
112 ImBufCache *cache = item->cache_owner;
113
114 PRINT("%s: cache '%s' free item %p buffer %p\n", __func__, cache->name, item, item->ibuf);
115
116 if (item->c_handle) {
117 limitor_lock.lock();
119 limitor_lock.unlock();
120 }
121
122 if (item->ibuf) {
123 IMB_freeImBuf(item->ibuf);
124 }
125
126 if (item->priority_data && cache->prioritydeleterfp) {
127 cache->prioritydeleterfp(item->priority_data);
128 }
129
131}
132
133static void check_unused_keys(ImBufCache *cache)
134{
135 GHashIterator gh_iter;
136
137 BLI_ghashIterator_init(&gh_iter, cache->hash);
138
139 while (!BLI_ghashIterator_done(&gh_iter)) {
140 const ImBufCacheKey *key = static_cast<const ImBufCacheKey *>(
141 BLI_ghashIterator_getKey(&gh_iter));
142 const ImBufCacheItem *item = static_cast<const ImBufCacheItem *>(
144
145 BLI_ghashIterator_step(&gh_iter);
146
147 if (item->added_empty) {
148 /* Don't remove entries that have been added empty. Those indicate that the image couldn't be
149 * loaded correctly. */
150 continue;
151 }
152
153 bool remove = !item->ibuf;
154
155 if (remove) {
156 PRINT("%s: cache '%s' remove item %p without buffer\n", __func__, cache->name, item);
157 }
158
159 if (remove) {
161 }
162 }
163}
164
165static int compare_int(const void *av, const void *bv)
166{
167 const int *a = static_cast<int *>(const_cast<void *>(av));
168 const int *b = static_cast<int *>(const_cast<void *>(bv));
169 return *a - *b;
170}
171
172static void imbufcache_destructor(void *p)
173{
174 ImBufCacheItem *item = static_cast<ImBufCacheItem *>(p);
175
176 if (item) {
177 item->c_handle = nullptr;
178 if (item->ibuf) {
179 ImBufCache *cache = item->cache_owner;
180
181 PRINT("%s: cache '%s' destroy item %p buffer %p\n", __func__, cache->name, item, item->ibuf);
182
183 IMB_freeImBuf(item->ibuf);
184
185 item->ibuf = nullptr;
186
187 /* force cached segments to be updated */
188 MEM_SAFE_DELETE(cache->points);
189 }
190 }
191}
192
193static size_t get_size_in_memory(ImBuf *ibuf)
194{
195 /* Keep textures in the memory to avoid constant file reload on viewport update. */
196 if (ibuf->userflags & IB_PERSISTENT) {
197 return 0;
198 }
199
200 return IMB_get_size_in_memory(ibuf);
201}
202static size_t get_item_size(void *p)
203{
204 size_t size = sizeof(ImBufCacheItem);
205 ImBufCacheItem *item = static_cast<ImBufCacheItem *>(p);
206
207 if (item->ibuf) {
208 size += get_size_in_memory(item->ibuf);
209 }
210
211 return size;
212}
213
214static int get_item_priority(void *item_v, int default_priority)
215{
216 ImBufCacheItem *item = static_cast<ImBufCacheItem *>(item_v);
217 ImBufCache *cache = item->cache_owner;
218 int priority;
219
220 if (!cache->getitempriorityfp) {
221 PRINT("%s: cache '%s' item %p use default priority %d\n",
222 __func__,
223 cache->name,
224 item,
225 default_priority);
226
227 return default_priority;
228 }
229
230 priority = cache->getitempriorityfp(cache->last_userkey, item->priority_data);
231
232 PRINT("%s: cache '%s' item %p priority %d\n", __func__, cache->name, item, priority);
233
234 return priority;
235}
236
237static bool get_item_destroyable(void *item_v)
238{
239 ImBufCacheItem *item = static_cast<ImBufCacheItem *>(item_v);
240 if (item->ibuf == nullptr) {
241 return true;
242 }
243 /* IB_BITMAPDIRTY means image was modified from inside blender and
244 * changes are not saved to disk.
245 *
246 * Such buffers are never to be freed.
247 */
248 if ((item->ibuf->userflags & IB_BITMAPDIRTY) || (item->ibuf->userflags & IB_PERSISTENT)) {
249 return false;
250 }
251 return true;
252}
253
261
263{
264 if (limitor) {
266 limitor = nullptr;
267 }
268}
269
270ImBufCache *IMB_cache_create(const char *name, int keysize, GHashHashFP hashfp, GHashCmpFP cmpfp)
271{
272 ImBufCache *cache;
273
274 PRINT("%s: cache '%s' create\n", __func__, name);
275
276 cache = MEM_new_zeroed<ImBufCache>("ImBufCache");
277
278 STRNCPY(cache->name, name);
279
282 cache->userkeys_pool = BLI_mempool_create(keysize, 0, 64, BLI_MEMPOOL_NOP);
283 cache->hash = BLI_ghash_new(
284 imbufcache_hashhash, imbufcache_hashcmp, "MovieClip ImBuf cache hash");
285
286 cache->keysize = keysize;
287 cache->hashfp = hashfp;
288 cache->cmpfp = cmpfp;
289 cache->proxy = -1;
290
291 return cache;
292}
293
295{
296 cache->getdatafp = getdatafp;
297}
298
300 ImBufCacheGetPriorityDataFP getprioritydatafp,
301 ImBufCacheGetItemPriorityFP getitempriorityfp,
302 ImBufCachePriorityDeleterFP prioritydeleterfp)
303{
304 cache->last_userkey = MEM_new_uninitialized(cache->keysize, "movie cache last user key");
305
306 cache->getprioritydatafp = getprioritydatafp;
307 cache->getitempriorityfp = getitempriorityfp;
308 cache->prioritydeleterfp = prioritydeleterfp;
309}
310
311static void do_imbufcache_put(ImBufCache *cache, void *userkey, ImBuf *ibuf, bool need_lock)
312{
313 ImBufCacheKey *key;
314 ImBufCacheItem *item;
315
316 if (!limitor) {
318 }
319
320 if (ibuf != nullptr) {
321 IMB_refImBuf(ibuf);
322 }
323
324 key = static_cast<ImBufCacheKey *>(BLI_mempool_alloc(cache->keys_pool));
325 key->cache_owner = cache;
327 memcpy(key->userkey, userkey, cache->keysize);
328
329 item = static_cast<ImBufCacheItem *>(BLI_mempool_alloc(cache->items_pool));
330
331 PRINT("%s: cache '%s' put %p, item %p\n", __func__, cache->name, ibuf, item);
332
333 item->ibuf = ibuf;
334 item->cache_owner = cache;
335 item->c_handle = nullptr;
336 item->priority_data = nullptr;
337 item->added_empty = ibuf == nullptr;
338
339 if (cache->getprioritydatafp) {
340 item->priority_data = cache->getprioritydatafp(userkey);
341 }
342
344
345 if (cache->last_userkey) {
346 memcpy(cache->last_userkey, userkey, cache->keysize);
347 }
348
349 if (need_lock) {
350 limitor_lock.lock();
351 }
352
354
358
359 if (need_lock) {
360 limitor_lock.unlock();
361 }
362
363 /* cache limiter can't remove unused keys which points to destroyed values */
364 check_unused_keys(cache);
365
366 MEM_SAFE_DELETE(cache->points);
367}
368
369void IMB_cache_put(ImBufCache *cache, void *userkey, ImBuf *ibuf)
370{
371 do_imbufcache_put(cache, userkey, ibuf, true);
372}
373
374bool IMB_cache_put_if_possible(ImBufCache *cache, void *userkey, ImBuf *ibuf)
375{
376 size_t mem_in_use, mem_limit, elem_size;
377 bool result = false;
378
379 elem_size = (ibuf == nullptr) ? 0 : get_size_in_memory(ibuf);
380 mem_limit = MEM_CacheLimiter_get_maximum();
381
382 limitor_lock.lock();
384
385 if (mem_in_use + elem_size <= mem_limit) {
386 do_imbufcache_put(cache, userkey, ibuf, false);
387 result = true;
388 }
389
390 limitor_lock.unlock();
391
392 return result;
393}
394
395void IMB_cache_remove(ImBufCache *cache, void *userkey)
396{
397 ImBufCacheKey key;
398 key.cache_owner = cache;
399 key.userkey = userkey;
401}
402
403ImBuf *IMB_cache_get(ImBufCache *cache, void *userkey, bool *r_is_cached_empty)
404{
405 ImBufCacheKey key;
406 ImBufCacheItem *item;
407
408 key.cache_owner = cache;
409 key.userkey = userkey;
410 item = static_cast<ImBufCacheItem *>(BLI_ghash_lookup(cache->hash, &key));
411
412 if (r_is_cached_empty) {
413 *r_is_cached_empty = false;
414 }
415
416 if (item) {
417 if (item->ibuf) {
418 std::lock_guard lock(limitor_lock);
419 /* Check again, the condition might have changed before we acquired the lock. */
420 if (item->ibuf) {
422 IMB_refImBuf(item->ibuf);
423 return item->ibuf;
424 }
425 }
426 if (r_is_cached_empty && item->added_empty) {
427 *r_is_cached_empty = true;
428 }
429 }
430
431 return nullptr;
432}
433
434bool IMB_cache_has_frame(ImBufCache *cache, void *userkey)
435{
436 ImBufCacheKey key;
437 ImBufCacheItem *item;
438
439 key.cache_owner = cache;
440 key.userkey = userkey;
441 item = static_cast<ImBufCacheItem *>(BLI_ghash_lookup(cache->hash, &key));
442
443 return item != nullptr;
444}
445
447{
448 PRINT("%s: cache '%s' free\n", __func__, cache->name);
449
451
455
456 if (cache->points) {
457 MEM_delete(cache->points);
458 }
459
460 if (cache->last_userkey) {
462 }
463
464 MEM_delete(cache);
465}
466
468 bool(cleanup_check_cb)(ImBuf *ibuf, void *userkey, void *userdata),
469 void *userdata)
470{
471 GHashIterator gh_iter;
472
473 check_unused_keys(cache);
474
475 BLI_ghashIterator_init(&gh_iter, cache->hash);
476
477 while (!BLI_ghashIterator_done(&gh_iter)) {
478 ImBufCacheKey *key = static_cast<ImBufCacheKey *>(BLI_ghashIterator_getKey(&gh_iter));
479 ImBufCacheItem *item = static_cast<ImBufCacheItem *>(BLI_ghashIterator_getValue(&gh_iter));
480
481 BLI_ghashIterator_step(&gh_iter);
482
483 if (cleanup_check_cb(item->ibuf, key->userkey, userdata)) {
484 PRINT("%s: cache '%s' remove item %p\n", __func__, cache->name, item);
485
487 }
488 }
489}
490
492 ImBufCache *cache, int proxy, int render_flags, int *r_totseg, int **r_points)
493{
494 *r_totseg = 0;
495 *r_points = nullptr;
496
497 if (!cache->getdatafp) {
498 return;
499 }
500
501 if (cache->proxy != proxy || cache->render_flags != render_flags) {
502 MEM_SAFE_DELETE(cache->points);
503 }
504
505 if (cache->points) {
506 *r_totseg = cache->totseg;
507 *r_points = cache->points;
508 }
509 else {
510 int totframe = BLI_ghash_len(cache->hash);
511 int *frames = MEM_new_array_zeroed<int>(totframe, "movieclip cache frames");
512 int a, totseg = 0;
513 GHashIterator gh_iter;
514
515 a = 0;
516 GHASH_ITER (gh_iter, cache->hash) {
517 ImBufCacheKey *key = static_cast<ImBufCacheKey *>(BLI_ghashIterator_getKey(&gh_iter));
518 ImBufCacheItem *item = static_cast<ImBufCacheItem *>(BLI_ghashIterator_getValue(&gh_iter));
519 int framenr, curproxy, curflags;
520
521 if (item->ibuf) {
522 cache->getdatafp(key->userkey, &framenr, &curproxy, &curflags);
523
524 if (curproxy == proxy && curflags == render_flags) {
525 frames[a++] = framenr;
526 }
527 }
528 }
529
530 qsort(frames, totframe, sizeof(int), compare_int);
531
532 /* count */
533 for (a = 0; a < totframe; a++) {
534 if (a && frames[a] - frames[a - 1] != 1) {
535 totseg++;
536 }
537
538 if (a == totframe - 1) {
539 totseg++;
540 }
541 }
542
543 if (totseg) {
544 int b, *points;
545
546 points = MEM_new_array_zeroed<int>(2 * size_t(totseg), "movieclip cache segments");
547
548 /* fill */
549 for (a = 0, b = 0; a < totframe; a++) {
550 if (a == 0) {
551 points[b++] = frames[a];
552 }
553
554 if (a && frames[a] - frames[a - 1] != 1) {
555 points[b++] = frames[a - 1];
556 points[b++] = frames[a];
557 }
558
559 if (a == totframe - 1) {
560 points[b++] = frames[a];
561 }
562 }
563
564 *r_totseg = totseg;
565 *r_points = points;
566
567 cache->totseg = totseg;
568 cache->points = points;
569 cache->proxy = proxy;
570 cache->render_flags = render_flags;
571 }
572
573 MEM_delete(frames);
574 }
575}
576
577ImBufCacheIter *IMB_cacheIter_new(ImBufCache *cache)
578{
579 GHashIterator *iter;
580
581 check_unused_keys(cache);
582 iter = BLI_ghashIterator_new(cache->hash);
583
584 return reinterpret_cast<ImBufCacheIter *>(iter);
585}
586
587void IMB_cacheIter_free(ImBufCacheIter *iter)
588{
589 BLI_ghashIterator_free(reinterpret_cast<GHashIterator *>(iter));
590}
591
592bool IMB_cacheIter_done(ImBufCacheIter *iter)
593{
594 return BLI_ghashIterator_done(reinterpret_cast<GHashIterator *>(iter));
595}
596
597void IMB_cacheIter_step(ImBufCacheIter *iter)
598{
599 BLI_ghashIterator_step(reinterpret_cast<GHashIterator *>(iter));
600}
601
602ImBuf *IMB_cacheIter_getImBuf(ImBufCacheIter *iter)
603{
604 ImBufCacheItem *item = static_cast<ImBufCacheItem *>(
605 BLI_ghashIterator_getValue(reinterpret_cast<GHashIterator *>(iter)));
606 return item->ibuf;
607}
608
609void *IMB_cacheIter_getUserKey(ImBufCacheIter *iter)
610{
611 ImBufCacheKey *key = static_cast<ImBufCacheKey *>(
612 BLI_ghashIterator_getKey(reinterpret_cast<GHashIterator *>(iter)));
613 return key->userkey;
614}
615
616} // namespace blender
#define GHASH_ITER(gh_iter_, ghash_)
Definition BLI_ghash.hh:320
void MEM_CacheLimiter_ItemPriority_Func_set(MEM_CacheLimiterC *This, MEM_CacheLimiter_ItemPriority_Func item_priority_func)
void MEM_CacheLimiter_enforce_limits(MEM_CacheLimiterC *This)
void MEM_CacheLimiter_touch(MEM_CacheLimiterHandleC *handle)
void MEM_CacheLimiter_unref(MEM_CacheLimiterHandleC *handle)
void delete_MEM_CacheLimiter(MEM_CacheLimiterC *This)
void MEM_CacheLimiter_ItemDestroyable_Func_set(MEM_CacheLimiterC *This, MEM_CacheLimiter_ItemDestroyable_Func item_destroyable_func)
size_t MEM_CacheLimiter_get_memory_in_use(MEM_CacheLimiterC *This)
size_t MEM_CacheLimiter_get_maximum()
MEM_CacheLimiterC * new_MEM_CacheLimiter(MEM_CacheLimiter_Destruct_Func data_destructor, MEM_CacheLimiter_DataSize_Func data_size)
MEM_CacheLimiterHandleC * MEM_CacheLimiter_insert(MEM_CacheLimiterC *This, void *data)
void MEM_CacheLimiter_ref(MEM_CacheLimiterHandleC *handle)
void MEM_CacheLimiter_unmanage(MEM_CacheLimiterHandleC *handle)
struct MEM_CacheLimiter_s MEM_CacheLimiterC
struct MEM_CacheLimiterHandle_s MEM_CacheLimiterHandleC
Read Blender memory allocation and freeing.
volatile int lock
#define PRINT(format,...)
Definition cache.cc:36
BMesh Iterators.
void * MEM_new_uninitialized(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void IMB_cacheIter_step(ImBufCacheIter *iter)
Definition cache.cc:597
void * IMB_cacheIter_getUserKey(ImBufCacheIter *iter)
Definition cache.cc:609
static size_t get_size_in_memory(ImBuf *ibuf)
Definition cache.cc:193
BLI_INLINE void * BLI_ghashIterator_getKey(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
Definition BLI_ghash.hh:297
char * STRNCPY(char(&dst)[N], const char *src)
static int get_item_priority(void *item_v, int default_priority)
Definition cache.cc:214
unsigned int uint
Definition BKE_text.h:55
void IMB_cache_get_cache_segments(ImBufCache *cache, int proxy, int render_flags, int *r_totseg, int **r_points)
Definition cache.cc:491
unsigned int(*) GHashHashFP(const void *key)
Definition BLI_ghash.hh:33
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
Definition BLI_ghash.cc:735
void IMB_cache_free(ImBufCache *cache)
Definition cache.cc:446
static uint imbufcache_hashhash(const void *keyv)
Definition cache.cc:85
static void check_unused_keys(ImBufCache *cache)
Definition cache.cc:133
static std::recursive_mutex limitor_lock
Definition cache.cc:45
ImBuf * IMB_cacheIter_getImBuf(ImBufCacheIter *iter)
Definition cache.cc:602
void IMB_refImBuf(ImBuf *ibuf)
ImBufCache * IMB_cache_create(const char *name, int keysize, GHashHashFP hashfp, GHashCmpFP cmpfp)
Definition cache.cc:270
void IMB_cache_put(ImBufCache *cache, void *userkey, ImBuf *ibuf)
Definition cache.cc:369
void MEM_delete_void(void *vmemh)
void(*)(void *priority_data) ImBufCachePriorityDeleterFP
Definition IMB_cache.hh:29
size_t IMB_get_size_in_memory(const ImBuf *ibuf)
ImBuf * IMB_cache_get(ImBufCache *cache, void *userkey, bool *r_is_cached_empty)
Definition cache.cc:403
bool(*) GHashCmpFP(const void *a, const void *b)
Definition BLI_ghash.hh:35
void BLI_mempool_free(BLI_mempool *pool, void *addr) ATTR_NONNULL(1
BLI_INLINE void * BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
Definition BLI_ghash.hh:301
static void imbufcache_keyfree(void *val)
Definition cache.cc:100
void IMB_cache_cleanup(ImBufCache *cache, bool(cleanup_check_cb)(ImBuf *ibuf, void *userkey, void *userdata), void *userdata)
Definition cache.cc:467
static int compare_int(const void *av, const void *bv)
Definition cache.cc:165
void BLI_mempool_destroy(BLI_mempool *pool) ATTR_NONNULL(1)
void BLI_ghashIterator_step(GHashIterator *ghi)
Definition BLI_ghash.cc:917
void IMB_freeImBuf(ImBuf *ibuf)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
ImBufCacheIter * IMB_cacheIter_new(ImBufCache *cache)
Definition cache.cc:577
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition BLI_ghash.cc:866
BLI_mempool * BLI_mempool_create(unsigned int esize, unsigned int elem_num, unsigned int pchunk, unsigned int flag) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
void *(*)(void *userkey) ImBufCacheGetPriorityDataFP
Definition IMB_cache.hh:27
static bool get_item_destroyable(void *item_v)
Definition cache.cc:237
static void do_imbufcache_put(ImBufCache *cache, void *userkey, ImBuf *ibuf, bool need_lock)
Definition cache.cc:311
static void imbufcache_valfree(void *val)
Definition cache.cc:109
unsigned int BLI_ghash_len(const GHash *gh) ATTR_WARN_UNUSED_RESULT
Definition BLI_ghash.cc:706
bool IMB_cacheIter_done(ImBufCacheIter *iter)
Definition cache.cc:592
void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh)
Definition BLI_ghash.cc:901
static void imbufcache_destructor(void *p)
Definition cache.cc:172
int(*)(void *last_userkey, void *priority_data) ImBufCacheGetItemPriorityFP
Definition IMB_cache.hh:28
void IMB_cache_set_priority_callback(ImBufCache *cache, ImBufCacheGetPriorityDataFP getprioritydatafp, ImBufCacheGetItemPriorityFP getitempriorityfp, ImBufCachePriorityDeleterFP prioritydeleterfp)
Definition cache.cc:299
bool IMB_cache_has_frame(ImBufCache *cache, void *userkey)
Definition cache.cc:434
void IMB_cache_set_getdata_callback(ImBufCache *cache, ImBufCacheGetKeyDataFP getdatafp)
Definition cache.cc:294
static size_t get_item_size(void *p)
Definition cache.cc:202
bool IMB_cache_put_if_possible(ImBufCache *cache, void *userkey, ImBuf *ibuf)
Definition cache.cc:374
@ BLI_MEMPOOL_NOP
void IMB_cache_destruct()
Definition cache.cc:262
GHashIterator * BLI_ghashIterator_new(GHash *gh) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
Definition BLI_ghash.cc:894
bool BLI_ghash_remove(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition BLI_ghash.cc:792
static bool imbufcache_hashcmp(const void *av, const void *bv)
Definition movieclip.cc:675
void(*)(void *userkey, int *framenr, int *proxy, int *render_flags) ImBufCacheGetKeyDataFP
Definition IMB_cache.hh:22
void * BLI_mempool_alloc(BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
GHash * BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
Definition BLI_ghash.cc:690
void IMB_cache_remove(ImBufCache *cache, void *userkey)
Definition cache.cc:395
BLI_INLINE bool BLI_ghashIterator_done(const GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
Definition BLI_ghash.hh:309
bool BLI_ghash_reinsert(GHash *gh, void *key, void *val, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition BLI_ghash.cc:716
void IMB_cacheIter_free(ImBufCacheIter *iter)
Definition cache.cc:587
static MEM_CacheLimiterC * limitor
Definition cache.cc:39
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void BLI_ghashIterator_free(GHashIterator *ghi)
Definition BLI_ghash.cc:931
void IMB_cache_init()
Definition cache.cc:254
ImBufCache * cache_owner
Definition cache.cc:77
MEM_CacheLimiterHandleC * c_handle
Definition cache.cc:79
ImBufCache * cache_owner
Definition cache.cc:72
GHashCmpFP cmpfp
Definition cache.cc:52
ImBufCachePriorityDeleterFP prioritydeleterfp
Definition cache.cc:57
ImBufCacheGetKeyDataFP getdatafp
Definition cache.cc:53
ImBufCacheGetItemPriorityFP getitempriorityfp
Definition cache.cc:56
BLI_mempool * keys_pool
Definition cache.cc:59
GHashHashFP hashfp
Definition cache.cc:51
char name[64]
Definition cache.cc:48
ImBufCacheGetPriorityDataFP getprioritydatafp
Definition cache.cc:55
void * last_userkey
Definition cache.cc:65
BLI_mempool * userkeys_pool
Definition cache.cc:61
BLI_mempool * items_pool
Definition cache.cc:60