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-19 12:22:19 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2013-10-28 15:47:14 +0900
commit467b1b17395cf712ee4ec1ac4a3cef710370ed6d (patch)
tree7fa5098167eb0bb85149276ed716258c61212610 /src/lib/evas/cserve2/evas_cs2_client.c
parentc7515f3300157419c42d8a9d224c46babebae37c (diff)
evas/cserve2: Store Glyph_Data in shared mempools
- Create one Glyph_Data array per Font_Entry - Copy Font_Source descriptors in shared array - Copy font entries in shared index - Send font index path over socket - Merge Font_Source and Font_Data in shared memory - Send font index path on client connect - Repack font index after free - Pass font shm name to clients
Diffstat (limited to '')
-rw-r--r--src/lib/evas/cserve2/evas_cs2_client.c218
1 files changed, 141 insertions, 77 deletions
diff --git a/src/lib/evas/cserve2/evas_cs2_client.c b/src/lib/evas/cserve2/evas_cs2_client.c
index 97f4315529..47ede9bf68 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -1085,6 +1085,9 @@ struct _Font_Entry
1085 unsigned int dpi; 1085 unsigned int dpi;
1086 Font_Rend_Flags wanted_rend; 1086 Font_Rend_Flags wanted_rend;
1087 1087
1088 char *hkey;
1089 int font_data_id;
1090
1088 unsigned int rid; // open 1091 unsigned int rid; // open
1089 1092
1090 Eina_Hash *glyphs_maps; 1093 Eina_Hash *glyphs_maps;
@@ -1305,8 +1308,12 @@ _glyph_request_cb(void *data, const void *msg, int size)
1305 const Msg_Font_Glyphs_Loaded *resp = msg; 1308 const Msg_Font_Glyphs_Loaded *resp = msg;
1306 Glyph_Request_Data *grd = data; 1309 Glyph_Request_Data *grd = data;
1307 Font_Entry *fe = grd->fe; 1310 Font_Entry *fe = grd->fe;
1308 unsigned int ncaches;
1309 const char *buf; 1311 const char *buf;
1312 int i, nglyphs;
1313 int namelen;
1314 const char *name;
1315 Glyph_Map *map;
1316 int pos;
1310 1317
1311 if (resp->base.type == CSERVE2_ERROR) 1318 if (resp->base.type == CSERVE2_ERROR)
1312 goto end; 1319 goto end;
@@ -1317,89 +1324,82 @@ _glyph_request_cb(void *data, const void *msg, int size)
1317 if (size <= (int) sizeof(*resp)) goto end; 1324 if (size <= (int) sizeof(*resp)) goto end;
1318 1325
1319 buf = (const char *)resp + sizeof(*resp); 1326 buf = (const char *)resp + sizeof(*resp);
1320 for (ncaches = 0; ncaches < resp->ncaches; ncaches++) 1327 pos = buf - (const char*) resp;
1321 {
1322 int i, nglyphs;
1323 int namelen;
1324 const char *name;
1325 Glyph_Map *map;
1326 int pos = buf - (const char*) resp;
1327 1328
1328 pos += sizeof(int); 1329 pos += sizeof(int);
1329 if (pos > size) goto end; 1330 if (pos > size) goto end;
1330 1331
1331 memcpy(&namelen, buf, sizeof(int)); 1332 memcpy(&namelen, buf, sizeof(int));
1332 buf += sizeof(int); 1333 buf += sizeof(int);
1333 1334
1334 pos += namelen + sizeof(int); 1335 pos += namelen + sizeof(int);
1335 if (pos > size) goto end; 1336 if (pos > size) goto end;
1336 1337
1337 name = eina_stringshare_add_length(buf, namelen); 1338 name = eina_stringshare_add_length(buf, namelen);
1338 buf += namelen; 1339 buf += namelen;
1339 1340
1340 memcpy(&nglyphs, buf, sizeof(int)); 1341 memcpy(&nglyphs, buf, sizeof(int));
1341 buf += sizeof(int); 1342 buf += sizeof(int);
1342 1343
1343 map = eina_hash_find(fe->glyphs_maps, name); 1344 map = eina_hash_find(fe->glyphs_maps, name);
1344 if (!map) 1345 if (!map)
1345 { 1346 {
1346 map = calloc(1, sizeof(*map)); 1347 map = calloc(1, sizeof(*map));
1347 map->fe = fe; 1348 map->fe = fe;
1348 map->name = name; 1349 map->name = name;
1349 map->map = eina_file_open(name, EINA_TRUE); 1350 map->map = eina_file_open(name, EINA_TRUE);
1350 map->data = eina_file_map_all(map->map, EINA_FILE_WILLNEED); 1351 map->data = eina_file_map_all(map->map, EINA_FILE_WILLNEED);
1351 eina_clist_init(&map->glyphs); 1352 eina_clist_init(&map->glyphs);
1352 eina_hash_direct_add(fe->glyphs_maps, &map->name, map); 1353 eina_hash_direct_add(fe->glyphs_maps, &map->name, map);
1353 } 1354 }
1354 else 1355 else
1355 eina_stringshare_del(name); 1356 eina_stringshare_del(name);
1357
1358 for (i = 0; i < nglyphs; i++)
1359 {
1360 string_t shm_id;
1361 unsigned int idx, offset, glsize;
1362 int rows, width, pitch, num_grays, pixel_mode;
1363 CS_Glyph_Out *gl;
1364
1365 pos = buf - (const char*) resp;
1366 pos += 8 * sizeof(int);
1367 if (pos > size) goto end;
1356 1368
1357 for (i = 0; i < nglyphs; i++) 1369 memcpy(&idx, buf, sizeof(int));
1370 buf += sizeof(int);
1371 memcpy(&shm_id, buf, sizeof(string_t));
1372 buf += sizeof(string_t);
1373 memcpy(&offset, buf, sizeof(int));
1374 buf += sizeof(int);
1375 memcpy(&glsize, buf, sizeof(int));
1376 buf += sizeof(int);
1377 memcpy(&rows, buf, sizeof(int));
1378 buf += sizeof(int);
1379 memcpy(&width, buf, sizeof(int));
1380 buf += sizeof(int);
1381 memcpy(&pitch, buf, sizeof(int));
1382 buf += sizeof(int);
1383 memcpy(&num_grays, buf, sizeof(int));
1384 buf += sizeof(int);
1385 memcpy(&pixel_mode, buf, sizeof(int));
1386 buf += sizeof(int);
1387
1388 gl = fash_gl_find(fe->fash[grd->hints], idx);
1389 if (gl)
1358 { 1390 {
1359 string_t shm_id; 1391 gl->map = map;
1360 unsigned int idx, offset, glsize; 1392 gl->offset = offset;
1361 int rows, width, pitch, num_grays, pixel_mode; 1393 gl->size = glsize;
1362 CS_Glyph_Out *gl; 1394 gl->base.bitmap.rows = rows;
1363 1395 gl->base.bitmap.width = width;
1364 pos = buf - (const char*) resp; 1396 gl->base.bitmap.pitch = pitch;
1365 pos += 8 * sizeof(int); 1397 gl->base.bitmap.buffer = map->data + gl->offset;
1366 if (pos > size) goto end; 1398 gl->base.bitmap.num_grays = num_grays;
1367 1399 gl->base.bitmap.pixel_mode = pixel_mode;
1368 memcpy(&idx, buf, sizeof(int)); 1400 gl->rid = 0;
1369 buf += sizeof(int); 1401
1370 memcpy(&shm_id, buf, sizeof(string_t)); 1402 eina_clist_add_head(&map->glyphs, &gl->map_entry);
1371 buf += sizeof(string_t);
1372 memcpy(&offset, buf, sizeof(int));
1373 buf += sizeof(int);
1374 memcpy(&glsize, buf, sizeof(int));
1375 buf += sizeof(int);
1376 memcpy(&rows, buf, sizeof(int));
1377 buf += sizeof(int);
1378 memcpy(&width, buf, sizeof(int));
1379 buf += sizeof(int);
1380 memcpy(&pitch, buf, sizeof(int));
1381 buf += sizeof(int);
1382 memcpy(&num_grays, buf, sizeof(int));
1383 buf += sizeof(int);
1384 memcpy(&pixel_mode, buf, sizeof(int));
1385 buf += sizeof(int);
1386
1387 gl = fash_gl_find(fe->fash[grd->hints], idx);
1388 if (gl)
1389 {
1390 gl->map = map;
1391 gl->offset = offset;
1392 gl->size = glsize;
1393 gl->base.bitmap.rows = rows;
1394 gl->base.bitmap.width = width;
1395 gl->base.bitmap.pitch = pitch;
1396 gl->base.bitmap.buffer = map->data + gl->offset;
1397 gl->base.bitmap.num_grays = num_grays;
1398 gl->base.bitmap.pixel_mode = pixel_mode;
1399 gl->rid = 0;
1400
1401 eina_clist_add_head(&map->glyphs, &gl->map_entry);
1402 }
1403 } 1403 }
1404 } 1404 }
1405 1405
@@ -1858,7 +1858,8 @@ _shared_image_entry_file_data_find(Image_Entry *ie)
1858 file = _shared_string_get(fd->path); 1858 file = _shared_string_get(fd->path);
1859 if (!file) 1859 if (!file)
1860 { 1860 {
1861 ERR("Could not find filename for file %d", fd->id); 1861 ERR("Could not find filename for file %d: path id: %d",
1862 fd->id, fd->path);
1862 add_to_hash = EINA_FALSE; 1863 add_to_hash = EINA_FALSE;
1863 continue; 1864 continue;
1864 } 1865 }
@@ -2191,5 +2192,68 @@ found:
2191 return idata; 2192 return idata;
2192} 2193}
2193 2194
2195static const Font_Data *
2196_shared_font_entry_data_get_by_id(int id)
2197{
2198 return (Font_Data *)
2199 _shared_index_item_get_by_id(&_index.fonts, sizeof(Font_Data), id);
2200}
2201
2202static const Font_Data *
2203_shared_font_entry_data_find(Font_Entry *fe)
2204{
2205 const Font_Data *fd = NULL;
2206 Eina_Bool add_to_hash = SHARED_INDEX_ADD_TO_HASH;
2207 char hkey[PATH_MAX];
2208 int k;
2209
2210 if (!_index.strings_entries.data || !_index.strings_index.data)
2211 return NULL;
2212
2213 if (!fe || !fe->hkey)
2214 return NULL;
2215
2216 if (fe->font_data_id)
2217 {
2218 fd = _shared_font_entry_data_get_by_id(fe->font_data_id);
2219 if (fd) return fd;
2220 fe->font_data_id = 0;
2221 }
2222
2223 // Find in hash
2224 fd = eina_hash_find(_index.fonts.entries_by_hkey, fe->hkey);
2225 if (fd) return fd;
2226
2227 // Find in shared index
2228 for (k = _index.fonts.last_entry_in_hash;
2229 k < _index.fonts.count && k < _index.fonts.header->emptyidx; k++)
2230 {
2231 const Font_Data *cur;
2232 const char *name, *source;
2233
2234 cur = &(_index.fonts.entries.fontdata[k]);
2235 if (!cur->id) return NULL;
2236 if (!cur->refcount) continue;
2237
2238 name = _shared_string_get(cur->name);
2239 source = _shared_string_get(cur->file);
2240 snprintf(hkey, PATH_MAX, "%s:%s/%u:%u:%u", source, name,
2241 cur->size, cur->dpi, cur->rend_flags);
2242
2243 if (add_to_hash)
2244 {
2245 eina_hash_add(_index.fonts.entries_by_hkey, hkey, cur);
2246 _index.fonts.last_entry_in_hash++;
2247 }
2248
2249 if (!strcmp(hkey, fe->hkey))
2250 {
2251 fe->font_data_id = cur->id;
2252 return cur;
2253 }
2254 }
2255
2256 return fd;
2257}
2194 2258
2195#endif 2259#endif