raster pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=af4c3c0fe134b4684ddf81b2a7f3e409688b99fd

commit af4c3c0fe134b4684ddf81b2a7f3e409688b99fd
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
Date:   Tue Apr 12 12:47:30 2016 +0900

    evas gl - fix leak with font glyph textures
    
    some font glyphs are still allocated after tyhe last gl window is
    freed which means we can't make current anymore to free textures after
    that. this fixes that by flushing gl texture info from the font cache
    when the last gl windows are gone.
    
    @fix
---
 src/examples/elementary/codegen_example.edj        | Bin 12063 -> 0 bytes
 src/lib/evas/common/evas_font.h                    |   1 +
 src/lib/evas/common/evas_font_load.c               |  57 +++++++++++++++++++++
 .../evas/engines/gl_cocoa/evas_gl_cocoa_main.m     |   1 +
 src/modules/evas/engines/gl_drm/evas_outbuf.c      |   2 +
 src/modules/evas/engines/gl_sdl/evas_engine.c      |   1 +
 src/modules/evas/engines/gl_x11/evas_x_main.c      |   2 +
 7 files changed, 64 insertions(+)

diff --git a/src/examples/elementary/codegen_example.edj 
b/src/examples/elementary/codegen_example.edj
deleted file mode 100644
index 4f87ec8..0000000
Binary files a/src/examples/elementary/codegen_example.edj and /dev/null differ
diff --git a/src/lib/evas/common/evas_font.h b/src/lib/evas/common/evas_font.h
index 5017262..3d59201 100644
--- a/src/lib/evas/common/evas_font.h
+++ b/src/lib/evas/common/evas_font.h
@@ -68,6 +68,7 @@ EAPI void              evas_common_font_flush                
(void);
 EAPI void              evas_common_font_flush_last           (void);
 EAPI RGBA_Font_Int    *evas_common_font_int_find             (const char 
*name, int size, Font_Rend_Flags wanted_rend);
 EAPI void              evas_common_font_all_clear            (void);
+EAPI void              evas_common_font_ext_clear            (void);
 
 /* query */
 
diff --git a/src/lib/evas/common/evas_font_load.c 
b/src/lib/evas/common/evas_font_load.c
index 041fe00..2afd124 100644
--- a/src/lib/evas/common/evas_font_load.c
+++ b/src/lib/evas/common/evas_font_load.c
@@ -962,3 +962,60 @@ evas_common_font_int_find(const char *name, int size,
    eina_stringshare_del(tmp_fn.name);
    return fi;
 }
+
+static void
+_font_int_ext_clear(RGBA_Font_Int *fi)
+{
+   RGBA_Font_Glyph *fg;
+   Fash_Glyph_Map *fmap;
+   Fash_Glyph_Map2 *fash2;
+   Fash_Glyph *fash;
+   int i, j, k;
+
+   fash = fi->fash;
+   if (!fash) return;
+   for (k = 0; k <= 0xff; k++)
+     {
+        fash2 = fash->bucket[k];
+        if (fash2)
+          {
+             for (j = 0; j <= 0xff; j++)
+               {
+                  fmap = fash2->bucket[j];
+                  if (fmap)
+                    {
+                       for (i = 0; i <= 0xff; i++)
+                         {
+                            fg = fmap->item[i];
+                            if ((fg) && (fg != (void *)(-1)))
+                              {
+                                 if (fg->ext_dat)
+                                   {
+                                      if (fg->ext_dat_free)
+                                        fg->ext_dat_free(fg->ext_dat);
+                                      fg->ext_dat = NULL;
+                                      fg->ext_dat_free = NULL;
+                                   }
+                              }
+                         }
+                    }
+               }
+          }
+     }
+}
+
+static Eina_Bool
+_cb_hash_font_ext(const Eina_Hash *hash EINA_UNUSED,
+                  const void *key EINA_UNUSED,
+                  void *data EINA_UNUSED,
+                  void *fdata EINA_UNUSED)
+{
+   _font_int_ext_clear(data);
+   return EINA_TRUE;
+}
+
+EAPI void
+evas_common_font_ext_clear(void)
+{
+   eina_hash_foreach(fonts, _cb_hash_font_ext, NULL);
+}
diff --git a/src/modules/evas/engines/gl_cocoa/evas_gl_cocoa_main.m 
b/src/modules/evas/engines/gl_cocoa/evas_gl_cocoa_main.m
index ea29753..15dc218 100644
--- a/src/modules/evas/engines/gl_cocoa/evas_gl_cocoa_main.m
+++ b/src/modules/evas/engines/gl_cocoa/evas_gl_cocoa_main.m
@@ -111,6 +111,7 @@ eng_window_free(Evas_GL_Cocoa_Window *gw)
    if (gw == _evas_gl_cocoa_window)
      _evas_gl_cocoa_window = NULL;
 
+   evas_common_font_ext_clear();
    evas_gl_common_context_free(gw->gl_context);
    [(EvasGLView*)gw->view release];
    free(gw);
diff --git a/src/modules/evas/engines/gl_drm/evas_outbuf.c 
b/src/modules/evas/engines/gl_drm/evas_outbuf.c
index 55d0e20..b120216 100644
--- a/src/modules/evas/engines/gl_drm/evas_outbuf.c
+++ b/src/modules/evas/engines/gl_drm/evas_outbuf.c
@@ -394,6 +394,8 @@ evas_outbuf_free(Outbuf *ob)
    win_count--;
    evas_outbuf_use(ob);
 
+   if (win_count == 0) evas_common_font_ext_clear();
+
    if (ob == _evas_gl_drm_window) _evas_gl_drm_window = NULL;
 
    if (ob->gl_context)
diff --git a/src/modules/evas/engines/gl_sdl/evas_engine.c 
b/src/modules/evas/engines/gl_sdl/evas_engine.c
index 8c70fba..99956ad 100644
--- a/src/modules/evas/engines/gl_sdl/evas_engine.c
+++ b/src/modules/evas/engines/gl_sdl/evas_engine.c
@@ -57,6 +57,7 @@ _outbuf_free_region_for_update(Outbuf *ob EINA_UNUSED, 
RGBA_Image *update EINA_U
 static void
 _outbuf_free(Outbuf *ob)
 {
+   evas_common_font_ext_clear();
    glsym_evas_gl_common_context_free(ob->gl_context);
 }
 
diff --git a/src/modules/evas/engines/gl_x11/evas_x_main.c 
b/src/modules/evas/engines/gl_x11/evas_x_main.c
index 031f790..654e384 100644
--- a/src/modules/evas/engines/gl_x11/evas_x_main.c
+++ b/src/modules/evas/engines/gl_x11/evas_x_main.c
@@ -587,6 +587,8 @@ eng_window_free(Outbuf *gw)
    win_count--;
    eng_window_use(gw);
 
+   if (win_count == 0) evas_common_font_ext_clear();
+
    context = _tls_context_get();
    xwin = _tls_outbuf_get();
 

-- 


Reply via email to