texture-2d/wayland: destroy transient EGLImages

When creating a texture from a wayland buffer we create an intermediate
EGLImage that we then create a GL texture from, but we were never
destroying that EGLImage. This patch ensures we destroy the image right
after we've created the texture so we don't leak a reference to the
underlying buffer.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
Robert Bragg 2012-01-11 16:05:53 +00:00
parent 99c651d2b4
commit 161fad2860

View File

@ -540,6 +540,7 @@ cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx,
else else
{ {
EGLImageKHR image; EGLImageKHR image;
CoglTexture2D *tex;
_COGL_RETURN_VAL_IF_FAIL (_cogl_context_get_winsys (ctx)->constraints & _COGL_RETURN_VAL_IF_FAIL (_cogl_context_get_winsys (ctx)->constraints &
COGL_RENDERER_CONSTRAINT_USES_EGL, COGL_RENDERER_CONSTRAINT_USES_EGL,
@ -548,13 +549,14 @@ cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx,
EGL_WAYLAND_BUFFER_WL, EGL_WAYLAND_BUFFER_WL,
buffer, buffer,
NULL); NULL);
#warning "XXX: without a way to query the format of a wayland buffer we have to guess!" tex = _cogl_egl_texture_2d_new_from_image (ctx,
return _cogl_egl_texture_2d_new_from_image (ctx, buffer->width,
buffer->width, buffer->height,
buffer->height, COGL_PIXEL_FORMAT_ARGB_8888_PRE,
COGL_PIXEL_FORMAT_ARGB_8888_PRE, image,
image, error);
error); _cogl_egl_destroy_image (ctx, image);
return tex;
} }
} }
#endif /* COGL_HAS_WAYLAND_EGL_SERVER_SUPPORT */ #endif /* COGL_HAS_WAYLAND_EGL_SERVER_SUPPORT */