Evas textblock: Fixed async rendering support.

SVN revision: 56506
This commit is contained in:
Tom Hacohen 2011-01-30 10:41:57 +00:00
parent f0a2a3229d
commit f63e8256ff
1 changed files with 45 additions and 24 deletions

View File

@ -116,22 +116,32 @@ _evas_common_font_ot_shape(hb_buffer_t *buffer, RGBA_Font_Source *src)
EAPI void EAPI void
evas_common_font_ot_cutoff_text_props(Evas_Text_Props *props, int cutoff) evas_common_font_ot_cutoff_text_props(Evas_Text_Props *props, int cutoff)
{ {
Evas_Font_OT_Data_Item *tmp; Evas_Font_OT_Data *new_data;
if ((cutoff <= 0) || (!props->ot_data) || if ((cutoff <= 0) || (!props->ot_data) ||
(((size_t) cutoff) >= props->ot_data->len)) (((size_t) cutoff) >= props->ot_data->len))
return; return;
new_data = malloc(sizeof(Evas_Font_OT_Data));
memcpy(new_data, props->ot_data, sizeof(Evas_Font_OT_Data));
new_data->refcount = 1;
new_data->len = cutoff;
new_data->items = malloc(cutoff * sizeof(Evas_Font_OT_Data_Item));
if (props->bidi.dir == EVAS_BIDI_DIRECTION_RTL) if (props->bidi.dir == EVAS_BIDI_DIRECTION_RTL)
{ {
memmove(props->ot_data->items, memcpy(new_data->items,
props->ot_data->items + (props->ot_data->len - cutoff), props->ot_data->items + (props->ot_data->len - cutoff),
cutoff * sizeof(Evas_Font_OT_Data_Item)); cutoff * sizeof(Evas_Font_OT_Data_Item));
} }
tmp = realloc(props->ot_data->items, else
cutoff * sizeof(Evas_Font_OT_Data_Item)); {
props->ot_data->items = tmp; memcpy(new_data->items,
props->ot_data->len = cutoff; props->ot_data->items,
cutoff * sizeof(Evas_Font_OT_Data_Item));
}
evas_common_font_ot_props_unref(props->ot_data);
props->ot_data = new_data;
} }
/* Won't work in the middle of ligatures /* Won't work in the middle of ligatures
@ -141,7 +151,7 @@ EAPI void
evas_common_font_ot_split_text_props(Evas_Text_Props *base, evas_common_font_ot_split_text_props(Evas_Text_Props *base,
Evas_Text_Props *ext, int cutoff) Evas_Text_Props *ext, int cutoff)
{ {
Evas_Font_OT_Data_Item *tmp; Evas_Font_OT_Data *new_data;
int i; int i;
if ((cutoff <= 0) || (!base->ot_data) || if ((cutoff <= 0) || (!base->ot_data) ||
(((size_t) cutoff) >= base->ot_data->len)) (((size_t) cutoff) >= base->ot_data->len))
@ -152,11 +162,18 @@ evas_common_font_ot_split_text_props(Evas_Text_Props *base,
ext->ot_data->len = base->ot_data->len - cutoff; ext->ot_data->len = base->ot_data->len - cutoff;
ext->ot_data->items = calloc(ext->ot_data->len, ext->ot_data->items = calloc(ext->ot_data->len,
sizeof(Evas_Font_OT_Data_Item)); sizeof(Evas_Font_OT_Data_Item));
new_data = malloc(sizeof(Evas_Font_OT_Data));
memcpy(new_data, base->ot_data, sizeof(Evas_Font_OT_Data));
new_data->refcount = 1;
new_data->items = malloc(cutoff * sizeof(Evas_Font_OT_Data_Item));
new_data->len = cutoff;
if (base->bidi.dir == EVAS_BIDI_DIRECTION_RTL) if (base->bidi.dir == EVAS_BIDI_DIRECTION_RTL)
{ {
memcpy(ext->ot_data->items, base->ot_data->items, memcpy(ext->ot_data->items, base->ot_data->items,
ext->ot_data->len * sizeof(Evas_Font_OT_Data_Item)); ext->ot_data->len * sizeof(Evas_Font_OT_Data_Item));
memmove(base->ot_data->items, memcpy(new_data->items,
base->ot_data->items + ext->ot_data->len, base->ot_data->items + ext->ot_data->len,
cutoff * sizeof(Evas_Font_OT_Data_Item)); cutoff * sizeof(Evas_Font_OT_Data_Item));
} }
@ -164,7 +181,11 @@ evas_common_font_ot_split_text_props(Evas_Text_Props *base,
{ {
memcpy(ext->ot_data->items, base->ot_data->items + cutoff, memcpy(ext->ot_data->items, base->ot_data->items + cutoff,
ext->ot_data->len * sizeof(Evas_Font_OT_Data_Item)); ext->ot_data->len * sizeof(Evas_Font_OT_Data_Item));
memcpy(new_data->items, base->ot_data->items,
cutoff * sizeof(Evas_Font_OT_Data_Item));
} }
evas_common_font_ot_props_unref(base->ot_data);
base->ot_data = new_data;
/* Adjust the offset of the clusters */ /* Adjust the offset of the clusters */
{ {
@ -183,11 +204,6 @@ evas_common_font_ot_split_text_props(Evas_Text_Props *base,
} }
ext->ot_data->offset = base->ot_data->offset + min; ext->ot_data->offset = base->ot_data->offset + min;
} }
tmp = realloc(base->ot_data->items,
cutoff * sizeof(Evas_Font_OT_Data_Item));
base->ot_data->items = tmp;
base->ot_data->len = cutoff;
} }
/* Won't work in the middle of ligatures /* Won't work in the middle of ligatures
@ -198,32 +214,37 @@ EAPI void
evas_common_font_ot_merge_text_props(Evas_Text_Props *item1, evas_common_font_ot_merge_text_props(Evas_Text_Props *item1,
const Evas_Text_Props *item2) const Evas_Text_Props *item2)
{ {
Evas_Font_OT_Data_Item *tmp, *itr; /* Itr will be used for adding back Evas_Font_OT_Data *new_data;
Evas_Font_OT_Data_Item *itr; /* Itr will be used for adding back
the offsets */ the offsets */
size_t len; size_t len;
if (!item1->ot_data || !item2->ot_data) if (!item1->ot_data || !item2->ot_data)
return; return;
len = item1->ot_data->len + item2->ot_data->len; len = item1->ot_data->len + item2->ot_data->len;
tmp = calloc(len, sizeof(Evas_Font_OT_Data_Item));
new_data = malloc(sizeof(Evas_Font_OT_Data));
memcpy(new_data, item1->ot_data, sizeof(Evas_Font_OT_Data));
new_data->refcount = 1;
new_data->items = malloc(len * sizeof(Evas_Font_OT_Data_Item));
new_data->len = len;
if (item1->bidi.dir == EVAS_BIDI_DIRECTION_RTL) if (item1->bidi.dir == EVAS_BIDI_DIRECTION_RTL)
{ {
memcpy(tmp, item2->ot_data->items, memcpy(new_data->items, item2->ot_data->items,
item2->ot_data->len * sizeof(Evas_Font_OT_Data_Item)); item2->ot_data->len * sizeof(Evas_Font_OT_Data_Item));
memcpy(tmp + item2->ot_data->len, item1->ot_data->items, memcpy(new_data->items + item2->ot_data->len, item1->ot_data->items,
item1->ot_data->len * sizeof(Evas_Font_OT_Data_Item)); item1->ot_data->len * sizeof(Evas_Font_OT_Data_Item));
itr = tmp; itr = new_data->items;
} }
else else
{ {
memcpy(tmp, item1->ot_data->items, memcpy(new_data->items, item1->ot_data->items,
item1->ot_data->len * sizeof(Evas_Font_OT_Data_Item)); item1->ot_data->len * sizeof(Evas_Font_OT_Data_Item));
memcpy(tmp + item1->ot_data->len, item2->ot_data->items, memcpy(new_data->items + item1->ot_data->len, item2->ot_data->items,
item2->ot_data->len * sizeof(Evas_Font_OT_Data_Item)); item2->ot_data->len * sizeof(Evas_Font_OT_Data_Item));
itr = tmp + item1->ot_data->len; itr = new_data->items + item1->ot_data->len;
} }
free(item1->ot_data->items); evas_common_font_ot_props_unref(item1->ot_data);
item1->ot_data->items = tmp; item1->ot_data = new_data;
item1->ot_data->len = len;
/* Add back the offset of item2 to the newly created */ /* Add back the offset of item2 to the newly created */
if (item2->ot_data->offset > 0) if (item2->ot_data->offset > 0)
{ {