rpi-backend: ensure pixels is destroyed in resource_update

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
This commit is contained in:
U. Artie Eoff 2014-01-17 13:56:41 -08:00 committed by Kristian Høgsberg
parent a62e0e0e02
commit 5e854bcca2

View File

@ -363,6 +363,7 @@ rpi_resource_update(struct rpi_resource *resource, struct weston_buffer *buffer,
int height; int height;
int stride; int stride;
int ret; int ret;
int applied_opaque_region = 0;
#ifdef HAVE_RESOURCE_WRITE_DATA_RECT #ifdef HAVE_RESOURCE_WRITE_DATA_RECT
int n; int n;
#endif #endif
@ -384,13 +385,18 @@ rpi_resource_update(struct rpi_resource *resource, struct weston_buffer *buffer,
if (!pixels) if (!pixels)
return -1; return -1;
applied_opaque_region = 1;
} }
#endif #endif
ret = rpi_resource_realloc(resource, ifmt & ~PREMULT_ALPHA_FLAG, ret = rpi_resource_realloc(resource, ifmt & ~PREMULT_ALPHA_FLAG,
width, height, stride, height); width, height, stride, height);
if (ret < 0) if (ret < 0) {
if (applied_opaque_region)
free(pixels);
return -1; return -1;
}
pixman_region32_init_rect(&write_region, 0, 0, width, height); pixman_region32_init_rect(&write_region, 0, 0, width, height);
if (ret == 0) if (ret == 0)
@ -437,12 +443,8 @@ rpi_resource_update(struct rpi_resource *resource, struct weston_buffer *buffer,
pixman_region32_fini(&write_region); pixman_region32_fini(&write_region);
#ifndef HAVE_ELEMENT_SET_OPAQUE_RECT if (applied_opaque_region)
if (pixman_region32_not_empty(opaque_region) &&
wl_shm_buffer_get_format(buffer->shm_buffer) == WL_SHM_FORMAT_ARGB8888 &&
resource->enable_opaque_regions)
free(pixels); free(pixels);
#endif
return ret ? -1 : 0; return ret ? -1 : 0;
} }