From 4ee6706770ec47678b41b08fb27f816bd64fd7b1 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sun, 30 Jan 2011 10:37:52 +0000 Subject: [PATCH] Evas font-engine: cache harfbuzz's face. SVN revision: 56466 --- .../src/lib/engines/common/evas_font_load.c | 13 +++++++++ .../src/lib/engines/common/evas_font_ot.c | 29 ++++++++++++++----- .../src/lib/engines/common/evas_font_ot.h | 6 ++++ legacy/evas/src/lib/include/evas_common.h | 7 +++++ 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/legacy/evas/src/lib/engines/common/evas_font_load.c b/legacy/evas/src/lib/engines/common/evas_font_load.c index daa4f961b0..01ecdc97b9 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_load.c +++ b/legacy/evas/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/legacy/evas/src/lib/engines/common/evas_font_ot.c b/legacy/evas/src/lib/engines/common/evas_font_ot.c index 06ad6b9ea9..fb1e7ec58d 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_ot.c +++ b/legacy/evas/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; } -static void -_evas_common_font_ot_shape(hb_buffer_t *buffer, FT_Face face) +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, 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/legacy/evas/src/lib/engines/common/evas_font_ot.h b/legacy/evas/src/lib/engines/common/evas_font_ot.h index 2b0be761c2..c219cac3ea 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_ot.h +++ b/legacy/evas/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/legacy/evas/src/lib/include/evas_common.h b/legacy/evas/src/lib/include/evas_common.h index 4cefba91a3..b43f937c39 100644 --- a/legacy/evas/src/lib/include/evas_common.h +++ b/legacy/evas/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