aboutsummaryrefslogtreecommitdiff
path: root/render/wlr_renderer.c
diff options
context:
space:
mode:
authorSimon Zeni <simon@bl4ckb0ne.ca>2021-04-20 14:48:52 -0400
committerSimon Ser <contact@emersion.fr>2021-04-20 21:14:27 +0200
commitcdacf4f632577a2d9c0f10f7b0aa9f8336e8a1d1 (patch)
tree6adf1f8bdf441fd7a52badc9eeb793ffd91602e4 /render/wlr_renderer.c
parent10c5199d85f54079a759f5de37574ccf8ae30825 (diff)
render: introduce WLR_RENDERER in wlr_renderer_autocreate_with_drm_fd
This env var forces the creation of a specific renderer. If no renderer is specified, the function will try to create all of the renderers one by one until one is created successfuly.
Diffstat (limited to 'render/wlr_renderer.c')
-rw-r--r--render/wlr_renderer.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c
index 77be3018..d9397c40 100644
--- a/render/wlr_renderer.c
+++ b/render/wlr_renderer.c
@@ -1,7 +1,6 @@
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
-#include <gbm.h>
#include <wlr/render/interface.h>
#include <wlr/render/pixman.h>
#include <wlr/render/wlr_renderer.h>
@@ -228,33 +227,35 @@ bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
}
struct wlr_renderer *wlr_renderer_autocreate_with_drm_fd(int drm_fd) {
+ const char *name = getenv("WLR_RENDERER");
+ if (name) {
#if WLR_HAS_GLES2_RENDERER
- struct gbm_device *gbm_device = gbm_create_device(drm_fd);
- if (!gbm_device) {
- wlr_log(WLR_ERROR, "Failed to create GBM device");
- return NULL;
- }
+ if (strcmp(name, "gles2") == 0) {
+ return wlr_gles2_renderer_create_with_drm_fd(drm_fd);
+ }
+#endif
+ if (strcmp(name, "pixman") == 0) {
+ return wlr_pixman_renderer_create();
+ }
- struct wlr_egl *egl = wlr_egl_create(EGL_PLATFORM_GBM_KHR, gbm_device);
- if (egl == NULL) {
- wlr_log(WLR_ERROR, "Could not initialize EGL");
- gbm_device_destroy(gbm_device);
+ wlr_log(WLR_ERROR, "Invalid WLR_RENDERER value: '%s'", name);
return NULL;
}
- egl->gbm_device = gbm_device;
-
- struct wlr_renderer *renderer = wlr_gles2_renderer_create(egl);
- if (!renderer) {
- wlr_log(WLR_ERROR, "Failed to create GLES2 renderer");
- wlr_egl_destroy(egl);
- return NULL;
+ struct wlr_renderer *renderer = NULL;
+#if WLR_HAS_GLES2_RENDERER
+ if ((renderer = wlr_gles2_renderer_create_with_drm_fd(drm_fd)) != NULL) {
+ return renderer;
}
-
- return renderer;
+ wlr_log(WLR_DEBUG, "Failed to create gles2 renderer");
#endif
- wlr_log(WLR_ERROR, "Failed to initialize any renderer");
+ if ((renderer = wlr_pixman_renderer_create()) != NULL) {
+ return renderer;
+ }
+ wlr_log(WLR_DEBUG, "Failed to create pixman renderer");
+
+ wlr_log(WLR_ERROR, "Could not initialize renderer");
return NULL;
}