[PATCH] gl-renderer: Always release previous EGL images on attach

John Kåre Alsaker john.kare.alsaker at gmail.com
Wed Jun 5 04:54:24 PDT 2013


May I suggest
https://github.com/Zoxc/weston/commit/062f5ca5dc5809c027f693f2d642bc24f568e348instead?


On Wed, Jun 5, 2013 at 11:21 AM, Ander Conselvan de Oliveira <
conselvan2 at gmail.com> wrote:

> 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
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20130605/9bf433c7/attachment.html>


More information about the wayland-devel mailing list