diff options
author | Jean-Philippe Andre <jp.andre@samsung.com> | 2013-10-11 15:36:11 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2013-10-28 15:47:16 +0900 |
commit | 7b62d77cf5441b89c17ff082204a6908259bd4c3 (patch) | |
tree | 7733379db7914b839eb8005eb999ae7162ed4bc5 /src/lib/evas/cserve2/evas_cs2_client.c | |
parent | 4c44b5a553290f0e35675974da59b1205e06e850 (diff) |
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.
Diffstat (limited to '')
-rw-r--r-- | src/lib/evas/cserve2/evas_cs2_client.c | 74 |
1 files changed, 46 insertions, 28 deletions
diff --git a/src/lib/evas/cserve2/evas_cs2_client.c b/src/lib/evas/cserve2/evas_cs2_client.c index 520c4002ea..c052c279e5 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: | |||
364 | } | 364 | } |
365 | 365 | ||
366 | static Eina_Bool | 366 | static Eina_Bool |
367 | _server_send(void *buf, int size, Op_Callback cb, void *data) | 367 | _request_answer_required(int type, Eina_Bool *valid) |
368 | { | 368 | { |
369 | Msg_Base *msg; | 369 | switch (type) |
370 | if (!_server_safe_send(socketfd, &size, sizeof(size))) | ||
371 | { | ||
372 | ERR("Couldn't send message size to server."); | ||
373 | goto on_error; | ||
374 | } | ||
375 | if (!_server_safe_send(socketfd, buf, size)) | ||
376 | { | ||
377 | ERR("Couldn't send message body to server."); | ||
378 | goto on_error; | ||
379 | } | ||
380 | |||
381 | msg = buf; | ||
382 | switch (msg->type) | ||
383 | { | 370 | { |
384 | case CSERVE2_OPEN: | 371 | case CSERVE2_OPEN: |
385 | case CSERVE2_LOAD: | 372 | case CSERVE2_LOAD: |
386 | case CSERVE2_PRELOAD: | 373 | case CSERVE2_PRELOAD: |
387 | case CSERVE2_FONT_LOAD: | 374 | case CSERVE2_FONT_LOAD: |
388 | case CSERVE2_FONT_GLYPHS_LOAD: | 375 | case CSERVE2_FONT_GLYPHS_LOAD: |
389 | _request_answer_add(msg, size, cb, data); | 376 | if (valid) *valid = EINA_TRUE; |
390 | break; | 377 | return EINA_TRUE; |
391 | case CSERVE2_CLOSE: | 378 | case CSERVE2_CLOSE: |
392 | case CSERVE2_UNLOAD: | 379 | case CSERVE2_UNLOAD: |
393 | case CSERVE2_FONT_UNLOAD: | 380 | case CSERVE2_FONT_UNLOAD: |
394 | case CSERVE2_FONT_GLYPHS_USED: | 381 | case CSERVE2_FONT_GLYPHS_USED: |
395 | free(msg); | 382 | if (valid) *valid = EINA_TRUE; |
396 | break; | 383 | return EINA_FALSE; |
397 | default: | 384 | default: |
398 | ERR("Invalid message type %d", msg->type); | 385 | ERR("Invalid message type %d", type); |
399 | free(msg); | 386 | if (valid) *valid = EINA_FALSE; |
400 | return EINA_FALSE; | 387 | return EINA_FALSE; |
401 | } | 388 | } |
389 | } | ||
402 | 390 | ||
403 | return EINA_TRUE; | 391 | static Eina_Bool |
392 | _server_send(void *buf, int size, Op_Callback cb, void *data) | ||
393 | { | ||
394 | Msg_Base *msg = buf; | ||
395 | int type = msg->type; | ||
396 | Eina_Bool valid = EINA_TRUE; | ||
397 | |||
398 | if (!_server_safe_send(socketfd, &size, sizeof(size))) | ||
399 | { | ||
400 | ERR("Couldn't send message size to server."); | ||
401 | goto on_error; | ||
402 | } | ||
403 | if (!_server_safe_send(socketfd, buf, size)) | ||
404 | { | ||
405 | ERR("Couldn't send message body to server."); | ||
406 | goto on_error; | ||
407 | } | ||
408 | |||
409 | if (_request_answer_required(type, &valid)) | ||
410 | _request_answer_add(msg, size, cb, data); | ||
411 | else | ||
412 | free(msg); | ||
413 | |||
414 | return valid; | ||
404 | 415 | ||
405 | on_error: | 416 | on_error: |
417 | if (!_request_answer_required(type, NULL)) | ||
418 | return EINA_FALSE; | ||
406 | ERR("Socket error: %d %m", errno); | 419 | ERR("Socket error: %d %m", errno); |
407 | switch (errno) | 420 | switch (errno) |
408 | { | 421 | { |
@@ -532,6 +545,7 @@ _server_dispatch(Eina_Bool *failed) | |||
532 | Eina_List *l, *l_next; | 545 | Eina_List *l, *l_next; |
533 | Client_Request *cr; | 546 | Client_Request *cr; |
534 | Msg_Base *msg; | 547 | Msg_Base *msg; |
548 | Eina_Bool found; | ||
535 | 549 | ||
536 | msg = _server_read(&size); | 550 | msg = _server_read(&size); |
537 | if (!msg) | 551 | if (!msg) |
@@ -560,6 +574,7 @@ _server_dispatch(Eina_Bool *failed) | |||
560 | if (cr->msg->rid != msg->rid) // dispatch this answer | 574 | if (cr->msg->rid != msg->rid) // dispatch this answer |
561 | continue; | 575 | continue; |
562 | 576 | ||
577 | found = EINA_TRUE; | ||
563 | if (cr->cb) | 578 | if (cr->cb) |
564 | remove = cr->cb(cr->data, msg, size); | 579 | remove = cr->cb(cr->data, msg, size); |
565 | if (remove) | 580 | if (remove) |
@@ -571,8 +586,10 @@ _server_dispatch(Eina_Bool *failed) | |||
571 | } | 586 | } |
572 | 587 | ||
573 | rid = msg->rid; | 588 | rid = msg->rid; |
574 | free(msg); | 589 | if (!found) |
590 | WRN("Got unexpected response %d for request %d", msg->type, rid); | ||
575 | 591 | ||
592 | free(msg); | ||
576 | return rid; | 593 | return rid; |
577 | } | 594 | } |
578 | 595 | ||
@@ -1786,6 +1803,7 @@ _glyph_map_remap_check(Glyph_Map *map, const char *idxpath, const char *datapath | |||
1786 | return changed; | 1803 | return changed; |
1787 | } | 1804 | } |
1788 | 1805 | ||
1806 | #if USE_SHARED_INDEX | ||
1789 | static int | 1807 | static int |
1790 | _font_entry_glyph_map_rebuild_check(Font_Entry *fe, Font_Hint_Flags hints) | 1808 | _font_entry_glyph_map_rebuild_check(Font_Entry *fe, Font_Hint_Flags hints) |
1791 | { | 1809 | { |
@@ -1862,6 +1880,7 @@ _font_entry_glyph_map_rebuild_check(Font_Entry *fe, Font_Hint_Flags hints) | |||
1862 | 1880 | ||
1863 | return cnt; | 1881 | return cnt; |
1864 | } | 1882 | } |
1883 | #endif | ||
1865 | 1884 | ||
1866 | static Eina_Bool | 1885 | static Eina_Bool |
1867 | _glyph_request_cb(void *data, const void *msg, int size) | 1886 | _glyph_request_cb(void *data, const void *msg, int size) |
@@ -1907,6 +1926,7 @@ _glyph_request_cb(void *data, const void *msg, int size) | |||
1907 | free(data); | 1926 | free(data); |
1908 | return EINA_TRUE; | 1927 | return EINA_TRUE; |
1909 | } | 1928 | } |
1929 | // Keep this request in the list for now | ||
1910 | return EINA_FALSE; | 1930 | return EINA_FALSE; |
1911 | } | 1931 | } |
1912 | free(data); | 1932 | free(data); |
@@ -2166,7 +2186,7 @@ evas_cserve2_font_glyph_request(Font_Entry *fe, unsigned int idx, Font_Hint_Flag | |||
2166 | } | 2186 | } |
2167 | 2187 | ||
2168 | /* FIXME crude way to manage a queue, but it will work for now */ | 2188 | /* FIXME crude way to manage a queue, but it will work for now */ |
2169 | if (fe->glyphs_queue_count == 50) | 2189 | if (fe->glyphs_queue_count >= 50) |
2170 | _glyph_request_server_send(fe, hints, EINA_FALSE); | 2190 | _glyph_request_server_send(fe, hints, EINA_FALSE); |
2171 | 2191 | ||
2172 | return EINA_TRUE; | 2192 | return EINA_TRUE; |
@@ -2240,7 +2260,7 @@ evas_cserve2_font_glyph_bitmap_get(Font_Entry *fe, unsigned int idx, | |||
2240 | if (fe->glyphs_queue_count) | 2260 | if (fe->glyphs_queue_count) |
2241 | _glyph_request_server_send(fe, hints, EINA_FALSE); | 2261 | _glyph_request_server_send(fe, hints, EINA_FALSE); |
2242 | 2262 | ||
2243 | if (fe->glyphs_used_count) | 2263 | if (fe->glyphs_used_count >= 50) |
2244 | _glyph_request_server_send(fe, hints, EINA_TRUE); | 2264 | _glyph_request_server_send(fe, hints, EINA_TRUE); |
2245 | 2265 | ||
2246 | fash = fe->fash[hints]; | 2266 | fash = fe->fash[hints]; |
@@ -2279,9 +2299,7 @@ try_again: | |||
2279 | 2299 | ||
2280 | 2300 | ||
2281 | #if USE_SHARED_INDEX | 2301 | #if USE_SHARED_INDEX |
2282 | // FIXME/TODO: Reimplement the following function. | 2302 | _font_entry_glyph_map_rebuild_check(fe, hints); |
2283 | // This is probably not the best point to call it, though. | ||
2284 | //_font_entry_glyph_map_rebuild_check(fe, hints); | ||
2285 | #endif | 2303 | #endif |
2286 | 2304 | ||
2287 | if (out->rid) | 2305 | if (out->rid) |