aboutsummaryrefslogtreecommitdiff
path: root/render/gles2
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-06-10 14:47:12 +0200
committerSimon Ser <contact@emersion.fr>2020-11-15 22:54:07 +0100
commiteb8360bda39bf48e2126e354fe6125c2e487c6b5 (patch)
treecc2ffeef09223aa01e21968e3e20fa4784c5052b /render/gles2
parentc8d95acc37a1f3aa74538e4b9c688c2ed98227c6 (diff)
render: introduce wlr_renderer_get_drm_fd
Diffstat (limited to 'render/gles2')
-rw-r--r--render/gles2/renderer.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c
index faef832f..b679eb7e 100644
--- a/render/gles2/renderer.c
+++ b/render/gles2/renderer.c
@@ -4,6 +4,7 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
#include <wayland-server-protocol.h>
#include <wayland-util.h>
#include <wlr/render/egl.h>
@@ -644,6 +645,17 @@ static bool gles2_init_wl_display(struct wlr_renderer *wlr_renderer,
return true;
}
+static int gles2_get_drm_fd(struct wlr_renderer *wlr_renderer) {
+ struct wlr_gles2_renderer *renderer =
+ gles2_get_renderer(wlr_renderer);
+
+ if (renderer->drm_fd < 0) {
+ renderer->drm_fd = wlr_egl_dup_drm_fd(renderer->egl);
+ }
+
+ return renderer->drm_fd;
+}
+
struct wlr_egl *wlr_gles2_renderer_get_egl(struct wlr_renderer *wlr_renderer) {
struct wlr_gles2_renderer *renderer =
gles2_get_renderer(wlr_renderer);
@@ -675,6 +687,10 @@ static void gles2_destroy(struct wlr_renderer *wlr_renderer) {
wlr_egl_unset_current(renderer->egl);
+ if (renderer->drm_fd >= 0) {
+ close(renderer->drm_fd);
+ }
+
free(renderer);
}
@@ -700,6 +716,7 @@ static const struct wlr_renderer_impl renderer_impl = {
.texture_from_dmabuf = gles2_texture_from_dmabuf,
.init_wl_display = gles2_init_wl_display,
.blit_dmabuf = gles2_blit_dmabuf,
+ .get_drm_fd = gles2_get_drm_fd,
};
void push_gles2_debug_(struct wlr_gles2_renderer *renderer,
@@ -856,6 +873,7 @@ struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_egl *egl) {
renderer->egl = egl;
renderer->exts_str = exts_str;
+ renderer->drm_fd = -1;
wlr_log(WLR_INFO, "Using %s", glGetString(GL_VERSION));
wlr_log(WLR_INFO, "GL vendor: %s", glGetString(GL_VENDOR));