summaryrefslogtreecommitdiff
path: root/src/lib/evas/cserve2/evas_cs2_client.c
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2013-08-26 15:40:54 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2013-10-28 15:47:14 +0900
commitd5ac5a8df37a6627b24455fb9364a007d6279872 (patch)
treea814b40df7e30a6a830ce2a0c3b3f121267163bf /src/lib/evas/cserve2/evas_cs2_client.c
parent22009a3f644094816e2ae649dd3ad48b04825a5f (diff)
evas/cserve2: Remap glyph mempool if resized
Diffstat (limited to 'src/lib/evas/cserve2/evas_cs2_client.c')
-rw-r--r--src/lib/evas/cserve2/evas_cs2_client.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/lib/evas/cserve2/evas_cs2_client.c b/src/lib/evas/cserve2/evas_cs2_client.c
index d6cedcc658..0b036e02f2 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -1141,6 +1141,7 @@ _glyphs_map_free(Glyph_Map *map)
1141 eina_file_close(map->mempool.f); 1141 eina_file_close(map->mempool.f);
1142 eina_file_map_free(map->index.f, map->index.data); 1142 eina_file_map_free(map->index.f, map->index.data);
1143 eina_file_close(map->index.f); 1143 eina_file_close(map->index.f);
1144 eina_hash_free(map->index.entries_by_hkey);
1144 map->fe->map = NULL; 1145 map->fe->map = NULL;
1145 free(map); 1146 free(map);
1146} 1147}
@@ -1338,11 +1339,14 @@ _glyph_map_open(Font_Entry *fe, const char *indexpath, const char *datapath)
1338 1339
1339 map->fe = fe; 1340 map->fe = fe;
1340 eina_clist_init(&map->glyphs); 1341 eina_clist_init(&map->glyphs);
1341 eina_strlcpy(map->index.path, indexpath, SHARED_BUFFER_PATH_MAX);
1342 eina_strlcpy(map->mempool.path, datapath, SHARED_BUFFER_PATH_MAX); 1342 eina_strlcpy(map->mempool.path, datapath, SHARED_BUFFER_PATH_MAX);
1343 1343
1344 map->index.generation_id = _index.generation_id; 1344 if (indexpath)
1345 _shared_index_remap_check(&map->index, sizeof(Glyph_Data)); 1345 {
1346 eina_strlcpy(map->index.path, indexpath, SHARED_BUFFER_PATH_MAX);
1347 map->index.generation_id = _index.generation_id;
1348 _shared_index_remap_check(&map->index, sizeof(Glyph_Data));
1349 }
1346 1350
1347 map->mempool.f = eina_file_open(map->mempool.path, EINA_TRUE); 1351 map->mempool.f = eina_file_open(map->mempool.path, EINA_TRUE);
1348 map->mempool.size = eina_file_size_get(map->mempool.f); 1352 map->mempool.size = eina_file_size_get(map->mempool.f);
@@ -1353,6 +1357,22 @@ _glyph_map_open(Font_Entry *fe, const char *indexpath, const char *datapath)
1353} 1357}
1354 1358
1355static void 1359static void
1360_glyph_map_remap_check(Glyph_Map *map)
1361{
1362 if (eina_file_refresh(map->mempool.f)
1363 || (eina_file_size_get(map->mempool.f) != (size_t) map->mempool.size))
1364 {
1365 WRN("Glyph pool has been resized.");
1366 eina_file_map_free(map->mempool.f, map->mempool.data);
1367 map->mempool.data = eina_file_map_all(map->mempool.f, EINA_FILE_RANDOM);
1368 if (map->mempool.data)
1369 map->mempool.size = eina_file_size_get(map->mempool.f);
1370 else
1371 map->mempool.size = 0;
1372 }
1373}
1374
1375static void
1356_glyph_request_cb(void *data, const void *msg, int size) 1376_glyph_request_cb(void *data, const void *msg, int size)
1357{ 1377{
1358 const Msg_Font_Glyphs_Loaded *resp = msg; 1378 const Msg_Font_Glyphs_Loaded *resp = msg;
@@ -1405,6 +1425,8 @@ _glyph_request_cb(void *data, const void *msg, int size)
1405 datapath = name; 1425 datapath = name;
1406 fe->map = _glyph_map_open(fe, idxpath, datapath); 1426 fe->map = _glyph_map_open(fe, idxpath, datapath);
1407 } 1427 }
1428 else
1429 _glyph_map_remap_check(fe->map);
1408 1430
1409 for (i = 0; i < nglyphs; i++) 1431 for (i = 0; i < nglyphs; i++)
1410 { 1432 {
@@ -1451,6 +1473,12 @@ _glyph_request_cb(void *data, const void *msg, int size)
1451 gl->base.bitmap.pixel_mode = pixel_mode; 1473 gl->base.bitmap.pixel_mode = pixel_mode;
1452 gl->rid = 0; 1474 gl->rid = 0;
1453 1475
1476 if (gl->offset + glsize > (size_t) fe->map->mempool.size)
1477 {
1478 ERR("Glyph is out of the buffer. Set buffer to NULL.");
1479 gl->base.bitmap.buffer = NULL;
1480 }
1481
1454 eina_clist_add_head(&fe->map->glyphs, &gl->map_entry); 1482 eina_clist_add_head(&fe->map->glyphs, &gl->map_entry);
1455 } 1483 }
1456 } 1484 }