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.
This commit is contained in:
parent
4c44b5a553
commit
7b62d77cf5
|
@ -234,8 +234,8 @@ _cserve2_client_font_glyphs_request(Client *client)
|
||||||
|
|
||||||
if (msg->base.type == CSERVE2_FONT_GLYPHS_LOAD)
|
if (msg->base.type == CSERVE2_FONT_GLYPHS_LOAD)
|
||||||
{
|
{
|
||||||
INF("Received CSERVE2_FONT_GLYPHS_LOAD command: RID=%d",
|
INF("Received CSERVE2_FONT_GLYPHS_LOAD command: RID=%d (%d glyphs)",
|
||||||
msg->base.rid);
|
msg->base.rid, msg->nglyphs);
|
||||||
cserve2_cache_font_glyphs_load(client, source, fontpath,
|
cserve2_cache_font_glyphs_load(client, source, fontpath,
|
||||||
msg->hint, msg->rend_flags, msg->size,
|
msg->hint, msg->rend_flags, msg->size,
|
||||||
msg->dpi, glyphs, msg->nglyphs,
|
msg->dpi, glyphs, msg->nglyphs,
|
||||||
|
@ -243,8 +243,8 @@ _cserve2_client_font_glyphs_request(Client *client)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
INF("Received CSERVE2_FONT_GLYPHS_USED command: RID=%d",
|
INF("Received CSERVE2_FONT_GLYPHS_USED command: RID=%d (%d glyphs)",
|
||||||
msg->base.rid);
|
msg->base.rid, msg->nglyphs);
|
||||||
cserve2_cache_font_glyphs_used(client, source, fontpath,
|
cserve2_cache_font_glyphs_used(client, source, fontpath,
|
||||||
msg->hint, msg->rend_flags, msg->size,
|
msg->hint, msg->rend_flags, msg->size,
|
||||||
msg->dpi, glyphs, msg->nglyphs,
|
msg->dpi, glyphs, msg->nglyphs,
|
||||||
|
|
|
@ -363,10 +363,38 @@ on_error:
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_request_answer_required(int type, Eina_Bool *valid)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case CSERVE2_OPEN:
|
||||||
|
case CSERVE2_LOAD:
|
||||||
|
case CSERVE2_PRELOAD:
|
||||||
|
case CSERVE2_FONT_LOAD:
|
||||||
|
case CSERVE2_FONT_GLYPHS_LOAD:
|
||||||
|
if (valid) *valid = EINA_TRUE;
|
||||||
|
return EINA_TRUE;
|
||||||
|
case CSERVE2_CLOSE:
|
||||||
|
case CSERVE2_UNLOAD:
|
||||||
|
case CSERVE2_FONT_UNLOAD:
|
||||||
|
case CSERVE2_FONT_GLYPHS_USED:
|
||||||
|
if (valid) *valid = EINA_TRUE;
|
||||||
|
return EINA_FALSE;
|
||||||
|
default:
|
||||||
|
ERR("Invalid message type %d", type);
|
||||||
|
if (valid) *valid = EINA_FALSE;
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_server_send(void *buf, int size, Op_Callback cb, void *data)
|
_server_send(void *buf, int size, Op_Callback cb, void *data)
|
||||||
{
|
{
|
||||||
Msg_Base *msg;
|
Msg_Base *msg = buf;
|
||||||
|
int type = msg->type;
|
||||||
|
Eina_Bool valid = EINA_TRUE;
|
||||||
|
|
||||||
if (!_server_safe_send(socketfd, &size, sizeof(size)))
|
if (!_server_safe_send(socketfd, &size, sizeof(size)))
|
||||||
{
|
{
|
||||||
ERR("Couldn't send message size to server.");
|
ERR("Couldn't send message size to server.");
|
||||||
|
@ -378,31 +406,16 @@ _server_send(void *buf, int size, Op_Callback cb, void *data)
|
||||||
goto on_error;
|
goto on_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = buf;
|
if (_request_answer_required(type, &valid))
|
||||||
switch (msg->type)
|
_request_answer_add(msg, size, cb, data);
|
||||||
{
|
else
|
||||||
case CSERVE2_OPEN:
|
free(msg);
|
||||||
case CSERVE2_LOAD:
|
|
||||||
case CSERVE2_PRELOAD:
|
|
||||||
case CSERVE2_FONT_LOAD:
|
|
||||||
case CSERVE2_FONT_GLYPHS_LOAD:
|
|
||||||
_request_answer_add(msg, size, cb, data);
|
|
||||||
break;
|
|
||||||
case CSERVE2_CLOSE:
|
|
||||||
case CSERVE2_UNLOAD:
|
|
||||||
case CSERVE2_FONT_UNLOAD:
|
|
||||||
case CSERVE2_FONT_GLYPHS_USED:
|
|
||||||
free(msg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ERR("Invalid message type %d", msg->type);
|
|
||||||
free(msg);
|
|
||||||
return EINA_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return EINA_TRUE;
|
return valid;
|
||||||
|
|
||||||
on_error:
|
on_error:
|
||||||
|
if (!_request_answer_required(type, NULL))
|
||||||
|
return EINA_FALSE;
|
||||||
ERR("Socket error: %d %m", errno);
|
ERR("Socket error: %d %m", errno);
|
||||||
switch (errno)
|
switch (errno)
|
||||||
{
|
{
|
||||||
|
@ -532,6 +545,7 @@ _server_dispatch(Eina_Bool *failed)
|
||||||
Eina_List *l, *l_next;
|
Eina_List *l, *l_next;
|
||||||
Client_Request *cr;
|
Client_Request *cr;
|
||||||
Msg_Base *msg;
|
Msg_Base *msg;
|
||||||
|
Eina_Bool found;
|
||||||
|
|
||||||
msg = _server_read(&size);
|
msg = _server_read(&size);
|
||||||
if (!msg)
|
if (!msg)
|
||||||
|
@ -560,6 +574,7 @@ _server_dispatch(Eina_Bool *failed)
|
||||||
if (cr->msg->rid != msg->rid) // dispatch this answer
|
if (cr->msg->rid != msg->rid) // dispatch this answer
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
found = EINA_TRUE;
|
||||||
if (cr->cb)
|
if (cr->cb)
|
||||||
remove = cr->cb(cr->data, msg, size);
|
remove = cr->cb(cr->data, msg, size);
|
||||||
if (remove)
|
if (remove)
|
||||||
|
@ -571,8 +586,10 @@ _server_dispatch(Eina_Bool *failed)
|
||||||
}
|
}
|
||||||
|
|
||||||
rid = msg->rid;
|
rid = msg->rid;
|
||||||
free(msg);
|
if (!found)
|
||||||
|
WRN("Got unexpected response %d for request %d", msg->type, rid);
|
||||||
|
|
||||||
|
free(msg);
|
||||||
return rid;
|
return rid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1786,6 +1803,7 @@ _glyph_map_remap_check(Glyph_Map *map, const char *idxpath, const char *datapath
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if USE_SHARED_INDEX
|
||||||
static int
|
static int
|
||||||
_font_entry_glyph_map_rebuild_check(Font_Entry *fe, Font_Hint_Flags hints)
|
_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;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_glyph_request_cb(void *data, const void *msg, int size)
|
_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);
|
free(data);
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
// Keep this request in the list for now
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
free(data);
|
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 */
|
/* 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);
|
_glyph_request_server_send(fe, hints, EINA_FALSE);
|
||||||
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
|
@ -2240,7 +2260,7 @@ evas_cserve2_font_glyph_bitmap_get(Font_Entry *fe, unsigned int idx,
|
||||||
if (fe->glyphs_queue_count)
|
if (fe->glyphs_queue_count)
|
||||||
_glyph_request_server_send(fe, hints, EINA_FALSE);
|
_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);
|
_glyph_request_server_send(fe, hints, EINA_TRUE);
|
||||||
|
|
||||||
fash = fe->fash[hints];
|
fash = fe->fash[hints];
|
||||||
|
@ -2279,9 +2299,7 @@ try_again:
|
||||||
|
|
||||||
|
|
||||||
#if USE_SHARED_INDEX
|
#if USE_SHARED_INDEX
|
||||||
// FIXME/TODO: Reimplement the following function.
|
_font_entry_glyph_map_rebuild_check(fe, hints);
|
||||||
// This is probably not the best point to call it, though.
|
|
||||||
//_font_entry_glyph_map_rebuild_check(fe, hints);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (out->rid)
|
if (out->rid)
|
||||||
|
|
Loading…
Reference in New Issue