mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-25 22:25:58 +01:00
render: simplify renderer_autocreate_with_drm_fd()
Use early returns to remove the !renderer checks.
This commit is contained in:
parent
8456ac6fa9
commit
1bd0ba3949
1 changed files with 15 additions and 13 deletions
|
@ -263,12 +263,14 @@ struct wlr_renderer *renderer_autocreate_with_drm_fd(int drm_fd) {
|
||||||
struct wlr_renderer *renderer = NULL;
|
struct wlr_renderer *renderer = NULL;
|
||||||
|
|
||||||
#if WLR_HAS_GLES2_RENDERER
|
#if WLR_HAS_GLES2_RENDERER
|
||||||
if (!renderer && (is_auto || strcmp(renderer_name, "gles2") == 0)) {
|
if (is_auto || strcmp(renderer_name, "gles2") == 0) {
|
||||||
if (drm_fd < 0) {
|
if (drm_fd < 0) {
|
||||||
log_creation_failure(is_auto, "Cannot create GLES2 renderer: no DRM FD available");
|
log_creation_failure(is_auto, "Cannot create GLES2 renderer: no DRM FD available");
|
||||||
} else {
|
} else {
|
||||||
renderer = wlr_gles2_renderer_create_with_drm_fd(drm_fd);
|
renderer = wlr_gles2_renderer_create_with_drm_fd(drm_fd);
|
||||||
if (!renderer) {
|
if (renderer) {
|
||||||
|
return renderer;
|
||||||
|
} else {
|
||||||
log_creation_failure(is_auto, "Failed to create a GLES2 renderer");
|
log_creation_failure(is_auto, "Failed to create a GLES2 renderer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,12 +278,14 @@ struct wlr_renderer *renderer_autocreate_with_drm_fd(int drm_fd) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if WLR_HAS_VULKAN_RENDERER
|
#if WLR_HAS_VULKAN_RENDERER
|
||||||
if (!renderer && strcmp(renderer_name, "vulkan") == 0) {
|
if (strcmp(renderer_name, "vulkan") == 0) {
|
||||||
if (drm_fd < 0) {
|
if (drm_fd < 0) {
|
||||||
log_creation_failure(is_auto, "Cannot create Vulkan renderer: no DRM FD available");
|
log_creation_failure(is_auto, "Cannot create Vulkan renderer: no DRM FD available");
|
||||||
} else {
|
} else {
|
||||||
renderer = wlr_vk_renderer_create_with_drm_fd(drm_fd);
|
renderer = wlr_vk_renderer_create_with_drm_fd(drm_fd);
|
||||||
if (!renderer) {
|
if (renderer) {
|
||||||
|
return renderer;
|
||||||
|
} else {
|
||||||
log_creation_failure(is_auto, "Failed to create a Vulkan renderer");
|
log_creation_failure(is_auto, "Failed to create a Vulkan renderer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -289,25 +293,23 @@ struct wlr_renderer *renderer_autocreate_with_drm_fd(int drm_fd) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool has_render_node = false;
|
bool has_render_node = false;
|
||||||
if (!renderer && is_auto && drm_fd >= 0) {
|
if (is_auto && drm_fd >= 0) {
|
||||||
char *render_node = drmGetRenderDeviceNameFromFd(drm_fd);
|
char *render_node = drmGetRenderDeviceNameFromFd(drm_fd);
|
||||||
has_render_node = render_node != NULL;
|
has_render_node = render_node != NULL;
|
||||||
free(render_node);
|
free(render_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!renderer && ((is_auto && !has_render_node) ||
|
if ((is_auto && !has_render_node) || strcmp(renderer_name, "pixman") == 0) {
|
||||||
strcmp(renderer_name, "pixman") == 0)) {
|
|
||||||
renderer = wlr_pixman_renderer_create();
|
renderer = wlr_pixman_renderer_create();
|
||||||
if (!renderer) {
|
if (renderer) {
|
||||||
|
return renderer;
|
||||||
|
} else {
|
||||||
log_creation_failure(is_auto, "Failed to create a pixman renderer");
|
log_creation_failure(is_auto, "Failed to create a pixman renderer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!renderer) {
|
|
||||||
wlr_log(WLR_ERROR, "Could not initialize renderer");
|
wlr_log(WLR_ERROR, "Could not initialize renderer");
|
||||||
}
|
return NULL;
|
||||||
|
|
||||||
return renderer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int open_drm_render_node(void) {
|
static int open_drm_render_node(void) {
|
||||||
|
|
Loading…
Reference in a new issue