jpeg pushed a commit to branch master.

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

commit 291fcca181f4ad2191e42dc97dfd8ddfb7987dc5
Author: Dongyeon Kim <dy5....@samsung.com>
Date:   Mon Jun 15 17:48:10 2015 +0900

    evas/gl_x11, gl_cocoa: remove static variable in eng_font_draw
    
    Summary:
    When evas is recreated, this static variable value remains,
    so it references already freed memory.
    
    Test Plan: Local tests
    
    Reviewers: cedric, jpeg
    
    Reviewed By: jpeg
    
    Subscribers: wonsik, mer.kim, cedric
    
    Differential Revision: https://phab.enlightenment.org/D2678
---
 src/modules/evas/engines/gl_cocoa/evas_engine.c    | 32 ++++++++++------------
 .../evas/engines/gl_common/evas_gl_common.h        |  2 ++
 .../evas/engines/gl_common/evas_gl_context.c       |  3 ++
 src/modules/evas/engines/gl_generic/evas_engine.c  | 13 ++++-----
 4 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/src/modules/evas/engines/gl_cocoa/evas_engine.c 
b/src/modules/evas/engines/gl_cocoa/evas_engine.c
index 4acca80..5aab2c2 100644
--- a/src/modules/evas/engines/gl_cocoa/evas_engine.c
+++ b/src/modules/evas/engines/gl_cocoa/evas_engine.c
@@ -1035,27 +1035,25 @@ eng_font_draw(void *data, void *context, void *surface, 
Evas_Font_Set *font EINA
    evas_gl_common_context_target_surface_set(re->win->gl_context, surface);
    re->win->gl_context->dc = context;
      {
-        // FIXME: put im into context so we can free it
-           static RGBA_Image *im = NULL;
-        
-        if (!im)
-          im = (RGBA_Image 
*)evas_cache_image_empty(evas_common_image_cache_get());
-        im->cache_entry.w = re->win->gl_context->shared->w;
-        im->cache_entry.h = re->win->gl_context->shared->h;
+        if (!re->win->gl_context->font_surface)
+          re->win->gl_context->font_surface = (RGBA_Image 
*)evas_cache_image_empty(evas_common_image_cache_get());
+        re->win->gl_context->font_surface->cache_entry.w = 
re->win->gl_context->shared->w;
+        re->win->gl_context->font_surface->cache_entry.h = 
re->win->gl_context->shared->h;
+
         evas_common_draw_context_font_ext_set(context,
-                                             re->win->gl_context,
-                                             evas_gl_font_texture_new,
-                                             evas_gl_font_texture_free,
-                                             evas_gl_font_texture_draw,
+                                              re->win->gl_context,
+                                              evas_gl_font_texture_new,
+                                              evas_gl_font_texture_free,
+                                              evas_gl_font_texture_draw,
                                               NULL,
                                               NULL,
                                               NULL);
-           evas_common_font_draw_prepare(intl_props);
-           evas_common_font_draw(im, context, x, y, intl_props->glyphs);
-           evas_common_draw_context_font_ext_set(context,
-                                             NULL,
-                                             NULL,
-                                             NULL,
+            evas_common_font_draw_prepare(intl_props);
+            evas_common_font_draw(re->win->gl_context->font_surface, context, 
x, y, intl_props->glyphs);
+            evas_common_draw_context_font_ext_set(context,
+                                              NULL,
+                                              NULL,
+                                              NULL,
                                               NULL,
                                               NULL,
                                               NULL,
diff --git a/src/modules/evas/engines/gl_common/evas_gl_common.h 
b/src/modules/evas/engines/gl_common/evas_gl_common.h
index 3ee8c5b..6dc673f 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_common.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_common.h
@@ -579,6 +579,8 @@ struct _Evas_Engine_GL_Context
 
    GLuint preserve_bit;
    int gles_version;
+
+   RGBA_Image *font_surface;
 };
 
 struct _Evas_GL_Texture_Pool
diff --git a/src/modules/evas/engines/gl_common/evas_gl_context.c 
b/src/modules/evas/engines/gl_common/evas_gl_context.c
index 9a1ef99..f79967a 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_context.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_context.c
@@ -973,6 +973,9 @@ evas_gl_common_context_free(Evas_Engine_GL_Context *gc)
 
    if (gc->def_surface) evas_gl_common_image_free(gc->def_surface);
 
+   if (gc->font_surface)
+     evas_cache_image_drop(&gc->font_surface->cache_entry);
+
    if (glsym_glMapBuffer && glsym_glUnmapBuffer)
      {
         for (i = 0; i < MAX_PIPES; i++)
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c 
b/src/modules/evas/engines/gl_generic/evas_engine.c
index 68dd9b4..ddcab2c 100644
--- a/src/modules/evas/engines/gl_generic/evas_engine.c
+++ b/src/modules/evas/engines/gl_generic/evas_engine.c
@@ -1335,13 +1335,10 @@ eng_font_draw(void *data, void *context, void *surface, 
Evas_Font_Set *font EINA
    evas_gl_common_context_target_surface_set(gl_context, surface);
    gl_context->dc = context;
      {
-        // FIXME: put im into context so we can free it
-        static RGBA_Image *im = NULL;
-
-        if (!im)
-          im = (RGBA_Image 
*)evas_cache_image_empty(evas_common_image_cache_get());
-        im->cache_entry.w = gl_context->shared->w;
-        im->cache_entry.h = gl_context->shared->h;
+        if (!gl_context->font_surface)
+          gl_context->font_surface = (RGBA_Image 
*)evas_cache_image_empty(evas_common_image_cache_get());
+        gl_context->font_surface->cache_entry.w = gl_context->shared->w;
+        gl_context->font_surface->cache_entry.h = gl_context->shared->h;
 
         evas_common_draw_context_font_ext_set(context,
                                               gl_context,
@@ -1352,7 +1349,7 @@ eng_font_draw(void *data, void *context, void *surface, 
Evas_Font_Set *font EINA
                                               evas_gl_image_free,
                                               evas_gl_image_draw);
         evas_common_font_draw_prepare(intl_props);
-        evas_common_font_draw(im, context, x, y, intl_props->glyphs);
+        evas_common_font_draw(gl_context->font_surface, context, x, y, 
intl_props->glyphs);
         evas_common_draw_context_font_ext_set(context,
                                               NULL,
                                               NULL,

-- 


Reply via email to