aboutsummaryrefslogtreecommitdiff
path: root/render/allocator/drm_dumb.c
diff options
context:
space:
mode:
Diffstat (limited to 'render/allocator/drm_dumb.c')
-rw-r--r--render/allocator/drm_dumb.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/render/allocator/drm_dumb.c b/render/allocator/drm_dumb.c
index 03d9ff98..fab3e930 100644
--- a/render/allocator/drm_dumb.c
+++ b/render/allocator/drm_dumb.c
@@ -28,23 +28,6 @@ static struct wlr_drm_dumb_buffer *drm_dumb_buffer_from_buffer(
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(
struct wlr_drm_dumb_allocator *alloc, int width, int height,
const struct wlr_drm_format *format) {
@@ -132,8 +115,7 @@ static struct wlr_drm_dumb_buffer *create_buffer(
return buffer;
create_destroy:
- finish_buffer(buffer);
- free(buffer);
+ wlr_buffer_drop(&buffer->base);
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) {
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);
}