From 4a02c3de8ec35e4e3b3ca45c33db4e368f14f7a6 Mon Sep 17 00:00:00 2001 From: tasn Date: Tue, 22 Feb 2011 13:00:02 +0000 Subject: [PATCH] Evas font-engine: Fixed walking to use ptrs instead of indexes. I.e walk using a ptr instead of arr[i] all the time. This should make things faster. Also as part of the change, fixed char_index to be an offset inside the string object, and not a general offset which was bad. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@57241 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/engines/common/evas_font_default_walk.x | 88 +++++++++++++++---------- src/lib/engines/common/evas_font_draw.c | 8 ++- src/lib/engines/common/evas_font_ot.c | 4 +- 3 files changed, 63 insertions(+), 37 deletions(-) diff --git a/src/lib/engines/common/evas_font_default_walk.x b/src/lib/engines/common/evas_font_default_walk.x index 2e4ba54..704db21 100644 --- a/src/lib/engines/common/evas_font_default_walk.x +++ b/src/lib/engines/common/evas_font_default_walk.x @@ -16,6 +16,19 @@ size_t char_index; \ (void) _pen_y; /* Sometimes it won't be used */ +/* Visual walk helper macros */ +#ifdef OT_SUPPORT +#define _EVAS_FONT_WALK_TEXT_VISUAL_START() \ + Evas_Font_OT_Info *_ot_itr = (text_props->info) ? \ + text_props->info->ot + text_props->start : NULL; \ + for (char_index = 0 ; char_index < text_props->len ; char_index++, _glyph_itr++, _ot_itr++) \ + { +#else +#define _EVAS_FONT_WALK_TEXT_VISUAL_START() \ + for (char_index = 0 ; char_index < text_props->len ; char_index++, _glyph_itr++) \ + { +#endif + /** * @def EVAS_FONT_WALK_TEXT_VISUAL_START * @internal @@ -31,8 +44,24 @@ #define EVAS_FONT_WALK_TEXT_VISUAL_START() \ do \ { \ - for (char_index = text_props->start ; char_index < text_props->start + text_props->len ; char_index++) \ + Evas_Font_Glyph_Info *_glyph_itr = (text_props->info) ? \ + text_props->info->glyph + text_props->start : NULL; \ + _EVAS_FONT_WALK_TEXT_VISUAL_START() + +/* Logical walk helper macros */ +#ifdef OT_SUPPORT +#define _EVAS_FONT_WALK_TEXT_LOGICAL_START() \ + Evas_Font_OT_Info *_ot_itr = (text_props->info) ? \ + text_props->info->ot + text_props->start : NULL; \ + if (text_props->bidi.dir == EVAS_BIDI_DIRECTION_RTL) \ + _ot_itr += text_props->len - 1; \ + for ( ; _i > 0 ; char_index += _char_index_d, _i--, _glyph_itr += _char_index_d, _ot_itr += _char_index_d) \ + { +#else +#define _EVAS_FONT_WALK_TEXT_LOGICAL_START() \ + for ( ; _i > 0 ; char_index += _char_index_d, _i--, _glyph_itr += _char_index_d) \ { +#endif /** * @def EVAS_FONT_WALK_TEXT_LOGICAL_START @@ -50,6 +79,9 @@ #define EVAS_FONT_WALK_TEXT_LOGICAL_START() \ do \ { \ + Evas_Font_Glyph_Info *_glyph_itr = (text_props->info) ? \ + text_props->info->glyph + text_props->start : \ + NULL; \ int _char_index_d; \ size_t _i; \ _i = text_props->len; \ @@ -57,16 +89,14 @@ { \ char_index = text_props->len - 1; \ _char_index_d = -1; \ + _glyph_itr += text_props->len - 1; \ } \ else \ { \ char_index = 0; \ _char_index_d = 1; \ } \ - char_index += text_props->start; \ - _i += text_props->start; \ - for ( ; _i > text_props->start ; char_index += _char_index_d, _i--) \ - { + _EVAS_FONT_WALK_TEXT_LOGICAL_START() #else #define EVAS_FONT_WALK_TEXT_LOGICAL_START() EVAS_FONT_WALK_TEXT_VISUAL_START() @@ -77,27 +107,20 @@ /*FIXME: doc */ #ifdef OT_SUPPORT # define EVAS_FONT_WALK_X_OFF \ - (EVAS_FONT_ROUND_26_6_TO_INT( \ - EVAS_FONT_OT_X_OFF_GET( \ - text_props->info->ot[char_index]))) + (EVAS_FONT_ROUND_26_6_TO_INT(EVAS_FONT_OT_X_OFF_GET(*_ot_itr))) # define EVAS_FONT_WALK_Y_OFF \ - (EVAS_FONT_ROUND_26_6_TO_INT( \ - EVAS_FONT_OT_Y_OFF_GET( \ - text_props->info->ot[char_index]))) + (EVAS_FONT_ROUND_26_6_TO_INT(EVAS_FONT_OT_Y_OFF_GET(*_ot_itr))) # define EVAS_FONT_WALK_POS \ - (EVAS_FONT_OT_POS_GET( \ - text_props->info->ot[char_index]) - text_props->text_offset) + (EVAS_FONT_OT_POS_GET(*_ot_itr) - text_props->text_offset) # define EVAS_FONT_WALK_POS_NEXT \ ((!EVAS_FONT_WALK_IS_LAST) ? \ - EVAS_FONT_OT_POS_GET( \ - text_props->info->ot[char_index + 1]) - \ - text_props->text_offset : \ + EVAS_FONT_OT_POS_GET(*(_ot_itr + 1)) - \ + text_props->text_offset : \ EVAS_FONT_WALK_POS \ ) # define EVAS_FONT_WALK_POS_PREV \ ((char_index > 0) ? \ - EVAS_FONT_OT_POS_GET( \ - text_props->info->ot[char_index - 1]) - \ + EVAS_FONT_OT_POS_GET(*(_ot_itr - 1)) - \ text_props->text_offset : \ EVAS_FONT_WALK_POS \ ) @@ -106,40 +129,39 @@ # define EVAS_FONT_WALK_Y_OFF 0 # define EVAS_FONT_WALK_POS \ ((text_props->bidi.dir == EVAS_BIDI_DIRECTION_RTL) ? \ - (text_props->len - (char_index - text_props->start) - 1) : \ - (char_index - text_props->start)) + (text_props->len - char_index - 1) : \ + (char_index)) # define EVAS_FONT_WALK_POS_NEXT \ ((!EVAS_FONT_WALK_IS_LAST) ? \ ((text_props->bidi.dir == EVAS_BIDI_DIRECTION_RTL) ? \ - text_props->len - ((char_index + 1) - text_props->start) \ - : (char_index + 1) - text_props->start) : \ + text_props->len - char_index - 2 \ + : (char_index + 1)) : \ EVAS_FONT_WALK_POS) # define EVAS_FONT_WALK_POS_PREV \ - ((char_index > text_props->start) ? \ + ((char_index > 0) ? \ ((text_props->bidi.dir == EVAS_BIDI_DIRECTION_RTL) ? \ - text_props->len - ((char_index - 1) - text_props->start) \ - : (char_index - 1) - text_props->start) : \ + text_props->len - char_index \ + : (char_index - 1)) : \ EVAS_FONT_WALK_POS) #endif -#define EVAS_FONT_WALK_IS_VISIBLE \ - (text_props->info->glyph[char_index].index != 0) -#define EVAS_FONT_WALK_X_BEAR (text_props->info->glyph[char_index].x_bear) +#define EVAS_FONT_WALK_IS_VISIBLE (_glyph_itr->index != 0) +#define EVAS_FONT_WALK_X_BEAR (_glyph_itr->x_bear) #define EVAS_FONT_WALK_Y_BEAR (fg->glyph_out->top) -#define _EVAS_FONT_WALK_X_ADV \ - (text_props->info->glyph[char_index].advance) -#define EVAS_FONT_WALK_WIDTH (text_props->info->glyph[char_index].width) +#define _EVAS_FONT_WALK_X_ADV (_glyph_itr->advance) +#define EVAS_FONT_WALK_WIDTH (_glyph_itr->width) +#define EVAS_FONT_WALK_INDEX (_glyph_itr->index) #define EVAS_FONT_WALK_X_ADV \ (EVAS_FONT_ROUND_26_6_TO_INT(_EVAS_FONT_WALK_X_ADV)) #define EVAS_FONT_WALK_PEN_X (EVAS_FONT_ROUND_26_6_TO_INT(_pen_x)) #define EVAS_FONT_WALK_PEN_Y (EVAS_FONT_ROUND_26_6_TO_INT(_pen_y)) #define EVAS_FONT_WALK_Y_ADV (0) #define EVAS_FONT_WALK_IS_LAST \ - (char_index + 1 == text_props->start + text_props->len) + (char_index + 1 == text_props->len) #define EVAS_FONT_WALK_IS_FIRST \ - (!char_index) + (char_index == 0) #define EVAS_FONT_WALK_LEN (text_props->len) /** diff --git a/src/lib/engines/common/evas_font_draw.c b/src/lib/engines/common/evas_font_draw.c index 377abb7..195fe16 100644 --- a/src/lib/engines/common/evas_font_draw.c +++ b/src/lib/engines/common/evas_font_draw.c @@ -529,7 +529,7 @@ evas_common_font_draw_internal(RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Font if (!EVAS_FONT_WALK_IS_VISIBLE) continue; #ifdef OT_SUPPORT - index = text_props->info->glyph[char_index].index; + index = EVAS_FONT_WALK_INDEX; #else /* FIXME: Should be removed once we split according to script without * the use of harfbuzz */ @@ -787,6 +787,7 @@ evas_font_word_prerender(RGBA_Draw_Context *dc, const Eina_Unicode *in_text, con struct prword *w; int last_delta = 0; int gl; + struct cinfo *ci; EVAS_FONT_WALK_TEXT_INIT(); # ifndef METRIC_CACHE @@ -829,13 +830,13 @@ evas_font_word_prerender(RGBA_Draw_Context *dc, const Eina_Unicode *in_text, con * but that'll have to be good enough ATM */ len = text_props->len; metrics = malloc(sizeof(struct cinfo) * len); + ci = metrics; EVAS_FONT_WALK_TEXT_VISUAL_START() { - struct cinfo *ci = metrics + char_index; FT_UInt index; RGBA_Font_Glyph *fg; #ifdef OT_SUPPORT - index = text_props->info->glyph[char_index].index; + index = EVAS_FONT_WALK_INDEX; #else /* FIXME: Should be removed once we split according to script without * the use of harfbuzz */ @@ -874,6 +875,7 @@ evas_font_word_prerender(RGBA_Draw_Context *dc, const Eina_Unicode *in_text, con ci->pos.y = EVAS_FONT_WALK_PEN_Y + EVAS_FONT_WALK_Y_OFF + EVAS_FONT_WALK_Y_BEAR; last_delta = EVAS_FONT_WALK_X_ADV - (ci->bm.w + ci->fg->glyph_out->left); + ci++; } EVAS_FONT_WALK_TEXT_END(); diff --git a/src/lib/engines/common/evas_font_ot.c b/src/lib/engines/common/evas_font_ot.c index ad0d522..62ed99a 100644 --- a/src/lib/engines/common/evas_font_ot.c +++ b/src/lib/engines/common/evas_font_ot.c @@ -18,7 +18,9 @@ evas_common_font_ot_cluster_size_get(const Evas_Text_Props *props, size_t char_i int i; int items; int left_bound, right_bound; - size_t base_cluster = EVAS_FONT_OT_POS_GET(props->info->ot[char_index]); + size_t base_cluster; + char_index += props->start; + base_cluster = EVAS_FONT_OT_POS_GET(props->info->ot[char_index]); for (i = (int) char_index ; (i >= (int) props->start) && (EVAS_FONT_OT_POS_GET(props->info->ot[i]) == base_cluster) ; -- 2.7.4