* evas: fix potential race condition with FT_Activate_Size and threaded rendering.
authorcedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 24 Mar 2010 11:07:37 +0000 (11:07 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 24 Mar 2010 11:07:37 +0000 (11:07 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/evas@47419 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/engines/common/evas_font_draw.c
src/lib/engines/common/evas_font_query.c

index d0240ec..87372de 100644 (file)
@@ -358,6 +358,7 @@ evas_common_font_draw_internal(RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Font
 
        if (gl == 0) break;
        index = evas_common_font_glyph_search(fn, &fi, gl);
+       LKL(fi->ft_mutex);
         if (fi->src->current_size != fi->size)
           {
              FT_Activate_Size(fi->ft.size);
@@ -388,6 +389,7 @@ evas_common_font_draw_internal(RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Font
 
          pface = fi->src->ft.face;
          fg = evas_common_font_int_cache_glyph_get(fi, index);
+         LKU(fi->ft_mutex);
          if (!fg) continue;
 
          if (dc->font_ext.func.gl_new)
index 2298bf4..c626612 100644 (file)
@@ -15,10 +15,6 @@ evas_common_font_query_kerning(RGBA_Font_Int* fi,
    key[0] = prev;
    key[1] = index;
 
-#ifdef HAVE_PTHREAD
-   pthread_mutex_lock(&fi->ft_mutex);
-#endif
-
    result = eina_hash_find(fi->kerning, key);
    if (result)
      {
@@ -53,9 +49,6 @@ evas_common_font_query_kerning(RGBA_Font_Int* fi,
    error = 0;
 
  on_correct:
-#ifdef HAVE_PTHREAD
-   pthread_mutex_unlock(&fi->ft_mutex);
-#endif
    return error;
 }
 
@@ -91,6 +84,7 @@ evas_common_font_query_size(RGBA_Font *fn, const char *text, int *w, int *h)
        gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
        if (gl == 0) break;
        index = evas_common_font_glyph_search(fn, &fi, gl);
+       LKL(fi->ft_mutex);
         if (fi->src->current_size != fi->size)
           {
              FT_Activate_Size(fi->ft.size);
@@ -107,6 +101,7 @@ evas_common_font_query_size(RGBA_Font *fn, const char *text, int *w, int *h)
 
        pface = fi->src->ft.face;
        fg = evas_common_font_int_cache_glyph_get(fi, index);
+       LKU(fi->ft_mutex);
        if (!fg) continue;
 
        if (kern < 0) kern = 0;
@@ -205,6 +200,7 @@ evas_common_font_query_advance(RGBA_Font *fn, const char *text, int *h_adv, int
        gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
        if (gl == 0) break;
        index = evas_common_font_glyph_search(fn, &fi, gl);
+       LKL(fi->ft_mutex);
         if (fi->src->current_size != fi->size)
           {
              FT_Activate_Size(fi->ft.size);
@@ -220,6 +216,7 @@ evas_common_font_query_advance(RGBA_Font *fn, const char *text, int *h_adv, int
 
        pface = fi->src->ft.face;
        fg = evas_common_font_int_cache_glyph_get(fi, index);
+       LKU(fi->ft_mutex);
        if (!fg) continue;
 
         chr_x = (pen_x + (fg->glyph_out->left));
@@ -305,6 +302,8 @@ evas_common_font_query_char_coords(RGBA_Font *fn, const char *in_text, int pos,
        gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
        if (gl == 0) break;
        index = evas_common_font_glyph_search(fn, &fi, gl);
+       LKL(fi->ft_mutex);
+       // FIXME: Why no FT_Activate_Size here ?
        kern = 0;
         /* hmmm kerning means i can't sanely do my own cached metric tables! */
        /* grrr - this means font face sharing is kinda... not an option if */
@@ -331,6 +330,7 @@ evas_common_font_query_char_coords(RGBA_Font *fn, const char *in_text, int pos,
 
        pface = fi->src->ft.face;
        fg = evas_common_font_int_cache_glyph_get(fi, index);
+       LKU(fi->ft_mutex);
        if (!fg) continue;
 
        if (kern < 0) kern = 0;
@@ -427,6 +427,8 @@ evas_common_font_query_text_at_pos(RGBA_Font *fn, const char *in_text, int x, in
        gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
        if (gl == 0) break;
        index = evas_common_font_glyph_search(fn, &fi, gl);
+       LKL(fi->ft_mutex);
+       // FIXME: Why not FT_Activate_Size here ?
        kern = 0;
         /* hmmm kerning means i can't sanely do my own cached metric tables! */
        /* grrr - this means font face sharing is kinda... not an option if */
@@ -453,6 +455,7 @@ evas_common_font_query_text_at_pos(RGBA_Font *fn, const char *in_text, int x, in
 
        pface = fi->src->ft.face;
        fg = evas_common_font_int_cache_glyph_get(fi, index);
+       LKU(fi->ft_mutex);
        if (!fg) continue;
 
        if (kern < 0) kern = 0;
@@ -547,6 +550,7 @@ evas_common_font_query_last_up_to_pos(RGBA_Font *fn, const char *text, int x, in
        gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
        if (gl == 0) break;
        index = evas_common_font_glyph_search(fn, &fi, gl);
+       LKL(fi->ft_mutex);
         if (fi->src->current_size != fi->size)
           {
              FT_Activate_Size(fi->ft.size);
@@ -563,6 +567,7 @@ evas_common_font_query_last_up_to_pos(RGBA_Font *fn, const char *text, int x, in
 
        pface = fi->src->ft.face;
        fg = evas_common_font_int_cache_glyph_get(fi, index);
+       LKU(fi->ft_mutex);
        if (!fg) continue;
 
        if (kern < 0) kern = 0;