Evas bidi: Changed the design a bit so it'll be easy to implement async-rendering with it.

Fixed a couple of issues with unwanted cleans and generally data corruption.
Cleaned up async-rendering.

SVN revision: 51806
This commit is contained in:
Tom Hacohen 2010-09-01 13:15:04 +00:00
parent b4ed699e9e
commit 5e433f1956
9 changed files with 151 additions and 154 deletions

View File

@ -27,7 +27,6 @@ struct _Evas_Object_Text
unsigned char style; unsigned char style;
Evas_BiDi_Props intl_props; Evas_BiDi_Props intl_props;
Evas_BiDi_Paragraph_Props paragraph_bidi_props;
} cur, prev; } cur, prev;
float ascent, descent; float ascent, descent;
@ -352,7 +351,8 @@ evas_object_text_text_set(Evas_Object *obj, const char *_text)
/* DO II */ /* DO II */
/*Update intl_props*/ /*Update intl_props*/
#ifdef BIDI_SUPPORT #ifdef BIDI_SUPPORT
evas_bidi_update_props(text, o->cur.intl_props.props); evas_bidi_paragraph_props_unref(o->cur.intl_props.props);
o->cur.intl_props.props = evas_bidi_paragraph_props_get(text);
#endif #endif
if (o->cur.text) eina_ustringshare_del(o->cur.text); if (o->cur.text) eina_ustringshare_del(o->cur.text);
if (o->cur.utf8_text) eina_stringshare_del(o->cur.utf8_text); if (o->cur.utf8_text) eina_stringshare_del(o->cur.utf8_text);
@ -1457,10 +1457,7 @@ evas_object_text_new(void)
o = calloc(1, sizeof(Evas_Object_Text)); o = calloc(1, sizeof(Evas_Object_Text));
o->magic = MAGIC_OBJ_TEXT; o->magic = MAGIC_OBJ_TEXT;
o->prev = o->cur; o->prev = o->cur;
o->cur.intl_props.props = &o->cur.paragraph_bidi_props; o->cur.intl_props.props = evas_bidi_paragraph_props_new();
#ifdef BIDI_SUPPORT
o->cur.intl_props.props->direction = EVAS_BIDI_PARAGRAPH_NATURAL;
#endif
return o; return o;
} }
@ -1480,8 +1477,7 @@ evas_object_text_free(Evas_Object *obj)
if (o->cur.font) eina_stringshare_del(o->cur.font); if (o->cur.font) eina_stringshare_del(o->cur.font);
if (o->cur.source) eina_stringshare_del(o->cur.source); if (o->cur.source) eina_stringshare_del(o->cur.source);
if (o->engine_data) evas_font_free(obj->layer->evas, o->engine_data); if (o->engine_data) evas_font_free(obj->layer->evas, o->engine_data);
if (o->cur.intl_props.props->embedding_levels) free(o->cur.intl_props.props->embedding_levels); evas_bidi_props_clean(&o->cur.intl_props);
if (o->cur.intl_props.props->char_types) free(o->cur.intl_props.props->char_types);
o->magic = 0; o->magic = 0;
free(o); free(o);
} }

View File

