evas/async_render: do not use async event to unref glyphs

Patch by: Leandro Pereira <leandro@profusion.mobi>



SVN revision: 82662
This commit is contained in:
Leandro Pereira 2013-01-11 19:55:40 +00:00 committed by Ulisses Furquim
parent ed79c2182e
commit d5f91fd5c2
11 changed files with 91 additions and 38 deletions

View File

@ -143,6 +143,7 @@ _constructor(Eo *eo_obj, void *class_data, va_list *list EINA_UNUSED)
EVAS_ARRAY_SET(e, calculate_objects);
EVAS_ARRAY_SET(e, clip_changes);
EVAS_ARRAY_SET(e, image_unref_queue);
EVAS_ARRAY_SET(e, glyph_unref_queue);
#undef EVAS_ARRAY_SET
}
@ -249,6 +250,7 @@ _destructor(Eo *eo_e, void *_pd, va_list *list EINA_UNUSED)
eina_array_flush(&e->calculate_objects);
eina_array_flush(&e->clip_changes);
eina_array_flush(&e->image_unref_queue);
eina_array_flush(&e->glyph_unref_queue);
EINA_LIST_FREE(e->touch_points, touch_point)
free(touch_point);

View File

@ -1886,6 +1886,25 @@ evas_object_text_free(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
#endif
}
void
evas_font_draw_async_check(Evas_Object_Protected_Data *obj,
void *data, void *context, void *surface,
Evas_Font_Set *font,
int x, int y, int w, int h, int ow, int oh,
Evas_Text_Props *intl_props, Eina_Bool do_async)
{
Eina_Bool async_unref;
async_unref = obj->layer->evas->engine.func->font_draw(data, context, surface,
font, x, y, w, h, ow, oh,
intl_props, do_async);
if (do_async && async_unref)
{
evas_common_font_glyphs_ref(intl_props->glyphs);
evas_unref_queue_glyph_put(obj->layer->evas, intl_props->glyphs);
}
}
static void
evas_object_text_render(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, void *output, void *context, void *surface, int x, int y, Eina_Bool do_async)
{
@ -1964,22 +1983,22 @@ evas_object_text_render(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, vo
(((int)object->sub.col.b) * (amul)) / 255, \
(((int)object->sub.col.a) * (amul)) / 255);
#define DRAW_TEXT(ox, oy) \
if ((o->font) && (it->text_props.len > 0)) \
ENFN->font_draw(output, \
context, \
surface, \
o->font, \
obj->cur.geometry.x + x + sl + ox + it->x, \
obj->cur.geometry.y + y + st + oy + \
(int) \
(((o->max_ascent * obj->cur.geometry.h) / obj->cur.geometry.h)), \
obj->cur.geometry.w, \
obj->cur.geometry.h, \
obj->cur.geometry.w, \
obj->cur.geometry.h, \
&it->text_props, \
do_async);
#define DRAW_TEXT(ox, oy) \
if ((o->font) && (it->text_props.len > 0)) \
evas_font_draw_async_check(obj, output, \
context, \
surface, \
o->font, \
obj->cur.geometry.x + x + sl + ox + it->x, \
obj->cur.geometry.y + y + st + oy + \
(int) \
(((o->max_ascent * obj->cur.geometry.h) / obj->cur.geometry.h)), \
obj->cur.geometry.w, \
obj->cur.geometry.h, \
obj->cur.geometry.w, \
obj->cur.geometry.h, \
&it->text_props, \
do_async);
/* shadows */
shad_dst = shad_sz = dx = dy = haveshad = 0;

View File

@ -10297,12 +10297,14 @@ evas_object_textblock_render(Evas_Object *eo_obj, Evas_Object_Protected_Data *ob
(obj->cur.cache.clip.g * ti->parent.format->color.col.g * (amul)) / 65025, \
(obj->cur.cache.clip.b * ti->parent.format->color.col.b * (amul)) / 65025, \
(obj->cur.cache.clip.a * ti->parent.format->color.col.a * (amul)) / 65025);
#define DRAW_TEXT(ox, oy) \
if (ti->parent.format->font.font) ENFN->font_draw(output, context, surface, ti->parent.format->font.font, \
obj->cur.geometry.x + ln->x + ti->parent.x + x + (ox), \
obj->cur.geometry.y + ln->par->y + ln->y + yoff + y + (oy), \
ti->parent.w, ti->parent.h, ti->parent.w, ti->parent.h, \
&ti->text_props, do_async);
#define DRAW_TEXT(ox, oy) \
if (ti->parent.format->font.font) \
evas_font_draw_async_check(obj, output, context, surface, \
ti->parent.format->font.font, \
obj->cur.geometry.x + ln->x + ti->parent.x + x + (ox), \
obj->cur.geometry.y + ln->par->y + ln->y + yoff + y + (oy), \
ti->parent.w, ti->parent.h, ti->parent.w, ti->parent.h, \
&ti->text_props, do_async);
/* backing */
#define DRAW_RECT(ox, oy, ow, oh, or, og, ob, oa) \

View File

@ -678,11 +678,11 @@ evas_object_textgrid_render(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj
ENFN->context_color_set(output, context,
row->texts[xx].r, row->texts[xx].g,
row->texts[xx].b, row->texts[xx].a);
ENFN->font_draw(output, context, surface, o->font,
xp + row->texts[xx].x, yp + o->max_ascent,
ww, hh, ww, hh,
evas_object_textgrid_textprop_int_to(o, row->texts[xx].text_props),
do_async);
evas_font_draw_async_check(obj, output, context, surface, o->font,
xp + row->texts[xx].x, yp + o->max_ascent,
ww, hh, ww, hh,
evas_object_textgrid_textprop_int_to(o, row->texts[xx].text_props),
do_async);
}
for (xx = 0; xx < row->lines_num; xx++)
{

View File

@ -1831,6 +1831,13 @@ evas_render_updates_internal(Evas *eo_e,
return EINA_TRUE;
}
static Eina_Bool
_drop_glyph_ref(const void *container EINA_UNUSED, void *data, void *fdata EINA_UNUSED)
{
evas_common_font_glyphs_unref(data);
return EINA_TRUE;
}
static void
evas_render_wakeup(Evas *eo_e)
{
@ -1868,9 +1875,11 @@ evas_render_wakeup(Evas *eo_e)
/* clear redraws */
e->engine.func->output_redraws_clear(e->engine.data.output);
/* unref queue */
/* unref queues */
eina_array_foreach(&e->image_unref_queue, _drop_image_cache_ref, NULL);
eina_array_clean(&e->image_unref_queue);
eina_array_foreach(&e->glyph_unref_queue, _drop_glyph_ref, NULL);
eina_array_clean(&e->glyph_unref_queue);
evas_event_callback_call(eo_e, EVAS_CALLBACK_RENDER_POST, NULL);
@ -2149,4 +2158,10 @@ evas_unref_queue_image_put(Evas_Public_Data *pd, void *image)
eina_array_push(&pd->image_unref_queue, image);
}
void
evas_unref_queue_glyph_put(Evas_Public_Data *pd, void *glyph)
{
eina_array_push(&pd->glyph_unref_queue, glyph);
}
/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/

View File

@ -387,6 +387,7 @@ struct _Evas_Public_Data
Eina_Array calculate_objects;
Eina_Array clip_changes;
Eina_Array image_unref_queue;
Eina_Array glyph_unref_queue;
Eina_Clist calc_list;
Eina_Clist calc_done;
@ -847,8 +848,7 @@ struct _Evas_Func
int (*font_v_advance_get) (void *data, Evas_Font_Set *font, const Evas_Text_Props *intl_props);
int (*font_char_coords_get) (void *data, Evas_Font_Set *font, const Evas_Text_Props *intl_props, int pos, int *cx, int *cy, int *cw, int *ch);
int (*font_char_at_coords_get) (void *data, Evas_Font_Set *font, const Evas_Text_Props *intl_props, int x, int y, int *cx, int *cy, int *cw, int *ch);
void (*font_draw) (void *data, void *context, void *surface, Evas_Font_Set *font, int x, int y, int w, int h, int ow, int oh, Evas_Text_Props *intl_props, Eina_Bool do_async);
Eina_Bool (*font_draw) (void *data, void *context, void *surface, Evas_Font_Set *font, int x, int y, int w, int h, int ow, int oh, Evas_Text_Props *intl_props, Eina_Bool do_async);
void (*font_cache_flush) (void *data);
void (*font_cache_set) (void *data, int bytes);
int (*font_cache_get) (void *data);
@ -1050,6 +1050,13 @@ void _evas_object_text_rehint(Evas_Object *obj);
void _evas_object_textblock_rehint(Evas_Object *obj);
void evas_unref_queue_image_put(Evas_Public_Data *pd, void *image);
void evas_unref_queue_glyph_put(Evas_Public_Data *pd, void *glyph);
void evas_font_draw_async_check(Evas_Object_Protected_Data *obj,
void *data, void *context, void *surface,
Evas_Font_Set *font,
int x, int y, int w, int h, int ow, int oh,
Evas_Text_Props *intl_props, Eina_Bool do_async);
void _freeze_events_set(Eo *obj, void *_pd, va_list *list);
void _freeze_events_get(Eo *obj, void *_pd, va_list *list);

View File

@ -1028,7 +1028,7 @@ eng_image_stride_get(void *data EINA_UNUSED, void *image, int *stride)
}
}
static void
static Eina_Bool
eng_font_draw(void *data, void *context, void *surface, Evas_Font_Set *font, int x, int y, int w EINA_UNUSED, int h EINA_UNUSED, int ow EINA_UNUSED, int oh EINA_UNUSED, Evas_Text_Props *intl_props)
{
Render_Engine *re;
@ -1058,6 +1058,8 @@ eng_font_draw(void *data, void *context, void *surface, Evas_Font_Set *font, int
NULL,
NULL);
}
return EINA_FALSE;
}

