forked from enlightenment/efl
evas/cserve2: Split out the glyph rendering code from
glyph_get(). Now it's possible to get a font glyph without needing to render it (although Evas is not doing so). SVN revision: 71131
This commit is contained in:
parent
633cba4505
commit
d94025ca29
|
@ -20,6 +20,7 @@ EAPI int evas_common_font_get_line_advance (RGBA_Font *fn);
|
||||||
EAPI void evas_common_font_draw (RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, const Evas_Text_Props *intl_props);
|
EAPI void evas_common_font_draw (RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, const Evas_Text_Props *intl_props);
|
||||||
EAPI int evas_common_font_glyph_search (RGBA_Font *fn, RGBA_Font_Int **fi_ret, Eina_Unicode gl);
|
EAPI int evas_common_font_glyph_search (RGBA_Font *fn, RGBA_Font_Int **fi_ret, Eina_Unicode gl);
|
||||||
EAPI RGBA_Font_Glyph *evas_common_font_int_cache_glyph_get (RGBA_Font_Int *fi, FT_UInt index);
|
EAPI RGBA_Font_Glyph *evas_common_font_int_cache_glyph_get (RGBA_Font_Int *fi, FT_UInt index);
|
||||||
|
EAPI Eina_Bool evas_common_font_int_cache_glyph_render(RGBA_Font_Glyph *fg);
|
||||||
EAPI FT_UInt evas_common_get_char_index (RGBA_Font_Int* fi, Eina_Unicode gl);
|
EAPI FT_UInt evas_common_get_char_index (RGBA_Font_Int* fi, Eina_Unicode gl);
|
||||||
EAPI void evas_common_font_draw_init (void);
|
EAPI void evas_common_font_draw_init (void);
|
||||||
EAPI void evas_common_font_draw_prepare (Evas_Text_Props *text_props);
|
EAPI void evas_common_font_draw_prepare (Evas_Text_Props *text_props);
|
||||||
|
|
|
@ -85,6 +85,8 @@ evas_common_font_draw_internal(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, in
|
||||||
|
|
||||||
fg = evas_common_font_int_cache_glyph_get(fi, idx);
|
fg = evas_common_font_int_cache_glyph_get(fi, idx);
|
||||||
if (!fg) continue;
|
if (!fg) continue;
|
||||||
|
if ((!fg->glyph_out) && (!evas_common_font_int_cache_glyph_render(fg)))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (dc->font_ext.func.gl_new)
|
if (dc->font_ext.func.gl_new)
|
||||||
{
|
{
|
||||||
|
@ -291,6 +293,8 @@ evas_common_font_draw_prepare(Evas_Text_Props *text_props)
|
||||||
idx = EVAS_FONT_WALK_INDEX;
|
idx = EVAS_FONT_WALK_INDEX;
|
||||||
|
|
||||||
fg = evas_common_font_int_cache_glyph_get(fi, idx);
|
fg = evas_common_font_int_cache_glyph_get(fi, idx);
|
||||||
|
if (!fg) continue;
|
||||||
|
if (!fg->glyph_out) evas_common_font_int_cache_glyph_render(fg);
|
||||||
}
|
}
|
||||||
EVAS_FONT_WALK_TEXT_END();
|
EVAS_FONT_WALK_TEXT_END();
|
||||||
|
|
||||||
|
|
|
@ -337,9 +337,7 @@ EAPI RGBA_Font_Glyph *
|
||||||
evas_common_font_int_cache_glyph_get(RGBA_Font_Int *fi, FT_UInt idx)
|
evas_common_font_int_cache_glyph_get(RGBA_Font_Int *fi, FT_UInt idx)
|
||||||
{
|
{
|
||||||
RGBA_Font_Glyph *fg;
|
RGBA_Font_Glyph *fg;
|
||||||
FT_UInt hindex;
|
|
||||||
FT_Error error;
|
FT_Error error;
|
||||||
int size;
|
|
||||||
const FT_Int32 hintflags[3] =
|
const FT_Int32 hintflags[3] =
|
||||||
{ FT_LOAD_NO_HINTING, FT_LOAD_FORCE_AUTOHINT, FT_LOAD_NO_AUTOHINT };
|
{ FT_LOAD_NO_HINTING, FT_LOAD_FORCE_AUTOHINT, FT_LOAD_NO_AUTOHINT };
|
||||||
static FT_Matrix transform = {0x10000, 0x05000, 0x0000, 0x10000}; // about 12 degree.
|
static FT_Matrix transform = {0x10000, 0x05000, 0x0000, 0x10000}; // about 12 degree.
|
||||||
|
@ -352,8 +350,6 @@ evas_common_font_int_cache_glyph_get(RGBA_Font_Int *fi, FT_UInt idx)
|
||||||
else if (fg) return fg;
|
else if (fg) return fg;
|
||||||
}
|
}
|
||||||
|
|
||||||
hindex = idx + (fi->hinting * 500000000);
|
|
||||||
|
|
||||||
// fg = eina_hash_find(fi->glyphs, &hindex);
|
// fg = eina_hash_find(fi->glyphs, &hindex);
|
||||||
// if (fg) return fg;
|
// if (fg) return fg;
|
||||||
|
|
||||||
|
@ -393,6 +389,22 @@ evas_common_font_int_cache_glyph_get(RGBA_Font_Int *fi, FT_UInt idx)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fg->index = idx;
|
||||||
|
fg->fi = fi;
|
||||||
|
|
||||||
|
if (!fi->fash) fi->fash = _fash_gl_new();
|
||||||
|
if (fi->fash) _fash_gl_add(fi->fash, idx, fg);
|
||||||
|
|
||||||
|
// eina_hash_direct_add(fi->glyphs, &fg->index, fg);
|
||||||
|
return fg;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI Eina_Bool
|
||||||
|
evas_common_font_int_cache_glyph_render(RGBA_Font_Glyph *fg)
|
||||||
|
{
|
||||||
|
int size;
|
||||||
|
FT_Error error;
|
||||||
|
RGBA_Font_Int *fi = fg->fi;
|
||||||
FTLOCK();
|
FTLOCK();
|
||||||
error = FT_Glyph_To_Bitmap(&(fg->glyph), FT_RENDER_MODE_NORMAL, 0, 1);
|
error = FT_Glyph_To_Bitmap(&(fg->glyph), FT_RENDER_MODE_NORMAL, 0, 1);
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -401,17 +413,12 @@ evas_common_font_int_cache_glyph_get(RGBA_Font_Int *fi, FT_UInt idx)
|
||||||
FTUNLOCK();
|
FTUNLOCK();
|
||||||
free(fg);
|
free(fg);
|
||||||
if (!fi->fash) fi->fash = _fash_gl_new();
|
if (!fi->fash) fi->fash = _fash_gl_new();
|
||||||
if (fi->fash) _fash_gl_add(fi->fash, idx, (void *)(-1));
|
if (fi->fash) _fash_gl_add(fi->fash, fg->index, (void *)(-1));
|
||||||
return NULL;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
FTUNLOCK();
|
FTUNLOCK();
|
||||||
|
|
||||||
fg->glyph_out = (FT_BitmapGlyph)fg->glyph;
|
fg->glyph_out = (FT_BitmapGlyph)fg->glyph;
|
||||||
fg->index = hindex;
|
|
||||||
fg->fi = fi;
|
|
||||||
|
|
||||||
if (!fi->fash) fi->fash = _fash_gl_new();
|
|
||||||
if (fi->fash) _fash_gl_add(fi->fash, idx, fg);
|
|
||||||
/* This '+ 200' is just an estimation of how much memory freetype will use
|
/* This '+ 200' is just an estimation of how much memory freetype will use
|
||||||
* on it's size. This value is not really used anywhere in code - it's
|
* on it's size. This value is not really used anywhere in code - it's
|
||||||
* only for statistics. */
|
* only for statistics. */
|
||||||
|
@ -420,8 +427,7 @@ evas_common_font_int_cache_glyph_get(RGBA_Font_Int *fi, FT_UInt idx)
|
||||||
fi->usage += size;
|
fi->usage += size;
|
||||||
if (fi->inuse) evas_common_font_int_use_increase(size);
|
if (fi->inuse) evas_common_font_int_use_increase(size);
|
||||||
|
|
||||||
// eina_hash_direct_add(fi->glyphs, &fg->index, fg);
|
return EINA_TRUE;
|
||||||
return fg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct _Font_Char_Index Font_Char_Index;
|
typedef struct _Font_Char_Index Font_Char_Index;
|
||||||
|
|
|
@ -337,6 +337,11 @@ evas_common_text_props_content_create(void *_fi, const Eina_Unicode *text,
|
||||||
LKU(fi->ft_mutex);
|
LKU(fi->ft_mutex);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if ((!fg->glyph_out) && (!evas_common_font_int_cache_glyph_render(fg)))
|
||||||
|
{
|
||||||
|
LKU(fi->ft_mutex);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
LKU(fi->ft_mutex);
|
LKU(fi->ft_mutex);
|
||||||
|
|
||||||
gl_itr->x_bear = fg->glyph_out->left;
|
gl_itr->x_bear = fg->glyph_out->left;
|
||||||
|
@ -430,6 +435,8 @@ evas_common_text_props_content_create(void *_fi, const Eina_Unicode *text,
|
||||||
|
|
||||||
fg = evas_common_font_int_cache_glyph_get(fi, idx);
|
fg = evas_common_font_int_cache_glyph_get(fi, idx);
|
||||||
if (!fg) continue;
|
if (!fg) continue;
|
||||||
|
if ((!fg->glyph_out) && (!evas_common_font_int_cache_glyph_render(fg)))
|
||||||
|
continue;
|
||||||
kern = 0;
|
kern = 0;
|
||||||
|
|
||||||
if ((use_kerning) && (prev_index) && (idx) &&
|
if ((use_kerning) && (prev_index) && (idx) &&
|
||||||
|
|
Loading…
Reference in New Issue