summaryrefslogtreecommitdiffstats
path: root/ui/egl-headless.c
diff options
context:
space:
mode:
authorMarc-André Lureau2021-10-09 21:48:46 +0200
committerMarc-André Lureau2021-12-21 07:50:21 +0100
commit5e79d516e8ac818d2a90aae9f787775055434ee9 (patch)
tree572cadfe13cb13f683b0be625929427dbca469e6 /ui/egl-headless.c
parentui: dispatch GL events to all listeners (diff)
downloadqemu-5e79d516e8ac818d2a90aae9f787775055434ee9.tar.gz
qemu-5e79d516e8ac818d2a90aae9f787775055434ee9.tar.xz
qemu-5e79d516e8ac818d2a90aae9f787775055434ee9.zip
ui: split the GL context in a different object
This will allow to have one GL context but a variable number of listeners. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'ui/egl-headless.c')
-rw-r--r--ui/egl-headless.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/ui/egl-headless.c b/ui/egl-headless.c
index 08327c40c6..94082a9da9 100644
--- a/ui/egl-headless.c
+++ b/ui/egl-headless.c
@@ -38,12 +38,12 @@ static void egl_gfx_switch(DisplayChangeListener *dcl,
edpy->ds = new_surface;
}
-static QEMUGLContext egl_create_context(DisplayChangeListener *dcl,
+static QEMUGLContext egl_create_context(DisplayGLCtx *dgc,
QEMUGLParams *params)
{
eglMakeCurrent(qemu_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
qemu_egl_rn_ctx);
- return qemu_egl_create_context(dcl, params);
+ return qemu_egl_create_context(dgc, params);
}
static void egl_scanout_disable(DisplayChangeListener *dcl)
@@ -157,10 +157,6 @@ static const DisplayChangeListenerOps egl_ops = {
.dpy_gfx_update = egl_gfx_update,
.dpy_gfx_switch = egl_gfx_switch,
- .dpy_gl_ctx_create = egl_create_context,
- .dpy_gl_ctx_destroy = qemu_egl_destroy_context,
- .dpy_gl_ctx_make_current = qemu_egl_make_context_current,
-
.dpy_gl_scanout_disable = egl_scanout_disable,
.dpy_gl_scanout_texture = egl_scanout_texture,
.dpy_gl_scanout_dmabuf = egl_scanout_dmabuf,
@@ -170,6 +166,13 @@ static const DisplayChangeListenerOps egl_ops = {
.dpy_gl_update = egl_scanout_flush,
};
+static const DisplayGLCtxOps eglctx_ops = {
+ .compatible_dcl = &egl_ops,
+ .dpy_gl_ctx_create = egl_create_context,
+ .dpy_gl_ctx_destroy = qemu_egl_destroy_context,
+ .dpy_gl_ctx_make_current = qemu_egl_make_context_current,
+};
+
static void early_egl_headless_init(DisplayOptions *opts)
{
display_opengl = 1;
@@ -188,6 +191,8 @@ static void egl_headless_init(DisplayState *ds, DisplayOptions *opts)
}
for (idx = 0;; idx++) {
+ DisplayGLCtx *ctx;
+
con = qemu_console_lookup_by_index(idx);
if (!con || !qemu_console_is_graphic(con)) {
break;
@@ -197,7 +202,9 @@ static void egl_headless_init(DisplayState *ds, DisplayOptions *opts)
edpy->dcl.con = con;
edpy->dcl.ops = &egl_ops;
edpy->gls = qemu_gl_init_shader();
- qemu_console_set_display_gl_ctx(con, &edpy->dcl);
+ ctx = g_new0(DisplayGLCtx, 1);
+ ctx->ops = &eglctx_ops;
+ qemu_console_set_display_gl_ctx(con, ctx);
register_displaychangelistener(&edpy->dcl);
}
}