summaryrefslogtreecommitdiff
path: root/src/bin/evas
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-01-13 05:13:00 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-01-13 05:15:32 +0900
commit86a97efeea946a760ed1fd0fb3ca4cc57bc81d3d (patch)
tree5b31f95b12083b653c7c8fa90c58c1b5c8d76f15 /src/bin/evas
parentf21b0ee6c383b9de2723d68a5a51f071624cd29d (diff)
evas - fonts - move to using 4bit and rel 4 bit compressed font glyphs
this changes the internal encoding of font glyphs in evas to use 4bit uncompressed if small, or 4bit rle (run length encoded) if larger. this caves at least 50% of memory on fonts - and more if bigger. with large fonts (40-80pixel size) we can save in the region of 80% of memory used for glyphs. this also happesn to allow speedups in rendering too.
Diffstat (limited to 'src/bin/evas')
-rw-r--r--src/bin/evas/evas_cserve2.h2
-rw-r--r--src/bin/evas/evas_cserve2_cache.c6
-rw-r--r--src/bin/evas/evas_cserve2_fonts.c27
3 files changed, 22 insertions, 13 deletions
diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index 6732d075dd..86b3f8ca3b 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -196,8 +196,6 @@ struct _Slave_Msg_Glyph {
196 unsigned int rows; 196 unsigned int rows;
197 unsigned int width; 197 unsigned int width;
198 unsigned int pitch; 198 unsigned int pitch;
199 unsigned int num_grays;
200 unsigned int pixel_mode;
201}; 199};
202 200
203typedef struct _Slave_Msg_Glyph Slave_Msg_Glyph; 201typedef struct _Slave_Msg_Glyph Slave_Msg_Glyph;
diff --git a/src/bin/evas/evas_cserve2_cache.c b/src/bin/evas/evas_cserve2_cache.c
index d3429f6db3..3b04245137 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -1933,10 +1933,6 @@ _glyphs_loaded_msg_create(Glyphs_Request *req, int *resp_size)
1933 buf += sizeof(int); 1933 buf += sizeof(int);
1934 memcpy(buf, &gldata->pitch, sizeof(int)); 1934 memcpy(buf, &gldata->pitch, sizeof(int));
1935 buf += sizeof(int); 1935 buf += sizeof(int);
1936 memcpy(buf, &gldata->num_grays, sizeof(int));
1937 buf += sizeof(int);
1938 memcpy(buf, &gldata->pixel_mode, sizeof(int));
1939 buf += sizeof(int);
1940 memcpy(buf, &gldata->hint, sizeof(int)); 1936 memcpy(buf, &gldata->hint, sizeof(int));
1941 buf += sizeof(int); 1937 buf += sizeof(int);
1942 } 1938 }
@@ -2177,8 +2173,6 @@ _glyphs_load_request_response(Glyphs_Request *req,
2177 gldata->rows = msg->glyphs[j].rows; 2173 gldata->rows = msg->glyphs[j].rows;
2178 gldata->width = msg->glyphs[j].width; 2174 gldata->width = msg->glyphs[j].width;
2179 gldata->pitch = msg->glyphs[j].pitch; 2175 gldata->pitch = msg->glyphs[j].pitch;
2180 gldata->num_grays = msg->glyphs[j].num_grays;
2181 gldata->pixel_mode = msg->glyphs[j].pixel_mode;
2182 gldata->hint = hint; 2176 gldata->hint = hint;
2183 2177
2184 fe->nglyphs++; 2178 fe->nglyphs++;
diff --git a/src/bin/evas/evas_cserve2_fonts.c b/src/bin/evas/evas_cserve2_fonts.c
index 782a9d1ff6..a13630b2d9 100644
--- a/src/bin/evas/evas_cserve2_fonts.c
+++ b/src/bin/evas/evas_cserve2_fonts.c
@@ -313,6 +313,9 @@ _font_slave_glyph_load(Font_Info *fi, unsigned int idx, unsigned int hint)
313 return EINA_TRUE; 313 return EINA_TRUE;
314} 314}
315 315
316// import the 1 func we need
317EAPI void *evas_common_font_glyph_compress(void *data, int num_grays, int pixel_mode, int pitch_data, int w, int h, int *size_ret);
318
316/* This function will render the glyph currently in the glyph slot into the 319/* This function will render the glyph currently in the glyph slot into the
317 * given Font Cache. 320 * given Font Cache.
318 */ 321 */
@@ -321,18 +324,32 @@ _font_slave_glyph_render(Font_Info *fi, Slave_Msg_Font_Glyphs_Loaded *response,
321 unsigned int idx) 324 unsigned int idx)
322{ 325{
323 Font_Source_Info *fsi = fi->fsi; 326 Font_Source_Info *fsi = fi->fsi;
324 unsigned int glyphsize; 327 int glyphsize = 0;
325 FT_Glyph glyph; 328 FT_Glyph glyph;
326 FT_BitmapGlyph bglyph; 329 FT_BitmapGlyph bglyph;
327 char *data; 330 char *data;
328 int buffer_id = 0; 331 int buffer_id = 0;
332 void *buf;
329 333
330 FT_Get_Glyph(fsi->face->glyph, &glyph); 334 FT_Get_Glyph(fsi->face->glyph, &glyph);
331 FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, 0, 1); 335 FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, 0, 1);
332 bglyph = (FT_BitmapGlyph)glyph; 336 bglyph = (FT_BitmapGlyph)glyph;
333 337
338 if ((bglyph->bitmap.pitch < 1) || (bglyph->bitmap.rows < 1))
339 {
340 FT_Done_Glyph(glyph);
341 goto on_error;
342 }
334 glyphsize = bglyph->bitmap.pitch * bglyph->bitmap.rows; 343 glyphsize = bglyph->bitmap.pitch * bglyph->bitmap.rows;
335 if (!glyphsize) 344
345 buf = evas_common_font_glyph_compress(bglyph->bitmap.buffer,
346 bglyph->bitmap.num_grays,
347 bglyph->bitmap.pixel_mode,
348 bglyph->bitmap.pitch,
349 bglyph->bitmap.width,
350 bglyph->bitmap.rows,
351 &glyphsize);
352 if (!buf)
336 { 353 {
337 FT_Done_Glyph(glyph); 354 FT_Done_Glyph(glyph);
338 goto on_error; 355 goto on_error;
@@ -342,10 +359,12 @@ _font_slave_glyph_render(Font_Info *fi, Slave_Msg_Font_Glyphs_Loaded *response,
342 data = cserve2_shared_mempool_buffer_get(response->mempool, buffer_id); 359 data = cserve2_shared_mempool_buffer_get(response->mempool, buffer_id);
343 if (!data) 360 if (!data)
344 { 361 {
362 free(buf);
345 FT_Done_Glyph(glyph); 363 FT_Done_Glyph(glyph);
346 goto on_error; 364 goto on_error;
347 } 365 }
348 memcpy(data, bglyph->bitmap.buffer, glyphsize); 366 memcpy(data, buf, glyphsize);
367 free(buf);
349 368
350 // TODO: Check if we have problems with alignment 369 // TODO: Check if we have problems with alignment
351 response->glyphs[response->nglyphs].index = idx; 370 response->glyphs[response->nglyphs].index = idx;
@@ -356,8 +375,6 @@ _font_slave_glyph_render(Font_Info *fi, Slave_Msg_Font_Glyphs_Loaded *response,
356 response->glyphs[response->nglyphs].rows = bglyph->bitmap.rows; 375 response->glyphs[response->nglyphs].rows = bglyph->bitmap.rows;
357 response->glyphs[response->nglyphs].width = bglyph->bitmap.width; 376 response->glyphs[response->nglyphs].width = bglyph->bitmap.width;
358 response->glyphs[response->nglyphs].pitch = bglyph->bitmap.pitch; 377 response->glyphs[response->nglyphs].pitch = bglyph->bitmap.pitch;
359 response->glyphs[response->nglyphs].num_grays = bglyph->bitmap.num_grays;
360 response->glyphs[response->nglyphs].pixel_mode = bglyph->bitmap.pixel_mode;
361 response->nglyphs++; 378 response->nglyphs++;
362 379
363 FT_Done_Glyph(glyph); 380 FT_Done_Glyph(glyph);