render/allocator/drm_dumb: drop finish_buffer()

Simplify things a bit.
This commit is contained in:
Simon Ser 2022-10-01 17:55:49 +02:00 committed by Alexander Orzechowski
parent c659792d7b
commit 58d4cfaca3

View file

@ -28,23 +28,6 @@ static struct wlr_drm_dumb_buffer *drm_dumb_buffer_from_buffer(
return (struct wlr_drm_dumb_buffer *)wlr_buf; return (struct wlr_drm_dumb_buffer *)wlr_buf;
} }
static void finish_buffer(struct wlr_drm_dumb_buffer *buf) {
if (buf->data) {
munmap(buf->data, buf->size);
}
wlr_dmabuf_attributes_finish(&buf->dmabuf);
if (buf->drm_fd >= 0) {
struct drm_mode_destroy_dumb destroy = { .handle = buf->handle };
if (drmIoctl(buf->drm_fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy)) {
wlr_log_errno(WLR_ERROR, "Failed to destroy DRM dumb buffer");
}
}
wl_list_remove(&buf->link);
}
static struct wlr_drm_dumb_buffer *create_buffer( static struct wlr_drm_dumb_buffer *create_buffer(
struct wlr_drm_dumb_allocator *alloc, int width, int height, struct wlr_drm_dumb_allocator *alloc, int width, int height,
const struct wlr_drm_format *format) { const struct wlr_drm_format *format) {
@ -132,8 +115,7 @@ static struct wlr_drm_dumb_buffer *create_buffer(
return buffer; return buffer;
create_destroy: create_destroy:
finish_buffer(buffer); wlr_buffer_drop(&buffer->base);
free(buffer);
return NULL; return NULL;
} }
@ -159,7 +141,21 @@ static bool buffer_get_dmabuf(struct wlr_buffer *wlr_buffer,
static void buffer_destroy(struct wlr_buffer *wlr_buffer) { static void buffer_destroy(struct wlr_buffer *wlr_buffer) {
struct wlr_drm_dumb_buffer *buf = drm_dumb_buffer_from_buffer(wlr_buffer); struct wlr_drm_dumb_buffer *buf = drm_dumb_buffer_from_buffer(wlr_buffer);
finish_buffer(buf);
if (buf->data) {
munmap(buf->data, buf->size);
}
wlr_dmabuf_attributes_finish(&buf->dmabuf);
if (buf->drm_fd >= 0) {
struct drm_mode_destroy_dumb destroy = { .handle = buf->handle };
if (drmIoctl(buf->drm_fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy)) {
wlr_log_errno(WLR_ERROR, "Failed to destroy DRM dumb buffer");
}
}
wl_list_remove(&buf->link);
free(buf); free(buf);
} }