aboutsummaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-10-01 17:55:49 +0200
committerAlexander Orzechowski <orzechowski.alexander@gmail.com>2022-10-01 19:45:29 +0000
commit58d4cfaca3a0934109fd4a2651b8ae3af758ca2c (patch)
treec787039ed7721ca76010ecb56047469a79bd9ab9 /render
parentc659792d7bc359ff19706624e26e9aab160a4b56 (diff)
render/allocator/drm_dumb: drop finish_buffer()
Simplify things a bit.
Diffstat (limited to 'render')
-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);
}