jpeg pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=7b62d77cf5441b89c17ff082204a6908259bd4c3
commit 7b62d77cf5441b89c17ff082204a6908259bd4c3 Author: Jean-Philippe Andre <[email protected]> Date: Fri Oct 11 15:36:11 2013 +0900 evas/cserve2: Add debug and reduce number of GLYPHS_USED messages One socket message was sent per each glyph used ... which means a LOT of messages when text is being redrawn. Reduce this flow of messages by triggering send() only when 50+ items are being used. Btw, USED is a bit useless as there is no UNUSED equivalent. Also, slightly improve debug logs. --- src/bin/evas/evas_cserve2_main.c | 8 ++-- src/lib/evas/cserve2/evas_cs2_client.c | 74 +++++++++++++++++++++------------- 2 files changed, 50 insertions(+), 32 deletions(-) diff --git a/src/bin/evas/evas_cserve2_main.c b/src/bin/evas/evas_cserve2_main.c index bd54cbf..1e8fd18 100644 --- a/src/bin/evas/evas_cserve2_main.c +++ b/src/bin/evas/evas_cserve2_main.c @@ -234,8 +234,8 @@ _cserve2_client_font_glyphs_request(Client *client) if (msg->base.type == CSERVE2_FONT_GLYPHS_LOAD) { - INF("Received CSERVE2_FONT_GLYPHS_LOAD command: RID=%d", - msg->base.rid); + INF("Received CSERVE2_FONT_GLYPHS_LOAD command: RID=%d (%d glyphs)", + msg->base.rid, msg->nglyphs); cserve2_cache_font_glyphs_load(client, source, fontpath, msg->hint, msg->rend_flags, msg->size, msg->dpi, glyphs, msg->nglyphs, @@ -243,8 +243,8 @@ _cserve2_client_font_glyphs_request(Client *client) } else { - INF("Received CSERVE2_FONT_GLYPHS_USED command: RID=%d", - msg->base.rid); + INF("Received CSERVE2_FONT_GLYPHS_USED command: RID=%d (%d glyphs)", + msg->base.rid, msg->nglyphs); cserve2_cache_font_glyphs_used(client, source, fontpath, msg->hint, msg->rend_flags, msg->size, msg->dpi, glyphs, msg->nglyphs, diff --git a/src/lib/evas/cserve2/evas_cs2_client.c b/src/lib/evas/cserve2/evas_cs2_client.c index 520c400..c052c27 100644 --- a/src/lib/evas/cserve2/evas_cs2_client.c +++ b/src/lib/evas/cserve2/evas_cs2_client.c @@ -364,45 +364,58 @@ on_error: } static Eina_Bool -_server_send(void *buf, int size, Op_Callback cb, void *data) +_request_answer_required(int type, Eina_Bool *valid) { - Msg_Base *msg; - if (!_server_safe_send(socketfd, &size, sizeof(size))) - { - ERR("Couldn't send message size to server."); - goto on_error; - } - if (!_server_safe_send(socketfd, buf, size)) - { - ERR("Couldn't send message body to server."); - goto on_error; - } - - msg = buf; - switch (msg->type) + switch (type) { case CSERVE2_OPEN: case CSERVE2_LOAD: case CSERVE2_PRELOAD: case CSERVE2_FONT_LOAD: case CSERVE2_FONT_GLYPHS_LOAD: - _request_answer_add(msg, size, cb, data); - break; + if (valid) *valid = EINA_TRUE; + return EINA_TRUE; case CSERVE2_CLOSE: case CSERVE2_UNLOAD: case CSERVE2_FONT_UNLOAD: case CSERVE2_FONT_GLYPHS_USED: - free(msg); - break; + if (valid) *valid = EINA_TRUE; + return EINA_FALSE; default: - ERR("Invalid message type %d", msg->type); - free(msg); + ERR("Invalid message type %d", type); + if (valid) *valid = EINA_FALSE; return EINA_FALSE; } +} - return EINA_TRUE; +static Eina_Bool +_server_send(void *buf, int size, Op_Callback cb, void *data) +{ + Msg_Base *msg = buf; + int type = msg->type; + Eina_Bool valid = EINA_TRUE; + + if (!_server_safe_send(socketfd, &size, sizeof(size))) + { + ERR("Couldn't send message size to server."); + goto on_error; + } + if (!_server_safe_send(socketfd, buf, size)) + { + ERR("Couldn't send message body to server."); + goto on_error; + } + + if (_request_answer_required(type, &valid)) + _request_answer_add(msg, size, cb, data); + else + free(msg); + + return valid; on_error: + if (!_request_answer_required(type, NULL)) + return EINA_FALSE; ERR("Socket error: %d %m", errno); switch (errno) { @@ -532,6 +545,7 @@ _server_dispatch(Eina_Bool *failed) Eina_List *l, *l_next; Client_Request *cr; Msg_Base *msg; + Eina_Bool found; msg = _server_read(&size); if (!msg) @@ -560,6 +574,7 @@ _server_dispatch(Eina_Bool *failed) if (cr->msg->rid != msg->rid) // dispatch this answer continue; + found = EINA_TRUE; if (cr->cb) remove = cr->cb(cr->data, msg, size); if (remove) @@ -571,8 +586,10 @@ _server_dispatch(Eina_Bool *failed) } rid = msg->rid; - free(msg); + if (!found) + WRN("Got unexpected response %d for request %d", msg->type, rid); + free(msg); return rid; } @@ -1786,6 +1803,7 @@ _glyph_map_remap_check(Glyph_Map *map, const char *idxpath, const char *datapath return changed; } +#if USE_SHARED_INDEX static int _font_entry_glyph_map_rebuild_check(Font_Entry *fe, Font_Hint_Flags hints) { @@ -1862,6 +1880,7 @@ _font_entry_glyph_map_rebuild_check(Font_Entry *fe, Font_Hint_Flags hints) return cnt; } +#endif static Eina_Bool _glyph_request_cb(void *data, const void *msg, int size) @@ -1907,6 +1926,7 @@ _glyph_request_cb(void *data, const void *msg, int size) free(data); return EINA_TRUE; } + // Keep this request in the list for now return EINA_FALSE; } free(data); @@ -2166,7 +2186,7 @@ evas_cserve2_font_glyph_request(Font_Entry *fe, unsigned int idx, Font_Hint_Flag } /* FIXME crude way to manage a queue, but it will work for now */ - if (fe->glyphs_queue_count == 50) + if (fe->glyphs_queue_count >= 50) _glyph_request_server_send(fe, hints, EINA_FALSE); return EINA_TRUE; @@ -2240,7 +2260,7 @@ evas_cserve2_font_glyph_bitmap_get(Font_Entry *fe, unsigned int idx, if (fe->glyphs_queue_count) _glyph_request_server_send(fe, hints, EINA_FALSE); - if (fe->glyphs_used_count) + if (fe->glyphs_used_count >= 50) _glyph_request_server_send(fe, hints, EINA_TRUE); fash = fe->fash[hints]; @@ -2279,9 +2299,7 @@ try_again: #if USE_SHARED_INDEX - // FIXME/TODO: Reimplement the following function. - // This is probably not the best point to call it, though. - //_font_entry_glyph_map_rebuild_check(fe, hints); + _font_entry_glyph_map_rebuild_check(fe, hints); #endif if (out->rid) --
