Evas filters: Fix memory leaks with buffers

In async rendering case, basically all buffers were leaked or
freed from the wrong thread. Fix that :)
This commit is contained in:
Jean-Philippe Andre 2014-01-24 10:54:51 +09:00
parent 2e401c2e91
commit 95550feb30
1 changed files with 29 additions and 13 deletions

View File

@ -532,11 +532,9 @@ evas_filter_context_buffers_allocate_all(Evas_Filter_Context *ctx,
ie = fb->backing; ie = fb->backing;
if (ie) if (ie)
{ {
if (ctx->async) // Not checking for async. It's also safe for sync rendering.
{ ie->references++;
ie->references++; evas_unref_queue_image_put(ctx->evas, ie);
evas_unref_queue_image_put(ctx->evas, ie);
}
continue; continue;
} }
@ -561,11 +559,9 @@ evas_filter_context_buffers_allocate_all(Evas_Filter_Context *ctx,
} }
fb->backing = ie; fb->backing = ie;
if (ctx->async) fb->allocated = (ie != NULL);
{ if (ctx->async && fb->allocated)
ie->references++; evas_unref_queue_image_put(ctx->evas, ie);
evas_unref_queue_image_put(ctx->evas, ie);
}
} }
return EINA_TRUE; return EINA_TRUE;
@ -609,6 +605,8 @@ _filter_buffer_data_set(Evas_Filter_Context *ctx, int bufid, void *data,
fb->backing = _rgba_image_alloc(fb, data); fb->backing = _rgba_image_alloc(fb, data);
fb->allocated = (!data && (fb->backing != NULL)); fb->allocated = (!data && (fb->backing != NULL));
if (ctx->async && fb->allocated)
evas_unref_queue_image_put(ctx->evas, fb->backing);
return fb->allocated; return fb->allocated;
} }
@ -706,7 +704,14 @@ evas_filter_buffer_backing_steal(Evas_Filter_Context *ctx, int bufid)
if (buffer->glimage) if (buffer->glimage)
return buffer->glimage; return buffer->glimage;
else else
return buffer->backing; {
if (ctx->async)
{
Image_Entry *ie = buffer->backing;
if (ie) ie->references++;
}
return buffer->backing;
}
} }
Eina_Bool Eina_Bool
@ -727,14 +732,25 @@ evas_filter_buffer_backing_release(Evas_Filter_Context *ctx, void *stolen_buffer
if (fb->delete_me) if (fb->delete_me)
{ {
ctx->buffers = eina_list_remove_list(ctx->buffers, li); ctx->buffers = eina_list_remove_list(ctx->buffers, li);
_buffer_free(fb); if (ctx->async)
{
if (fb->allocated)
evas_unref_queue_image_put(ctx->evas, ie);
free(fb);
}
else
_buffer_free(fb);
return EINA_TRUE; return EINA_TRUE;
} }
return EINA_TRUE; return EINA_TRUE;
} }
} }
_backing_free(ctx, ie); if (ctx->async)
evas_unref_queue_image_put(ctx->evas, ie);
else
_backing_free(ctx, ie);
return EINA_TRUE; return EINA_TRUE;
} }