Evas textblock + font engine: add an optimized way of doing a cut-off on the text props.

SVN revision: 56470
This commit is contained in:
Tom Hacohen 2011-01-30 10:38:15 +00:00
parent 0e44717373
commit 9f0ce7a272
5 changed files with 39 additions and 3 deletions

View File

@ -2296,9 +2296,7 @@ _layout_item_text_cutoff(Ctxt *c __UNUSED__, Evas_Object_Textblock_Text_Item *ti
ts[cut] = 0;
ti->text = eina_unicode_strdup(ts);
free(ts);
c->ENFN->font_shape(c->ENDT, ti->format->font.font, ti->text,
&ti->parent.text_props, ti->parent.text_node->bidi_props,
ti->parent.text_pos, cut);
evas_common_text_props_cutoff(&ti->parent.text_props, cut);
}
/**

View File

@ -112,6 +112,28 @@ _evas_common_font_ot_shape(hb_buffer_t *buffer, RGBA_Font_Source *src)
hb_font_destroy(hb_font);
}
/* Won't work in the middle of ligatures */
EAPI void
evas_common_font_ot_cutoff_text_props(Evas_Text_Props *props, int cutoff)
{
Evas_Font_OT_Data_Item *tmp;
if ((cutoff <= 0) || (!props->ot_data) ||
(((size_t) cutoff) >= props->ot_data->len))
return;
if (props->bidi.dir == EVAS_BIDI_DIRECTION_RTL)
{
memmove(props->ot_data->items,
props->ot_data->items + (props->ot_data->len - cutoff),
cutoff * sizeof(Evas_Font_OT_Data_Item));
}
tmp = realloc(props->ot_data->items,
cutoff * sizeof(Evas_Font_OT_Data_Item));
props->ot_data->items = tmp;
props->ot_data->len = cutoff;
}
EAPI Eina_Bool
evas_common_font_ot_populate_text_props(void *_fn, const Eina_Unicode *text,
Evas_Text_Props *props, int len)

View File

@ -75,5 +75,8 @@ evas_common_font_ot_cluster_size_get(const Evas_Text_Props *props, size_t char_i
EAPI Eina_Bool
evas_common_font_ot_populate_text_props(void *fn, const Eina_Unicode *text,
Evas_Text_Props *props, int len);
EAPI void
evas_common_font_ot_cutoff_text_props(Evas_Text_Props *props, int cutoff);
#endif

View File

@ -57,3 +57,13 @@ evas_common_text_props_content_unref(Evas_Text_Props *props)
#endif
}
/* Won't work in the middle of ligatures */
EAPI void
evas_common_text_props_cutoff(Evas_Text_Props *props, int cutoff)
{
#ifdef OT_SUPPORT
evas_common_font_ot_cutoff_text_props(props, cutoff);
#endif
}

View File

@ -29,4 +29,7 @@ evas_common_text_props_content_copy_and_ref(Evas_Text_Props *dst,
void
evas_common_text_props_content_unref(Evas_Text_Props *props);
EAPI void
evas_common_text_props_cutoff(Evas_Text_Props *props, int cutoff);
#endif