Commit 63fc73d1 authored by Marius Vlad's avatar Marius Vlad
Browse files

gl-renderer: Assume num images the same as the no of planes



Potential failures when creating the EGL image could cause an incorrect
number of num images (num_planes > num_images). With this change
egl_image_unref() requires an additional check to avoid any potential NULL
derefs when cleaning up. We do it straight in egl_image_unref() instead
of adding guards all over the necessary parts.
Signed-off-by: Marius Vlad's avatarMarius Vlad <marius.vlad@collabora.com>
parent 2a6ea687
Pipeline #365050 passed with stages
in 2 minutes and 34 seconds
......@@ -388,8 +388,18 @@ egl_image_ref(struct egl_image *image)
static int
egl_image_unref(struct egl_image *image)
{
struct gl_renderer *gr = image->renderer;
struct gl_renderer *gr;
/* in multi-planar cases, egl_image_create() might fail on an
* intermediary step resulting in egl_image being NULL. In order to go
* over all successful ones, and avoid leaking one of them (the last
* one), we'll have to guard against it -- until we'll have a correct
* way of disposing of any previous created images.
*/
if (!image)
return 0;
gr = image->renderer;
assert(image->refcount > 0);
image->refcount--;
......@@ -2107,7 +2117,6 @@ gl_renderer_attach_egl(struct weston_surface *es, struct weston_buffer *buffer,
egl_image_unref(gs->images[i]);
gs->images[i] = NULL;
}
gs->num_images = 0;
es->is_opaque = false;
switch (format) {
case EGL_TEXTURE_RGB:
......@@ -2139,6 +2148,7 @@ gl_renderer_attach_egl(struct weston_surface *es, struct weston_buffer *buffer,
break;
}
gs->num_images = num_planes;
target = gl_shader_texture_variant_get_target(gs->shader_variant);
ensure_textures(gs, target, num_planes);
for (i = 0; i < num_planes; i++) {
......@@ -2153,7 +2163,6 @@ gl_renderer_attach_egl(struct weston_surface *es, struct weston_buffer *buffer,
weston_log("failed to create img for plane %d\n", i);
continue;
}
gs->num_images++;
glActiveTexture(GL_TEXTURE0 + i);
glBindTexture(target, gs->textures[i]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment