diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2021-10-09 23:48:46 +0400 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2021-12-21 10:50:21 +0400 |
commit | 5e79d516e8ac818d2a90aae9f787775055434ee9 (patch) | |
tree | 572cadfe13cb13f683b0be625929427dbca469e6 /ui/console.c | |
parent | 7cc712e9862ffdbe4161dbdf3bbf41bcbe547472 (diff) |
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/console.c')
-rw-r--r-- | ui/console.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/ui/console.c b/ui/console.c index 13c0d001c0..78583df920 100644 --- a/ui/console.c +++ b/ui/console.c @@ -78,7 +78,7 @@ struct QemuConsole { DisplayState *ds; DisplaySurface *surface; int dcls; - DisplayChangeListener *gl; + DisplayGLCtx *gl; int gl_block; QEMUTimer *gl_unblock_timer; int window_id; @@ -1458,17 +1458,24 @@ static bool dpy_compatible_with(QemuConsole *con, return true; } -void qemu_console_set_display_gl_ctx(QemuConsole *con, - DisplayChangeListener *dcl) +void qemu_console_set_display_gl_ctx(QemuConsole *con, DisplayGLCtx *gl) { /* display has opengl support */ - assert(dcl->con); - if (dcl->con->gl) { - fprintf(stderr, "can't register two opengl displays (%s, %s)\n", - dcl->ops->dpy_name, dcl->con->gl->ops->dpy_name); + assert(con); + if (con->gl) { + error_report("The console already has an OpenGL context."); exit(1); } - dcl->con->gl = dcl; + con->gl = gl; +} + +static bool dpy_gl_compatible_with(QemuConsole *con, DisplayChangeListener *dcl) +{ + if (!con->gl) { + return true; + } + + return con->gl->ops->compatible_dcl == dcl->ops; } void register_displaychangelistener(DisplayChangeListener *dcl) @@ -1480,8 +1487,7 @@ void register_displaychangelistener(DisplayChangeListener *dcl) assert(!dcl->ds); - if (dcl->con && dcl->con->gl && - dcl->con->gl != dcl) { + if (dcl->con && !dpy_gl_compatible_with(dcl->con, dcl)) { error_report("Display %s is incompatible with the GL context", dcl->ops->dpy_name); exit(1); |