View File

@ -902,7 +902,7 @@ eng_image_scale_hint_get(void *data EINA_UNUSED, void *image)
return gim->scale_hint;
}
static void
static Eina_Bool
eng_font_draw(void *data, void *context, void *surface, Evas_Font_Set *font, int x, int y, int w EINA_UNUSED, int h EINA_UNUSED, int ow EINA_UNUSED, int oh EINA_UNUSED, Evas_Text_Props *intl_props)
{
Render_Engine *re;
@ -931,6 +931,8 @@ eng_font_draw(void *data, void *context, void *surface, Evas_Font_Set *font, int
NULL,
NULL);
}
return EINA_FALSE;
}
static Eina_Bool

View File

@ -2607,7 +2607,7 @@ eng_image_stride_get(void *data EINA_UNUSED, void *image, int *stride)
*stride = im->w * 4;
}
static void
static Eina_Bool
eng_font_draw(void *data, void *context, void *surface, Evas_Font_Set *font EINA_UNUSED, int x, int y, int w EINA_UNUSED, int h EINA_UNUSED, int ow EINA_UNUSED, int oh EINA_UNUSED, Evas_Text_Props *intl_props, Eina_Bool do_async EINA_UNUSED)
{
Render_Engine *re;
@ -2638,6 +2638,8 @@ eng_font_draw(void *data, void *context, void *surface, Evas_Font_Set *font EINA
NULL,
NULL);
}
return EINA_FALSE;
}
static Eina_Bool

