diff options
author | Simon Ser <contact@emersion.fr> | 2021-06-24 13:11:21 +0200 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2021-06-30 14:02:26 -0400 |
commit | 1db976cecb6968b2d989840c6f16aa00bb83d026 (patch) | |
tree | 79f47a4e2d0e11a648dc4f9b10b25a18762e3796 /render/egl.c | |
parent | 1c4b5bcab3aa1ca7b2c40fd64f77f90b8dde11d7 (diff) |
render/egl: replace wlr_egl_create with wlr_egl_create_with_drm_fd
We never create an EGL context with the platform set to something
other than EGL_PLATFORM_GBM_KHR. Let's simplify wlr_egl_create by
taking a DRM FD instead of a (platform, remote_display) tuple.
This hides the internal details of creating an EGL context for a
specific device. This will allow us to transparently use the device
platform [1] when the time comes.
[1]: https://github.com/swaywm/wlroots/pull/2671
Diffstat (limited to 'render/egl.c')
-rw-r--r-- | render/egl.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/render/egl.c b/render/egl.c index 7f88880c..b01f7d54 100644 --- a/render/egl.c +++ b/render/egl.c @@ -156,7 +156,7 @@ out: free(formats); } -struct wlr_egl *wlr_egl_create(EGLenum platform, void *remote_display) { +struct wlr_egl *wlr_egl_create_with_drm_fd(int drm_fd) { struct wlr_egl *egl = calloc(1, sizeof(struct wlr_egl)); if (egl == NULL) { wlr_log_errno(WLR_ERROR, "Allocation failed"); @@ -173,11 +173,9 @@ struct wlr_egl *wlr_egl_create(EGLenum platform, void *remote_display) { return NULL; } - if (platform == EGL_PLATFORM_GBM_KHR) { - if (!check_egl_ext(client_exts_str, "EGL_KHR_platform_gbm")) { - wlr_log(WLR_ERROR, "EGL_KHR_platform_gbm not supported"); - return NULL; - } + if (!check_egl_ext(client_exts_str, "EGL_KHR_platform_gbm")) { + wlr_log(WLR_ERROR, "EGL_KHR_platform_gbm not supported"); + return NULL; } if (!check_egl_ext(client_exts_str, "EGL_EXT_platform_base")) { @@ -206,8 +204,14 @@ struct wlr_egl *wlr_egl_create(EGLenum platform, void *remote_display) { goto error; } - egl->display = egl->procs.eglGetPlatformDisplayEXT(platform, - remote_display, NULL); + egl->gbm_device = gbm_create_device(drm_fd); + if (!egl->gbm_device) { + wlr_log(WLR_ERROR, "Failed to create GBM device"); + goto error; + } + + egl->display = egl->procs.eglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_KHR, + egl->gbm_device, NULL); if (egl->display == EGL_NO_DISPLAY) { wlr_log(WLR_ERROR, "Failed to create EGL display"); goto error; |