evas: clean up GL images for emojis when GL context is free'd in shutdown process 10/116710/1
authorYoungbok Shin <youngb.shin@samsung.com>
Sun, 26 Feb 2017 04:34:38 +0000 (13:34 +0900)
committerYoungbok Shin <youngb.shin@samsung.com>
Tue, 28 Feb 2017 01:51:56 +0000 (17:51 -0800)
If GL context is free'd before processing font shutdown,
textures for emoji glyph's GL images will be free'd without clean up its GL images.
It causes eina mempool infinite loop issue when emoji's GL images are free'd
in shutdown process.
So, the patch will make a list for emoji's GL images in context and clean up them
when the context is free'd. Just like font textures in context.

@tizen_fix

Change-Id: I3904f9aff74888e227a4f2143c4ff607ebb82415
(cherry picked from commit cecaf12a3bea725b53041126031c58035d76dfd1)

src/lib/evas/common/evas_draw.h
src/lib/evas/common/evas_draw_main.c
src/lib/evas/common/evas_font_draw.c
src/lib/evas/include/evas_common_private.h
src/modules/evas/engines/gl_common/evas_gl_common.h
src/modules/evas/engines/gl_common/evas_gl_context.c
src/modules/evas/engines/gl_common/evas_gl_image.c

index 0beb84c..72b0b8a 100644 (file)
@@ -12,7 +12,11 @@ EAPI void               evas_common_draw_context_font_ext_set            (RGBA_D
                                                                           void *(*gl_new)  (void *data, RGBA_Font_Glyph *fg),
                                                                           void  (*gl_free) (void *ext_dat),
                                                                           void  (*gl_draw) (void *data, void *dest, void *context, RGBA_Font_Glyph *fg, int x, int y),
+                                                                          /* TIZEN_ONLY(20170226): clean up GL images for emojis when GL context is free'd in shutdown process
                                                                           void *(*gl_image_new_from_data) (void *gc, unsigned int w, unsigned int h, DATA32 *image_data, int alpha, Evas_Colorspace cspace),
+                                                                           */
+                                                                          void *(*gl_image_new_from_data) (void *gc, RGBA_Font_Glyph *fg, unsigned int w, unsigned int h, DATA32 *image_data, int alpha, Evas_Colorspace cspace),
+                                                                          /* END */
                                                                           void  (*gl_image_free) (void *image),
                                                                           void  (*gl_image_draw) (void *gc, void *im, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int smooth));
 EAPI void               evas_common_draw_context_clip_clip               (RGBA_Draw_Context *dc, int x, int y, int w, int h);
index 460a296..66cae9a 100644 (file)
@@ -148,7 +148,11 @@ evas_common_draw_context_font_ext_set(RGBA_Draw_Context *dc,
                                       void *(*gl_new)  (void *data, RGBA_Font_Glyph *fg),
                                       void  (*gl_free) (void *ext_dat),
                                       void  (*gl_draw) (void *data, void *dest, void *context, RGBA_Font_Glyph *fg, int x, int y),
+                                      /* TIZEN_ONLY(20170226): clean up GL images for emojis when GL context is free'd in shutdown process
                                       void *(*gl_image_new_from_data) (void *gc, unsigned int w, unsigned int h, DATA32 *image_data, int alpha, Evas_Colorspace cspace),
+                                       */
+                                      void *(*gl_image_new_from_data) (void *gc, RGBA_Font_Glyph *fg, unsigned int w, unsigned int h, DATA32 *image_data, int alpha, Evas_Colorspace cspace),
+                                      /* END */
                                       void  (*gl_image_free) (void *image),
                                       void  (*gl_image_draw) (void *gc, void *im, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int smooth))
 {
index 03671b6..3192cfb 100644 (file)
@@ -140,10 +140,17 @@ evas_common_font_rgba_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y,
              if (dc->font_ext.func.gl_image_new_from_data)
                {
                   /* extension calls */
+                  /* TIZEN_ONLY(20170226): clean up GL images for emojis when GL context is free'd in shutdown process
                   fg->ext_dat = dc->font_ext.func.gl_image_new_from_data
                     (dc->font_ext.data, (unsigned int)w, (unsigned int)h,
                      (DATA32 *)fg->glyph_out->bitmap.buffer, EINA_TRUE,
                      EVAS_COLORSPACE_ARGB8888);
+                   */
+                  fg->ext_dat = dc->font_ext.func.gl_image_new_from_data
+                    (dc->font_ext.data, fg, (unsigned int)w, (unsigned int)h,
+                     (DATA32 *)fg->glyph_out->bitmap.buffer, EINA_TRUE,
+                     EVAS_COLORSPACE_ARGB8888);
+                  /* END */
                   fg->ext_dat_free = dc->font_ext.func.gl_image_free;
                }
              else
index 2d00d31..643a5bb 100644 (file)
@@ -755,7 +755,11 @@ struct _RGBA_Draw_Context
          void *(*gl_new)  (void *data, RGBA_Font_Glyph *fg);
          void  (*gl_free) (void *ext_dat);
          void  (*gl_draw) (void *data, void *dest, void *context, RGBA_Font_Glyph *fg, int x, int y);
+         /* TIZEN_ONLY(20170226): clean up GL images for emojis when GL context is free'd in shutdown process
          void *(*gl_image_new_from_data) (void *gc, unsigned int w, unsigned int h, DATA32 *image_data, int alpha, Evas_Colorspace cspace);
+          */
+         void *(*gl_image_new_from_data) (void *gc, RGBA_Font_Glyph *fg, unsigned int w, unsigned int h, DATA32 *image_data, int alpha, Evas_Colorspace cspace);
+         /* END */
          void  (*gl_image_free) (void *image);
          void  (*gl_image_draw) (void *gc, void *im, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int smooth);
       } func;