View File

@ -1935,8 +1935,6 @@ _draw_thread_font_draw(void *data)
font->ext.x, font->ext.y, font->ext.w, font->ext.h,
font->im_w, font->im_h);
evas_async_events_put(font->glyphs, 0, NULL,
(Evas_Async_Events_Put_Cb)evas_common_font_glyphs_unref);
eina_mempool_free(_mp_command_font, font);
}
@ -1965,11 +1963,10 @@ _font_draw_thread_cmd(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, Evas
cf->im_w = im_w;
cf->im_h = im_h;
evas_common_font_glyphs_ref(glyphs);
evas_thread_cmd_enqueue(_draw_thread_font_draw, cf);
}
static void
static Eina_Bool
eng_font_draw(void *data EINA_UNUSED, void *context, void *surface, Evas_Font_Set *font EINA_UNUSED, int x, int y, int w EINA_UNUSED, int h EINA_UNUSED, int ow EINA_UNUSED, int oh EINA_UNUSED, Evas_Text_Props *text_props, Eina_Bool do_async)
{
if (do_async)
@ -1977,6 +1974,7 @@ eng_font_draw(void *data EINA_UNUSED, void *context, void *surface, Evas_Font_Se
evas_common_font_draw_prepare(text_props);
evas_common_font_draw_cb(surface, context, x, y, text_props->glyphs,
_font_draw_thread_cmd);
return EINA_TRUE;
}
#ifdef BUILD_PIPE_RENDER
else if ((cpunum > 1))
@ -1988,6 +1986,8 @@ eng_font_draw(void *data EINA_UNUSED, void *context, void *surface, Evas_Font_Se
evas_common_font_draw(surface, context, x, y, text_props->glyphs);
evas_common_cpu_end_opt();
}
return EINA_FALSE;
}
static void

View File

@ -2048,7 +2048,7 @@ eng_image_stride_get(void *data EINA_UNUSED, void *image, int *stride)
*stride = im->w * 4;
}
static void
static Eina_Bool
eng_font_draw(void *data, void *context, void *surface, Evas_Font_Set *font EINA_UNUSED, int x, int y, int w EINA_UNUSED, int h EINA_UNUSED, int ow EINA_UNUSED, int oh EINA_UNUSED, Evas_Text_Props *intl_props)
{
Render_Engine *re;
@ -2074,6 +2074,8 @@ eng_font_draw(void *data, void *context, void *surface, Evas_Font_Set *font EINA
evas_common_font_draw(im, context, x, y, intl_props->glyphs);
evas_common_draw_context_font_ext_set(context, NULL, NULL, NULL, NULL);
}
return EINA_FALSE;
}
static Eina_Bool