aboutsummaryrefslogtreecommitdiff
path: root/backend/drm
diff options
context:
space:
mode:
authorIlia Bozhinov <ammen99@gmail.com>2018-05-25 13:14:35 +0300
committerIlia Bozhinov <ammen99@gmail.com>2018-05-25 14:56:52 +0300
commit24cf70ae9691d605e4a1f7e9d8dc59ec72401bd0 (patch)
tree93d550e437722bdeabca5605ada5c0b4d41128cf /backend/drm
parenta0eb37e2ea4ad96b4f6e98fddbc5c31d0bd0f293 (diff)
backends: implement custom EGL and renderer initialization
Compositors now have more control over how the backend creates its renderer. Currently all backends create an EGL/GLES2 renderer, so the necessary attributes for creating the context are passed to a user-provided callback function. It is responsible for initializing provided wlr_egl and to return a renderer. On fail, return 0. Fixes #987
Diffstat (limited to 'backend/drm')
-rw-r--r--backend/drm/backend.c5
-rw-r--r--backend/drm/renderer.c17
2 files changed, 11 insertions, 11 deletions
diff --git a/backend/drm/backend.c b/backend/drm/backend.c
index c14b99e3..744a32d2 100644
--- a/backend/drm/backend.c
+++ b/backend/drm/backend.c
@@ -114,7 +114,8 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
}
struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
- struct wlr_session *session, int gpu_fd, struct wlr_backend *parent) {
+ struct wlr_session *session, int gpu_fd, struct wlr_backend *parent,
+ wlr_renderer_create_func_t create_renderer_func) {
assert(display && session && gpu_fd >= 0);
assert(!parent || wlr_backend_is_drm(parent));
@@ -161,7 +162,7 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
goto error_event;
}
- if (!init_drm_renderer(drm, &drm->renderer)) {
+ if (!init_drm_renderer(drm, &drm->renderer, create_renderer_func)) {
wlr_log(L_ERROR, "Failed to initialize renderer");
goto error_event;
}
diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c
index 7e2b5174..d5bcef2b 100644
--- a/backend/drm/renderer.c
+++ b/backend/drm/renderer.c
@@ -19,29 +19,28 @@
#endif
bool init_drm_renderer(struct wlr_drm_backend *drm,
- struct wlr_drm_renderer *renderer) {
+ struct wlr_drm_renderer *renderer, wlr_renderer_create_func_t create_renderer_func) {
renderer->gbm = gbm_create_device(drm->fd);
if (!renderer->gbm) {
wlr_log(L_ERROR, "Failed to create GBM device");
return false;
}
- if (!wlr_egl_init(&renderer->egl, EGL_PLATFORM_GBM_MESA, renderer->gbm,
- NULL, GBM_FORMAT_ARGB8888)) {
- goto error_gbm;
+ if (!create_renderer_func) {
+ create_renderer_func = wlr_renderer_autocreate;
}
- renderer->wlr_rend = wlr_gles2_renderer_create(&renderer->egl);
+ renderer->wlr_rend = create_renderer_func(&renderer->egl,
+ EGL_PLATFORM_GBM_MESA, renderer->gbm, NULL, GBM_FORMAT_ARGB8888);
+
if (!renderer->wlr_rend) {
- wlr_log(L_ERROR, "Failed to create WLR renderer");
- goto error_egl;
+ wlr_log(L_ERROR, "Failed to create EGL/WLR renderer");
+ goto error_gbm;
}
renderer->fd = drm->fd;
return true;
-error_egl:
- wlr_egl_finish(&renderer->egl);
error_gbm:
gbm_device_destroy(renderer->gbm);
return false;