forked from enlightenment/efl
evas: Try to reuse glyph array if possible
This sould bring back a little bit of text rendering performance, while at the same time decreasing memory usage and fragmentation. Patch by: Leandro Pereira <leandro@profusion.mobi> SVN revision: 82660
This commit is contained in:
parent
468b44c444
commit
a868276f11
|
@ -244,6 +244,7 @@ evas_common_font_draw_prepare(Evas_Text_Props *text_props)
|
||||||
RGBA_Font_Glyph *fg;
|
RGBA_Font_Glyph *fg;
|
||||||
Eina_Inarray *glyphs;
|
Eina_Inarray *glyphs;
|
||||||
size_t unit = 32;
|
size_t unit = 32;
|
||||||
|
Eina_Bool reused_glyphs;
|
||||||
EVAS_FONT_WALK_TEXT_INIT();
|
EVAS_FONT_WALK_TEXT_INIT();
|
||||||
|
|
||||||
fi = text_props->font_instance;
|
fi = text_props->font_instance;
|
||||||
|
@ -253,7 +254,17 @@ evas_common_font_draw_prepare(Evas_Text_Props *text_props)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (text_props->len < unit) unit = text_props->len;
|
if (text_props->len < unit) unit = text_props->len;
|
||||||
glyphs = eina_inarray_new(sizeof(Evas_Glyph), unit);
|
if (text_props->glyphs && text_props->glyphs->refcount == 1)
|
||||||
|
{
|
||||||
|
glyphs = text_props->glyphs->array;
|
||||||
|
glyphs->len = 0;
|
||||||
|
reused_glyphs = EINA_TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glyphs = eina_inarray_new(sizeof(Evas_Glyph), unit);
|
||||||
|
reused_glyphs = EINA_FALSE;
|
||||||
|
}
|
||||||
evas_common_font_int_reload(fi);
|
evas_common_font_int_reload(fi);
|
||||||
|
|
||||||
if (fi->src->current_size != fi->size)
|
if (fi->src->current_size != fi->size)
|
||||||
|
@ -286,18 +297,21 @@ evas_common_font_draw_prepare(Evas_Text_Props *text_props)
|
||||||
}
|
}
|
||||||
EVAS_FONT_WALK_TEXT_END();
|
EVAS_FONT_WALK_TEXT_END();
|
||||||
|
|
||||||
/*
|
if (!reused_glyphs)
|
||||||
* Clearing the reference to the glyph array is fine, since this
|
{
|
||||||
* reference is only used to use this from another thread, which is now
|
/*
|
||||||
* holding the reference.
|
* Clearing the reference to the glyph array is fine, since this
|
||||||
*/
|
* reference is only used to use this from another thread, which is now
|
||||||
if (text_props->glyphs)
|
* holding the reference.
|
||||||
evas_common_font_glyphs_unref(text_props->glyphs);
|
*/
|
||||||
|
if (text_props->glyphs)
|
||||||
|
evas_common_font_glyphs_unref(text_props->glyphs);
|
||||||
|
|
||||||
text_props->glyphs = malloc(sizeof(*text_props->glyphs));
|
text_props->glyphs = malloc(sizeof(*text_props->glyphs));
|
||||||
if (!text_props->glyphs) goto error;
|
if (!text_props->glyphs) goto error;
|
||||||
text_props->glyphs->refcount = 1;
|
text_props->glyphs->refcount = 1;
|
||||||
text_props->glyphs->array = glyphs;
|
text_props->glyphs->array = glyphs;
|
||||||
|
}
|
||||||
|
|
||||||
/* check if there's a request queue in fi, if so ask cserve2 to render
|
/* check if there's a request queue in fi, if so ask cserve2 to render
|
||||||
* those glyphs
|
* those glyphs
|
||||||
|
|
Loading…
Reference in New Issue