dont realod ye demons of evil slowness! FIX FIX! cache you biotch! cache!
SVN revision: 14055
This commit is contained in:
parent
6425209481
commit
f047113949
|
@ -7,6 +7,19 @@
|
|||
|
||||
/* font dir cache */
|
||||
static Evas_Hash *font_dirs = NULL;
|
||||
static Evas_List *fonts_cache = NULL;
|
||||
static Evas_List *fonts_zero = NULL;
|
||||
|
||||
typedef struct _Fndat Fndat;
|
||||
|
||||
struct _Fndat
|
||||
{
|
||||
char *name;
|
||||
char *source;
|
||||
int size;
|
||||
void *font;
|
||||
int ref;
|
||||
};
|
||||
|
||||
/* private methods for font dir cache */
|
||||
static Evas_Bool font_cache_dir_free(Evas_Hash *hash, const char *key, void *data, void *fdata);
|
||||
|
@ -27,6 +40,30 @@ evas_font_dir_cache_free(void)
|
|||
evas_hash_foreach (font_dirs, font_cache_dir_free, NULL);
|
||||
evas_hash_free (font_dirs);
|
||||
font_dirs = NULL;
|
||||
/*
|
||||
while (fonts_cache)
|
||||
{
|
||||
Fndat *fd;
|
||||
|
||||
fd = evas_list_data(fonts_cache);
|
||||
fonts_cache = evas_list_remove_list(fonts_cache, fonts_cache);
|
||||
if (fd->name) free(fd->name);
|
||||
if (fd->source) free(fd->source);
|
||||
evas->engine.func->font_free(evas->engine.data.output, fd->font);
|
||||
free(fd);
|
||||
}
|
||||
while (fonts_zero)
|
||||
{
|
||||
Fndat *fd;
|
||||
|
||||
fd = evas_list_data(fonts_zero);
|
||||
fonts_zero = evas_list_remove_list(fonts_zero, fonts_zero);
|
||||
if (fd->name) free(fd->name);
|
||||
if (fd->source) free(fd->source);
|
||||
evas->engine.func->font_free(evas->engine.data.output, fd->font);
|
||||
free(fd);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
char *
|
||||
|
@ -41,7 +78,10 @@ evas_font_dir_cache_find(char *dir, char *font)
|
|||
Evas_Font *fn;
|
||||
|
||||
fn = object_text_font_cache_font_find(fd, font);
|
||||
if (fn) return fn->path;
|
||||
if (fn)
|
||||
{
|
||||
return fn->path;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -76,12 +116,85 @@ evas_font_set_get(char *name)
|
|||
return fonts;
|
||||
}
|
||||
|
||||
void
|
||||
evas_font_free(Evas *evas, void *font)
|
||||
{
|
||||
Evas_List *l;
|
||||
|
||||
for (l = fonts_cache; l; l = l->next)
|
||||
{
|
||||
Fndat *fd;
|
||||
|
||||
fd = l->data;
|
||||
if (fd->font == font)
|
||||
{
|
||||
fd->ref--;
|
||||
if (fd->ref == 0)
|
||||
{
|
||||
fonts_cache = evas_list_remove_list(fonts_cache, l);
|
||||
fonts_zero = evas_list_append(fonts_zero, fd);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
while ((fonts_zero) &&
|
||||
(evas_list_count(fonts_zero) > 4)) /* 4 is arbitrary */
|
||||
{
|
||||
Fndat *fd;
|
||||
|
||||
fd = evas_list_data(fonts_zero);
|
||||
if (fd->ref != 0) break;
|
||||
fonts_zero = evas_list_remove_list(fonts_zero, fonts_zero);
|
||||
if (fd->name) free(fd->name);
|
||||
if (fd->source) free(fd->source);
|
||||
evas->engine.func->font_free(evas->engine.data.output, fd->font);
|
||||
free(fd);
|
||||
}
|
||||
}
|
||||
|
||||
void *
|
||||
evas_font_load(Evas *evas, char *name, char *source, int size)
|
||||
{
|
||||
void *font = NULL;
|
||||
Evas_List *fonts, *l;
|
||||
|
||||
Fndat *fd;
|
||||
|
||||
for (l = fonts_cache; l; l = l->next)
|
||||
{
|
||||
fd = l->data;
|
||||
if (!strcmp(name, fd->name))
|
||||
{
|
||||
if (((!source) && (!fd->source)) ||
|
||||
((source) && (fd->source) && (!strcmp(source, fd->source))))
|
||||
{
|
||||
if (size == fd->size)
|
||||
{
|
||||
fonts_cache = evas_list_remove_list(fonts_cache, l);
|
||||
fonts_cache = evas_list_prepend(fonts_cache, fd);
|
||||
fd->ref++;
|
||||
return fd->font;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (l = fonts_zero; l; l = l->next)
|
||||
{
|
||||
fd = l->data;
|
||||
if (!strcmp(name, fd->name))
|
||||
{
|
||||
if (((!source) && (!fd->source)) ||
|
||||
((source) && (fd->source) && (!strcmp(source, fd->source))))
|
||||
{
|
||||
if (size == fd->size)
|
||||
{
|
||||
fonts_zero = evas_list_remove_list(fonts_zero, l);
|
||||
fonts_cache = evas_list_prepend(fonts_cache, fd);
|
||||
fd->ref++;
|
||||
return fd->font;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fonts = evas_font_set_get(name);
|
||||
for (l = fonts; l; l = l->next)
|
||||
{
|
||||
|
@ -211,6 +324,16 @@ evas_font_load(Evas *evas, char *name, char *source, int size)
|
|||
free(nm);
|
||||
}
|
||||
evas_list_free(fonts);
|
||||
fd = calloc(1, sizeof(Fndat));
|
||||
if (fd)
|
||||
{
|
||||
fd->name = strdup(name);
|
||||
if (source) fd->source = strdup(source);
|
||||
fd->size = size;
|
||||
fd->font = font;
|
||||
fd->ref = 1;
|
||||
fonts_cache = evas_list_prepend(fonts_cache, fd);
|
||||
}
|
||||
return font;
|
||||
}
|
||||
|
||||
|
@ -220,7 +343,6 @@ static Evas_Bool
|
|||
font_cache_dir_free(Evas_Hash *hash, const char *key, void *data, void *fdata)
|
||||
{
|
||||
object_text_font_cache_dir_del((char *) key, data);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -160,8 +160,7 @@ evas_object_text_font_set(Evas_Object *obj, const char *font, Evas_Font_Size siz
|
|||
/* DO IT */
|
||||
if (o->engine_data)
|
||||
{
|
||||
obj->layer->evas->engine.func->font_free(obj->layer->evas->engine.data.output,
|
||||
o->engine_data);
|
||||
evas_font_free(obj->layer->evas, o->engine_data);
|
||||
o->engine_data = NULL;
|
||||
}
|
||||
o->engine_data = evas_font_load(obj->layer->evas, font, o->cur.source, size);
|
||||
|
@ -826,9 +825,7 @@ evas_object_text_free(Evas_Object *obj)
|
|||
if (o->cur.text) free(o->cur.text);
|
||||
if (o->cur.font) free(o->cur.font);
|
||||
if (o->cur.source) free(o->cur.source);
|
||||
if (o->engine_data)
|
||||
obj->layer->evas->engine.func->font_free(obj->layer->evas->engine.data.output,
|
||||
o->engine_data);
|
||||
if (o->engine_data) evas_font_free(obj->layer->evas, o->engine_data);
|
||||
o->magic = 0;
|
||||
free(o);
|
||||
}
|
||||
|
|
|
@ -842,7 +842,7 @@ evas_object_textblock_layout_clear(Evas_Object *obj, Layout *layout)
|
|||
{
|
||||
if (layout->font.name) free(layout->font.name);
|
||||
if (layout->font.source) free(layout->font.source);
|
||||
if (layout->font.font) ENFN->font_free(ENDT, layout->font.font);
|
||||
if (layout->font.font) evas_font_free(obj->layer->evas, layout->font.font);
|
||||
memset(layout, 0, sizeof(Layout));
|
||||
}
|
||||
|
||||
|
@ -876,7 +876,7 @@ evas_object_textblock_layout_fonts_hold_clean(Evas_Object *obj)
|
|||
|
||||
while (o->font_hold)
|
||||
{
|
||||
ENFN->font_free(ENDT, o->font_hold->data);
|
||||
evas_font_free(obj->layer->evas, o->font_hold->data);
|
||||
o->font_hold = evas_list_remove_list(o->font_hold, o->font_hold);
|
||||
}
|
||||
}
|
||||
|
@ -1086,7 +1086,7 @@ evas_object_textblock_layout_internal(Evas_Object *obj, int w, int h, int *forma
|
|||
if (layout.line.mdescent < layout.line.descent)
|
||||
layout.line.mdescent = layout.line.descent;
|
||||
if (layout.font.font)
|
||||
ENFN->font_free(ENDT, layout.font.font);
|
||||
evas_font_free(obj->layer->evas, layout.font.font);
|
||||
layout.font.font = NULL;
|
||||
}
|
||||
if ((layout.line.y + layout.line.mascent + layout.line.mdescent) > hh)
|
||||
|
|
|
@ -398,7 +398,7 @@ evas_common_image_unstore(RGBA_Image *im)
|
|||
RGBA_Image *
|
||||
evas_common_image_find(const char *filename, const char *key, DATA64 timestamp)
|
||||
{
|
||||
char *real_filename;
|
||||
char *real_filename = NULL;
|
||||
Evas_Object_List *l;
|
||||
RGBA_Image *im;
|
||||
char *str;
|
||||
|
@ -407,7 +407,7 @@ evas_common_image_find(const char *filename, const char *key, DATA64 timestamp)
|
|||
|
||||
if ((!filename) && (!key)) return NULL;
|
||||
if (!filename) return NULL;
|
||||
real_filename = evas_file_path_resolve((char *)filename);
|
||||
// real_filename = evas_file_path_resolve((char *)filename);
|
||||
l1 = 0;
|
||||
if (real_filename) l1 = strlen(real_filename);
|
||||
else if (filename) l1 = strlen(filename);
|
||||
|
@ -442,7 +442,7 @@ evas_common_image_find(const char *filename, const char *key, DATA64 timestamp)
|
|||
|
||||
im = (RGBA_Image *)l;
|
||||
ok = 0;
|
||||
if (real_filename)
|
||||
if ((real_filename) && (im->info.real_file))
|
||||
{
|
||||
if ((im->info.real_file) &&
|
||||
(real_filename) &&
|
||||
|
|
|
@ -692,6 +692,7 @@ void evas_object_grabs_cleanup(Evas_Object *obj);
|
|||
void evas_key_grab_free(Evas_Object *obj, const char *keyname, Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers);
|
||||
void evas_font_dir_cache_free(void);
|
||||
char *evas_font_dir_cache_find(char *dir, char *font);
|
||||
void evas_font_free(Evas *evas, void *font);
|
||||
void *evas_font_load(Evas *evas, char *name, char *source, int size);
|
||||
|
||||
extern int _evas_alloc_error;
|
||||
|
|
Loading…
Reference in New Issue