예제 #1
0
static void do_moviecache_put(MovieCache *cache, void *userkey, ImBuf *ibuf, int need_lock)
{
	MovieCacheKey *key;
	MovieCacheItem *item;

	if (!limitor)
		IMB_moviecache_init();

	IMB_refImBuf(ibuf);

	key = BLI_mempool_alloc(cache->keys_pool);
	key->cache_owner = cache;
	key->userkey = BLI_mempool_alloc(cache->userkeys_pool);
	memcpy(key->userkey, userkey, cache->keysize);

	item = BLI_mempool_alloc(cache->items_pool);

	PRINT("%s: cache '%s' put %p, item %p\n", __func__, cache-> name, ibuf, item);

	item->ibuf = ibuf;
	item->cache_owner = cache;
	item->c_handle = NULL;
	item->priority_data = NULL;

	if (cache->getprioritydatafp) {
		item->priority_data = cache->getprioritydatafp(userkey);
	}

	BLI_ghash_remove(cache->hash, key, moviecache_keyfree, moviecache_valfree);
	BLI_ghash_insert(cache->hash, key, item);

	if (cache->last_userkey) {
		memcpy(cache->last_userkey, userkey, cache->keysize);
	}

	if (need_lock)
		BLI_mutex_lock(&limitor_lock);

	item->c_handle = MEM_CacheLimiter_insert(limitor, item);

	MEM_CacheLimiter_ref(item->c_handle);
	MEM_CacheLimiter_enforce_limits(limitor);
	MEM_CacheLimiter_unref(item->c_handle);

	if (need_lock)
		BLI_mutex_unlock(&limitor_lock);

	/* cache limiter can't remove unused keys which points to destoryed values */
	check_unused_keys(cache);

	if (cache->points) {
		MEM_freeN(cache->points);
		cache->points = NULL;
	}
}
예제 #2
0
void seq_stripelem_cache_put(
	SeqRenderData context, struct Sequence * seq, 
	float cfra, seq_stripelem_ibuf_t type, struct ImBuf * i)
{
	seqCacheKey * key;
	seqCacheEntry * e;

	if (!i) {
		return;
	}

	ibufs_in++;

	if (!entrypool) {
		seq_stripelem_cache_init();
	}

	key = (seqCacheKey*) BLI_mempool_alloc(keypool);

	key->seq = seq;
	key->context = context;
	key->cfra = cfra - seq->start;
	key->type = type;

	/* Normally we want our own version, but start and end stills are duplicates of the original. */
	if(ELEM(type, SEQ_STRIPELEM_IBUF_STARTSTILL, SEQ_STRIPELEM_IBUF_ENDSTILL)==0)
		IMB_refImBuf(i);

	e = (seqCacheEntry*) BLI_mempool_alloc(entrypool);

	e->ibuf = i;
	e->c_handle = NULL;

	BLI_ghash_remove(hash, key, HashKeyFree, HashValFree);
	BLI_ghash_insert(hash, key, e);

	e->c_handle = MEM_CacheLimiter_insert(limitor, e);

	MEM_CacheLimiter_ref(e->c_handle);
	MEM_CacheLimiter_enforce_limits(limitor);
	MEM_CacheLimiter_unref(e->c_handle);
}
예제 #3
0
void seq_stripelem_cache_put(
	SeqRenderData context, struct Sequence * seq, 
	float cfra, seq_stripelem_ibuf_t type, struct ImBuf * i)
{
	seqCacheKey * key;
	seqCacheEntry * e;

	if (!i) {
		return;
	}

	ibufs_in++;

	if (!entrypool) {
		seq_stripelem_cache_init();
	}

	key = (seqCacheKey*) BLI_mempool_alloc(keypool);

	key->seq = seq;
	key->context = context;
	key->cfra = cfra - seq->start;
	key->type = type;

	IMB_refImBuf(i);

	e = (seqCacheEntry*) BLI_mempool_alloc(entrypool);

	e->ibuf = i;
	e->c_handle = NULL;

	BLI_ghash_remove(hash, key, HashKeyFree, HashValFree);
	BLI_ghash_insert(hash, key, e);

	e->c_handle = MEM_CacheLimiter_insert(limitor, e);

	MEM_CacheLimiter_ref(e->c_handle);
	MEM_CacheLimiter_enforce_limits(limitor);
	MEM_CacheLimiter_unref(e->c_handle);
}