summaryrefslogtreecommitdiff
path: root/src/lib/evas/cserve2
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2013-08-26 16:48:49 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2013-10-28 15:47:14 +0900
commitca44473f184c95b88a2dadc02e85bb0806236c05 (patch)
treec9e29d06777c45c216520d480d05992fac81303e /src/lib/evas/cserve2
parentd5ac5a8df37a6627b24455fb9364a007d6279872 (diff)
evas/cserve2: Scan glyphs and add to fash
This will save (just) a few socket waits.
Diffstat (limited to 'src/lib/evas/cserve2')
-rw-r--r--src/lib/evas/cserve2/evas_cs2_client.c88
-rw-r--r--src/lib/evas/cserve2/evas_cs2_private.h3
2 files changed, 86 insertions, 5 deletions
diff --git a/src/lib/evas/cserve2/evas_cs2_client.c b/src/lib/evas/cserve2/evas_cs2_client.c
index 0b036e02f2..cc5458ad02 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -1356,9 +1356,12 @@ _glyph_map_open(Font_Entry *fe, const char *indexpath, const char *datapath)
1356 return map; 1356 return map;
1357} 1357}
1358 1358
1359static void 1359static Eina_Bool
1360_glyph_map_remap_check(Glyph_Map *map) 1360_glyph_map_remap_check(Glyph_Map *map)
1361{ 1361{
1362 Eina_Bool changed = EINA_FALSE;
1363 int oldcount;
1364
1362 if (eina_file_refresh(map->mempool.f) 1365 if (eina_file_refresh(map->mempool.f)
1363 || (eina_file_size_get(map->mempool.f) != (size_t) map->mempool.size)) 1366 || (eina_file_size_get(map->mempool.f) != (size_t) map->mempool.size))
1364 { 1367 {
@@ -1369,7 +1372,78 @@ _glyph_map_remap_check(Glyph_Map *map)
1369 map->mempool.size = eina_file_size_get(map->mempool.f); 1372 map->mempool.size = eina_file_size_get(map->mempool.f);
1370 else 1373 else
1371 map->mempool.size = 0; 1374 map->mempool.size = 0;
1375 changed = EINA_TRUE;
1376 }
1377
1378 map->index.generation_id = _index.generation_id;
1379 oldcount = map->index.count;
1380 _shared_index_remap_check(&map->index, sizeof(Glyph_Data));
1381 changed |= (oldcount != map->index.count);
1382
1383 return changed;
1384}
1385
1386static int
1387_font_entry_glyph_map_rebuild_check(Font_Entry *fe, Font_Hint_Flags hints)
1388{
1389 Eina_Bool changed = EINA_FALSE;
1390 int cnt = 0;
1391
1392 if (!fe->map)
1393 {
1394 const Font_Data *fd;
1395 const char *idxpath, *datapath;
1396
1397 fd = _shared_font_entry_data_find(fe);
1398 if (!fd) return -1;
1399
1400 idxpath = _shared_string_get(fd->glyph_index_shm);
1401 datapath = _shared_string_get(fd->mempool_shm);
1402 if (!idxpath || !datapath) return -1;
1403
1404 fe->map =_glyph_map_open(fe, idxpath, datapath);
1405 changed = EINA_TRUE;
1406 }
1407
1408 changed |= _glyph_map_remap_check(fe->map);
1409 if (changed && fe->map && fe->map->index.data && fe->map->mempool.data)
1410 {
1411 CS_Glyph_Out *gl;
1412 const Glyph_Data *gd;
1413 int k, tot = 0;
1414
1415 DBG("Rebuilding font hash based on shared index...");
1416 for (k = 0; k < fe->map->index.count; k++)
1417 {
1418 gd = &(fe->map->index.entries.gldata[k]);
1419 if (!gd->id) break;
1420 if (!gd->refcount) continue;
1421
1422 tot++;
1423 gl = fash_gl_find(fe->fash[hints], gd->index);
1424 if (gl && gl->base.bitmap.buffer) continue;
1425
1426 if (!gl) gl = calloc(1, sizeof(*gl));
1427 gl->map = fe->map;
1428 gl->offset = gd->offset;
1429 gl->size = gd->size;
1430 gl->base.bitmap.rows = gd->rows;
1431 gl->base.bitmap.width = gd->width;
1432 gl->base.bitmap.pitch = gd->pitch;
1433 gl->base.bitmap.buffer = (unsigned char *)
1434 fe->map->mempool.data + gl->offset;
1435 gl->base.bitmap.num_grays = gd->num_grays;
1436 gl->base.bitmap.pixel_mode = gd->pixel_mode;
1437 gl->rid = 0;
1438
1439 eina_clist_add_head(&fe->map->glyphs, &gl->map_entry);
1440 fash_gl_add(fe->fash[hints], gd->index, gl);
1441 cnt++;
1442 }
1443 DBG("Added %d glyphs to the font hash (out of %d scanned)", cnt, tot);
1372 } 1444 }
1445
1446 return cnt;
1373} 1447}
1374 1448
1375static void 1449static void
@@ -1668,7 +1742,8 @@ evas_cserve2_font_glyph_used(Font_Entry *fe, unsigned int idx, Font_Hint_Flags h
1668} 1742}
1669 1743
1670RGBA_Font_Glyph_Out * 1744RGBA_Font_Glyph_Out *
1671evas_cserve2_font_glyph_bitmap_get(Font_Entry *fe, unsigned int idx, Font_Hint_Flags hints) 1745evas_cserve2_font_glyph_bitmap_get(Font_Entry *fe, unsigned int idx,
1746 Font_Hint_Flags hints)
1672{ 1747{
1673 Fash_Glyph2 *fash; 1748 Fash_Glyph2 *fash;
1674 CS_Glyph_Out *out; 1749 CS_Glyph_Out *out;
@@ -1687,7 +1762,7 @@ evas_cserve2_font_glyph_bitmap_get(Font_Entry *fe, unsigned int idx, Font_Hint_F
1687 if (!fash) 1762 if (!fash)
1688 { 1763 {
1689 // this should not happen really, so let the user know he fucked up 1764 // this should not happen really, so let the user know he fucked up
1690 ERR("%s was called with a hinting value that was not requested!", __FUNCTION__); 1765 ERR("was called with a hinting value that was not requested!");
1691 return NULL; 1766 return NULL;
1692 } 1767 }
1693 1768
@@ -1696,9 +1771,14 @@ evas_cserve2_font_glyph_bitmap_get(Font_Entry *fe, unsigned int idx, Font_Hint_F
1696 { 1771 {
1697 // again, if we are asking for a bitmap we were supposed to already 1772 // again, if we are asking for a bitmap we were supposed to already
1698 // have requested the glyph, it must be there 1773 // have requested the glyph, it must be there
1699 ERR("%s was called with a glyph index that was not requested!", __FUNCTION__); 1774 ERR("was called with a glyph index that was not requested!");
1700 return NULL; 1775 return NULL;
1701 } 1776 }
1777
1778#if USE_SHARED_INDEX
1779 _font_entry_glyph_map_rebuild_check(fe, hints);
1780#endif
1781
1702 if (out->rid) 1782 if (out->rid)
1703 _server_dispatch_until(out->rid); 1783 _server_dispatch_until(out->rid);
1704 1784
diff --git a/src/lib/evas/cserve2/evas_cs2_private.h b/src/lib/evas/cserve2/evas_cs2_private.h
index b1719e87f1..8d12e693c7 100644
--- a/src/lib/evas/cserve2/evas_cs2_private.h
+++ b/src/lib/evas/cserve2/evas_cs2_private.h
@@ -39,10 +39,11 @@ struct _Shared_Index
39 union 39 union
40 { 40 {
41 const char *p; // Random access 41 const char *p; // Random access
42 const Index_Entry *index; // TODO for strings 42 const Index_Entry *index;
43 const Image_Data *idata; 43 const Image_Data *idata;
44 const File_Data *filedata; 44 const File_Data *filedata;
45 const Font_Data *fontdata; 45 const Font_Data *fontdata;
46 const Glyph_Data *gldata;
46 } entries; 47 } entries;
47 int count; 48 int count;
48 Eina_Hash *entries_by_hkey; 49 Eina_Hash *entries_by_hkey;