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>
This commit is contained in:
Marc-André Lureau 2021-10-09 23:48:46 +04:00
parent 7cc712e986
commit 5e79d516e8
14 changed files with 119 additions and 76 deletions

View file

@ -179,6 +179,7 @@ typedef struct QemuDmaBuf {
} QemuDmaBuf;
typedef struct DisplayState DisplayState;
typedef struct DisplayGLCtx DisplayGLCtx;
typedef struct DisplayChangeListenerOps {
const char *dpy_name;
@ -213,16 +214,6 @@ typedef struct DisplayChangeListenerOps {
void (*dpy_cursor_define)(DisplayChangeListener *dcl,
QEMUCursor *cursor);
/* required if GL */
QEMUGLContext (*dpy_gl_ctx_create)(DisplayChangeListener *dcl,
QEMUGLParams *params);
/* required if GL */
void (*dpy_gl_ctx_destroy)(DisplayChangeListener *dcl,
QEMUGLContext ctx);
/* required if GL */
int (*dpy_gl_ctx_make_current)(DisplayChangeListener *dcl,
QEMUGLContext ctx);
/* required if GL */
void (*dpy_gl_scanout_disable)(DisplayChangeListener *dcl);
/* required if GL */
@ -263,6 +254,26 @@ struct DisplayChangeListener {
QLIST_ENTRY(DisplayChangeListener) next;
};
typedef struct DisplayGLCtxOps {
/*
* We only check if the GLCtx is compatible with a DCL via ops. A natural
* evolution of this would be a callback to check some runtime requirements
* and allow various DCL kinds.
*/
const DisplayChangeListenerOps *compatible_dcl;
QEMUGLContext (*dpy_gl_ctx_create)(DisplayGLCtx *dgc,
QEMUGLParams *params);
void (*dpy_gl_ctx_destroy)(DisplayGLCtx *dgc,
QEMUGLContext ctx);
int (*dpy_gl_ctx_make_current)(DisplayGLCtx *dgc,
QEMUGLContext ctx);
} DisplayGLCtxOps;
struct DisplayGLCtx {
const DisplayGLCtxOps *ops;
};
DisplayState *init_displaystate(void);
DisplaySurface *qemu_create_displaysurface_from(int width, int height,
pixman_format_code_t format,
@ -409,8 +420,7 @@ void graphic_hw_gl_block(QemuConsole *con, bool block);
void qemu_console_early_init(void);
void qemu_console_set_display_gl_ctx(QemuConsole *con,
DisplayChangeListener *dcl);
void qemu_console_set_display_gl_ctx(QemuConsole *con, DisplayGLCtx *ctx);
QemuConsole *qemu_console_lookup_by_index(unsigned int index);
QemuConsole *qemu_console_lookup_by_device(DeviceState *dev, uint32_t head);