index 6b4b9d6..15d8a08 100644 (file)
@@ -331,6 +331,9 @@ struct _Evas_Engine_GL_Context
    } pipe[MAX_PIPES];
 
    Eina_List *font_glyph_textures;
+   /* TIZEN_ONLY(20170226): clean up GL images for emojis when GL context is free'd in shutdown process */
+   Eina_List *font_glyph_images;
+   /* END */
 
    Eina_Bool havestuff : 1;
 
@@ -422,6 +425,9 @@ struct _Evas_GL_Image
    RGBA_Image      *im;
    Evas_GL_Texture *tex;
    Evas_Image_Load_Opts load_opts;
+   /* TIZEN_ONLY(20170226): clean up GL images for emojis when GL context is free'd in shutdown process */
+   RGBA_Font_Glyph *fglyph;
+   /* END */
    int              references;
    // if im->im == NULL, it's a render-surface so these here are used
    int              w, h;
@@ -688,7 +694,11 @@ void              evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_
 void             *evas_gl_font_texture_new(void *gc, RGBA_Font_Glyph *fg);
 void              evas_gl_font_texture_free(void *);
 void              evas_gl_font_texture_draw(void *gc, void *surface, void *dc, RGBA_Font_Glyph *fg, int x, int y);
+/* TIZEN_ONLY(20170226): clean up GL images for emojis when GL context is free'd in shutdown process
 void             *evas_gl_image_new_from_data(void *gc, unsigned int w, unsigned int h, DATA32 *data, int alpha, Evas_Colorspace cspace);
+ */
+void             *evas_gl_image_new_from_data(void *gc, RGBA_Font_Glyph *fg, unsigned int w, unsigned int h, DATA32 *data, int alpha, Evas_Colorspace cspace);
+/* END */
 void              evas_gl_image_free(void *im);
 void              evas_gl_image_draw(void *gc, void *im, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int smooth);
 
index 2d8049e..276994c 100644 (file)
@@ -1051,6 +1051,11 @@ evas_gl_common_context_free(Evas_Engine_GL_Context *gc)
    while (gc->font_glyph_textures)
      evas_gl_common_texture_free(gc->font_glyph_textures->data, EINA_TRUE);
 
+   /* TIZEN_ONLY(20170226): clean up GL images for emojis when GL context is free'd in shutdown process */
+   while (gc->font_glyph_images)
+     evas_gl_common_image_free(gc->font_glyph_images->data);
+   /* END */
+
    if ((gc->shared) && (gc->shared->references == 0))
      {
         Evas_GL_Texture_Pool *pt;
index 6bedf40..c57c14f 100644 (file)
@@ -695,6 +695,14 @@ evas_gl_common_image_free(Evas_GL_Image *im)
 {
    im->references--;
    if (im->references > 0) return;
+   /* TIZEN_ONLY(20170226): clean up GL images for emojis when GL context is free'd in shutdown process */
+   if (im->fglyph)
+     {
+        im->gc->font_glyph_images = eina_list_remove(im->gc->font_glyph_images, im);
+        im->fglyph->ext_dat = NULL;
+        im->fglyph->ext_dat_free = NULL;
+     }
+   /* END */
    evas_gl_common_context_flush(im->gc);
 
    if (im->scaled.origin)
@@ -1256,6 +1264,7 @@ evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx,
    gc->dc->clip.use = c; gc->dc->clip.x = cx; gc->dc->clip.y = cy; gc->dc->clip.w = cw; gc->dc->clip.h = ch;
 }
 
+/* TIZEN_ONLY(20170226): clean up GL images for emojis when GL context is free'd in shutdown process
 void *
 evas_gl_image_new_from_data(void *gc, unsigned int w, unsigned int h, DATA32 *data, int alpha, Evas_Colorspace cspace)
 {
@@ -1265,6 +1274,26 @@ evas_gl_image_new_from_data(void *gc, unsigned int w, unsigned int h, DATA32 *da
                                                      alpha,
                                                      cspace);
 }
+ */
+void *
+evas_gl_image_new_from_data(void *gc, RGBA_Font_Glyph *fg, unsigned int w, unsigned int h, DATA32 *data, int alpha, Evas_Colorspace cspace)
+{
+   Evas_Engine_GL_Context *context = (Evas_Engine_GL_Context *)gc;
+   Evas_GL_Image *im = evas_gl_common_image_new_from_data(context,
+                                                          w, h,
+                                                          data,
+                                                          alpha,
+                                                          cspace);
+
+   if (im)
+     {
+        im->fglyph = fg;
+        context->font_glyph_images = eina_list_append(context->font_glyph_images, im);
+     }
+
+   return (void *)im;
+}
+/* END */
 
 void
 evas_gl_image_free(void *im)