summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2013-09-02 16:17:05 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2013-10-28 15:47:15 +0900
commit808c20f9896d4a92f15a653dd23d7e9088ab84d6 (patch)
tree8eff7c3036b8cd770955d2a1dfc3209c14744a5f /src
parenta7b3f7efd3bf7291109131db7fb694c8eef72248 (diff)
evas/cserve2: Fix font hinting
cserve2 was not handling font hints properly in the server side Add some consistency checks and separate glyphs per hinting value
Diffstat (limited to 'src')
-rw-r--r--src/bin/evas/evas_cserve2_cache.c51
-rw-r--r--src/bin/evas/evas_cserve2_debug.c4
-rw-r--r--src/bin/evas/evas_cserve2_shm_debug.c9
-rw-r--r--src/lib/evas/cserve2/evas_cs2.h1
-rw-r--r--src/lib/evas/cserve2/evas_cs2_client.c12
5 files changed, 57 insertions, 20 deletions
diff --git a/src/bin/evas/evas_cserve2_cache.c b/src/bin/evas/evas_cserve2_cache.c
index b71ce019b8..40cd55df4b 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -73,7 +73,7 @@ struct _Font_Entry {
73 unsigned int font_data_id; 73 unsigned int font_data_id;
74 Font_Source *src; 74 Font_Source *src;
75 void *ft; // Font_Info 75 void *ft; // Font_Info
76 Fash_Glyph2 *glyph_entries; // Fast access to the Glyph_Entry objects 76 Fash_Glyph2 *glyph_entries[3]; // Fast access to the Glyph_Entry objects
77 Shared_Array *glyph_datas; // Contains the Glyph_Data objects 77 Shared_Array *glyph_datas; // Contains the Glyph_Data objects
78 unsigned int nglyphs; 78 unsigned int nglyphs;
79 Eina_Bool unused : 1; 79 Eina_Bool unused : 1;
@@ -1130,7 +1130,7 @@ static void
1130_font_entry_free(Font_Entry *fe) 1130_font_entry_free(Font_Entry *fe)
1131{ 1131{
1132 Font_Data *fd; 1132 Font_Data *fd;
1133 int size; 1133 int size, k;
1134 1134
1135 if (!fe) return; 1135 if (!fe) return;
1136 size = _font_entry_memory_usage_get(fe); 1136 size = _font_entry_memory_usage_get(fe);
@@ -1148,7 +1148,8 @@ _font_entry_free(Font_Entry *fe)
1148 cserve2_shared_string_del(fd->name); 1148 cserve2_shared_string_del(fd->name);
1149 } 1149 }
1150 1150
1151 fash_gl_free(fe->glyph_entries); 1151 for (k = 0; k < 3; k++)
1152 fash_gl_free(fe->glyph_entries[k]);
1152 cserve2_shared_array_del(fe->glyph_datas); 1153 cserve2_shared_array_del(fe->glyph_datas);
1153 cserve2_shared_mempool_del(fe->mempool); 1154 cserve2_shared_mempool_del(fe->mempool);
1154 cserve2_font_ft_free(fe->ft); 1155 cserve2_font_ft_free(fe->ft);
@@ -1720,16 +1721,23 @@ static Slave_Request_Funcs _font_load_funcs = {
1720static Eina_Bool 1721static Eina_Bool
1721_glyphs_request_check(Glyphs_Request *req, Eina_Bool report_load) 1722_glyphs_request_check(Glyphs_Request *req, Eina_Bool report_load)
1722{ 1723{
1723 unsigned int i; 1724 unsigned int i, hint;
1724 Font_Entry *fe = req->fe; 1725 Font_Entry *fe = req->fe;
1725 1726
1726 req->answer = malloc(sizeof(*req->answer) * req->nglyphs); 1727 req->answer = malloc(sizeof(*req->answer) * req->nglyphs);
1727 req->nanswer = 0; 1728 req->nanswer = 0;
1728 1729
1730 hint = req->hint;
1731 if (hint > 2)
1732 {
1733 WRN("Invalid font hint requested. Defaulting to 0.");
1734 hint = 0;
1735 }
1736
1729 for (i = req->current; i < req->nglyphs; i++) 1737 for (i = req->current; i < req->nglyphs; i++)
1730 { 1738 {
1731 Glyph_Entry *ge; 1739 Glyph_Entry *ge;
1732 ge = fash_gl_find(fe->glyph_entries, req->glyphs[i]); 1740 ge = fash_gl_find(fe->glyph_entries[hint], req->glyphs[i]);
1733 if (ge) 1741 if (ge)
1734 { 1742 {
1735 req->answer[req->nanswer++] = ge; 1743 req->answer[req->nanswer++] = ge;
@@ -1767,7 +1775,7 @@ _glyphs_loaded_msg_create(Glyphs_Request *req, int *resp_size)
1767 size = sizeof(Msg_Font_Glyphs_Loaded); 1775 size = sizeof(Msg_Font_Glyphs_Loaded);
1768 size += sizeof(int) * 2; 1776 size += sizeof(int) * 2;
1769 size += shmname_size; 1777 size += shmname_size;
1770 size += req->nanswer * 9 * sizeof(int); 1778 size += req->nanswer * 10 * sizeof(int);
1771 1779
1772 response = malloc(size); 1780 response = malloc(size);
1773 if (!response) return NULL; 1781 if (!response) return NULL;
@@ -1813,6 +1821,8 @@ _glyphs_loaded_msg_create(Glyphs_Request *req, int *resp_size)
1813 buf += sizeof(int); 1821 buf += sizeof(int);
1814 memcpy(buf, &gldata->pixel_mode, sizeof(int)); 1822 memcpy(buf, &gldata->pixel_mode, sizeof(int));
1815 buf += sizeof(int); 1823 buf += sizeof(int);
1824 memcpy(buf, &gldata->hint, sizeof(int));
1825 buf += sizeof(int);
1816 } 1826 }
1817 1827
1818 *resp_size = size; 1828 *resp_size = size;
@@ -1915,7 +1925,7 @@ _glyphs_request_free(Glyphs_Request *req)
1915static void 1925static void
1916_glyphs_load_request_prepare(Glyphs_Request *req) 1926_glyphs_load_request_prepare(Glyphs_Request *req)
1917{ 1927{
1918 unsigned int i, max; 1928 unsigned int i, max, hint;
1919 req->nrender = 0; 1929 req->nrender = 0;
1920 Font_Entry *fe = req->fe; 1930 Font_Entry *fe = req->fe;
1921 1931
@@ -1925,6 +1935,13 @@ _glyphs_load_request_prepare(Glyphs_Request *req)
1925 return; 1935 return;
1926 } 1936 }
1927 1937
1938 hint = req->hint;
1939 if (hint > 2)
1940 {
1941 WRN("Invalid font hint requested. Defaulting to 0.");
1942 hint = 0;
1943 }
1944
1928 // Won't render more than this number of glyphs 1945 // Won't render more than this number of glyphs
1929 max = req->nglyphs - req->nanswer; 1946 max = req->nglyphs - req->nanswer;
1930 req->render = malloc(sizeof(*req->render) * max); 1947 req->render = malloc(sizeof(*req->render) * max);
@@ -1932,7 +1949,7 @@ _glyphs_load_request_prepare(Glyphs_Request *req)
1932 for (i = req->current; i < req->nglyphs; i++) 1949 for (i = req->current; i < req->nglyphs; i++)
1933 { 1950 {
1934 Glyph_Entry *ge; 1951 Glyph_Entry *ge;
1935 ge = fash_gl_find(fe->glyph_entries, req->glyphs[i]); 1952 ge = fash_gl_find(fe->glyph_entries[hint], req->glyphs[i]);
1936 if (ge) 1953 if (ge)
1937 { 1954 {
1938 req->answer[req->nanswer++] = ge; 1955 req->answer[req->nanswer++] = ge;
@@ -1987,13 +2004,20 @@ _glyphs_load_request_response(Glyphs_Request *req,
1987{ 2004{
1988 Font_Entry *fe = req->fe; 2005 Font_Entry *fe = req->fe;
1989 Shared_Mempool *mempool = msg->mempool; 2006 Shared_Mempool *mempool = msg->mempool;
1990 unsigned int j; 2007 unsigned int j, hint;
1991 string_t shm_id = 0; 2008 string_t shm_id = 0;
1992 Font_Data *fd; 2009 Font_Data *fd;
1993 2010
1994 if (!msg->nglyphs) 2011 if (!msg->nglyphs)
1995 return _glyphs_loaded_msg_create(req, size); 2012 return _glyphs_loaded_msg_create(req, size);
1996 2013
2014 hint = req->hint;
2015 if (hint > 2)
2016 {
2017 WRN("Invalid font hint requested. Defaulting to 0.");
2018 hint = 0;
2019 }
2020
1997 fd = _font_data_find(fe->font_data_id); 2021 fd = _font_data_find(fe->font_data_id);
1998 2022
1999 DBG("Font memory usage [begin]: %d / %d", font_mem_usage, max_font_usage); 2023 DBG("Font memory usage [begin]: %d / %d", font_mem_usage, max_font_usage);
@@ -2022,7 +2046,7 @@ _glyphs_load_request_response(Glyphs_Request *req,
2022 { 2046 {
2023 Glyph_Entry *gl; 2047 Glyph_Entry *gl;
2024 2048
2025 gl = fash_gl_find(fe->glyph_entries, msg->glyphs[j].index); 2049 gl = fash_gl_find(fe->glyph_entries[hint], msg->glyphs[j].index);
2026 if (!gl) 2050 if (!gl)
2027 { 2051 {
2028 int glyph_id, orig_mapsize, new_mapsize; 2052 int glyph_id, orig_mapsize, new_mapsize;
@@ -2056,9 +2080,10 @@ _glyphs_load_request_response(Glyphs_Request *req,
2056 gldata->pitch = msg->glyphs[j].pitch; 2080 gldata->pitch = msg->glyphs[j].pitch;
2057 gldata->num_grays = msg->glyphs[j].num_grays; 2081 gldata->num_grays = msg->glyphs[j].num_grays;
2058 gldata->pixel_mode = msg->glyphs[j].pixel_mode; 2082 gldata->pixel_mode = msg->glyphs[j].pixel_mode;
2083 gldata->hint = hint;
2059 2084
2060 fe->nglyphs++; 2085 fe->nglyphs++;
2061 fash_gl_add(fe->glyph_entries, gldata->index, gl); 2086 fash_gl_add(fe->glyph_entries[hint], gldata->index, gl);
2062 2087
2063 new_mapsize = cserve2_shared_array_map_size_get(fe->glyph_datas); 2088 new_mapsize = cserve2_shared_array_map_size_get(fe->glyph_datas);
2064 font_mem_usage += new_mapsize - orig_mapsize; 2089 font_mem_usage += new_mapsize - orig_mapsize;
@@ -2845,6 +2870,7 @@ cserve2_cache_font_load(Client *client, const char *source, const char *name,
2845 Font_Entry *fe; 2870 Font_Entry *fe;
2846 char *fullname; 2871 char *fullname;
2847 int fd_index; 2872 int fd_index;
2873 int k;
2848 2874
2849 if (source && !*source) 2875 if (source && !*source)
2850 source = NULL; 2876 source = NULL;
@@ -2879,7 +2905,8 @@ cserve2_cache_font_load(Client *client, const char *source, const char *name,
2879 fe->size = size; 2905 fe->size = size;
2880 fe->dpi = dpi; 2906 fe->dpi = dpi;
2881 fe->base.type = CSERVE2_FONT_ENTRY; 2907 fe->base.type = CSERVE2_FONT_ENTRY;
2882 fe->glyph_entries = fash_gl_new(_glyph_free_cb); 2908 for (k = 0; k < 3; k++)
2909 fe->glyph_entries[k] = fash_gl_new(_glyph_free_cb);
2883 ref = _entry_reference_add((Entry *)fe, client, 0); 2910 ref = _entry_reference_add((Entry *)fe, client, 0);
2884 client->fonts.referencing = eina_list_append(client->fonts.referencing, ref); 2911 client->fonts.referencing = eina_list_append(client->fonts.referencing, ref);
2885 fe->unused = EINA_FALSE; 2912 fe->unused = EINA_FALSE;
diff --git a/src/bin/evas/evas_cserve2_debug.c b/src/bin/evas/evas_cserve2_debug.c
index 7eaea5d7d9..92c8c8899f 100644
--- a/src/bin/evas/evas_cserve2_debug.c
+++ b/src/bin/evas/evas_cserve2_debug.c
@@ -300,10 +300,10 @@ _glyph_data_print(Glyph_Data *gd)
300 "FT_PIXEL_MODE_LCD_V" 300 "FT_PIXEL_MODE_LCD_V"
301 }; 301 };
302 printf(" GLYPH id: %-4u refcount %-2u: index: %-6u offset: %-6u size: %-3u " 302 printf(" GLYPH id: %-4u refcount %-2u: index: %-6u offset: %-6u size: %-3u "
303 "%2ux%-3u pitch: %-2u grays: %-3u pixel mode: %s\n", 303 "%2ux%-3u pitch: %-2u grays: %-3u pixel mode: %s hint: %d\n",
304 gd->id, gd->refcount, gd->index, gd->offset, gd->size, 304 gd->id, gd->refcount, gd->index, gd->offset, gd->size,
305 gd->width, gd->rows, gd->pitch, 305 gd->width, gd->rows, gd->pitch,
306 gd->num_grays, pxmode[gd->pixel_mode]); 306 gd->num_grays, pxmode[gd->pixel_mode], gd->hint);
307} 307}
308 308
309static void 309static void
diff --git a/src/bin/evas/evas_cserve2_shm_debug.c b/src/bin/evas/evas_cserve2_shm_debug.c
index bde62bd89b..426fd67a95 100644
--- a/src/bin/evas/evas_cserve2_shm_debug.c
+++ b/src/bin/evas/evas_cserve2_shm_debug.c
@@ -586,7 +586,7 @@ _glyphs_all_print(Shm_File *sf)
586 int nglyphs = 0; 586 int nglyphs = 0;
587 int mem_used = 0; 587 int mem_used = 0;
588 588
589 printf(" GlyphID Refcnt Index Size Rows Width Pitch Grays Mode " 589 printf(" GlyphID Refcnt Index Size Rows Width Pitch Grays H M "
590 "BufID Offset ShmPath\n"); 590 "BufID Offset ShmPath\n");
591 591
592 for (k = 0; k < sf->header->count; k++) 592 for (k = 0; k < sf->header->count; k++)
@@ -597,9 +597,9 @@ _glyphs_all_print(Shm_File *sf)
597 if (!gd) break; 597 if (!gd) break;
598 if (!gd->id) continue; 598 if (!gd->id) continue;
599 599
600 printf(" %8u %6u %6u %5u %5u %5u %5u %5u %5u %6u %6u '%s'\n", 600 printf(" %8u %6u %6u %5u %5u %5u %5u %5u %1u %1u %6u %6u '%s'\n",
601 gd->id, gd->refcount, gd->index, gd->size, gd->rows, gd->width, 601 gd->id, gd->refcount, gd->index, gd->size, gd->rows, gd->width,
602 gd->pitch, gd->num_grays, gd->pixel_mode, gd->buffer_id, 602 gd->pitch, gd->num_grays, gd->hint, gd->pixel_mode, gd->buffer_id,
603 gd->offset, _shared_string_get(gd->shm_id)); 603 gd->offset, _shared_string_get(gd->shm_id));
604 604
605 nglyphs++; 605 nglyphs++;
@@ -621,7 +621,8 @@ _fonts_all_print_full(void)
621 621
622 printf("List of loaded fonts: %s\n", eina_file_filename_get(sf_fonts->f)); 622 printf("List of loaded fonts: %s\n", eina_file_filename_get(sf_fonts->f));
623 printf("Rendering flags: " 623 printf("Rendering flags: "
624 "R: Regular, S: Slanted, W: Weight, X: Invalid\n\n"); 624 "R: Regular, S: Slanted, W: Weight, X: Invalid\n");
625 printf("H: Hint, M: Pixel mode\n\n");
625 printf_newline(0); 626 printf_newline(0);
626 627
627 for (k = 0; k < sf_fonts->header->count; k++) 628 for (k = 0; k < sf_fonts->header->count; k++)
diff --git a/src/lib/evas/cserve2/evas_cs2.h b/src/lib/evas/cserve2/evas_cs2.h
index bcba89a5d6..a47c384b82 100644
--- a/src/lib/evas/cserve2/evas_cs2.h
+++ b/src/lib/evas/cserve2/evas_cs2.h
@@ -373,6 +373,7 @@ struct _Glyph_Data {
373 uint32_t pitch; 373 uint32_t pitch;
374 uint32_t num_grays; 374 uint32_t num_grays;
375 uint32_t pixel_mode; 375 uint32_t pixel_mode;
376 uint32_t hint;
376}; 377};
377 378
378struct _Msg_Error { 379struct _Msg_Error {
diff --git a/src/lib/evas/cserve2/evas_cs2_client.c b/src/lib/evas/cserve2/evas_cs2_client.c
index 1538b4967b..e32dc1d684 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -1434,6 +1434,7 @@ _font_entry_glyph_map_rebuild_check(Font_Entry *fe, Font_Hint_Flags hints)
1434 gd = &(fe->map->index.entries.gldata[k]); 1434 gd = &(fe->map->index.entries.gldata[k]);
1435 if (!gd->id) break; 1435 if (!gd->id) break;
1436 if (!gd->refcount) continue; 1436 if (!gd->refcount) continue;
1437 if (gd->hint != hints) continue;
1437 1438
1438 tot++; 1439 tot++;
1439 gl = fash_gl_find(fe->fash[hints], gd->index); 1440 gl = fash_gl_find(fe->fash[hints], gd->index);
@@ -1523,7 +1524,7 @@ _glyph_request_cb(void *data, const void *msg, int size)
1523 for (i = 0; i < nglyphs; i++) 1524 for (i = 0; i < nglyphs; i++)
1524 { 1525 {
1525 string_t shm_id; 1526 string_t shm_id;
1526 unsigned int idx, offset, glsize; 1527 unsigned int idx, offset, glsize, hints;
1527 int rows, width, pitch, num_grays, pixel_mode; 1528 int rows, width, pitch, num_grays, pixel_mode;
1528 CS_Glyph_Out *gl; 1529 CS_Glyph_Out *gl;
1529 1530
@@ -1549,8 +1550,15 @@ _glyph_request_cb(void *data, const void *msg, int size)
1549 buf += sizeof(int); 1550 buf += sizeof(int);
1550 memcpy(&pixel_mode, buf, sizeof(int)); 1551 memcpy(&pixel_mode, buf, sizeof(int));
1551 buf += sizeof(int); 1552 buf += sizeof(int);
1553 memcpy(&hints, buf, sizeof(int));
1554 buf += sizeof(int);
1555 if (hints != grd->hints)
1556 {
1557 WRN("Invalid hints received: %d vs %d. Skip.", hints, grd->hints);
1558 continue;
1559 }
1552 1560
1553 gl = fash_gl_find(fe->fash[grd->hints], idx); 1561 gl = fash_gl_find(fe->fash[hints], idx);
1554 if (gl) 1562 if (gl)
1555 { 1563 {
1556 gl->map = fe->map; 1564 gl->map = fe->map;