// Default LRU size. If 0, all scaled images will be dropped instantly.
#define DEFAULT_CACHE_LRU_SIZE (4*1024*1024)
-static void _evas_cache_image_dirty_add(Image_Entry *im);
-static void _evas_cache_image_dirty_del(Image_Entry *im);
-static void _evas_cache_image_activ_add(Image_Entry *im);
-static void _evas_cache_image_activ_del(Image_Entry *im);
-static void _evas_cache_image_lru_add(Image_Entry *im);
-static void _evas_cache_image_lru_del(Image_Entry *im);
+static void _evas_cache2_image_dirty_add(Image_Entry *im);
+static void _evas_cache2_image_dirty_del(Image_Entry *im);
+static void _evas_cache2_image_activ_add(Image_Entry *im);
+static void _evas_cache2_image_activ_del(Image_Entry *im);
+static void _evas_cache2_image_lru_add(Image_Entry *im);
+static void _evas_cache2_image_lru_del(Image_Entry *im);
static void _evas_cache2_image_entry_preload_remove(Image_Entry *ie, const void *target);
-// static void _evas_cache_image_lru_nodata_add(Image_Entry *im);
-// static void _evas_cache_image_lru_nodata_del(Image_Entry *im);
+// static void _evas_cache2_image_lru_nodata_add(Image_Entry *im);
+// static void _evas_cache2_image_lru_nodata_del(Image_Entry *im);
static void
-_evas_cache_image_dirty_add(Image_Entry *im)
+_evas_cache2_image_dirty_add(Image_Entry *im)
{
if (im->flags.dirty) return;
- _evas_cache_image_activ_del(im);
- _evas_cache_image_lru_del(im);
- // _evas_cache_image_lru_nodata_del(im);
+ _evas_cache2_image_activ_del(im);
+ _evas_cache2_image_lru_del(im);
+ // _evas_cache2_image_lru_nodata_del(im);
im->flags.dirty = 1;
im->flags.cached = 1;
im->cache2->dirty = eina_inlist_prepend(im->cache2->dirty, EINA_INLIST_GET(im));
}
static void
-_evas_cache_image_dirty_del(Image_Entry *im)
+_evas_cache2_image_dirty_del(Image_Entry *im)
{
if (!im->flags.dirty) return;
if (!im->cache2) return;
}
static void
-_evas_cache_image_activ_add(Image_Entry *im)
+_evas_cache2_image_activ_add(Image_Entry *im)
{
if (im->flags.activ) return;
- _evas_cache_image_dirty_del(im);
- _evas_cache_image_lru_del(im);
- // _evas_cache_image_lru_nodata_del(im);
+ _evas_cache2_image_dirty_del(im);
+ _evas_cache2_image_lru_del(im);
+ // _evas_cache2_image_lru_nodata_del(im);
if (!im->cache_key) return;
im->flags.activ = 1;
im->flags.cached = 1;
}
static void
-_evas_cache_image_activ_del(Image_Entry *im)
+_evas_cache2_image_activ_del(Image_Entry *im)
{
if (!im->flags.activ) return;
if (!im->cache_key) return;
}
static void
-_evas_cache_image_lru_add(Image_Entry *im)
+_evas_cache2_image_lru_add(Image_Entry *im)
{
if (im->flags.lru) return;
- _evas_cache_image_dirty_del(im);
- _evas_cache_image_activ_del(im);
- // _evas_cache_image_lru_nodata_del(im);
+ _evas_cache2_image_dirty_del(im);
+ _evas_cache2_image_activ_del(im);
+ // _evas_cache2_image_lru_nodata_del(im);
if (!im->cache_key) return;
im->flags.lru = 1;
im->flags.cached = 1;
}
static void
-_evas_cache_image_lru_del(Image_Entry *im)
+_evas_cache2_image_lru_del(Image_Entry *im)
{
if (!im->flags.lru) return;
if (!im->cache_key) return;
/*
static void
-_evas_cache_image_lru_nodata_add(Image_Entry *im)
+_evas_cache2_image_lru_nodata_add(Image_Entry *im)
{
if (im->flags.lru_nodata) return;
- _evas_cache_image_dirty_del(im);
- _evas_cache_image_activ_del(im);
- _evas_cache_image_lru_del(im);
+ _evas_cache2_image_dirty_del(im);
+ _evas_cache2_image_activ_del(im);
+ _evas_cache2_image_lru_del(im);
im->flags.lru = 1;
im->flags.cached = 1;
im->cache2->lru_nodata = eina_inlist_prepend(im->cache2->lru_nodata, EINA_INLIST_GET(im));
}
static void
-_evas_cache_image_lru_nodata_del(Image_Entry *im)
+_evas_cache2_image_lru_nodata_del(Image_Entry *im)
{
if (!im->flags.lru_nodata) return;
im->flags.lru = 0;
}
static void
-_evas_cache_image_entry_delete(Evas_Cache2 *cache, Image_Entry *ie)
+_evas_cache2_image_entry_delete(Evas_Cache2 *cache, Image_Entry *ie)
{
if (!ie) return;
return;
}
- _evas_cache_image_dirty_del(ie);
- _evas_cache_image_activ_del(ie);
- _evas_cache_image_lru_del(ie);
- // _evas_cache_image_lru_nodata_del(ie);
+ _evas_cache2_image_dirty_del(ie);
+ _evas_cache2_image_activ_del(ie);
+ _evas_cache2_image_lru_del(ie);
+ // _evas_cache2_image_lru_nodata_del(ie);
if (ie->data1)
}
static Image_Entry *
-_evas_cache_image_entry_new(Evas_Cache2 *cache,
+_evas_cache2_image_entry_new(Evas_Cache2 *cache,
const char *hkey,
Image_Timestamp *tstamp,
const char *file,
{
ERR("couldn't load '%s' '%s' with cserve2!",
ie->file, ie->key ? ie->key : "");
- _evas_cache_image_entry_delete(cache, ie);
+ _evas_cache2_image_entry_delete(cache, ie);
if (error)
*error = EVAS_LOAD_ERROR_GENERIC;
return NULL;
}
}
- if (ie->cache_key) _evas_cache_image_activ_add(ie);
- else _evas_cache_image_dirty_add(ie);
+ if (ie->cache_key) _evas_cache2_image_activ_add(ie);
+ else _evas_cache2_image_dirty_add(ie);
if (error)
*error = EVAS_LOAD_ERROR_NONE;
}
if (ie->flags.delete_me)
- _evas_cache_image_entry_delete(ie->cache2, ie);
+ _evas_cache2_image_entry_delete(ie->cache2, ie);
}
static Eina_Bool
(cspace == EVAS_COLORSPACE_YCBCR422601_PL))
w &= ~0x1;
- im = _evas_cache_image_entry_new(cache, NULL, NULL, NULL, NULL, NULL, NULL);
+ im = _evas_cache2_image_entry_new(cache, NULL, NULL, NULL, NULL, NULL, NULL);
if (!im)
return NULL;
evas_cache2_image_surface_alloc(im, w, h);
if (cache->func.copied_data(im, w, h, image_data, alpha, cspace) != 0)
{
- _evas_cache_image_entry_delete(cache, im);
+ _evas_cache2_image_entry_delete(cache, im);
return NULL;
}
(cspace == EVAS_COLORSPACE_YCBCR422601_PL))
w &= ~0x1;
- im = _evas_cache_image_entry_new(cache, NULL, NULL, NULL, NULL, NULL, NULL);
+ im = _evas_cache2_image_entry_new(cache, NULL, NULL, NULL, NULL, NULL, NULL);
if (!im) return NULL;
im->w = w;
im->h = h;
im->flags.alpha = alpha;
if (cache->func.data(im, w, h, image_data, alpha, cspace) != 0)
{
- _evas_cache_image_entry_delete(cache, im);
+ _evas_cache2_image_entry_delete(cache, im);
return NULL;
}
im->references = 1;
{
Image_Entry *im;
- im = _evas_cache_image_entry_new(cache, NULL, NULL, NULL, NULL, NULL, NULL);
+ im = _evas_cache2_image_entry_new(cache, NULL, NULL, NULL, NULL, NULL, NULL);
if (!im)
return NULL;
if ((im->w == w) && (im->h == h)) return im;
cache = im->cache2;
- im2 = _evas_cache_image_entry_new(cache, NULL, NULL, NULL, NULL, NULL,
+ im2 = _evas_cache2_image_entry_new(cache, NULL, NULL, NULL, NULL, NULL,
NULL);
if (!im2) goto on_error;
on_error:
if (im2)
- _evas_cache_image_entry_delete(cache, im2);
+ _evas_cache2_image_entry_delete(cache, im2);
return NULL;
}
}
static Eina_Bool
-_evas_cache_image_free_cb(EINA_UNUSED const Eina_Hash *hash, EINA_UNUSED const void *key, void *data, void *fdata)
+_evas_cache2_image_free_cb(EINA_UNUSED const Eina_Hash *hash, EINA_UNUSED const void *key, void *data, void *fdata)
{
Eina_List **delete_list = fdata;
*delete_list = eina_list_prepend(*delete_list, data);
while (cache->lru)
{
im = (Image_Entry *)cache->lru;
- _evas_cache_image_entry_delete(cache, im);
+ _evas_cache2_image_entry_delete(cache, im);
}
/* This is mad, I am about to destroy image still alive, but we need to prevent leak. */
while (cache->dirty)
{
im = (Image_Entry *)cache->dirty;
- _evas_cache_image_entry_delete(cache, im);
+ _evas_cache2_image_entry_delete(cache, im);
}
delete_list = NULL;
- eina_hash_foreach(cache->activ, _evas_cache_image_free_cb, &delete_list);
+ eina_hash_foreach(cache->activ, _evas_cache2_image_free_cb, &delete_list);
while (delete_list)
{
- _evas_cache_image_entry_delete(cache, eina_list_data_get(delete_list));
+ _evas_cache2_image_entry_delete(cache, eina_list_data_get(delete_list));
delete_list = eina_list_remove_list(delete_list, delete_list);
}
* of an image at a given key. we wither find it and keep re-reffing
* it or we dirty it and get it out */
DBG("Entry on inactive hash was invalid (file changed or deleted).");
- _evas_cache_image_dirty_add(im);
+ _evas_cache2_image_dirty_add(im);
im = NULL;
}
if (ok)
{
/* remove from lru and make it active again */
- _evas_cache_image_lru_del(im);
- _evas_cache_image_activ_add(im);
+ _evas_cache2_image_lru_del(im);
+ _evas_cache2_image_activ_add(im);
goto on_ok;
}
DBG("Entry on inactive hash was invalid (file changed or deleted).");
/* as avtive cache find - if we match in lru and its invalid, dirty */
- _evas_cache_image_dirty_add(im);
+ _evas_cache2_image_dirty_add(im);
/* this image never used, so it have to be deleted */
- _evas_cache_image_entry_delete(cache, im);
+ _evas_cache2_image_entry_delete(cache, im);
im = NULL;
}
if (stat_failed) goto on_stat_error;
}
_timestamp_build(&tstamp, &st);
DBG("Creating a new entry for key '%s'.", hkey);
- im = _evas_cache_image_entry_new(cache, hkey, &tstamp, path, key,
+ im = _evas_cache2_image_entry_new(cache, hkey, &tstamp, path, key,
lo, error);
if (!im) goto on_stat_error;
else
*error = EVAS_LOAD_ERROR_GENERIC;
- if (im) _evas_cache_image_entry_delete(cache, im);
+ if (im) _evas_cache2_image_entry_delete(cache, im);
return NULL;
}
if (!ret) return NULL;
/* Remove from lru and make it active again */
- _evas_cache_image_lru_del(ret);
- _evas_cache_image_activ_add(ret);
+ _evas_cache2_image_lru_del(ret);
+ _evas_cache2_image_activ_add(ret);
found:
ret->references++;
evas_cache2_image_cache_key_create(hkey, im->file, pathlen,
im->key, keylen, &lo);
- ret = _evas_cache_image_entry_new(im->cache2, hkey, NULL, im->file, im->key,
+ ret = _evas_cache2_image_entry_new(im->cache2, hkey, NULL, im->file, im->key,
&lo, &error);
if (error != EVAS_LOAD_ERROR_NONE)
{
ERR("Failed to create scale image entry with error code %d.", error);
- if (ret) _evas_cache_image_entry_delete(im->cache2, ret);
+ if (ret) _evas_cache2_image_entry_delete(im->cache2, ret);
goto parent_out;
}
if (im->flags.dirty)
{
- _evas_cache_image_entry_delete(cache, im);
+ _evas_cache2_image_entry_delete(cache, im);
return;
}
- _evas_cache_image_lru_add(im);
+ _evas_cache2_image_lru_add(im);
if (cache)
evas_cache2_flush(cache);
}
if (!im->cache_key)
{
if (!im->flags.dirty)
- _evas_cache_image_dirty_add(im);
+ _evas_cache2_image_dirty_add(im);
return im;
}
on_error:
if (im2)
- _evas_cache_image_entry_delete(cache, im2);
+ _evas_cache2_image_entry_delete(cache, im2);
return NULL;
}
if (!im->cache_key)
{
if (!im->flags.dirty)
- _evas_cache_image_dirty_add(im);
+ _evas_cache2_image_dirty_add(im);
im2 = im;
}
else
im = (Image_Entry *)cache->lru->last;
DBG("Remove unused entry from cache.");
- _evas_cache_image_entry_delete(cache, im);
+ _evas_cache2_image_entry_delete(cache, im);
}
return cache->usage;