Remove use of evas_hash from evas and use directly eina.

SVN revision: 38066
This commit is contained in:
Cedric BAIL 2008-12-09 17:56:31 +00:00
parent 9bdf013fa4
commit 2b278b9419
15 changed files with 159 additions and 175 deletions

View File

@ -102,29 +102,10 @@ extern "C" {
return 255; return 255;
} }
static inline void *evas_hash_find(const Eina_Hash *hash, const void *key) #define evas_hash_find eina_hash_find
{ #define evas_hash_modify eina_hash_modify
if (!hash) return NULL; #define evas_hash_free eina_hash_free
return eina_hash_find(hash, key); #define evas_hash_foreach eina_hash_foreach
}
static inline void *evas_hash_modify(Eina_Hash *hash, const void *key, const void *data)
{
if (!hash) return NULL;
return eina_hash_modify(hash, key, data);
}
static inline void evas_hash_free(Eina_Hash *hash)
{
if (!hash) return ;
eina_hash_free(hash);
}
static inline void evas_hash_foreach(const Eina_Hash *hash, Eina_Hash_Foreach cb, const void *fdata)
{
if (!hash) return;
eina_hash_foreach(hash, cb, fdata);
}
#define evas_hash_alloc_error eina_error_get #define evas_hash_alloc_error eina_error_get
/* /*

View File

@ -50,8 +50,8 @@ struct _Evas_Cache_Image
Eina_Inlist *lru; Eina_Inlist *lru;
Eina_Inlist *lru_nodata; Eina_Inlist *lru_nodata;
Evas_Hash *inactiv; Eina_Hash *inactiv;
Evas_Hash *activ; Eina_Hash *activ;
void *data; void *data;
int usage; int usage;
@ -87,11 +87,11 @@ struct _Evas_Cache_Engine_Image
{ {
Evas_Cache_Engine_Image_Func func; Evas_Cache_Engine_Image_Func func;
Eina_Inlist* dirty; Eina_Inlist* dirty;
Evas_Hash* activ; Eina_Hash* activ;
Evas_Hash* inactiv; Eina_Hash* inactiv;
Eina_Inlist* lru; Eina_Inlist* lru;
Evas_Cache_Image* parent; Evas_Cache_Image* parent;
Evas_Cache_Engine_Image* brother; Evas_Cache_Engine_Image* brother;

View File

@ -26,7 +26,7 @@ _evas_cache_engine_image_make_active(Evas_Cache_Engine_Image *cache,
eim->flags.cached = 1; eim->flags.cached = 1;
eim->flags.activ = 1; eim->flags.activ = 1;
eim->flags.dirty = 0; eim->flags.dirty = 0;
cache->activ = evas_hash_add(cache->activ, key, eim); eina_hash_add(cache->activ, key, eim);
} }
static void static void
@ -37,7 +37,7 @@ _evas_cache_engine_image_make_inactive(Evas_Cache_Engine_Image *cache,
eim->flags.cached = 1; eim->flags.cached = 1;
eim->flags.dirty = 0; eim->flags.dirty = 0;
eim->flags.activ = 0; eim->flags.activ = 0;
cache->inactiv = evas_hash_add(cache->inactiv, key, eim); eina_hash_add(cache->inactiv, key, eim);
cache->lru = eina_inlist_prepend(cache->lru, EINA_INLIST_GET(eim)); cache->lru = eina_inlist_prepend(cache->lru, EINA_INLIST_GET(eim));
cache->usage += cache->func.mem_size_get(eim); cache->usage += cache->func.mem_size_get(eim);
} }
@ -55,12 +55,12 @@ _evas_cache_engine_image_remove_activ(Evas_Cache_Engine_Image *cache,
else else
if (eim->flags.activ) if (eim->flags.activ)
{ {
cache->activ = evas_hash_del(cache->activ, eim->cache_key, eim); eina_hash_del(cache->activ, eim->cache_key, eim);
} }
else else
{ {
cache->usage -= cache->func.mem_size_get(eim); cache->usage -= cache->func.mem_size_get(eim);
cache->inactiv = evas_hash_del(cache->inactiv, eim->cache_key, eim); eina_hash_del(cache->inactiv, eim->cache_key, eim);
cache->lru = eina_inlist_remove(cache->lru, EINA_INLIST_GET(eim)); cache->lru = eina_inlist_remove(cache->lru, EINA_INLIST_GET(eim));
} }
eim->flags.cached = 0; eim->flags.cached = 0;
@ -185,8 +185,8 @@ evas_cache_engine_image_init(const Evas_Cache_Engine_Image_Func *cb, Evas_Cache_
new->dirty = NULL; new->dirty = NULL;
new->lru = NULL; new->lru = NULL;
new->activ = NULL; new->activ = eina_hash_string_superfast_new(NULL);
new->inactiv = NULL; new->inactiv = eina_hash_string_superfast_new(NULL);
new->parent = parent; new->parent = parent;
parent->references++; parent->references++;
@ -239,7 +239,7 @@ evas_cache_engine_image_dup(const Evas_Cache_Engine_Image_Func *cb, Evas_Cache_E
} }
static Evas_Bool static Evas_Bool
_evas_cache_engine_image_free_cb(__UNUSED__ const Evas_Hash *hash, __UNUSED__ const void *key, void *data, void *fdata) _evas_cache_engine_image_free_cb(__UNUSED__ const Eina_Hash *hash, __UNUSED__ const void *key, void *data, void *fdata)
{ {
Eina_List **delete_list = fdata; Eina_List **delete_list = fdata;
@ -272,8 +272,8 @@ evas_cache_engine_image_shutdown(Evas_Cache_Engine_Image *cache)
if (cache->func.debug) cache->func.debug("shutdown-engine", NULL); if (cache->func.debug) cache->func.debug("shutdown-engine", NULL);
evas_hash_foreach(cache->inactiv, _evas_cache_engine_image_free_cb, &delete_list); eina_hash_foreach(cache->inactiv, _evas_cache_engine_image_free_cb, &delete_list);
evas_hash_foreach(cache->activ, _evas_cache_engine_image_free_cb, &delete_list); eina_hash_foreach(cache->activ, _evas_cache_engine_image_free_cb, &delete_list);
while (delete_list) while (delete_list)
{ {
@ -281,8 +281,8 @@ evas_cache_engine_image_shutdown(Evas_Cache_Engine_Image *cache)
delete_list = eina_list_remove_list(delete_list, delete_list); delete_list = eina_list_remove_list(delete_list, delete_list);
} }
evas_hash_free(cache->inactiv); eina_hash_free(cache->inactiv);
evas_hash_free(cache->activ); eina_hash_free(cache->activ);
/* This is mad, I am about to destroy image still alive, but we need to prevent leak. */ /* This is mad, I am about to destroy image still alive, but we need to prevent leak. */
while (cache->dirty) while (cache->dirty)
@ -325,14 +325,14 @@ evas_cache_engine_image_request(Evas_Cache_Engine_Image *cache,
if (!ekey) if (!ekey)
goto on_error; goto on_error;
eim = evas_hash_find(cache->activ, ekey); eim = eina_hash_find(cache->activ, ekey);
if (eim) if (eim)
{ {
evas_cache_image_drop(im); evas_cache_image_drop(im);
goto on_ok; goto on_ok;
} }
eim = evas_hash_find(cache->inactiv, ekey); eim = eina_hash_find(cache->inactiv, ekey);
if (eim) if (eim)
{ {
_evas_cache_engine_image_remove_activ(cache, eim); _evas_cache_engine_image_remove_activ(cache, eim);

View File

@ -72,7 +72,7 @@ _evas_cache_image_make_activ(Evas_Cache_Image *cache,
im->flags.activ = 1; im->flags.activ = 1;
im->flags.lru_nodata = 0; im->flags.lru_nodata = 0;
im->flags.dirty = 0; im->flags.dirty = 0;
cache->activ = evas_hash_direct_add(cache->activ, key, im); eina_hash_direct_add(cache->activ, key, im);
} }
else else
{ {
@ -90,7 +90,7 @@ _evas_cache_image_make_inactiv(Evas_Cache_Image *cache,
im->flags.activ = 0; im->flags.activ = 0;
im->flags.dirty = 0; im->flags.dirty = 0;
im->flags.cached = 1; im->flags.cached = 1;
cache->inactiv = evas_hash_direct_add(cache->inactiv, key, im); eina_hash_direct_add(cache->inactiv, key, im);
cache->lru = eina_inlist_prepend(cache->lru, EINA_INLIST_GET(im)); cache->lru = eina_inlist_prepend(cache->lru, EINA_INLIST_GET(im));
cache->usage += cache->func.mem_size_get(im); cache->usage += cache->func.mem_size_get(im);
} }
@ -130,7 +130,7 @@ _evas_cache_image_remove_activ(Evas_Cache_Image *cache,
{ {
if (ie->flags.activ) if (ie->flags.activ)
{ {
cache->activ = evas_hash_del(cache->activ, ie->cache_key, ie); eina_hash_del(cache->activ, ie->cache_key, ie);
_evas_cache_image_remove_lru_nodata(cache, ie); _evas_cache_image_remove_lru_nodata(cache, ie);
} }
else else
@ -141,7 +141,7 @@ _evas_cache_image_remove_activ(Evas_Cache_Image *cache,
} }
else else
{ {
cache->inactiv = evas_hash_del(cache->inactiv, ie->cache_key, ie); eina_hash_del(cache->inactiv, ie->cache_key, ie);
cache->lru = eina_inlist_remove(cache->lru, EINA_INLIST_GET(ie)); cache->lru = eina_inlist_remove(cache->lru, EINA_INLIST_GET(ie));
cache->usage -= cache->func.mem_size_get(ie); cache->usage -= cache->func.mem_size_get(ie);
} }
@ -377,8 +377,8 @@ evas_cache_image_init(const Evas_Cache_Image_Func *cb)
new->dirty = NULL; new->dirty = NULL;
new->lru = NULL; new->lru = NULL;
new->lru_nodata = NULL; new->lru_nodata = NULL;
new->inactiv = NULL; new->inactiv = eina_hash_string_superfast_new(NULL);
new->activ = NULL; new->activ = eina_hash_string_superfast_new(NULL);
new->references = 1; new->references = 1;
@ -386,7 +386,7 @@ evas_cache_image_init(const Evas_Cache_Image_Func *cb)
} }
static Evas_Bool static Evas_Bool
_evas_cache_image_free_cb(__UNUSED__ const Evas_Hash *hash, __UNUSED__ const void *key, void *data, void *fdata) _evas_cache_image_free_cb(__UNUSED__ const Eina_Hash *hash, __UNUSED__ const void *key, void *data, void *fdata)
{ {
Eina_List **delete_list = fdata; Eina_List **delete_list = fdata;
@ -426,7 +426,7 @@ evas_cache_image_shutdown(Evas_Cache_Image *cache)
_evas_cache_image_entry_delete(cache, im); _evas_cache_image_entry_delete(cache, im);
} }
evas_hash_foreach(cache->activ, _evas_cache_image_free_cb, &delete_list); eina_hash_foreach(cache->activ, _evas_cache_image_free_cb, &delete_list);
while (delete_list) while (delete_list)
{ {
@ -434,8 +434,8 @@ evas_cache_image_shutdown(Evas_Cache_Image *cache)
delete_list = eina_list_remove_list(delete_list, delete_list); delete_list = eina_list_remove_list(delete_list, delete_list);
} }
evas_hash_free(cache->activ); eina_hash_free(cache->activ);
evas_hash_free(cache->inactiv); eina_hash_free(cache->inactiv);
free(cache); free(cache);
} }
@ -514,7 +514,7 @@ evas_cache_image_request(Evas_Cache_Image *cache, const char *file, const char *
hkey[size] = '\0'; hkey[size] = '\0';
im = evas_hash_find(cache->activ, hkey); im = eina_hash_find(cache->activ, hkey);
if (im) if (im)
{ {
time_t t; time_t t;
@ -537,7 +537,7 @@ evas_cache_image_request(Evas_Cache_Image *cache, const char *file, const char *
_evas_cache_image_make_dirty(cache, im); _evas_cache_image_make_dirty(cache, im);
} }
im = evas_hash_find(cache->inactiv, hkey); im = eina_hash_find(cache->inactiv, hkey);
if (im) if (im)
{ {
int ok; int ok;

View File

@ -19,7 +19,7 @@
#endif #endif
/* font dir cache */ /* font dir cache */
static Evas_Hash *font_dirs = NULL; static Eina_Hash *font_dirs = NULL;
static Eina_List *fonts_cache = NULL; static Eina_List *fonts_cache = NULL;
static Eina_List *fonts_zero = NULL; static Eina_List *fonts_zero = NULL;
@ -35,7 +35,7 @@ struct _Fndat
}; };
/* private methods for font dir cache */ /* private methods for font dir cache */
static Evas_Bool font_cache_dir_free(const Evas_Hash *hash, const void *key, void *data, void *fdata); static Evas_Bool font_cache_dir_free(const Eina_Hash *hash, const void *key, void *data, void *fdata);
static Evas_Font_Dir *object_text_font_cache_dir_update(char *dir, Evas_Font_Dir *fd); static Evas_Font_Dir *object_text_font_cache_dir_update(char *dir, Evas_Font_Dir *fd);
static Evas_Font *object_text_font_cache_font_find_x(Evas_Font_Dir *fd, char *font); static Evas_Font *object_text_font_cache_font_find_x(Evas_Font_Dir *fd, char *font);
static Evas_Font *object_text_font_cache_font_find_file(Evas_Font_Dir *fd, char *font); static Evas_Font *object_text_font_cache_font_find_file(Evas_Font_Dir *fd, char *font);
@ -50,17 +50,18 @@ evas_font_dir_cache_free(void)
{ {
if (!font_dirs) return; if (!font_dirs) return;
evas_hash_foreach(font_dirs, font_cache_dir_free, NULL); eina_hash_foreach(font_dirs, font_cache_dir_free, NULL);
evas_hash_free(font_dirs); eina_hash_free(font_dirs);
font_dirs = NULL; font_dirs = NULL;
} }
const char * const char *
evas_font_dir_cache_find(char *dir, char *font) evas_font_dir_cache_find(char *dir, char *font)
{ {
Evas_Font_Dir *fd; Evas_Font_Dir *fd = NULL;
fd = evas_hash_find(font_dirs, dir); if (!font_dirs) font_dirs = eina_hash_string_superfast_new(NULL);
else fd = eina_hash_find(font_dirs, dir);
fd = object_text_font_cache_dir_update(dir, fd); fd = object_text_font_cache_dir_update(dir, fd);
if (fd) if (fd)
{ {
@ -435,11 +436,13 @@ evas_font_dir_available_list(const Evas *evas)
if (!evas->font_path) if (!evas->font_path)
return available; return available;
if (!font_dirs) font_dirs = eina_hash_string_superfast_new(NULL);
EINA_LIST_FOREACH(evas->font_path, l, dir) EINA_LIST_FOREACH(evas->font_path, l, dir)
{ {
Evas_Font_Dir *fd; Evas_Font_Dir *fd;
fd = evas_hash_find(font_dirs, dir); fd = eina_hash_find(font_dirs, dir);
fd = object_text_font_cache_dir_update(dir, fd); fd = object_text_font_cache_dir_update(dir, fd);
if (fd && fd->aliases) if (fd && fd->aliases)
{ {
@ -465,7 +468,7 @@ evas_font_dir_available_list_free(Eina_List *available)
/* private stuff */ /* private stuff */
static Eina_Bool static Eina_Bool
font_cache_dir_free(const Evas_Hash *hash, const void *key, void *data, void *fdata) font_cache_dir_free(const Eina_Hash *hash, const void *key, void *data, void *fdata)
{ {
object_text_font_cache_dir_del((char *) key, data); object_text_font_cache_dir_del((char *) key, data);
return 1; return 1;
@ -483,7 +486,7 @@ object_text_font_cache_dir_update(char *dir, Evas_Font_Dir *fd)
if (mt != fd->dir_mod_time) if (mt != fd->dir_mod_time)
{ {
object_text_font_cache_dir_del(dir, fd); object_text_font_cache_dir_del(dir, fd);
font_dirs = evas_hash_del(font_dirs, dir, fd); eina_hash_del(font_dirs, dir, fd);
} }
else else
{ {
@ -495,7 +498,7 @@ object_text_font_cache_dir_update(char *dir, Evas_Font_Dir *fd)
if (mt != fd->fonts_dir_mod_time) if (mt != fd->fonts_dir_mod_time)
{ {
object_text_font_cache_dir_del(dir, fd); object_text_font_cache_dir_del(dir, fd);
font_dirs = evas_hash_del(font_dirs, dir, fd); eina_hash_del(font_dirs, dir, fd);
} }
else else
{ {
@ -508,7 +511,7 @@ object_text_font_cache_dir_update(char *dir, Evas_Font_Dir *fd)
if (mt != fd->fonts_alias_mod_time) if (mt != fd->fonts_alias_mod_time)
{ {
object_text_font_cache_dir_del(dir, fd); object_text_font_cache_dir_del(dir, fd);
font_dirs = evas_hash_del(font_dirs, dir, fd); eina_hash_del(font_dirs, dir, fd);
} }
else else
return fd; return fd;
@ -584,13 +587,13 @@ object_text_font_cache_font_find(Evas_Font_Dir *fd, char *font)
{ {
Evas_Font *fn; Evas_Font *fn;
fn = evas_hash_find(fd->lookup, font); fn = eina_hash_find(fd->lookup, font);
if (fn) return fn; if (fn) return fn;
fn = object_text_font_cache_font_find_alias(fd, font); fn = object_text_font_cache_font_find_alias(fd, font);
if (!fn) fn = object_text_font_cache_font_find_x(fd, font); if (!fn) fn = object_text_font_cache_font_find_x(fd, font);
if (!fn) fn = object_text_font_cache_font_find_file(fd, font); if (!fn) fn = object_text_font_cache_font_find_file(fd, font);
if (!fn) return NULL; if (!fn) return NULL;
fd->lookup = evas_hash_add(fd->lookup, font, fn); eina_hash_add(fd->lookup, font, fn);
return fn; return fn;
} }
@ -600,10 +603,13 @@ object_text_font_cache_dir_add(char *dir)
Evas_Font_Dir *fd; Evas_Font_Dir *fd;
char *tmp, *tmp2; char *tmp, *tmp2;
Eina_List *fdir; Eina_List *fdir;
Evas_Font *fn;
fd = calloc(1, sizeof(Evas_Font_Dir)); fd = calloc(1, sizeof(Evas_Font_Dir));
if (!fd) return NULL; if (!fd) return NULL;
font_dirs = evas_hash_add(font_dirs, dir, fd); fd->lookup = eina_hash_string_superfast_new(NULL);
eina_hash_add(font_dirs, dir, fd);
/* READ fonts.alias, fonts.dir and directory listing */ /* READ fonts.alias, fonts.dir and directory listing */
@ -632,8 +638,6 @@ object_text_font_cache_dir_add(char *dir)
num = evas_object_text_font_string_parse((char *)fdef, font_prop); num = evas_object_text_font_string_parse((char *)fdef, font_prop);
if (num == 14) if (num == 14)
{ {
Evas_Font *fn;
fn = calloc(1, sizeof(Evas_Font)); fn = calloc(1, sizeof(Evas_Font));
if (fn) if (fn)
{ {
@ -663,8 +667,6 @@ object_text_font_cache_dir_add(char *dir)
tmp = evas_file_path_join(dir, fdir->data); tmp = evas_file_path_join(dir, fdir->data);
if (tmp) if (tmp)
{ {
Evas_Font *fn;
fn = calloc(1, sizeof(Evas_Font)); fn = calloc(1, sizeof(Evas_Font));
if (fn) if (fn)
{ {
@ -747,7 +749,7 @@ object_text_font_cache_dir_add(char *dir)
static void static void
object_text_font_cache_dir_del(char *dir, Evas_Font_Dir *fd) object_text_font_cache_dir_del(char *dir, Evas_Font_Dir *fd)
{ {
if (fd->lookup) evas_hash_free(fd->lookup); if (fd->lookup) eina_hash_free(fd->lookup);
while (fd->fonts) while (fd->fonts)
{ {
Evas_Font *fn; Evas_Font *fn;

View File

@ -68,6 +68,7 @@ evas_new(void)
e->viewport.w = 1; e->viewport.w = 1;
e->viewport.h = 1; e->viewport.h = 1;
e->hinting = EVAS_FONT_HINTING_BYTECODE; e->hinting = EVAS_FONT_HINTING_BYTECODE;
e->name_hash = eina_hash_string_superfast_new(NULL);
eina_array_step_set(&e->delete_objects, 16); eina_array_step_set(&e->delete_objects, 16);
eina_array_step_set(&e->active_objects, 16); eina_array_step_set(&e->active_objects, 16);
@ -141,7 +142,8 @@ evas_free(Evas *e)
evas_font_path_clear(e); evas_font_path_clear(e);
e->pointer.object.in = eina_list_free(e->pointer.object.in); e->pointer.object.in = eina_list_free(e->pointer.object.in);
if (e->name_hash) evas_hash_free(e->name_hash); if (e->name_hash) eina_hash_free(e->name_hash);
e->name_hash = NULL;
while (e->damages) while (e->damages)
{ {

View File

@ -19,14 +19,14 @@ evas_object_name_set(Evas_Object *obj, const char *name)
MAGIC_CHECK_END(); MAGIC_CHECK_END();
if (obj->name) if (obj->name)
{ {
obj->layer->evas->name_hash = evas_hash_del(obj->layer->evas->name_hash, obj->name, obj); eina_hash_del(obj->layer->evas->name_hash, obj->name, obj);
free(obj->name); free(obj->name);
} }
if (!name) obj->name = NULL; if (!name) obj->name = NULL;
else else
{ {
obj->name = strdup(name); obj->name = strdup(name);
obj->layer->evas->name_hash = evas_hash_add(obj->layer->evas->name_hash, obj->name, obj); eina_hash_add(obj->layer->evas->name_hash, obj->name, obj);
} }
} }
@ -59,7 +59,7 @@ evas_object_name_find(const Evas *e, const char *name)
return NULL; return NULL;
MAGIC_CHECK_END(); MAGIC_CHECK_END();
if (!name) return NULL; if (!name) return NULL;
return (Evas_Object *)evas_hash_find(e->name_hash, name); return (Evas_Object *)eina_hash_find(e->name_hash, name);
} }
/** /**

View File

@ -9,7 +9,6 @@ EAPI RGBA_Font_Glyph *
evas_common_font_int_cache_glyph_get(RGBA_Font_Int *fi, FT_UInt index) evas_common_font_int_cache_glyph_get(RGBA_Font_Int *fi, FT_UInt index)
{ {
RGBA_Font_Glyph *fg; RGBA_Font_Glyph *fg;
char key[6];
FT_UInt hindex; FT_UInt hindex;
FT_Error error; FT_Error error;
const FT_Int32 hintflags[3] = const FT_Int32 hintflags[3] =
@ -17,14 +16,7 @@ evas_common_font_int_cache_glyph_get(RGBA_Font_Int *fi, FT_UInt index)
hindex = index + (fi->hinting * 500000000); hindex = index + (fi->hinting * 500000000);
key[0] = ((hindex ) & 0x7f) + 1; fg = eina_hash_find(fi->glyphs, &hindex);
key[1] = ((hindex >> 7 ) & 0x7f) + 1;
key[2] = ((hindex >> 14 ) & 0x7f) + 1;
key[3] = ((hindex >> 21 ) & 0x7f) + 1;
key[4] = ((hindex >> 28 ) & 0x0f) + 1;
key[5] = 0;
fg = evas_hash_find(fi->glyphs, key);
if (fg) return fg; if (fg) return fg;
// error = FT_Load_Glyph(fi->src->ft.face, index, FT_LOAD_NO_BITMAP); // error = FT_Load_Glyph(fi->src->ft.face, index, FT_LOAD_NO_BITMAP);
@ -54,7 +46,7 @@ evas_common_font_int_cache_glyph_get(RGBA_Font_Int *fi, FT_UInt index)
} }
fg->glyph_out = (FT_BitmapGlyph)fg->glyph; fg->glyph_out = (FT_BitmapGlyph)fg->glyph;
fi->glyphs = evas_hash_add(fi->glyphs, key, fg); eina_hash_add(fi->glyphs, &hindex, fg);
return fg; return fg;
} }

View File

@ -12,8 +12,8 @@ static int font_cache = 0;
static Eina_Inlist * fonts_src = NULL; static Eina_Inlist * fonts_src = NULL;
static Eina_Inlist * fonts = NULL; static Eina_Inlist * fonts = NULL;
static Evas_Bool font_modify_cache_cb(const Evas_Hash *hash, const char *key, void *data, void *fdata); static Evas_Bool font_modify_cache_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata);
static Evas_Bool font_flush_free_glyph_cb(const Evas_Hash *hash, const char *key, void *data, void *fdata); static Evas_Bool font_flush_free_glyph_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata);
EAPI RGBA_Font_Source * EAPI RGBA_Font_Source *
evas_common_font_source_memory_load(const char *name, const void *data, int data_size) evas_common_font_source_memory_load(const char *name, const void *data, int data_size)
@ -197,10 +197,11 @@ EAPI RGBA_Font_Int *
evas_common_font_int_load_init(RGBA_Font_Int *fi) evas_common_font_int_load_init(RGBA_Font_Int *fi)
{ {
fi->ft.size = NULL; fi->ft.size = NULL;
fi->glyphs = NULL; fi->glyphs = eina_hash_int32_new(NULL);
fi->usage = 0; fi->usage = 0;
fi->references = 1; fi->references = 1;
fonts = eina_inlist_prepend(fonts, EINA_INLIST_GET(fi)); fonts = eina_inlist_prepend(fonts, EINA_INLIST_GET(fi));
return fi; return fi;
} }
@ -363,16 +364,14 @@ EAPI void
evas_common_font_free(RGBA_Font *fn) evas_common_font_free(RGBA_Font *fn)
{ {
Eina_List *l; Eina_List *l;
RGBA_Font_Int *fi;
if (!fn) if (!fn)
return; return;
fn->references--; fn->references--;
if (fn->references > 0) return; if (fn->references > 0) return;
for (l = fn->fonts; l; l = l->next) EINA_LIST_FOREACH(fn->fonts, l, fi)
{ {
RGBA_Font_Int *fi;
fi = l->data;
fi->references--; fi->references--;
if (fi->references == 0) if (fi->references == 0)
{ {
@ -389,17 +388,13 @@ EAPI void
evas_common_font_hinting_set(RGBA_Font *fn, Font_Hint_Flags hinting) evas_common_font_hinting_set(RGBA_Font *fn, Font_Hint_Flags hinting)
{ {
Eina_List *l; Eina_List *l;
RGBA_Font_Int *fi;
if (!fn) if (!fn)
return; return;
fn->hinting = hinting; fn->hinting = hinting;
for (l = fn->fonts; l; l = l->next) EINA_LIST_FOREACH(fn->fonts, l, fi)
{ fi->hinting = fn->hinting;
RGBA_Font_Int *fi;
fi = l->data;
fi->hinting = fn->hinting;
}
} }
EAPI Evas_Bool EAPI Evas_Bool
@ -473,8 +468,8 @@ evas_common_font_memory_hinting_add(RGBA_Font *fn, const char *name, int size, c
return fn; return fn;
} }
static Evas_Bool static Eina_Bool
font_modify_cache_cb(const Evas_Hash *hash, const char *key, void *data, void *fdata) font_modify_cache_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata)
{ {
int *dir; int *dir;
RGBA_Font_Glyph *fg; RGBA_Font_Glyph *fg;
@ -498,8 +493,8 @@ evas_common_font_int_modify_cache_by(RGBA_Font_Int *fi, int dir)
{ {
int sz_hash = 0; int sz_hash = 0;
if (fi->glyphs) sz_hash = evas_hash_size(fi->glyphs); if (fi->glyphs) sz_hash = eina_hash_population(fi->glyphs);
evas_hash_foreach(fi->glyphs, font_modify_cache_cb, &dir); eina_hash_foreach(fi->glyphs, font_modify_cache_cb, &dir);
font_cache_usage += dir * (sizeof(RGBA_Font) + sz_hash + font_cache_usage += dir * (sizeof(RGBA_Font) + sz_hash +
sizeof(FT_FaceRec) + 16384); /* fudge values */ sizeof(FT_FaceRec) + 16384); /* fudge values */
} }
@ -524,8 +519,8 @@ evas_common_font_flush(void)
while (font_cache_usage > font_cache) evas_common_font_flush_last(); while (font_cache_usage > font_cache) evas_common_font_flush_last();
} }
static Evas_Bool static Eina_Bool
font_flush_free_glyph_cb(const Evas_Hash *hash, const char *key, void *data, void *fdata) font_flush_free_glyph_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata)
{ {
RGBA_Font_Glyph *fg; RGBA_Font_Glyph *fg;
@ -560,8 +555,8 @@ evas_common_font_flush_last(void)
fonts = eina_inlist_remove(fonts, EINA_INLIST_GET(fi)); fonts = eina_inlist_remove(fonts, EINA_INLIST_GET(fi));
evas_common_font_int_modify_cache_by(fi, -1); evas_common_font_int_modify_cache_by(fi, -1);
evas_hash_foreach(fi->glyphs, font_flush_free_glyph_cb, NULL); eina_hash_foreach(fi->glyphs, font_flush_free_glyph_cb, NULL);
evas_hash_free(fi->glyphs); eina_hash_free(fi->glyphs);
evas_common_font_source_free(fi->src); evas_common_font_source_free(fi->src);

View File

@ -629,7 +629,7 @@ struct _RGBA_Font_Int
FT_Size size; FT_Size size;
} ft; } ft;
Evas_Hash *glyphs; Eina_Hash *glyphs;
int usage; int usage;
Font_Hint_Flags hinting; Font_Hint_Flags hinting;

View File

@ -270,7 +270,7 @@ struct _Evas
Evas_Layer *layers; Evas_Layer *layers;
Evas_Hash *name_hash; Eina_Hash *name_hash;
int output_validity; int output_validity;
@ -479,7 +479,7 @@ struct _Evas_Data_Node
struct _Evas_Font_Dir struct _Evas_Font_Dir
{ {
Evas_Hash *lookup; Eina_Hash *lookup;
Eina_List *fonts; Eina_List *fonts;
Eina_List *aliases; Eina_List *aliases;
DATA64 dir_mod_time; DATA64 dir_mod_time;

View File

@ -3,20 +3,20 @@
#include "evas_engine.h" #include "evas_engine.h"
#include "Evas_Engine_XRender_X11.h" #include "Evas_Engine_XRender_X11.h"
static Evas_Hash *_xr_fg_pool = NULL; static Eina_Hash *_xr_fg_pool = NULL;
XR_Font_Surface * XR_Font_Surface *
_xre_font_surface_new(Ximage_Info *xinf, RGBA_Font_Glyph *fg) _xre_font_surface_new(Ximage_Info *xinf, RGBA_Font_Glyph *fg)
{ {
XR_Font_Surface *fs; XR_Font_Surface *fs;
DATA8 *data; DATA8 *data;
int w, h, j; int w, h, j;
XRenderPictureAttributes att; XRenderPictureAttributes att;
XRenderPictFormat *fmt; XRenderPictFormat *fmt;
Ximage_Image *xim; Ximage_Image *xim;
Evas_Hash *pool; Eina_Hash *pool;
char buf[256], buf2[256]; char buf[256], buf2[256];
data = fg->glyph_out->bitmap.buffer; data = fg->glyph_out->bitmap.buffer;
w = fg->glyph_out->bitmap.width; w = fg->glyph_out->bitmap.width;
h = fg->glyph_out->bitmap.rows; h = fg->glyph_out->bitmap.rows;
@ -30,11 +30,11 @@ _xre_font_surface_new(Ximage_Info *xinf, RGBA_Font_Glyph *fg)
if ((fs->xinf->disp == xinf->disp) && (fs->xinf->root == xinf->root)) if ((fs->xinf->disp == xinf->disp) && (fs->xinf->root == xinf->root))
return fs; return fs;
snprintf(buf, sizeof(buf), "@%p@/@%lx@", fs->xinf->disp, fs->xinf->root); snprintf(buf, sizeof(buf), "@%p@/@%lx@", fs->xinf->disp, fs->xinf->root);
pool = evas_hash_find(_xr_fg_pool, buf); pool = eina_hash_find(_xr_fg_pool, buf);
if (pool) if (pool)
{ {
snprintf(buf, sizeof(buf), "%p", fg); snprintf(buf, sizeof(buf), "%p", fg);
fs = evas_hash_find(pool, buf); fs = eina_hash_find(pool, buf);
if (fs) return fs; if (fs) return fs;
} }
} }
@ -47,12 +47,14 @@ _xre_font_surface_new(Ximage_Info *xinf, RGBA_Font_Glyph *fg)
fs->xinf->references++; fs->xinf->references++;
fs->w = w; fs->w = w;
fs->h = h; fs->h = h;
snprintf(buf, sizeof(buf), "@%p@/@%lx@", fs->xinf->disp, fs->xinf->root); snprintf(buf, sizeof(buf), "@%p@/@%lx@", fs->xinf->disp, fs->xinf->root);
pool = evas_hash_find(_xr_fg_pool, buf); pool = eina_hash_find(_xr_fg_pool, buf);
if (!pool) pool = eina_hash_string_superfast_new(NULL);
snprintf(buf2, sizeof(buf2), "%p", fg); snprintf(buf2, sizeof(buf2), "%p", fg);
pool = evas_hash_add(pool, buf2, fs); eina_hash_add(pool, buf2, fs);
_xr_fg_pool = evas_hash_add(_xr_fg_pool, buf, pool); if (!_xr_fg_pool) _xr_fg_pool = eina_hash_string_superfast_new(NULL);
eina_hash_add(_xr_fg_pool, buf, pool);
/* FIXME: maybe use fmt4? */ /* FIXME: maybe use fmt4? */
fmt = xinf->fmt8; fmt = xinf->fmt8;
@ -60,9 +62,9 @@ _xre_font_surface_new(Ximage_Info *xinf, RGBA_Font_Glyph *fg)
att.dither = 0; att.dither = 0;
att.component_alpha = 0; att.component_alpha = 0;
att.repeat = 0; att.repeat = 0;
fs->pic = XRenderCreatePicture(xinf->disp, fs->draw,fmt, fs->pic = XRenderCreatePicture(xinf->disp, fs->draw,fmt,
CPRepeat | CPDither | CPComponentAlpha, &att); CPRepeat | CPDither | CPComponentAlpha, &att);
/* FIXME: handle if fmt->depth != 8 */ /* FIXME: handle if fmt->depth != 8 */
xim = _xr_image_new(fs->xinf, w, h,fmt->depth); xim = _xr_image_new(fs->xinf, w, h,fmt->depth);
if ((fg->glyph_out->bitmap.num_grays == 256) && if ((fg->glyph_out->bitmap.num_grays == 256) &&
@ -127,17 +129,18 @@ _xre_font_surface_new(Ximage_Info *xinf, RGBA_Font_Glyph *fg)
} }
static Evas_Bool static Evas_Bool
_xre_font_pool_cb(const Evas_Hash *hash, const char *key, void *data, void *fdata) _xre_font_pool_cb(const Eina_Hash *hash, const char *key, void *data, void *fdata)
{ {
Evas_Hash *pool; Eina_Hash *pool;
XR_Font_Surface *fs; XR_Font_Surface *fs;
char buf[256]; char buf[256];
fs = fdata; fs = fdata;
pool = data; pool = data;
snprintf(buf, sizeof(buf), "@%p@/@%lx@", fs->xinf->disp, fs->xinf->root); snprintf(buf, sizeof(buf), "@%p@/@%lx@", fs->xinf->disp, fs->xinf->root);
pool = evas_hash_del(pool, buf, fs); eina_hash_del(pool, buf, fs);
hash = evas_hash_modify(hash, key, pool); if (!hash) hash = eina_hash_string_superfast_new(NULL);
eina_hash_modify(hash, key, pool);
return 1; return 1;
} }
@ -145,7 +148,7 @@ void
_xre_font_surface_free(XR_Font_Surface *fs) _xre_font_surface_free(XR_Font_Surface *fs)
{ {
if (!fs) return; if (!fs) return;
evas_hash_foreach(_xr_fg_pool, _xre_font_pool_cb, fs); eina_hash_foreach(_xr_fg_pool, _xre_font_pool_cb, fs);
XFreePixmap(fs->xinf->disp, fs->draw); XFreePixmap(fs->xinf->disp, fs->draw);
XRenderFreePicture(fs->xinf->disp, fs->pic); XRenderFreePicture(fs->xinf->disp, fs->pic);
_xr_image_info_free(fs->xinf); _xr_image_info_free(fs->xinf);

View File

@ -3,58 +3,60 @@
#include "evas_engine.h" #include "evas_engine.h"
#include "Evas_Engine_XRender_X11.h" #include "Evas_Engine_XRender_X11.h"
static Evas_Hash *_xr_image_hash = NULL; static Eina_Hash *_xr_image_hash = NULL;
static int _xr_image_cache_size = 0; static int _xr_image_cache_size = 0;
static int _xr_image_cache_usage = 0; static int _xr_image_cache_usage = 0;
static Eina_List *_xr_image_cache = NULL; static Eina_List *_xr_image_cache = NULL;
static Evas_Hash *_xr_image_dirty_hash = NULL; static Eina_Hash *_xr_image_dirty_hash = NULL;
static void static void
__xre_image_dirty_hash_add(XR_Image *im) __xre_image_dirty_hash_add(XR_Image *im)
{ {
char buf[64]; char buf[64];
if (!im->data) return; if (!im->data) return;
snprintf(buf, sizeof(buf), "%p", im->data); snprintf(buf, sizeof(buf), "%p", im->data);
_xr_image_dirty_hash = evas_hash_add(_xr_image_dirty_hash, buf, im); if (!_xr_image_dirty_hash) _xr_image_dirty_hash = eina_hash_string_superfast_new(NULL);
eina_hash_add(_xr_image_dirty_hash, buf, im);
} }
static void static void
__xre_image_dirty_hash_del(XR_Image *im) __xre_image_dirty_hash_del(XR_Image *im)
{ {
char buf[64]; char buf[64];
if (!im->data) return; if (!im->data) return;
snprintf(buf, sizeof(buf), "%p", im->data); snprintf(buf, sizeof(buf), "%p", im->data);
_xr_image_dirty_hash = evas_hash_del(_xr_image_dirty_hash, buf, im); eina_hash_del(_xr_image_dirty_hash, buf, im);
} }
static XR_Image * static XR_Image *
__xre_image_dirty_hash_find(void *data) __xre_image_dirty_hash_find(void *data)
{ {
char buf[64]; char buf[64];
snprintf(buf, sizeof(buf), "%p", data); snprintf(buf, sizeof(buf), "%p", data);
return evas_hash_find(_xr_image_dirty_hash, buf); return eina_hash_find(_xr_image_dirty_hash, buf);
} }
static XR_Image * static XR_Image *
__xre_image_find(char *fkey) __xre_image_find(char *fkey)
{ {
XR_Image *im; XR_Image *im;
im = evas_hash_find(_xr_image_hash, fkey); im = eina_hash_find(_xr_image_hash, fkey);
if (!im) if (!im)
{ {
Eina_List *l; Eina_List *l;
for (l = _xr_image_cache; l; l = l->next) for (l = _xr_image_cache; l; l = l->next)
{ {
im = l->data; im = l->data;
if (!strcmp(im->fkey, fkey)) if (!strcmp(im->fkey, fkey))
{ {
_xr_image_cache = eina_list_remove_list(_xr_image_cache, l); _xr_image_cache = eina_list_remove_list(_xr_image_cache, l);
_xr_image_hash = evas_hash_add(_xr_image_hash, im->fkey, im); if (!_xr_image_hash) _xr_image_hash = eina_hash_string_superfast_new(NULL);
eina_hash_add(_xr_image_hash, im->fkey, im);
_xr_image_cache_usage -= (im->w * im->h * 4); _xr_image_cache_usage -= (im->w * im->h * 4);
break; break;
} }
@ -91,7 +93,7 @@ _xre_image_load(Ximage_Info *xinf, const char *file, const char *key, Evas_Image
{ {
return im; return im;
} }
im = calloc(1, sizeof(XR_Image)); im = calloc(1, sizeof(XR_Image));
if (!im) return NULL; if (!im) return NULL;
im->im = evas_common_load_image_from_file(file, key, lo); im->im = evas_common_load_image_from_file(file, key, lo);
@ -113,7 +115,8 @@ _xre_image_load(Ximage_Info *xinf, const char *file, const char *key, Evas_Image
if (im->im->info.comment) im->comment = eina_stringshare_add(im->im->info.comment); if (im->im->info.comment) im->comment = eina_stringshare_add(im->im->info.comment);
// if (im->im->info.format == 1) im->format = eina_stringshare_add("png"); // if (im->im->info.format == 1) im->format = eina_stringshare_add("png");
if (im->im->cache_entry.flags.alpha) im->alpha = 1; if (im->im->cache_entry.flags.alpha) im->alpha = 1;
_xr_image_hash = evas_hash_direct_add(_xr_image_hash, im->fkey, im); if (!_xr_image_hash) _xr_image_hash = eina_hash_string_superfast_new(NULL);
eina_hash_direct_add(_xr_image_hash, im->fkey, im);
return im; return im;
} }
@ -170,7 +173,7 @@ _xre_image_new_from_copied_data(Ximage_Info *xinf, int w, int h, void *data, int
if (data) if (data)
{ {
Gfx_Func_Copy func; Gfx_Func_Copy func;
func = evas_common_draw_func_copy_get(w * h, 0); func = evas_common_draw_func_copy_get(w * h, 0);
if (func) func(data, im->data, w * h); if (func) func(data, im->data, w * h);
evas_common_cpu_end_opt(); evas_common_cpu_end_opt();
@ -254,7 +257,7 @@ _xre_image_free(XR_Image *im)
if (!im->dirty) if (!im->dirty)
{ {
if (im->fkey) if (im->fkey)
_xr_image_hash = evas_hash_del(_xr_image_hash, im->fkey, im); eina_hash_del(_xr_image_hash, im->fkey, im);
_xr_image_cache = eina_list_prepend(_xr_image_cache, im); _xr_image_cache = eina_list_prepend(_xr_image_cache, im);
_xr_image_cache_usage += (im->w * im->h * 4); _xr_image_cache_usage += (im->w * im->h * 4);
_xre_image_cache_set(_xr_image_cache_size); _xre_image_cache_set(_xr_image_cache_size);
@ -282,7 +285,7 @@ _xre_image_dirty(XR_Image *im)
{ {
if (im->dirty) return; if (im->dirty) return;
if (im->fkey) if (im->fkey)
_xr_image_hash = evas_hash_del(_xr_image_hash, im->fkey, im); eina_hash_del(_xr_image_hash, im->fkey, im);
im->dirty = 1; im->dirty = 1;
__xre_image_dirty_hash_add(im); __xre_image_dirty_hash_add(im);
} }
@ -463,7 +466,7 @@ _xre_image_data_put(XR_Image *im, void *data)
if (!im->dirty) if (!im->dirty)
{ {
if (im->fkey) if (im->fkey)
_xr_image_hash = evas_hash_del(_xr_image_hash, im->fkey, im); eina_hash_del(_xr_image_hash, im->fkey, im);
im->dirty = 1; im->dirty = 1;
} }
if (im->updates) if (im->updates)

View File

@ -3,21 +3,21 @@
#include "evas_engine.h" #include "evas_engine.h"
#include "Evas_Engine_XRender_Xcb.h" #include "Evas_Engine_XRender_Xcb.h"
static Evas_Hash *_xr_fg_pool = NULL; static Eina_Hash *_xr_fg_pool = NULL;
XR_Font_Surface * XR_Font_Surface *
_xre_font_surface_new(Xcb_Image_Info *xcbinf, RGBA_Font_Glyph *fg) _xre_font_surface_new(Xcb_Image_Info *xcbinf, RGBA_Font_Glyph *fg)
{ {
char buf[256]; char buf[256];
char buf2[256]; char buf2[256];
XR_Font_Surface *fs; XR_Font_Surface *fs;
DATA8 *data; DATA8 *data;
int w, h, j; int w, h, j;
Xcb_Image_Image *xcim; Xcb_Image_Image *xcim;
Evas_Hash *pool; Eina_Hash *pool;
uint32_t mask; uint32_t mask;
uint32_t values[3]; uint32_t values[3];
data = fg->glyph_out->bitmap.buffer; data = fg->glyph_out->bitmap.buffer;
w = fg->glyph_out->bitmap.width; w = fg->glyph_out->bitmap.width;
h = fg->glyph_out->bitmap.rows; h = fg->glyph_out->bitmap.rows;
@ -32,11 +32,11 @@ _xre_font_surface_new(Xcb_Image_Info *xcbinf, RGBA_Font_Glyph *fg)
(fs->xcbinf->root == xcbinf->root)) (fs->xcbinf->root == xcbinf->root))
return fs; return fs;
snprintf(buf, sizeof(buf), "@%p@/@%x@", fs->xcbinf->conn, fs->xcbinf->root); snprintf(buf, sizeof(buf), "@%p@/@%x@", fs->xcbinf->conn, fs->xcbinf->root);
pool = evas_hash_find(_xr_fg_pool, buf); pool = eina_hash_find(_xr_fg_pool, buf);
if (pool) if (pool)
{ {
snprintf(buf, sizeof(buf), "%p", fg); snprintf(buf, sizeof(buf), "%p", fg);
fs = evas_hash_find(pool, buf); fs = eina_hash_find(pool, buf);
if (fs) return fs; if (fs) return fs;
} }
} }
@ -49,12 +49,14 @@ _xre_font_surface_new(Xcb_Image_Info *xcbinf, RGBA_Font_Glyph *fg)
fs->xcbinf->references++; fs->xcbinf->references++;
fs->w = w; fs->w = w;
fs->h = h; fs->h = h;
snprintf(buf, sizeof(buf), "@%p@/@%x@", fs->xcbinf->conn, fs->xcbinf->root); snprintf(buf, sizeof(buf), "@%p@/@%x@", fs->xcbinf->conn, fs->xcbinf->root);
pool = evas_hash_find(_xr_fg_pool, buf); pool = eina_hash_find(_xr_fg_pool, buf);
if (!pool) pool = eina_hash_string_superfast_new(NULL);
snprintf(buf2, sizeof(buf2), "%p", fg); snprintf(buf2, sizeof(buf2), "%p", fg);
pool = evas_hash_add(pool, buf2, fs); eina_hash_add(pool, buf2, fs);
_xr_fg_pool = evas_hash_add(_xr_fg_pool, buf, pool); if (!_xr_fg_pool) _xr_fg_pool = eina_hash_string_superfast_new(NULL);
eina_hash_add(_xr_fg_pool, buf, pool);
fs->draw = xcb_generate_id(xcbinf->conn); fs->draw = xcb_generate_id(xcbinf->conn);
xcb_create_pixmap(xcbinf->conn, xcbinf->fmt8->depth, fs->draw, xcbinf->root, w, h); xcb_create_pixmap(xcbinf->conn, xcbinf->fmt8->depth, fs->draw, xcbinf->root, w, h);
@ -129,17 +131,18 @@ _xre_font_surface_new(Xcb_Image_Info *xcbinf, RGBA_Font_Glyph *fg)
} }
static Evas_Bool static Evas_Bool
_xre_font_pool_cb(const Evas_Hash *hash, const char *key, void *data, void *fdata) _xre_font_pool_cb(const Eina_Hash *hash, const char *key, void *data, void *fdata)
{ {
char buf[256]; char buf[256];
Evas_Hash *pool; Eina_Hash *pool;
XR_Font_Surface *fs; XR_Font_Surface *fs;
fs = fdata; fs = fdata;
pool = data; pool = data;
snprintf(buf, sizeof(buf), "@%p@/@%x@", fs->xcbinf->conn, fs->xcbinf->root); snprintf(buf, sizeof(buf), "@%p@/@%x@", fs->xcbinf->conn, fs->xcbinf->root);
pool = evas_hash_del(pool, buf, fs); eina_hash_del(pool, buf, fs);
hash = evas_hash_modify(hash, key, pool); if (!hash) hash = eina_hash_string_superfast_new(NULL);
eina_hash_modify(hash, key, pool);
return 1; return 1;
} }
@ -147,7 +150,7 @@ void
_xre_font_surface_free(XR_Font_Surface *fs) _xre_font_surface_free(XR_Font_Surface *fs)
{ {
if (!fs) return; if (!fs) return;
evas_hash_foreach(_xr_fg_pool, _xre_font_pool_cb, fs); eina_hash_foreach(_xr_fg_pool, _xre_font_pool_cb, fs);
xcb_free_pixmap(fs->xcbinf->conn, fs->draw); xcb_free_pixmap(fs->xcbinf->conn, fs->draw);
xcb_render_free_picture(fs->xcbinf->conn, fs->pic); xcb_render_free_picture(fs->xcbinf->conn, fs->pic);
_xr_image_info_free(fs->xcbinf); _xr_image_info_free(fs->xcbinf);

View File

@ -3,11 +3,11 @@
#include "evas_engine.h" #include "evas_engine.h"
#include "Evas_Engine_XRender_Xcb.h" #include "Evas_Engine_XRender_Xcb.h"
static Evas_Hash *_xr_image_hash = NULL; static Eina_Hash *_xr_image_hash = NULL;
static int _xr_image_cache_size = 0; static int _xr_image_cache_size = 0;
static int _xr_image_cache_usage = 0; static int _xr_image_cache_usage = 0;
static Eina_List *_xr_image_cache = NULL; static Eina_List *_xr_image_cache = NULL;
static Evas_Hash *_xr_image_dirty_hash = NULL; static Eina_Hash *_xr_image_dirty_hash = NULL;
static void static void
__xre_image_dirty_hash_add(XR_Image *im) __xre_image_dirty_hash_add(XR_Image *im)
@ -16,7 +16,8 @@ __xre_image_dirty_hash_add(XR_Image *im)
if (!im->data) return; if (!im->data) return;
snprintf(buf, sizeof(buf), "%p", im->data); snprintf(buf, sizeof(buf), "%p", im->data);
_xr_image_dirty_hash = evas_hash_add(_xr_image_dirty_hash, buf, im); if (!_xr_image_dirty_hash) _xr_image_dirty_hash = eina_hash_string_superfast_new(NULL);
eina_hash_add(_xr_image_dirty_hash, buf, im);
} }
static void static void
@ -26,7 +27,7 @@ __xre_image_dirty_hash_del(XR_Image *im)
if (!im->data) return; if (!im->data) return;
snprintf(buf, sizeof(buf), "%p", im->data); snprintf(buf, sizeof(buf), "%p", im->data);
_xr_image_dirty_hash = evas_hash_del(_xr_image_dirty_hash, buf, im); eina_hash_del(_xr_image_dirty_hash, buf, im);
} }
static XR_Image * static XR_Image *
@ -35,7 +36,7 @@ __xre_image_dirty_hash_find(void *data)
char buf[64]; char buf[64];
snprintf(buf, sizeof(buf), "%p", data); snprintf(buf, sizeof(buf), "%p", data);
return evas_hash_find(_xr_image_dirty_hash, buf); return eina_hash_find(_xr_image_dirty_hash, buf);
} }
static XR_Image * static XR_Image *
@ -43,7 +44,7 @@ __xre_image_find(char *fkey)
{ {
XR_Image *im; XR_Image *im;
im = evas_hash_find(_xr_image_hash, fkey); im = eina_hash_find(_xr_image_hash, fkey);
if (!im) if (!im)
{ {
Eina_List *l; Eina_List *l;
@ -53,7 +54,8 @@ __xre_image_find(char *fkey)
if (!strcmp(im->fkey, fkey)) if (!strcmp(im->fkey, fkey))
{ {
_xr_image_cache = eina_list_remove_list(_xr_image_cache, l); _xr_image_cache = eina_list_remove_list(_xr_image_cache, l);
_xr_image_hash = evas_hash_add(_xr_image_hash, im->fkey, im); if (!_xr_image_hash) _xr_image_hash = eina_hash_string_superfast_new(NULL);
eina_hash_add(_xr_image_hash, im->fkey, im);
_xr_image_cache_usage -= (im->w * im->h * 4); _xr_image_cache_usage -= (im->w * im->h * 4);
break; break;
} }
@ -111,7 +113,8 @@ _xre_image_load(Xcb_Image_Info *xcbinf, const char *file, const char *key, Evas_
if (im->im->info.comment) im->comment = (char *)eina_stringshare_add(im->im->info.comment); if (im->im->info.comment) im->comment = (char *)eina_stringshare_add(im->im->info.comment);
/* if (im->im->info.format == 1) im->format = eina_stringshare_add("png"); */ /* if (im->im->info.format == 1) im->format = eina_stringshare_add("png"); */
if (im->im->cache_entry.flags.alpha) im->alpha = 1; if (im->im->cache_entry.flags.alpha) im->alpha = 1;
_xr_image_hash = evas_hash_direct_add(_xr_image_hash, im->fkey, im); if (!_xr_image_hash) _xr_image_hash = eina_hash_string_superfast_new(NULL);
_xr_image_hash = eina_hash_direct_add(_xr_image_hash, im->fkey, im);
return im; return im;
} }
@ -217,7 +220,7 @@ _xre_image_free(XR_Image *im)
if (!im->dirty) if (!im->dirty)
{ {
if (im->fkey) if (im->fkey)
_xr_image_hash = evas_hash_del(_xr_image_hash, im->fkey, im); eina_hash_del(_xr_image_hash, im->fkey, im);
_xr_image_cache = eina_list_prepend(_xr_image_cache, im); _xr_image_cache = eina_list_prepend(_xr_image_cache, im);
_xr_image_cache_usage += (im->w * im->h * 4); _xr_image_cache_usage += (im->w * im->h * 4);
_xre_image_cache_set(_xr_image_cache_size); _xre_image_cache_set(_xr_image_cache_size);
@ -245,7 +248,7 @@ _xre_image_dirty(XR_Image *im)
{ {
if (im->dirty) return; if (im->dirty) return;
if (im->fkey) if (im->fkey)
_xr_image_hash = evas_hash_del(_xr_image_hash, im->fkey, im); eina_hash_del(_xr_image_hash, im->fkey, im);
im->dirty = 1; im->dirty = 1;
__xre_image_dirty_hash_add(im); __xre_image_dirty_hash_add(im);
} }
@ -441,7 +444,7 @@ _xre_image_data_put(XR_Image *im, void *data)
if (!im->dirty) if (!im->dirty)
{ {
if (im->fkey) if (im->fkey)
_xr_image_hash = evas_hash_del(_xr_image_hash, im->fkey, im); eina_hash_del(_xr_image_hash, im->fkey, im);
im->dirty = 1; im->dirty = 1;
} }
if (im->updates) if (im->updates)