@ -228,9 +228,9 @@ struct _Evas_Object_Textblock_Node_Text
{ {
EINA_INLIST; EINA_INLIST;
Eina_UStrbuf *unicode; Eina_UStrbuf *unicode;
char * utf8; char *utf8;
Evas_Object_Textblock_Node_Format *format_node; Evas_Object_Textblock_Node_Format *format_node;
Evas_BiDi_Paragraph_Props bidi_props; Evas_BiDi_Paragraph_Props *bidi_props;
}; };
struct _Evas_Object_Textblock_Node_Format struct _Evas_Object_Textblock_Node_Format
@ -1922,8 +1922,9 @@ _layout_line_align_get(Ctxt *c)
if (c->align_auto && c->ln && c->ln->items) if (c->align_auto && c->ln && c->ln->items)
{ {
if (c->ln->items->source_node && if (c->ln->items->source_node &&
EVAS_BIDI_PARAGRAPH_DIRECTION_IS_RTL( EVAS_BIDI_PARAGRAPH_DIRECTION_IS_RTL(
c->ln->items->source_node->bidi_props.direction)) c->ln->items->source_node->bidi_props))
{ {
/* Align right*/ /* Align right*/
return 1.0; return 1.0;
@ -2329,7 +2330,7 @@ _layout_walk_back_to_item_word_redo(Ctxt *c, Evas_Object_Textblock_Item *it)
new_it->source_node = pit->source_node; new_it->source_node = pit->source_node;
new_it->source_pos = pit->source_pos + index; new_it->source_pos = pit->source_pos + index;
new_it->bidi_props.start = new_it->source_pos; new_it->bidi_props.start = new_it->source_pos;
new_it->bidi_props.props = &new_it->source_node->bidi_props; new_it->bidi_props.props = new_it->source_node->bidi_props;
# ifdef BIDI_SUPPORT # ifdef BIDI_SUPPORT
evas_bidi_shape_string(new_it->text, &new_it->bidi_props, evas_bidi_shape_string(new_it->text, &new_it->bidi_props,
eina_unicode_strlen(new_it->text)); eina_unicode_strlen(new_it->text));
@ -2484,7 +2485,7 @@ skip:
if (it->source_node) if (it->source_node)
{ {
it->bidi_props.start = it->source_pos; it->bidi_props.start = it->source_pos;
it->bidi_props.props = &it->source_node->bidi_props; it->bidi_props.props = it->source_node->bidi_props;
# ifdef BIDI_SUPPORT # ifdef BIDI_SUPPORT
evas_bidi_shape_string(it->text, &it->bidi_props, evas_bidi_shape_string(it->text, &it->bidi_props,
eina_unicode_strlen(it->text)); eina_unicode_strlen(it->text));
@ -5497,6 +5498,8 @@ _evas_textblock_node_text_free(Evas_Object_Textblock_Node_Text *n)
eina_ustrbuf_free(n->unicode); eina_ustrbuf_free(n->unicode);
if (n->utf8) if (n->utf8)
free(n->utf8); free(n->utf8);
if (&n->bidi_props)
evas_bidi_paragraph_props_unref(n->bidi_props);
free(n); free(n);
} }
@ -5513,8 +5516,9 @@ _evas_textblock_node_text_new(void)
n = calloc(1, sizeof(Evas_Object_Textblock_Node_Text)); n = calloc(1, sizeof(Evas_Object_Textblock_Node_Text));
n->unicode = eina_ustrbuf_new(); n->unicode = eina_ustrbuf_new();
n->bidi_props = evas_bidi_paragraph_props_new();
#ifdef BIDI_SUPPORT #ifdef BIDI_SUPPORT
n->bidi_props.direction = EVAS_BIDI_PARAGRAPH_NATURAL; n->bidi_props->direction = EVAS_BIDI_PARAGRAPH_NATURAL;
#endif #endif
return n; return n;
@ -5579,13 +5583,13 @@ _evas_textblock_cursor_break_paragraph(Evas_Textblock_Cursor *cur,
eina_ustrbuf_append_length(n->unicode, text + start, len); eina_ustrbuf_append_length(n->unicode, text + start, len);
eina_ustrbuf_remove(cur->node->unicode, start, start + len); eina_ustrbuf_remove(cur->node->unicode, start, start + len);
#ifdef BIDI_SUPPORT #ifdef BIDI_SUPPORT
/* Reset paragraph direction */ evas_bidi_paragraph_props_unref(n->bidi_props);
n->bidi_props.direction = EVAS_BIDI_PARAGRAPH_NATURAL; n->bidi_props = evas_bidi_paragraph_props_get(
evas_bidi_update_props(eina_ustrbuf_string_get(n->unicode), eina_ustrbuf_string_get(n->unicode));
&n->bidi_props);
cur->node->bidi_props.direction = EVAS_BIDI_PARAGRAPH_NATURAL; evas_bidi_paragraph_props_unref(cur->node->bidi_props);
evas_bidi_update_props(eina_ustrbuf_string_get(cur->node->unicode), cur->node->bidi_props = evas_bidi_paragraph_props_get(
&cur->node->bidi_props); eina_ustrbuf_string_get(cur->node->unicode));
#endif #endif
} }
else else
@ -5778,9 +5782,8 @@ evas_textblock_cursor_text_append(Evas_Textblock_Cursor *cur, const char *_text)
if (fnode && (fnode->text_node == cur->node)) if (fnode && (fnode->text_node == cur->node))
fnode->offset += len; fnode->offset += len;
#ifdef BIDI_SUPPORT #ifdef BIDI_SUPPORT
/* Reset paragraph direction */ evas_bidi_paragraph_props_unref(n->bidi_props);
n->bidi_props.direction = EVAS_BIDI_PARAGRAPH_NATURAL; n->bidi_props = evas_bidi_paragraph_props_get(eina_ustrbuf_string_get(n->unicode));
evas_bidi_update_props(eina_ustrbuf_string_get(n->unicode), &n->bidi_props);
#endif #endif
_evas_textblock_changed(o, cur->obj); _evas_textblock_changed(o, cur->obj);
free(text); free(text);
@ -6068,10 +6071,8 @@ evas_textblock_cursor_char_delete(Evas_Textblock_Cursor *cur)
_evas_textblock_cursor_nodes_merge(cur); _evas_textblock_cursor_nodes_merge(cur);
} }
#ifdef BIDI_SUPPORT #ifdef BIDI_SUPPORT
/* Reset paragraph direction */ evas_bidi_paragraph_props_unref(n->bidi_props);
n->bidi_props.direction = EVAS_BIDI_PARAGRAPH_NATURAL; n->bidi_props = evas_bidi_paragraph_props_get(eina_ustrbuf_string_get(n->unicode));
evas_bidi_update_props(eina_ustrbuf_string_get(n->unicode),
&n->bidi_props);
#endif #endif
if (cur->pos == eina_ustrbuf_length_get(n->unicode)) if (cur->pos == eina_ustrbuf_length_get(n->unicode))
@ -6172,10 +6173,9 @@ evas_textblock_cursor_range_delete(Evas_Textblock_Cursor *cur1, Evas_Textblock_C
} }
#ifdef BIDI_SUPPORT #ifdef BIDI_SUPPORT
/* Reset paragraph direction */ evas_bidi_paragraph_props_unref(n1->bidi_props);
n1->bidi_props.direction = EVAS_BIDI_PARAGRAPH_NATURAL; n1->bidi_props = evas_bidi_paragraph_props_get(
evas_bidi_update_props(eina_ustrbuf_string_get(n1->unicode), eina_ustrbuf_string_get(n1->unicode));
&n1->bidi_props);
#endif #endif
evas_textblock_cursor_copy(cur1, cur2); evas_textblock_cursor_copy(cur1, cur2);

