From ff8e75bbd19245caf893ea924cf59548e485485b Mon Sep 17 00:00:00 2001 From: tasn Date: Sun, 30 Jan 2011 10:37:52 +0000 Subject: [PATCH] Evas font-engine: cache harfbuzz's face. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@56466 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/engines/common/evas_font_load.c | 13 +++++++++++++ src/lib/engines/common/evas_font_ot.c | 27 ++++++++++++++++++++------- src/lib/engines/common/evas_font_ot.h | 6 ++++++ src/lib/include/evas_common.h | 7 +++++++ 4 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/lib/engines/common/evas_font_load.c b/src/lib/engines/common/evas_font_load.c index daa4f96..01ecdc9 100644 --- a/src/lib/engines/common/evas_font_load.c +++ b/src/lib/engines/common/evas_font_load.c @@ -4,6 +4,7 @@ #include #include "evas_font_private.h" /* for Frame-Queuing support */ +#include "evas_font_ot.h" extern FT_Library evas_ft_lib; @@ -164,6 +165,12 @@ evas_common_font_source_unload(RGBA_Font_Source *fs) FTLOCK(); FT_Done_Face(fs->ft.face); fs->ft.face = NULL; +#ifdef OT_SUPPORT + if (evas_common_font_ot_is_enabled()) + { + evas_common_font_ot_unload_face(fs); + } +#endif FTUNLOCK(); } @@ -213,6 +220,12 @@ evas_common_font_source_load_complete(RGBA_Font_Source *fs) fs->ft.face = NULL; return error; } +#ifdef OT_SUPPORT + if (evas_common_font_ot_is_enabled()) + { + evas_common_font_ot_load_face(fs); + } +#endif FTUNLOCK(); fs->ft.orig_upem = fs->ft.face->units_per_EM; return error; diff --git a/src/lib/engines/common/evas_font_ot.c b/src/lib/engines/common/evas_font_ot.c index 06ad6b9..fb1e7ec 100644 --- a/src/lib/engines/common/evas_font_ot.c +++ b/src/lib/engines/common/evas_font_ot.c @@ -85,18 +85,31 @@ evas_common_font_ot_cluster_size_get(const Evas_Text_Props *props, size_t char_i return (items > 0) ? items : 1; } +EAPI void +evas_common_font_ot_load_face(void *_font) +{ + RGBA_Font_Source *font = (RGBA_Font_Source *) _font; + font->hb.face = hb_ft_face_create(font->ft.face, NULL); +} + +EAPI void +evas_common_font_ot_unload_face(void *_font) +{ + RGBA_Font_Source *font = (RGBA_Font_Source *) _font; + if (!font->hb.face) return; + hb_face_destroy(font->hb.face); + font->hb.face = NULL; +} + static void -_evas_common_font_ot_shape(hb_buffer_t *buffer, FT_Face face) +_evas_common_font_ot_shape(hb_buffer_t *buffer, RGBA_Font_Source *src) { - hb_face_t *hb_face; hb_font_t *hb_font; - hb_face = hb_ft_face_create(face, NULL); - hb_font = hb_ft_font_create(face, NULL); + hb_font = hb_ft_font_create(src->ft.face, NULL); - hb_shape(hb_font, hb_face, buffer, NULL, 0); + hb_shape(hb_font, src->hb.face, buffer, NULL, 0); hb_font_destroy(hb_font); - hb_face_destroy(hb_face); } EAPI Eina_Bool @@ -149,7 +162,7 @@ evas_common_font_ot_populate_text_props(void *_fn, const Eina_Unicode *text, /* FIXME: add run-time conversions if needed, which is very unlikely */ hb_buffer_add_utf32(buffer, (const uint32_t *) text, slen, 0, slen); - _evas_common_font_ot_shape(buffer, fi->src->ft.face); + _evas_common_font_ot_shape(buffer, fi->src); props->ot_data->len = hb_buffer_get_length(buffer); props->ot_data->items = calloc(props->ot_data->len, diff --git a/src/lib/engines/common/evas_font_ot.h b/src/lib/engines/common/evas_font_ot.h index 2b0be76..c219cac 100644 --- a/src/lib/engines/common/evas_font_ot.h +++ b/src/lib/engines/common/evas_font_ot.h @@ -62,6 +62,12 @@ evas_common_font_ot_props_ref(Evas_Font_OT_Data *data); EAPI void evas_common_font_ot_props_unref(Evas_Font_OT_Data *data); +EAPI void +evas_common_font_ot_load_face(void *_font); + +EAPI void +evas_common_font_ot_unload_face(void *_font); + #include "evas_text_utils.h" EAPI int evas_common_font_ot_cluster_size_get(const Evas_Text_Props *props, size_t char_index, int orig_len); diff --git a/src/lib/include/evas_common.h b/src/lib/include/evas_common.h index 4cefba9..b43f937 100644 --- a/src/lib/include/evas_common.h +++ b/src/lib/include/evas_common.h @@ -884,6 +884,8 @@ struct _RGBA_Font_Int unsigned char inuse : 1; }; +#include "../engines/common/evas_font_ot.h" + struct _RGBA_Font_Source { const char *name; @@ -896,6 +898,11 @@ struct _RGBA_Font_Source int orig_upem; FT_Face face; } ft; +#ifdef OT_SUPPORT + struct { + void *face; + } hb; +#endif }; struct _RGBA_Font_Glyph -- 2.7.4