software_generic: Call native surface free callbacks

In the near future this will prevent leaking native surface data for
wayland dmabuf buffers.
This commit is contained in:
Derek Foreman 2016-05-16 16:47:05 -05:00
parent c59eb1ce62
commit 0a6cdcc58c
1 changed files with 25 additions and 11 deletions

View File

@ -1110,35 +1110,49 @@ static void *
eng_image_native_set(void *data EINA_UNUSED, void *image, void *native) eng_image_native_set(void *data EINA_UNUSED, void *image, void *native)
{ {
Evas_Native_Surface *ns = native; Evas_Native_Surface *ns = native;
Image_Entry *im = image, *im2 = NULL; RGBA_Image *im = image;
Image_Entry *ie = image, *ie2;
if (!im || !ns) return im; if (!im) return NULL;
if (!ns)
{
if (im->native.data && im->native.func.free)
im->native.func.free(im);
return NULL;
}
if ((ns->type == EVAS_NATIVE_SURFACE_EVASGL) && if ((ns->type == EVAS_NATIVE_SURFACE_EVASGL) &&
(ns->version == EVAS_NATIVE_SURFACE_VERSION)) (ns->version == EVAS_NATIVE_SURFACE_VERSION))
{ {
im2 = evas_cache_image_data(evas_common_image_cache_get(), ie2 = evas_cache_image_data(evas_common_image_cache_get(),
im->w, im->h, ie->w, ie->h,
ns->data.evasgl.surface, 1, ns->data.evasgl.surface, 1,
EVAS_COLORSPACE_ARGB8888); EVAS_COLORSPACE_ARGB8888);
} }
else else
im2 = evas_cache_image_data(evas_common_image_cache_get(), ie2 = evas_cache_image_data(evas_common_image_cache_get(),
im->w, im->h, ie->w, ie->h,
NULL, 1, NULL, 1,
EVAS_COLORSPACE_ARGB8888); EVAS_COLORSPACE_ARGB8888);
if (im->references > 1) if (ie->references > 1)
ERR("Setting native with more than one references for im=%p", im); ERR("Setting native with more than one references for im=%p", im);
if (im->native.data)
{
if (im->native.func.free)
im->native.func.free(im);
}
#ifdef EVAS_CSERVE2 #ifdef EVAS_CSERVE2
if (evas_cserve2_use_get() && evas_cache2_image_cached(im)) if (evas_cserve2_use_get() && evas_cache2_image_cached(ie))
evas_cache2_image_close(im); evas_cache2_image_close(ie);
else else
#endif #endif
evas_cache_image_drop(im); evas_cache_image_drop(ie);
return im2;
return ie2;
} }
static void * static void *