Ejemplo n.º 1
0
struct ImBuf * seq_stripelem_cache_get(
	SeqRenderData context, struct Sequence * seq, 
	float cfra, seq_stripelem_ibuf_t type)
{
	seqCacheKey key;
	seqCacheEntry * e;

	if (!seq) {
		return NULL;
	}

	if (!entrypool) {
		seq_stripelem_cache_init();
	}

	key.seq = seq;
	key.context = context;
	key.cfra = cfra - seq->start;
	key.type = type;
	
	e = (seqCacheEntry*) BLI_ghash_lookup(hash, &key);

	if (e && e->ibuf) {
		IMB_refImBuf(e->ibuf);

		MEM_CacheLimiter_touch(e->c_handle);
		return e->ibuf;
	}
	return NULL;
}
Ejemplo n.º 2
0
void seq_stripelem_cache_cleanup(void)
{
	if (!entrypool) {
		seq_stripelem_cache_init();
	}

	/* fprintf(stderr, "Stats before cleanup: in: %d rem: %d\n",
	   ibufs_in, ibufs_rem); */

	BLI_ghash_free(hash, HashKeyFree, HashValFree);
	hash = BLI_ghash_new(HashHash, HashCmp, "seq stripelem cache hash");

	/* fprintf(stderr, "Stats after cleanup: in: %d rem: %d\n",
	   ibufs_in, ibufs_rem); */

}
Ejemplo n.º 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;

	/* 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);
}
Ejemplo n.º 4
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);
}