From 8b796edce75b037df1c2fafe7e94f4e4dde417be Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Thu, 7 Aug 2014 18:13:07 +0900 Subject: [PATCH] evas gl - fixz minor leak on exit of rectangles these were static rect cutouts, so they stayed around on exit and thus we "lost" them. this nukes them on context free and each new frame. fixes the "leak" --- src/modules/evas/engines/gl_common/evas_gl_context.c | 12 +++++++++++- src/modules/evas/engines/gl_common/evas_gl_font.c | 8 ++++---- src/modules/evas/engines/gl_common/evas_gl_image.c | 8 ++++---- src/modules/evas/engines/gl_common/evas_gl_polygon.c | 8 ++++---- src/modules/evas/engines/gl_common/evas_gl_private.h | 2 ++ .../evas/engines/gl_common/evas_gl_rectangle.c | 8 ++++---- 6 files changed, 29 insertions(+), 17 deletions(-) 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 a48a6d0493..11e5c6dae0 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_context.c +++ b/src/modules/evas/engines/gl_common/evas_gl_context.c @@ -11,6 +11,7 @@ static int sym_done = 0; int _evas_engine_GL_common_log_dom = -1; +Cutout_Rects *_evas_gl_common_cutout_rects = NULL; typedef void (*glsym_func_void) (); typedef void *(*glsym_func_void_ptr) (); @@ -934,6 +935,11 @@ evas_gl_common_context_free(Evas_Engine_GL_Context *gc) } if (gc == _evas_gl_common_context) _evas_gl_common_context = NULL; free(gc); + if (_evas_gl_common_cutout_rects) + { + evas_common_draw_context_apply_clear_cutouts(_evas_gl_common_cutout_rects); + _evas_gl_common_cutout_rects = NULL; + } } EAPI void @@ -949,6 +955,11 @@ evas_gl_common_context_newframe(Evas_Engine_GL_Context *gc) { int i; + if (_evas_gl_common_cutout_rects) + { + evas_common_draw_context_apply_clear_cutouts(_evas_gl_common_cutout_rects); + _evas_gl_common_cutout_rects = NULL; + } if (dbgflushnum < 0) { dbgflushnum = 0; @@ -3332,7 +3343,6 @@ finish: else return 0; } - Eina_Bool evas_gl_common_module_open(void) { diff --git a/src/modules/evas/engines/gl_common/evas_gl_font.c b/src/modules/evas/engines/gl_common/evas_gl_font.c index 70ee3b2af2..33c1f58561 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_font.c +++ b/src/modules/evas/engines/gl_common/evas_gl_font.c @@ -62,7 +62,6 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c Evas_Engine_GL_Context *gc = context; RGBA_Draw_Context *dc = draw_context; Evas_GL_Texture *tex; - static Cutout_Rects *rects = NULL; Cutout_Rect *rct; int r, g, b, a; double ssx, ssy, ssw, ssh; @@ -130,12 +129,12 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c 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; return; } - rects = evas_common_draw_context_apply_cutouts(dc, rects); - for (i = 0; i < rects->active; ++i) + _evas_gl_common_cutout_rects = evas_common_draw_context_apply_cutouts(dc, _evas_gl_common_cutout_rects); + for (i = 0; i < _evas_gl_common_cutout_rects->active; ++i) { int nx, ny, nw, nh; - rct = rects->rects + i; + rct = _evas_gl_common_cutout_rects->rects + i; nx = x; ny = y; nw = tex->w; nh = tex->h; RECTS_CLIP_TO_RECT(nx, ny, nw, nh, rct->x, rct->y, rct->w, rct->h); if ((nw < 1) || (nh < 1)) continue; @@ -157,6 +156,7 @@ evas_gl_font_texture_draw(void *context, void *surface EINA_UNUSED, void *draw_c nx, ny, nw, nh, r, g, b, a); } + evas_common_draw_context_cutouts_free(_evas_gl_common_cutout_rects); /* restore clip info */ 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; } diff --git a/src/modules/evas/engines/gl_common/evas_gl_image.c b/src/modules/evas/engines/gl_common/evas_gl_image.c index dfe4f1edd6..21b9498f06 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_image.c +++ b/src/modules/evas/engines/gl_common/evas_gl_image.c @@ -1074,7 +1074,6 @@ _evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, void evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int smooth) { - static Cutout_Rects *rects = NULL; RGBA_Draw_Context *dc; int r, g, b, a; Cutout_Rect *rct; @@ -1165,10 +1164,10 @@ 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; return; } - rects = evas_common_draw_context_apply_cutouts(dc, rects); - for (i = 0; i < rects->active; ++i) + _evas_gl_common_cutout_rects = evas_common_draw_context_apply_cutouts(dc, _evas_gl_common_cutout_rects); + for (i = 0; i < _evas_gl_common_cutout_rects->active; ++i) { - rct = rects->rects + i; + rct = _evas_gl_common_cutout_rects->rects + i; _evas_gl_common_image_push(gc, im, dx, dy, dw, dh, @@ -1177,6 +1176,7 @@ evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx, r, g, b, a, smooth, yuv, yuy2, nv12, rgb_a_pair); } + evas_common_draw_context_cutouts_free(_evas_gl_common_cutout_rects); /* restore clip info */ 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; } diff --git a/src/modules/evas/engines/gl_common/evas_gl_polygon.c b/src/modules/evas/engines/gl_common/evas_gl_polygon.c index f143d4cf30..afaaad586e 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_polygon.c +++ b/src/modules/evas/engines/gl_common/evas_gl_polygon.c @@ -128,7 +128,6 @@ polygon_edge_sorter(const void *a, const void *b) void evas_gl_common_poly_draw(Evas_Engine_GL_Context *gc, Evas_GL_Polygon *poly, int dx, int dy) { - static Cutout_Rects *rects = NULL; Cutout_Rect *r; int c, cx, cy, cw, ch, cr, cg, cb, ca, i; int x = 0, y = 0, w = 0, h = 0; @@ -277,10 +276,10 @@ evas_gl_common_poly_draw(Evas_Engine_GL_Context *gc, Evas_GL_Polygon *poly, int /* our clip is 0 size.. abort */ if ((gc->dc->clip.w > 0) && (gc->dc->clip.h > 0)) { - rects = evas_common_draw_context_apply_cutouts(gc->dc, rects); - for (i = 0; i < rects->active; ++i) + _evas_gl_common_cutout_rects = evas_common_draw_context_apply_cutouts(gc->dc, _evas_gl_common_cutout_rects); + for (i = 0; i < _evas_gl_common_cutout_rects->active; ++i) { - r = rects->rects + i; + r = _evas_gl_common_cutout_rects->rects + i; if ((r->w > 0) && (r->h > 0)) { EINA_INLIST_FOREACH(spans, span) @@ -295,6 +294,7 @@ evas_gl_common_poly_draw(Evas_Engine_GL_Context *gc, Evas_GL_Polygon *poly, int } } } + evas_common_draw_context_cutouts_free(_evas_gl_common_cutout_rects); } } while (spans) diff --git a/src/modules/evas/engines/gl_common/evas_gl_private.h b/src/modules/evas/engines/gl_common/evas_gl_private.h index 8f7eb21a23..de44997903 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_private.h +++ b/src/modules/evas/engines/gl_common/evas_gl_private.h @@ -29,4 +29,6 @@ extern int _evas_engine_GL_common_log_dom; #endif #define CRI(...) EINA_LOG_DOM_CRIT(_evas_engine_GL_common_log_dom, __VA_ARGS__) +extern Cutout_Rects *_evas_gl_common_cutout_rects; + #endif diff --git a/src/modules/evas/engines/gl_common/evas_gl_rectangle.c b/src/modules/evas/engines/gl_common/evas_gl_rectangle.c index 8dd0931369..b9ae03ab34 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_rectangle.c +++ b/src/modules/evas/engines/gl_common/evas_gl_rectangle.c @@ -3,7 +3,6 @@ void evas_gl_common_rect_draw(Evas_Engine_GL_Context *gc, int x, int y, int w, int h) { - static Cutout_Rects *rects = NULL; Cutout_Rect *r; int c, cx, cy, cw, ch, cr, cg, cb, ca, i; @@ -37,15 +36,16 @@ evas_gl_common_rect_draw(Evas_Engine_GL_Context *gc, int x, int y, int w, int h) /* our clip is 0 size.. abort */ if ((gc->dc->clip.w > 0) && (gc->dc->clip.h > 0)) { - rects = evas_common_draw_context_apply_cutouts(gc->dc, rects); - for (i = 0; i < rects->active; ++i) + _evas_gl_common_cutout_rects = evas_common_draw_context_apply_cutouts(gc->dc, _evas_gl_common_cutout_rects); + for (i = 0; i < _evas_gl_common_cutout_rects->active; ++i) { - r = rects->rects + i; + r = _evas_gl_common_cutout_rects->rects + i; if ((r->w > 0) && (r->h > 0)) { evas_gl_common_context_rectangle_push(gc, r->x, r->y, r->w, r->h, cr, cg, cb, ca); } } + evas_common_draw_context_cutouts_free(_evas_gl_common_cutout_rects); } } /* restore clip info */