From 533ef3530ebb3bc588041bd5eaf411a8841cd5d1 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 29 Mar 2011 13:52:22 +0000 Subject: [PATCH] Evas font-engine: Added right_inset_get. This lets us get the difference between the width and the advance of a string pretty fast, which means we only need to calculate either advance or width, because we can now calculate one from the other. SVN revision: 58181 --- legacy/evas/src/lib/engines/common/evas_font.h | 1 + .../src/lib/engines/common/evas_font_query.c | 16 ++++++++++++++++ legacy/evas/src/lib/include/evas_private.h | 1 + .../src/modules/engines/cairo_x11/evas_engine.c | 4 +++- .../modules/engines/quartz/evas_quartz_private.h | 1 + .../modules/engines/software_16/evas_engine.c | 9 ++++++++- .../src/modules/engines/software_8/evas_engine.c | 9 ++++++++- .../engines/software_generic/evas_engine.c | 9 ++++++++- 8 files changed, 46 insertions(+), 4 deletions(-) diff --git a/legacy/evas/src/lib/engines/common/evas_font.h b/legacy/evas/src/lib/engines/common/evas_font.h index 3db436630c..13e5dc5b32 100644 --- a/legacy/evas/src/lib/engines/common/evas_font.h +++ b/legacy/evas/src/lib/engines/common/evas_font.h @@ -58,6 +58,7 @@ EAPI void evas_common_font_all_clear (void); EAPI int evas_common_font_query_kerning (RGBA_Font_Int* fi, FT_UInt left, FT_UInt right, int* kerning); EAPI void evas_common_font_query_size (RGBA_Font *fn, const Eina_Unicode *text, const Evas_Text_Props *intl_props, int *w, int *h); EAPI int evas_common_font_query_inset (RGBA_Font *fn __UNUSED__, const Evas_Text_Props *text_props); +EAPI int evas_common_font_query_right_inset (RGBA_Font *fn __UNUSED__, const Evas_Text_Props *text_props); EAPI void evas_common_font_query_advance (RGBA_Font *fn, const Eina_Unicode *text, const Evas_Text_Props *intl_props, int *h_adv, int *v_adv); EAPI int evas_common_font_query_char_coords (RGBA_Font *fn, const Eina_Unicode *text, const Evas_Text_Props *intl_props, int pos, int *cx, int *cy, int *cw, int *ch); EAPI int evas_common_font_query_pen_coords (RGBA_Font *fn, const Eina_Unicode *text, const Evas_Text_Props *intl_props, int pos, int *cpen_x, int *cy, int *cadv, int *ch); diff --git a/legacy/evas/src/lib/engines/common/evas_font_query.c b/legacy/evas/src/lib/engines/common/evas_font_query.c index ae73e60b2a..026afcebe0 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_query.c +++ b/legacy/evas/src/lib/engines/common/evas_font_query.c @@ -66,6 +66,22 @@ evas_common_font_query_inset(RGBA_Font *fn __UNUSED__, const Evas_Text_Props *te return text_props->info->glyph[text_props->start].x_bear; } +/* text right x inset */ +EAPI int +evas_common_font_query_right_inset(RGBA_Font *fn __UNUSED__, const Evas_Text_Props *text_props) +{ + const Evas_Font_Glyph_Info *gli; + if (!text_props->len) return 0; + gli = text_props->info->glyph + text_props->start + text_props->len - 1; + + return EVAS_FONT_ROUND_26_6_TO_INT(gli->advance) - + (gli->width + gli->x_bear +#ifdef OT_SUPPORT + + text_props->info->ot[text_props->start + text_props->len - 1].x_offset +#endif + ); +} + /* size of the string (width and height) in pixels * BiDi handling: We receive the shaped string + other props from text_props, * We only care about the size, and the size does not depend on the visual order. diff --git a/legacy/evas/src/lib/include/evas_private.h b/legacy/evas/src/lib/include/evas_private.h index a8dbf4b6af..4251d7d986 100644 --- a/legacy/evas/src/lib/include/evas_private.h +++ b/legacy/evas/src/lib/include/evas_private.h @@ -683,6 +683,7 @@ struct _Evas_Func int (*image_content_hint_get) (void *data, void *surface); int (*font_pen_coords_get) (void *data, void *font, const Eina_Unicode *text, const Evas_Text_Props *intl_props, int pos, int *cpen_x, int *cy, int *cadv, int *ch); Eina_Bool (*font_text_props_info_create) (void *data __UNUSED__, void *font, Eina_Unicode *text, Evas_Text_Props *intl_props, const Evas_BiDi_Paragraph_Props *par_props, size_t pos, size_t len); + int (*font_right_inset_get) (void *data, void *font, const Evas_Text_Props *text_props); }; struct _Evas_Image_Load_Func diff --git a/legacy/evas/src/modules/engines/cairo_x11/evas_engine.c b/legacy/evas/src/modules/engines/cairo_x11/evas_engine.c index 0f9ea14d5d..5a9881efe8 100644 --- a/legacy/evas/src/modules/engines/cairo_x11/evas_engine.c +++ b/legacy/evas/src/modules/engines/cairo_x11/evas_engine.c @@ -90,6 +90,7 @@ static int eng_font_max_ascent_get(void *data, void *font); static int eng_font_max_descent_get(void *data, void *font); static void eng_font_string_size_get(void *data, void *font, char *text, int *w, int *h); static int eng_font_inset_get(void *data, void *font, const Evas_Text_Props *intl_props); +static int eng_font_right_inset_get(void *data, void *font, const Evas_Text_Props *intl_props); static int eng_font_h_advance_get(void *data, void *font, char *text); static int eng_font_v_advance_get(void *data, void *font, char *text); static int eng_font_char_coords_get(void *data, void *font, char *text, int pos, int *cx, int *cy, int *cw, int *ch); @@ -219,7 +220,8 @@ static Evas_Func eng_func = NULL, // eng_image_content_hint_set - software doesn't use it NULL, // eng_image_content_hint_get - software doesn't use it eng_font_pen_coords_get, - eng_font_text_props_info_create + eng_font_text_props_info_create, + eng_font_right_inset_get /* FUTURE software generic calls go here */ }; diff --git a/legacy/evas/src/modules/engines/quartz/evas_quartz_private.h b/legacy/evas/src/modules/engines/quartz/evas_quartz_private.h index c1a1123d81..024d274d3f 100644 --- a/legacy/evas/src/modules/engines/quartz/evas_quartz_private.h +++ b/legacy/evas/src/modules/engines/quartz/evas_quartz_private.h @@ -77,6 +77,7 @@ static int eng_font_max_ascent_get(void *data, void *font); static int eng_font_max_descent_get(void *data, void *font); static void eng_font_string_size_get(void *data, void *font, const char *text, const Evas_Text_Props *intl_props, int *w, int *h); static int eng_font_inset_get(void *data, void *font, const Evas_Text_Props *intl_props); +static int eng_font_right_inset_get(void *data, void *font, const Evas_Text_Props *intl_props); static int eng_font_h_advance_get(void *data, void *font, const char *text, const Evas_Text_Props *intl_props); static int eng_font_v_advance_get(void *data, void *font, const char *text, const Evas_Text_Props *intl_props); static int eng_font_char_coords_get(void *data, void *font, const char *text, const Evas_Text_Props *intl_props, int pos, int *cx, int *cy, int *cw, int *ch); diff --git a/legacy/evas/src/modules/engines/software_16/evas_engine.c b/legacy/evas/src/modules/engines/software_16/evas_engine.c index fd657d906f..eaec10e000 100644 --- a/legacy/evas/src/modules/engines/software_16/evas_engine.c +++ b/legacy/evas/src/modules/engines/software_16/evas_engine.c @@ -516,6 +516,12 @@ eng_font_inset_get(void *data __UNUSED__, void *font, const Evas_Text_Props *tex return evas_common_font_query_inset(font, text_props); } +static int +eng_font_right_inset_get(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props) +{ + return evas_common_font_query_right_inset(font, text_props); +} + static int eng_font_h_advance_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_Text_Props *text_props) { @@ -746,7 +752,8 @@ static Evas_Func func = NULL, // eng_image_content_hint_set - software doesn't use it NULL, // eng_image_content_hint_get - software doesn't use it eng_font_pen_coords_get, - eng_font_text_props_info_create + eng_font_text_props_info_create, + eng_font_right_inset_get /* FUTURE software generic calls go here */ }; diff --git a/legacy/evas/src/modules/engines/software_8/evas_engine.c b/legacy/evas/src/modules/engines/software_8/evas_engine.c index bc8b93311a..e060cdb45e 100644 --- a/legacy/evas/src/modules/engines/software_8/evas_engine.c +++ b/legacy/evas/src/modules/engines/software_8/evas_engine.c @@ -573,6 +573,12 @@ eng_font_inset_get(void *data __UNUSED__, void *font, const Evas_Text_Props *tex return evas_common_font_query_inset(font, text_props); } +static int +eng_font_right_inset_get(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props) +{ + return evas_common_font_query_right_inset(font, text_props); +} + static int eng_font_h_advance_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_Text_Props *text_props) { @@ -792,7 +798,8 @@ static Evas_Func func = { NULL, // eng_image_content_hint_set - software doesn't use it NULL, // eng_image_content_hint_get - software doesn't use it eng_font_pen_coords_get, - eng_font_text_props_info_create + eng_font_text_props_info_create, + eng_font_right_inset_get /* FUTURE software generic calls go here */ }; diff --git a/legacy/evas/src/modules/engines/software_generic/evas_engine.c b/legacy/evas/src/modules/engines/software_generic/evas_engine.c index be96fe15b1..d40e09b309 100644 --- a/legacy/evas/src/modules/engines/software_generic/evas_engine.c +++ b/legacy/evas/src/modules/engines/software_generic/evas_engine.c @@ -694,6 +694,12 @@ eng_font_inset_get(void *data __UNUSED__, void *font, const Evas_Text_Props *tex return evas_common_font_query_inset(font, text_props); } +static int +eng_font_right_inset_get(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props) +{ + return evas_common_font_query_right_inset(font, text_props); +} + static int eng_font_h_advance_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_Text_Props *text_props) { @@ -926,7 +932,8 @@ static Evas_Func func = NULL, // eng_image_content_hint_set - software doesn't use it NULL, // eng_image_content_hint_get - software doesn't use it eng_font_pen_coords_get, - eng_font_text_props_info_create + eng_font_text_props_info_create, + eng_font_right_inset_get /* FUTURE software generic calls go here */ };