render/allocator/drm_dumb: get format info before allocating

Simplifies error handling a bit.
Simon Ser 2 years ago committed by Alexander Orzechowski
parent d81f68d2b4
commit 3e7ea8715b

@ -55,20 +55,20 @@ static struct wlr_drm_dumb_buffer *create_buffer(
return NULL; return NULL;
} }
struct wlr_drm_dumb_buffer *buffer = calloc(1, sizeof(*buffer));
if (buffer == NULL) {
return NULL;
}
wlr_buffer_init(&buffer->base, &buffer_impl, width, height);
wl_list_insert(&alloc->buffers, &buffer->link);
const struct wlr_pixel_format_info *info = const struct wlr_pixel_format_info *info =
drm_get_pixel_format_info(format->format); drm_get_pixel_format_info(format->format);
if (info == NULL) { if (info == NULL) {
wlr_log(WLR_ERROR, "DRM format 0x%"PRIX32" not supported", wlr_log(WLR_ERROR, "DRM format 0x%"PRIX32" not supported",
format->format); format->format);
goto create_err; return NULL;
}
struct wlr_drm_dumb_buffer *buffer = calloc(1, sizeof(*buffer));
if (buffer == NULL) {
return NULL;
} }
wlr_buffer_init(&buffer->base, &buffer_impl, width, height);
wl_list_insert(&alloc->buffers, &buffer->link);
struct drm_mode_create_dumb create = {0}; struct drm_mode_create_dumb create = {0};
create.width = (uint32_t)width; create.width = (uint32_t)width;

Loading…
Cancel
Save