diff options
-rw-r--r-- | backend/wayland/backend.c | 10 | ||||
-rw-r--r-- | backend/x11/backend.c | 10 | ||||
-rw-r--r-- | include/render/shm_allocator.h | 2 | ||||
-rw-r--r-- | render/shm_allocator.c | 5 |
4 files changed, 12 insertions, 15 deletions
diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c index 42f4d6e2..60ac76cb 100644 --- a/backend/wayland/backend.c +++ b/backend/wayland/backend.c @@ -452,21 +452,19 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display, goto error_drm_fd; } - struct wlr_allocator *alloc = wlr_gbm_allocator_create(drm_fd); - if (alloc == NULL) { + wl->allocator = wlr_gbm_allocator_create(drm_fd); + if (wl->allocator == NULL) { wlr_log(WLR_ERROR, "Failed to create GBM allocator"); close(drm_fd); goto error_drm_fd; } - wl->allocator = alloc; } else { wlr_log(WLR_DEBUG, "No render node found, falling back to shared memory"); - struct wlr_shm_allocator *shm_alloc = wlr_shm_allocator_create(); - if (shm_alloc == NULL) { + wl->allocator = wlr_shm_allocator_create(); + if (wl->allocator == NULL) { wlr_log(WLR_ERROR, "Failed to create shared memory allocator"); goto error_remote_display_src; } - wl->allocator = &shm_alloc->base; } wl->renderer = wlr_renderer_autocreate(&wl->backend); diff --git a/backend/x11/backend.c b/backend/x11/backend.c index 06bbfc6c..743f19ff 100644 --- a/backend/x11/backend.c +++ b/backend/x11/backend.c @@ -622,22 +622,20 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display, goto error_event; } - struct wlr_allocator *alloc = wlr_gbm_allocator_create(drm_fd); - if (alloc == NULL) { + x11->allocator = wlr_gbm_allocator_create(drm_fd); + if (x11->allocator == NULL) { wlr_log(WLR_ERROR, "Failed to create GBM allocator"); close(drm_fd); goto error_event; } - x11->allocator = alloc; pixmap_formats = &x11->dri3_formats; } else if (x11->have_shm) { x11->drm_fd = -1; - struct wlr_shm_allocator *shm_alloc = wlr_shm_allocator_create(); - if (shm_alloc == NULL) { + x11->allocator = wlr_shm_allocator_create(); + if (x11->allocator == NULL) { wlr_log(WLR_ERROR, "Failed to create shared memory allocator"); goto error_event; } - x11->allocator = &shm_alloc->base; pixmap_formats = &x11->shm_formats; } else { wlr_log(WLR_ERROR, diff --git a/include/render/shm_allocator.h b/include/render/shm_allocator.h index e6cba83b..d1f48f7f 100644 --- a/include/render/shm_allocator.h +++ b/include/render/shm_allocator.h @@ -18,6 +18,6 @@ struct wlr_shm_allocator { /** * Creates a new shared memory allocator. */ -struct wlr_shm_allocator *wlr_shm_allocator_create(void); +struct wlr_allocator *wlr_shm_allocator_create(void); #endif diff --git a/render/shm_allocator.c b/render/shm_allocator.c index 8da7bea6..16d0e5c9 100644 --- a/render/shm_allocator.c +++ b/render/shm_allocator.c @@ -98,12 +98,13 @@ static const struct wlr_allocator_interface allocator_impl = { .create_buffer = allocator_create_buffer, }; -struct wlr_shm_allocator *wlr_shm_allocator_create(void) { +struct wlr_allocator *wlr_shm_allocator_create(void) { struct wlr_shm_allocator *allocator = calloc(1, sizeof(*allocator)); if (allocator == NULL) { return NULL; } wlr_allocator_init(&allocator->base, &allocator_impl); - return allocator; + wlr_log(WLR_DEBUG, "Created shm allocator"); + return &allocator->base; } |