diff options
author | Jean-Philippe Andre <jp.andre@samsung.com> | 2013-10-07 21:39:16 +0900 |
---|---|---|
committer | Cedric Bail <cedric.bail@free.fr> | 2013-10-17 20:49:23 +0900 |
commit | 9c1b7306c1e431ef0a85ea80114f7a230399f2a2 (patch) | |
tree | 436669c6174366c6b8c195ea25be0cf7773ff325 | |
parent | 906047adf84efe881040610ed506fdb70f03f56c (diff) | |
download | efl-9c1b7306c1e431ef0a85ea80114f7a230399f2a2.tar.gz |
evas/cserve2: Fix glyph refcount even more
Maybe a little overkill on the iterations (ref/unref)
-rw-r--r-- | src/lib/evas/common/evas_font_draw.c | 17 | ||||
-rw-r--r-- | src/lib/evas/cserve2/evas_cs2_client.c | 41 |
2 files changed, 53 insertions, 5 deletions
diff --git a/src/lib/evas/common/evas_font_draw.c b/src/lib/evas/common/evas_font_draw.c index 5670b0d6e1..02f681c93f 100644 --- a/src/lib/evas/common/evas_font_draw.c +++ b/src/lib/evas/common/evas_font_draw.c @@ -304,6 +304,18 @@ evas_common_font_draw_prepare(Evas_Text_Props *text_props) if (text_props->len < unit) unit = text_props->len; if (text_props->glyphs && text_props->glyphs->refcount == 1) { +#ifdef EVAS_CSERVE2 + if (evas_cserve2_use_get()) + { + Eina_Iterator *iter; + Evas_Glyph *glyph; + + iter = eina_inarray_iterator_new(text_props->glyphs->array); + EINA_ITERATOR_FOREACH(iter, glyph) + evas_cserve2_font_glyph_ref(glyph->fg->glyph_out, EINA_FALSE); + eina_iterator_free(iter); + } +#endif glyphs = text_props->glyphs->array; glyphs->len = 0; reused_glyphs = EINA_TRUE; @@ -348,6 +360,11 @@ evas_common_font_draw_prepare(Evas_Text_Props *text_props) glyph->idx = idx; glyph->coord.x = EVAS_FONT_WALK_PEN_X + EVAS_FONT_WALK_X_OFF + EVAS_FONT_WALK_X_BEAR; glyph->coord.y = EVAS_FONT_WALK_PEN_Y + EVAS_FONT_WALK_Y_OFF + EVAS_FONT_WALK_Y_BEAR; + +#ifdef EVAS_CSERVE2 + if (reused_glyphs && evas_cserve2_use_get()) + evas_cserve2_font_glyph_ref(glyph->fg->glyph_out, EINA_TRUE); +#endif } EVAS_FONT_WALK_TEXT_END(); diff --git a/src/lib/evas/cserve2/evas_cs2_client.c b/src/lib/evas/cserve2/evas_cs2_client.c index aaba8d98e3..64e335afdf 100644 --- a/src/lib/evas/cserve2/evas_cs2_client.c +++ b/src/lib/evas/cserve2/evas_cs2_client.c @@ -1419,7 +1419,8 @@ struct _CS_Glyph_Out unsigned int offset; unsigned int size; Eina_Bool used; - unsigned int refcount; + int refcount; + int pending_ref; }; static void @@ -1665,6 +1666,7 @@ _glyph_map_remap_check(Glyph_Map *map) || (eina_file_size_get(map->mempool.f) != (size_t) map->mempool.size)) { CS_Glyph_Out *gl; + Shared_Buffer *oldbuf = NULL; WRN("Glyph pool has been resized."); @@ -1676,7 +1678,7 @@ _glyph_map_remap_check(Glyph_Map *map) if (map->mempool.refcount > 0) { - Shared_Buffer *oldbuf = calloc(1, sizeof(Glyph_Map)); + oldbuf = calloc(1, sizeof(Glyph_Map)); oldbuf->f = eina_file_dup(map->mempool.f); oldbuf->data = map->mempool.data; oldbuf->size = map->mempool.size; @@ -1702,6 +1704,9 @@ _glyph_map_remap_check(Glyph_Map *map) gl->sb = &map->mempool; gl->base.bitmap.buffer = (unsigned char *) gl->sb->data + gl->offset; } + else if (oldbuf) + gl->sb = oldbuf; + else CRIT("Invalid refcount state"); } } @@ -2198,27 +2203,52 @@ evas_cserve2_font_glyph_ref(RGBA_Font_Glyph_Out *glyph, Eina_Bool incref) EINA_SAFETY_ON_FALSE_RETURN(evas_cserve2_use_get()); + // For debugging only. + static int inc = 0, dec = 0; + if (incref) inc++; else dec++; + // glout = (CS_Glyph_Out *) glyph; glout = (CS_Glyph_Out *) (((char *) glyph) - offsetof(CS_Glyph_Out, base)); if (incref) { if (!glout->sb) - WRN("Increasing glyph refcount while no buffer is associated!"); + { + // This can happen when cserve2 restarted. + glout->pending_ref++; + return; + } else if (!glout->refcount) glout->sb->refcount++; + if (glout->pending_ref) + { + glout->refcount += glout->pending_ref; + glout->pending_ref = 0; + } glout->refcount++; return; } EINA_SAFETY_ON_FALSE_RETURN(glout->refcount > 0); EINA_SAFETY_ON_NULL_RETURN(glout->sb); + if (glout->pending_ref) + { + glout->refcount += glout->pending_ref; + glout->pending_ref = 0; + glout->sb->refcount++; + } glout->refcount--; if (!glout->refcount) { + EINA_SAFETY_ON_FALSE_RETURN(glout->sb->refcount > 0); glout->sb->refcount--; - if (glout->sb->data != glout->map->mempool.data) + + if (!glout->sb->refcount) + DBG("Shared buffer %p reached refcount ZERO. %d/%d", glout->sb, dec, inc); + + //if (glout->sb->data != glout->map->mempool.data) + if (glout->sb != &glout->map->mempool) { if (!glout->sb->refcount) { @@ -2227,6 +2257,7 @@ evas_cserve2_font_glyph_ref(RGBA_Font_Glyph_Out *glyph, Eina_Bool incref) eina_list_remove(glout->map->mempool_lru, glout->sb); eina_file_map_free(glout->sb->f, glout->sb->data); eina_file_close(glout->sb->f); + free(glout->sb); } glout->sb = &glout->map->mempool; glout->base.bitmap.buffer = @@ -2777,7 +2808,7 @@ _shared_image_entry_image_data_find(Image_Entry *ie) const File_Data *fdata = _shared_image_entry_file_data_find(ie); if (!fdata) { - ERR("File is not opened by cserve2"); + DBG("File is not opened by cserve2"); return NULL; } file_id = fdata->id; |