diff mbox series

[05/27] ui: factor out qemu_console_set_display_gl_ctx()

Message ID 20210312100108.2706195-6-marcandre.lureau@redhat.com (mailing list archive)
State New, archived
Headers show
Series Add D-Bus display backend | expand

Commit Message

Marc-André Lureau March 12, 2021, 10 a.m. UTC
From: Marc-André Lureau <marcandre.lureau@redhat.com>

The next patch will make use of this function to dissociate
DisplayChangeListener from GL context.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/ui/console.h |  2 ++
 ui/console.c         | 21 +++++++++++++--------
 2 files changed, 15 insertions(+), 8 deletions(-)

Comments

Philippe Mathieu-Daudé March 12, 2021, 3:34 p.m. UTC | #1
On 3/12/21 11:00 AM, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> The next patch will make use of this function to dissociate
> DisplayChangeListener from GL context.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/ui/console.h |  2 ++
>  ui/console.c         | 21 +++++++++++++--------
>  2 files changed, 15 insertions(+), 8 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
diff mbox series

Patch

diff --git a/include/ui/console.h b/include/ui/console.h
index c960b7066c..9391fb052b 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -413,6 +413,8 @@  void graphic_hw_gl_flushed(QemuConsole *con);
 
 void qemu_console_early_init(void);
 
+void qemu_console_set_display_gl_ctx(QemuConsole *con, DisplayChangeListener *dcl);
+
 QemuConsole *qemu_console_lookup_by_index(unsigned int index);
 QemuConsole *qemu_console_lookup_by_device(DeviceState *dev, uint32_t head);
 QemuConsole *qemu_console_lookup_by_device_name(const char *device_id,
diff --git a/ui/console.c b/ui/console.c
index bab32723b5..83475bd8c3 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1502,6 +1502,18 @@  static bool dpy_compatible_with(QemuConsole *con,
     return true;
 }
 
+void qemu_console_set_display_gl_ctx(QemuConsole *con, DisplayChangeListener *dcl)
+{
+    /* 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);
+        exit(1);
+    }
+    dcl->con->gl = dcl;
+}
+
 void register_displaychangelistener(DisplayChangeListener *dcl)
 {
     static const char nodev[] =
@@ -1513,14 +1525,7 @@  void register_displaychangelistener(DisplayChangeListener *dcl)
     assert(!dcl->ds);
 
     if (dcl->ops->dpy_gl_ctx_create) {
-        /* 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);
-            exit(1);
-        }
-        dcl->con->gl = dcl;
+        qemu_console_set_display_gl_ctx(dcl->con, dcl);
     }
 
     if (dcl->con && !dpy_compatible_with(dcl->con, dcl, &err)) {