[PATCH] gl-renderer: Always release previous EGL images on attach
Ander Conselvan de Oliveira
conselvan2 at gmail.com
Wed Jun 5 02:21:05 PDT 2013
From: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira at intel.com>
When attaching a new buffer, the EGL images created for the previous one
would be released if this new buffer was an EGL or NULL buffer, but not
if is was an SHM buffer. This wouldn't cause the resources to be leaked
becaused they are free()'d when the surface is destroyed, but they
would linger around for longer than necessary.
Note that this change the behaviour when attaching an unknow buffer
type. Before the EGL images would still be around, but now that would
cause them to be destroyed.
---
src/gl-renderer.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index d783a0b..13c0fa9 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -1192,12 +1192,13 @@ gl_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer)
weston_buffer_reference(&gs->buffer_ref, buffer);
+ for (i = 0; i < gs->num_images; i++) {
+ gr->destroy_image(gr->egl_display, gs->images[i]);
+ gs->images[i] = NULL;
+ }
+ gs->num_images = 0;
+
if (!buffer) {
- for (i = 0; i < gs->num_images; i++) {
- gr->destroy_image(gr->egl_display, gs->images[i]);
- gs->images[i] = NULL;
- }
- gs->num_images = 0;
glDeleteTextures(gs->num_textures, gs->textures);
gs->num_textures = 0;
return;
@@ -1219,9 +1220,6 @@ gl_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer)
gs->shader = &gr->texture_shader_rgba;
} else if (gr->query_buffer(gr->egl_display, buffer,
EGL_TEXTURE_FORMAT, &format)) {
- for (i = 0; i < gs->num_images; i++)
- gr->destroy_image(gr->egl_display, gs->images[i]);
- gs->num_images = 0;
gs->target = GL_TEXTURE_2D;
switch (format) {
case EGL_TEXTURE_RGB:
--
1.7.9.5
More information about the wayland-devel
mailing list