#ifndef __TEX_CACHE_H
#define __TEX_CACHE_H
#include "include/iosupport.h"
/// A single cache entry...
typedef struct
{
GSTEXTURE texture;
// NULL not queued, otherwise queue request record
void *qr;
// frame counter the icon was used the last time - oldest get rewritten first in case new icon is requested and cache is full. negative numbers mean
// slot is free and can be used right now
int lastUsed;
int UID;
} cache_entry_t;
/// One texture cache instance
typedef struct
{
/// User specified ID, not used in any way by the cache code (not even initialized!)
int userId;
/// count of entries (copy of the requested cache size upon cache initialization)
int count;
/// directory prefix for this cache (if any)
char *prefix;
int isPrefixRelative;
char *suffix;
int nextUID;
/// the cache entries itself
cache_entry_t *content;
} image_cache_t;
/** Initializes the cache subsystem.
*/
void cacheInit();
/** Terminates the cache. Does nothing currently. Users of this code have to destroy caches via cacheDestroyCache
*/
void cacheEnd();
/** Initializes a single cache
*/
image_cache_t *cacheInitCache(int userId, const char *prefix, int isPrefixRelative, const char *suffix, int count);
/** Destroys a given cache (unallocates all memory stored there, disconnects the pixmaps from the usage points).
*/
void cacheDestroyCache(image_cache_t *cache);
GSTEXTURE *cacheGetTexture(image_cache_t *cache, item_list_t *list, int *cacheId, int *UID, char *value);
#endif