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:
parent
2e401c2e91
commit
95550feb30
|
@ -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,12 +559,10 @@ 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
|
||||||
|
{
|
||||||
|
if (ctx->async)
|
||||||
|
{
|
||||||
|
Image_Entry *ie = buffer->backing;
|
||||||
|
if (ie) ie->references++;
|
||||||
|
}
|
||||||
return buffer->backing;
|
return buffer->backing;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Eina_Bool
|
Eina_Bool
|
||||||
|
@ -727,6 +732,13 @@ 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);
|
||||||
|
if (ctx->async)
|
||||||
|
{
|
||||||
|
if (fb->allocated)
|
||||||
|
evas_unref_queue_image_put(ctx->evas, ie);
|
||||||
|
free(fb);
|
||||||
|
}
|
||||||
|
else
|
||||||
_buffer_free(fb);
|
_buffer_free(fb);
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -734,7 +746,11 @@ evas_filter_buffer_backing_release(Evas_Filter_Context *ctx, void *stolen_buffer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ctx->async)
|
||||||
|
evas_unref_queue_image_put(ctx->evas, ie);
|
||||||
|
else
|
||||||
_backing_free(ctx, ie);
|
_backing_free(ctx, ie);
|
||||||
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue