if (dri2_surf->color_buffers[i].wl_buffer == buffer)
break;
- if (i == ARRAY_SIZE(dri2_surf->color_buffers)) {
+ assert (i < ARRAY_SIZE(dri2_surf->color_buffers));
+
+ if (dri2_surf->color_buffers[i].wl_release) {
wl_buffer_destroy(buffer);
- return;
+ dri2_surf->color_buffers[i].wl_release = false;
+ dri2_surf->color_buffers[i].wl_buffer = NULL;
}
dri2_surf->color_buffers[i].locked = false;
dri2_egl_display(dri2_surf->base.Resource.Display);
for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
- if (dri2_surf->color_buffers[i].wl_buffer &&
- !dri2_surf->color_buffers[i].locked)
- wl_buffer_destroy(dri2_surf->color_buffers[i].wl_buffer);
+ if (dri2_surf->color_buffers[i].wl_buffer) {
+ if (dri2_surf->color_buffers[i].locked) {
+ dri2_surf->color_buffers[i].wl_release = true;
+ } else {
+ wl_buffer_destroy(dri2_surf->color_buffers[i].wl_buffer);
+ dri2_surf->color_buffers[i].wl_buffer = NULL;
+ }
+ }
if (dri2_surf->color_buffers[i].dri_image)
dri2_dpy->image->destroyImage(dri2_surf->color_buffers[i].dri_image);
if (dri2_surf->color_buffers[i].linear_copy)
munmap(dri2_surf->color_buffers[i].data,
dri2_surf->color_buffers[i].data_size);
- dri2_surf->color_buffers[i].wl_buffer = NULL;
dri2_surf->color_buffers[i].dri_image = NULL;
dri2_surf->color_buffers[i].linear_copy = NULL;
dri2_surf->color_buffers[i].data = NULL;
- dri2_surf->color_buffers[i].locked = false;
}
if (dri2_dpy->dri2)
dri2_surf->current->wl_buffer =
create_wl_buffer(dri2_dpy, dri2_surf, image);
+ dri2_surf->current->wl_release = false;
+
wl_buffer_add_listener(dri2_surf->current->wl_buffer,
&wl_buffer_listener, dri2_surf);
}