View File

@ -100,12 +100,13 @@ evas_bidi_shape_string(Eina_Unicode *eina_ustr, const Evas_BiDi_Props *bidi_prop
{ {
FriBidiChar *ustr, *base_ustr = NULL; FriBidiChar *ustr, *base_ustr = NULL;
if (!EVAS_BIDI_IS_BIDI_PROP(bidi_props->props)) if (!bidi_props->props)
return EINA_FALSE; return EINA_FALSE;
/* The size of fribidichar is different than eina_unicode, convert */ /* The size of fribidichar is different than eina_unicode, convert */
/*FIXME: Make this comparison at compile time and compile out /*FIXME: Make this comparison at compile time and compile out
* unwanted code. - In all of this source file. */ * unwanted code. - In all of this source file. (including the actual
* function declerations. */
if (sizeof(Eina_Unicode) != sizeof(FriBidiChar)) if (sizeof(Eina_Unicode) != sizeof(FriBidiChar))
{ {
base_ustr = ustr = calloc(len + 1, sizeof(FriBidiChar)); base_ustr = ustr = calloc(len + 1, sizeof(FriBidiChar));
@ -145,19 +146,17 @@ evas_bidi_shape_string(Eina_Unicode *eina_ustr, const Evas_BiDi_Props *bidi_prop
/** /**
* @internal * @internal
* Updates the bidi properties according to ustr. First checks to see if the * Allocates bidi properties according to ustr. First checks to see if the
* passed has rtl chars, if not, it cleans intl_props and returns. * passed has rtl chars, if not, it returns NULL.
* Otherwise, it essentially frees the old fields, allocates new fields, and
* populates them.
* On error: bidi_props is cleaned.
* *
* @param ustr The string to update according to. * @param ustr The string to update according to.
* @param bidi_props the bidi_props to update. * @return returns allocated paragraph props on success, NULL otherwise.
* @return returns the length of the string on success, a negative value on error.
*/ */
int
evas_bidi_update_props(const Eina_Unicode *eina_ustr, Evas_BiDi_Paragraph_Props *bidi_props) Evas_BiDi_Paragraph_Props *
evas_bidi_paragraph_props_get(const Eina_Unicode *eina_ustr)
{ {
Evas_BiDi_Paragraph_Props *bidi_props = NULL;
EvasBiDiCharType *char_types = NULL; EvasBiDiCharType *char_types = NULL;
EvasBiDiLevel *embedding_levels = NULL; EvasBiDiLevel *embedding_levels = NULL;
const FriBidiChar *ustr; const FriBidiChar *ustr;
@ -165,7 +164,8 @@ evas_bidi_update_props(const Eina_Unicode *eina_ustr, Evas_BiDi_Paragraph_Props
size_t len; size_t len;
if (!eina_ustr) if (!eina_ustr)
return -2; return NULL;
len = eina_unicode_strlen(eina_ustr); len = eina_unicode_strlen(eina_ustr);
@ -188,6 +188,8 @@ evas_bidi_update_props(const Eina_Unicode *eina_ustr, Evas_BiDi_Paragraph_Props
goto cleanup; goto cleanup;
} }
bidi_props = evas_bidi_paragraph_props_new();
/* Prep work for reordering */ /* Prep work for reordering */
char_types = (EvasBiDiCharType *) malloc(sizeof(EvasBiDiCharType) * len); char_types = (EvasBiDiCharType *) malloc(sizeof(EvasBiDiCharType) * len);
if (!char_types) if (!char_types)
@ -224,76 +226,33 @@ evas_bidi_update_props(const Eina_Unicode *eina_ustr, Evas_BiDi_Paragraph_Props
free(bidi_props->char_types); free(bidi_props->char_types);
} }
bidi_props->char_types = char_types; bidi_props->char_types = char_types;
bidi_props->len = len;
if (base_ustr) free(base_ustr); if (base_ustr) free(base_ustr);
return len; return bidi_props;
/* Cleanup */ /* Cleanup */
cleanup: cleanup:
if (char_types) free(char_types); if (char_types) free(char_types);
if (embedding_levels) free(embedding_levels); if (embedding_levels) free(embedding_levels);
if (base_ustr) free(base_ustr); if (base_ustr) free(base_ustr);
evas_bidi_paragraph_props_clean(bidi_props); /*Mark that we don't need bidi handling */ if (bidi_props) evas_bidi_paragraph_props_unref(bidi_props); /* Clean up the bidi props */
return len; return NULL;
} }
int /**
evas_bidi_update_props_dup(const Evas_BiDi_Props *src, Evas_BiDi_Props *dst) * @internal
* Copies dst to src and refs (doesn't copy) the paragraph props.
*
* @param src the props to copy
* @param dst the props to copy to.
*/
void
evas_bidi_props_copy_and_ref(const Evas_BiDi_Props *src, Evas_BiDi_Props *dst)
{ {
dst->start = src->start; dst->start = src->start;
dst->props = NULL; dst->props = evas_bidi_paragraph_props_ref(src->props);
if (!src->props) return 1;
dst->props = malloc(sizeof(Evas_BiDi_Paragraph_Props));
if (!dst->props) return 0;
if (src->props->len > 0)
{
if (src->props->char_types)
{
dst->props->char_types =
malloc(sizeof(EvasBiDiCharType) * src->props->len);
if (!dst->props->char_types)
{
free(dst->props);
dst->props = NULL;
dst->start = 0;
return 0;
}
memcpy(dst->props->char_types, src->props->char_types,
sizeof(EvasBiDiCharType) * src->props->len);
}
else
dst->props->char_types = NULL;
if (src->props->embedding_levels)
{
dst->props->embedding_levels =
malloc(sizeof(EvasBiDiLevel) * src->props->len);
if (!dst->props->embedding_levels)
{
if (dst->props->char_types) free(dst->props->char_types);
free(dst->props);
dst->props = NULL;
dst->start = 0;
return 0;
}
memcpy(dst->props->embedding_levels, src->props->embedding_levels,
sizeof(EvasBiDiLevel) * src->props->len);
}
else
dst->props->embedding_levels = NULL;
}
else
{
dst->props->char_types = NULL;
dst->props->embedding_levels = NULL;
dst->props->len = 0;
}
dst->props->len = src->props->len;
dst->props->direction = src->props->direction;
return 1;
} }
/** /**
@ -312,7 +271,7 @@ evas_bidi_props_reorder_line(Eina_Unicode *eina_ustr, const Evas_BiDi_Props *int
FriBidiChar *ustr, *base_ustr = NULL; FriBidiChar *ustr, *base_ustr = NULL;
size_t len; size_t len;
if (!EVAS_BIDI_IS_BIDI_PROP(intl_props->props)) if (!intl_props->props)
return EINA_FALSE; return EINA_FALSE;
len = eina_unicode_strlen(eina_ustr); len = eina_unicode_strlen(eina_ustr);
@ -329,7 +288,7 @@ evas_bidi_props_reorder_line(Eina_Unicode *eina_ustr, const Evas_BiDi_Props *int
if (_v_to_l) { if (_v_to_l) {
int i; size_t i;
v_to_l = *_v_to_l = calloc(len, sizeof(EvasBiDiStrIndex)); v_to_l = *_v_to_l = calloc(len, sizeof(EvasBiDiStrIndex));
if (!v_to_l) if (!v_to_l)
{ {
@ -401,18 +360,69 @@ evas_bidi_position_logical_to_visual(EvasBiDiStrIndex *v_to_l, int len, EvasBiDi
* Checks if the char is rtl oriented. I.e even a neutral char can become rtl * Checks if the char is rtl oriented. I.e even a neutral char can become rtl
* if surrounded by rtl chars. * if surrounded by rtl chars.
* *
* @param embedded_level_list the bidi embedding list. * @param bidi_props The bidi properties
* @param index the index of the string. * @param index the index of the string.
* @return #EINA_TRUE if true, #EINA_FALSE otherwise. * @return #EINA_TRUE if true, #EINA_FALSE otherwise.
*/ */
Eina_Bool Eina_Bool
evas_bidi_is_rtl_char(EvasBiDiLevel *embedded_level_list, EvasBiDiStrIndex index) evas_bidi_is_rtl_char(const Evas_BiDi_Props *bidi_props, EvasBiDiStrIndex index)
{ {
if(!embedded_level_list || index < 0) if(!bidi_props || !bidi_props->props || index < 0)
return EINA_FALSE; return EINA_FALSE;
return (FRIBIDI_IS_RTL(embedded_level_list[index])) ? EINA_TRUE : EINA_FALSE; return (FRIBIDI_IS_RTL(
bidi_props->props->embedding_levels[index + bidi_props->start]))
? EINA_TRUE : EINA_FALSE;
} }
Evas_BiDi_Paragraph_Props *
evas_bidi_paragraph_props_new(void)
{
Evas_BiDi_Paragraph_Props *ret;
ret = calloc(1, sizeof(Evas_BiDi_Paragraph_Props));
ret->direction = EVAS_BIDI_PARAGRAPH_NATURAL;
ret->refcount = 1;
return ret;
}
/**
* @internal
* Refs the bidi props.
*
* @param bidi_props the props to ref.
*/
Evas_BiDi_Paragraph_Props *
evas_bidi_paragraph_props_ref(Evas_BiDi_Paragraph_Props *bidi_props)
{
if (!bidi_props) return NULL;
BIDILOCK();
bidi_props->refcount++;
BIDIUNLOCK();
return bidi_props;
}
/**
* @internal
* Unrefs and potentially frees the props.
*
* @param bidi_props the properties to unref
*/
void
evas_bidi_paragraph_props_unref(Evas_BiDi_Paragraph_Props *bidi_props)
{
if (!bidi_props) return;
BIDILOCK();
if (--bidi_props->refcount == 0)
{
evas_bidi_paragraph_props_clean(bidi_props);
free(bidi_props);
}
BIDIUNLOCK();
}
/** /**
* @internal * @internal
* Cleans the paragraph properties. * Cleans the paragraph properties.
@ -436,7 +446,7 @@ void
evas_bidi_props_clean(Evas_BiDi_Props *bidi_props) evas_bidi_props_clean(Evas_BiDi_Props *bidi_props)
{ {
if (!bidi_props) return; if (!bidi_props) return;
evas_bidi_paragraph_props_clean(bidi_props->props); evas_bidi_paragraph_props_unref(bidi_props->props);
bidi_props->props = NULL; bidi_props->props = NULL;
} }
/** /**

View File

@ -67,7 +67,7 @@ typedef struct _Evas_BiDi_Props Evas_BiDi_Props;
struct _Evas_BiDi_Paragraph_Props { struct _Evas_BiDi_Paragraph_Props {
EvasBiDiCharType *char_types; /* BiDi char types */ EvasBiDiCharType *char_types; /* BiDi char types */
EvasBiDiLevel *embedding_levels; /* BiDi embedding levels */ EvasBiDiLevel *embedding_levels; /* BiDi embedding levels */
int len; /* length of char_types & embedding_levels */ int refcount; /* The number of references to this object */
#ifdef USE_FRIBIDI #ifdef USE_FRIBIDI
EvasBiDiParType direction; EvasBiDiParType direction;
#endif #endif
@ -89,13 +89,13 @@ struct _Evas_BiDi_Props {
#define EVAS_BIDI_PARAGRAPH_WLTR FRIBIDI_PAR_WLTR #define EVAS_BIDI_PARAGRAPH_WLTR FRIBIDI_PAR_WLTR
#define EVAS_BIDI_PARAGRAPH_WRTL FRIBIDI_PAR_WRTL #define EVAS_BIDI_PARAGRAPH_WRTL FRIBIDI_PAR_WRTL
#define EVAS_BIDI_PARAGRAPH_DIRECTION_IS_RTL(direction) \ #define EVAS_BIDI_PARAGRAPH_DIRECTION_IS_RTL(x) \
(((direction == EVAS_BIDI_PARAGRAPH_RTL) || \ (((x) && \
(direction == EVAS_BIDI_PARAGRAPH_WRTL)) ? \ ((x->direction == EVAS_BIDI_PARAGRAPH_RTL) || \
EINA_TRUE : EINA_FALSE) (x->direction == EVAS_BIDI_PARAGRAPH_WRTL))) ? \
EINA_TRUE : EINA_FALSE)
# define EVAS_BIDI_IS_BIDI_PROP(intl_props) ((intl_props) && (intl_props)->char_types)
# define evas_bidi_position_visual_to_logical(list, position) \ # define evas_bidi_position_visual_to_logical(list, position) \
(list) ? list[position] : position; (list) ? list[position] : position;
@ -106,15 +106,16 @@ Eina_Bool
evas_bidi_is_rtl_str(const Eina_Unicode *str); evas_bidi_is_rtl_str(const Eina_Unicode *str);
Eina_Bool Eina_Bool
evas_bidi_is_rtl_char(EvasBiDiLevel *embedded_level_list, EvasBiDiStrIndex index); evas_bidi_is_rtl_char(const Evas_BiDi_Props *bidi_props, EvasBiDiStrIndex index);
Eina_Bool Eina_Bool
evas_bidi_props_reorder_line(Eina_Unicode *text, const Evas_BiDi_Props *intl_props, EvasBiDiStrIndex **_v_to_l); evas_bidi_props_reorder_line(Eina_Unicode *text, const Evas_BiDi_Props *intl_props, EvasBiDiStrIndex **_v_to_l);
int Evas_BiDi_Paragraph_Props *
evas_bidi_update_props(const Eina_Unicode *text, Evas_BiDi_Paragraph_Props *intl_props) EINA_ARG_NONNULL(1, 2); evas_bidi_paragraph_props_get(const Eina_Unicode *eina_ustr) EINA_ARG_NONNULL(1) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
int
evas_bidi_update_props_dup(const Evas_BiDi_Props *src, Evas_BiDi_Props *dst); void
evas_bidi_props_copy_and_ref(const Evas_BiDi_Props *src, Evas_BiDi_Props *dst);
Eina_Bool Eina_Bool
evas_bidi_shape_string(Eina_Unicode *ustr, const Evas_BiDi_Props *intl_props, size_t len); evas_bidi_shape_string(Eina_Unicode *ustr, const Evas_BiDi_Props *intl_props, size_t len);
@ -125,6 +126,15 @@ evas_bidi_props_clean(Evas_BiDi_Props *intl_props) EINA_ARG_NONNULL(1);
void void
evas_bidi_paragraph_props_clean(Evas_BiDi_Paragraph_Props *bidi_props) EINA_ARG_NONNULL(1); evas_bidi_paragraph_props_clean(Evas_BiDi_Paragraph_Props *bidi_props) EINA_ARG_NONNULL(1);
Evas_BiDi_Paragraph_Props *
evas_bidi_paragraph_props_ref(Evas_BiDi_Paragraph_Props *bidi_props) EINA_ARG_NONNULL(1);
void
evas_bidi_paragraph_props_unref(Evas_BiDi_Paragraph_Props *bidi_props) EINA_ARG_NONNULL(1);
Evas_BiDi_Paragraph_Props *
evas_bidi_paragraph_props_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
#endif #endif
/** /**
* @} * @}

View File

@ -482,7 +482,6 @@ evas_common_font_draw_internal(RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Font
#endif #endif
#ifdef BIDI_SUPPORT #ifdef BIDI_SUPPORT
LKL(lock_fribidi);
Eina_Unicode *visual_text; Eina_Unicode *visual_text;
visual_text = eina_unicode_strdup(in_text); visual_text = eina_unicode_strdup(in_text);
@ -496,7 +495,6 @@ evas_common_font_draw_internal(RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Font
{ {
text = in_text; text = in_text;
} }
LKU(lock_fribidi);
#endif #endif
@ -847,13 +845,12 @@ evas_font_word_prerender(RGBA_Draw_Context *dc, const Eina_Unicode *in_text, Eva
{ {
int kern = 0; int kern = 0;
# ifdef BIDI_SUPPORT # ifdef BIDI_SUPPORT
LKL(lock_fribidi);
/* if it's rtl, the kerning matching should be reversed, i.e prev /* if it's rtl, the kerning matching should be reversed, i.e prev
* index is now the index and the other way around. * index is now the index and the other way around.
* There is a slight exception when there are compositing chars * There is a slight exception when there are compositing chars
* involved.*/ * involved.*/
if (intl_props && intl_props->props && if (intl_props && intl_props->props &&
evas_bidi_is_rtl_char(intl_props->props->embedding_levels, char_index) && evas_bidi_is_rtl_char(intl_props, char_index) &&
ci->fg->glyph->advance.x >> 16 > 0) ci->fg->glyph->advance.x >> 16 > 0)
{ {
if (evas_common_font_query_kerning(fi, ci->index, prev_index, &kern)) if (evas_common_font_query_kerning(fi, ci->index, prev_index, &kern))
@ -864,9 +861,7 @@ evas_font_word_prerender(RGBA_Draw_Context *dc, const Eina_Unicode *in_text, Eva
if (evas_common_font_query_kerning(fi, prev_index, ci->index, &kern)) if (evas_common_font_query_kerning(fi, prev_index, ci->index, &kern))
pen_x += kern; pen_x += kern;
} }
LKU(lock_fribidi); # else
# else
if (evas_common_font_query_kerning(fi, prev_index, ci->index, &kern)) if (evas_common_font_query_kerning(fi, prev_index, ci->index, &kern))
pen_x += kern; pen_x += kern;
# endif # endif

View File

@ -8,7 +8,7 @@ FT_Library evas_ft_lib = 0;
static int initialised = 0; static int initialised = 0;
LK(lock_font_draw); // for freetype2 API calls LK(lock_font_draw); // for freetype2 API calls
LK(lock_fribidi); // for fribidi API calls LK(lock_bidi); // for evas bidi internal usage.
EAPI void EAPI void
evas_common_font_init(void) evas_common_font_init(void)
@ -22,7 +22,7 @@ evas_common_font_init(void)
evas_common_font_load_init(); evas_common_font_load_init();
evas_common_font_draw_init(); evas_common_font_draw_init();
LKI(lock_font_draw); LKI(lock_font_draw);
LKI(lock_fribidi); LKI(lock_bidi);
} }
EAPI void EAPI void
@ -35,8 +35,8 @@ evas_common_font_shutdown(void)
if (initialised != 0) return; if (initialised != 0) return;
LKD(lock_font_draw); LKD(lock_font_draw);
LKD(lock_fribidi); LKD(lock_bidi);
evas_common_font_load_shutdown(); evas_common_font_load_shutdown();
evas_common_font_cache_set(0); evas_common_font_cache_set(0);
evas_common_font_flush(); evas_common_font_flush();

View File

@ -3,21 +3,21 @@
#ifdef BUILD_PTHREAD #ifdef BUILD_PTHREAD
extern LK(lock_font_draw); // for freetype2 API calls extern LK(lock_font_draw); // for freetype2 API calls
extern LK(lock_fribidi); // for fribidi API calls extern LK(lock_bidi); // for fribidi API calls
#endif #endif
# if defined(EVAS_FRAME_QUEUING) || defined(BUILD_PIPE_RENDER) # if defined(EVAS_FRAME_QUEUING) || defined(BUILD_PIPE_RENDER)
# define FTLOCK() LKL(lock_font_draw) # define FTLOCK() LKL(lock_font_draw)
# define FTUNLOCK() LKU(lock_font_draw) # define FTUNLOCK() LKU(lock_font_draw)
# define FBDLOCK() LKL(lock_fribidi) # define BIDILOCK() LKL(lock_bidi)
# define FBDUNLOCK() LKU(lock_fribidi) # define BIDIUNLOCK() LKU(lock_bidi)
# else # else
# define FTLOCK(x) # define FTLOCK(x)
# define FTUNLOCK(x) # define FTUNLOCK(x)
# define FBDLOCK() # define BIDILOCK()
# define FBDUNLOCK() # define BIDIUNLOCK()
# endif # endif
#endif /* !_EVAS_FONT_PRIVATE_H */ #endif /* !_EVAS_FONT_PRIVATE_H */

View File

@ -111,13 +111,12 @@ evas_common_font_query_size(RGBA_Font *fn, const Eina_Unicode *text, const Evas_
(pface == fi->src->ft.face)) (pface == fi->src->ft.face))
{ {
#ifdef BIDI_SUPPORT #ifdef BIDI_SUPPORT
LKL(lock_fribidi);
/* if it's rtl, the kerning matching should be reversed, i.e prev /* if it's rtl, the kerning matching should be reversed, i.e prev
* index is now the index and the other way around. * index is now the index and the other way around.
* There is a slight exception when there are compositing chars * There is a slight exception when there are compositing chars
* involved.*/ * involved.*/
if (intl_props && if (intl_props &&
evas_bidi_is_rtl_char(intl_props->props->embedding_levels, char_index) && evas_bidi_is_rtl_char(intl_props, char_index) &&
fg->glyph->advance.x >> 16 > 0) fg->glyph->advance.x >> 16 > 0)
{ {
if (evas_common_font_query_kerning(fi, index, prev_index, &kern)) if (evas_common_font_query_kerning(fi, index, prev_index, &kern))
@ -128,7 +127,6 @@ evas_common_font_query_size(RGBA_Font *fn, const Eina_Unicode *text, const Evas_
if (evas_common_font_query_kerning(fi, prev_index, index, &kern)) if (evas_common_font_query_kerning(fi, prev_index, index, &kern))
pen_x += kern; pen_x += kern;
} }
LKU(lock_fribidi);
#else #else
if (evas_common_font_query_kerning(fi, prev_index, index, &kern)) if (evas_common_font_query_kerning(fi, prev_index, index, &kern))
pen_x += kern; pen_x += kern;
@ -277,13 +275,12 @@ evas_common_font_query_advance(RGBA_Font *fn, const Eina_Unicode *text, const Ev
(pface == fi->src->ft.face)) (pface == fi->src->ft.face))
{ {
#ifdef BIDI_SUPPORT #ifdef BIDI_SUPPORT
LKL(lock_fribidi);
/* if it's rtl, the kerning matching should be reversed, i.e prev /* if it's rtl, the kerning matching should be reversed, i.e prev
* index is now the index and the other way around. * index is now the index and the other way around.
* There is a slight exception when there are compositing chars * There is a slight exception when there are compositing chars
* involved.*/ * involved.*/
if (intl_props && if (intl_props &&
evas_bidi_is_rtl_char(intl_props->props->embedding_levels, char_index) && evas_bidi_is_rtl_char(intl_props, char_index) &&
fg->glyph->advance.x >> 16 > 0) fg->glyph->advance.x >> 16 > 0)
{ {
if (evas_common_font_query_kerning(fi, index, prev_index, &kern)) if (evas_common_font_query_kerning(fi, index, prev_index, &kern))
@ -294,7 +291,6 @@ evas_common_font_query_advance(RGBA_Font *fn, const Eina_Unicode *text, const Ev
if (evas_common_font_query_kerning(fi, prev_index, index, &kern)) if (evas_common_font_query_kerning(fi, prev_index, index, &kern))
pen_x += kern; pen_x += kern;
} }
LKU(lock_fribidi);
#else #else
if (evas_common_font_query_kerning(fi, prev_index, index, &kern)) if (evas_common_font_query_kerning(fi, prev_index, index, &kern))
pen_x += kern; pen_x += kern;
@ -341,7 +337,6 @@ evas_common_font_query_char_coords(RGBA_Font *fn, const Eina_Unicode *in_text, c
EvasBiDiStrIndex *visual_to_logical = NULL; EvasBiDiStrIndex *visual_to_logical = NULL;
Eina_Unicode *visual_text; Eina_Unicode *visual_text;
LKL(lock_fribidi);
visual_text = eina_unicode_strdup(in_text); visual_text = eina_unicode_strdup(in_text);
if (visual_text) if (visual_text)
{ {
@ -353,7 +348,6 @@ evas_common_font_query_char_coords(RGBA_Font *fn, const Eina_Unicode *in_text, c
text = in_text; text = in_text;
} }
len = eina_unicode_strlen(text); len = eina_unicode_strlen(text);
LKU(lock_fribidi);
#endif #endif
fi = fn->fonts->data; fi = fn->fonts->data;
@ -375,10 +369,8 @@ evas_common_font_query_char_coords(RGBA_Font *fn, const Eina_Unicode *in_text, c
desc = evas_common_font_max_descent_get(fn); desc = evas_common_font_max_descent_get(fn);
#ifdef BIDI_SUPPORT #ifdef BIDI_SUPPORT
LKL(lock_fribidi);
/* Get the position in the visual string because those are the coords we care about */ /* Get the position in the visual string because those are the coords we care about */
position = evas_bidi_position_logical_to_visual(visual_to_logical, len, pos); position = evas_bidi_position_logical_to_visual(visual_to_logical, len, pos);
LKU(lock_fribidi);
#else #else
position = pos; position = pos;
#endif #endif
@ -490,7 +482,6 @@ evas_common_font_query_char_at_coords(RGBA_Font *fn, const Eina_Unicode *in_text
EvasBiDiStrIndex *visual_to_logical = NULL; EvasBiDiStrIndex *visual_to_logical = NULL;
Eina_Unicode *visual_text; Eina_Unicode *visual_text;
LKL(lock_fribidi);
visual_text = eina_unicode_strdup(in_text); visual_text = eina_unicode_strdup(in_text);
if (visual_text) if (visual_text)
@ -503,7 +494,6 @@ evas_common_font_query_char_at_coords(RGBA_Font *fn, const Eina_Unicode *in_text
text = in_text; text = in_text;
} }
len = eina_unicode_strlen(text); len = eina_unicode_strlen(text);
LKU(lock_fribidi);
#endif #endif
fi = fn->fonts->data; fi = fn->fonts->data;
@ -593,12 +583,10 @@ evas_common_font_query_char_at_coords(RGBA_Font *fn, const Eina_Unicode *in_text
if (cw) *cw = chr_w; if (cw) *cw = chr_w;
if (ch) *ch = asc + desc; if (ch) *ch = asc + desc;
#ifdef BIDI_SUPPORT #ifdef BIDI_SUPPORT
LKL(lock_fribidi);
/* we found the char position of the wanted char in the /* we found the char position of the wanted char in the
* visual string, we now need to translate it to the * visual string, we now need to translate it to the
* position in the logical string */ * position in the logical string */
position = evas_bidi_position_visual_to_logical(visual_to_logical, position); position = evas_bidi_position_visual_to_logical(visual_to_logical, position);
LKU(lock_fribidi);
#endif #endif
ret_val = position; ret_val = position;
goto end; goto end;
@ -674,14 +662,13 @@ evas_common_font_query_last_up_to_pos(RGBA_Font *fn, const Eina_Unicode *in_text
(pface == fi->src->ft.face)) (pface == fi->src->ft.face))
{ {
#ifdef BIDI_SUPPORT #ifdef BIDI_SUPPORT
LKL(lock_fribidi);
/* if it's rtl, the kerning matching should be reversed, i.e prev /* if it's rtl, the kerning matching should be reversed, i.e prev
* index is now the index and the other way around. * index is now the index and the other way around.
* There is a slight exception when there are compositing chars * There is a slight exception when there are compositing chars
* involved.*/ * involved.*/
if (intl_props && if (intl_props &&
evas_bidi_is_rtl_char(intl_props->props->embedding_levels, evas_bidi_is_rtl_char(intl_props, char_index) &&
char_index) && fg->glyph->advance.x >> 16 > 0) fg->glyph->advance.x >> 16 > 0)
{ {
if (evas_common_font_query_kerning(fi, index, prev_index, if (evas_common_font_query_kerning(fi, index, prev_index,
&kern)) &kern))
@ -693,8 +680,7 @@ evas_common_font_query_last_up_to_pos(RGBA_Font *fn, const Eina_Unicode *in_text
&kern)) &kern))
pen_x += kern; pen_x += kern;
} }
LKU(lock_fribidi); #else
#else
if (evas_common_font_query_kerning(fi, prev_index, index, if (evas_common_font_query_kerning(fi, prev_index, index,
&kern)) &kern))
pen_x += kern; pen_x += kern;

View File

@ -1249,7 +1249,7 @@ evas_common_pipe_text_draw(RGBA_Image *dst, RGBA_Draw_Context *dc,
op->op.text.y = y; op->op.text.y = y;
op->op.text.text = eina_unicode_strdup(text); op->op.text.text = eina_unicode_strdup(text);
#ifdef BIDI_SUPPORT #ifdef BIDI_SUPPORT
evas_bidi_update_props_dup(intl_props, &(op->op.text.intl_props)); evas_bidi_props_copy_and_ref(intl_props, &(op->op.text.intl_props));
#endif #endif
#ifdef EVAS_FRAME_QUEUING #ifdef EVAS_FRAME_QUEUING
LKL(fn->ref_fq_add); LKL(fn->ref_fq_add);