aboutsummaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorSimon Zeni <simon@bl4ckb0ne.ca>2021-01-13 22:49:07 -0500
committerSimon Ser <contact@emersion.fr>2021-01-16 08:57:42 +0100
commite128e6c08dc0a735b1a8c6cc61097eaf0f61fb83 (patch)
treefaa2b6327b407f91786a823cdc83c3b1d797ed35 /render
parentaffc59454ec9b650cc345ab5ec0c310e8350427f (diff)
render: drop egl parameters from wlr_renderer_autocreate
Diffstat (limited to 'render')
-rw-r--r--render/egl.c5
-rw-r--r--render/wlr_renderer.c24
2 files changed, 26 insertions, 3 deletions
diff --git a/render/egl.c b/render/egl.c
index 1c986e47..9fa1068f 100644
--- a/render/egl.c
+++ b/render/egl.c
@@ -5,6 +5,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <gbm.h>
#include <wlr/render/egl.h>
#include <wlr/util/log.h>
#include <wlr/util/region.h>
@@ -362,6 +363,10 @@ void wlr_egl_destroy(struct wlr_egl *egl) {
return;
}
+ if (egl->gbm_device) {
+ gbm_device_destroy(egl->gbm_device);
+ }
+
wlr_drm_format_set_finish(&egl->dmabuf_render_formats);
wlr_drm_format_set_finish(&egl->dmabuf_texture_formats);
diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c
index 377b795e..3c757430 100644
--- a/render/wlr_renderer.c
+++ b/render/wlr_renderer.c
@@ -1,6 +1,8 @@
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
+#include <gbm.h>
+#include <wlr/render/egl.h>
#include <wlr/render/gles2.h>
#include <wlr/render/interface.h>
#include <wlr/render/wlr_renderer.h>
@@ -8,6 +10,7 @@
#include <wlr/util/log.h>
#include "util/signal.h"
#include "render/wlr_renderer.h"
+#include "backend/backend.h"
void wlr_renderer_init(struct wlr_renderer *renderer,
const struct wlr_renderer_impl *impl) {
@@ -247,14 +250,29 @@ bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
return true;
}
-struct wlr_renderer *wlr_renderer_autocreate(EGLenum platform,
- void *remote_display) {
- struct wlr_egl *egl = wlr_egl_create(platform, remote_display, NULL);
+struct wlr_renderer *wlr_renderer_autocreate(struct wlr_backend *backend) {
+ int fd = backend_get_drm_fd(backend);
+ if (fd < 0) {
+ wlr_log(WLR_ERROR, "Failed to get DRM FD from backend");
+ return NULL;
+ }
+
+ struct gbm_device *gbm_device = gbm_create_device(fd);
+ if (!gbm_device) {
+ wlr_log(WLR_ERROR, "Failed to create GBM device");
+ return NULL;
+ }
+
+ struct wlr_egl *egl = wlr_egl_create(EGL_PLATFORM_GBM_KHR, gbm_device,
+ NULL);
if (egl == NULL) {
wlr_log(WLR_ERROR, "Could not initialize EGL");
+ gbm_device_destroy(gbm_device);
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");