diff options
author | Marc-André Lureau | 2022-02-17 12:07:21 +0100 |
---|---|---|
committer | Marc-André Lureau | 2022-03-15 09:54:55 +0100 |
commit | 589089feee5bf5110f21fd582f9c2c479ae718a2 (patch) | |
tree | 2e658edeb5b5abdc5b3dfb9f798d9abb9875afe0 /ui/console.c | |
parent | ui/console: optionally update after gfx switch (diff) | |
download | qemu-589089feee5bf5110f21fd582f9c2c479ae718a2.tar.gz qemu-589089feee5bf5110f21fd582f9c2c479ae718a2.tar.xz qemu-589089feee5bf5110f21fd582f9c2c479ae718a2.zip |
ui/dbus: fix texture sharing
The DBus listener naively create, update and destroy textures without
taking into account other listeners. The texture were shared, but
texture update was unnecessarily duplicated.
Teach DisplayGLCtx to do optionally shared texture handling. This is
only implemented for DBus display at this point, however the same
infrastructure could potentially be used for other future combinations.
Reported-by: Akihiko Odaki <akihiko.odaki@gmail.com>
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 | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/ui/console.c b/ui/console.c index 06ba82db61..3b56645356 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1073,6 +1073,27 @@ static void displaychangelistener_gfx_switch(DisplayChangeListener *dcl, } } +static void dpy_gfx_create_texture(QemuConsole *con, DisplaySurface *surface) +{ + if (con->gl && con->gl->ops->dpy_gl_ctx_create_texture) { + con->gl->ops->dpy_gl_ctx_create_texture(con->gl, surface); + } +} + +static void dpy_gfx_destroy_texture(QemuConsole *con, DisplaySurface *surface) +{ + if (con->gl && con->gl->ops->dpy_gl_ctx_destroy_texture) { + con->gl->ops->dpy_gl_ctx_destroy_texture(con->gl, surface); + } +} + +static void dpy_gfx_update_texture(QemuConsole *con, DisplaySurface *surface, + int x, int y, int w, int h) +{ + if (con->gl && con->gl->ops->dpy_gl_ctx_update_texture) { + con->gl->ops->dpy_gl_ctx_update_texture(con->gl, surface, x, y, w, h); + } +} static void displaychangelistener_display_console(DisplayChangeListener *dcl, QemuConsole *con, @@ -1086,6 +1107,9 @@ static void displaychangelistener_display_console(DisplayChangeListener *dcl, if (!dummy) { dummy = qemu_create_placeholder_surface(640, 480, nodev); } + if (con) { + dpy_gfx_create_texture(con, dummy); + } displaychangelistener_gfx_switch(dcl, dummy, TRUE); return; } @@ -1105,6 +1129,7 @@ static void displaychangelistener_display_console(DisplayChangeListener *dcl, con->scanout.texture.width, con->scanout.texture.height); } else if (con->scanout.kind == SCANOUT_SURFACE) { + dpy_gfx_create_texture(con, con->surface); displaychangelistener_gfx_switch(dcl, con->surface, TRUE); } } @@ -1637,6 +1662,7 @@ void dpy_gfx_update(QemuConsole *con, int x, int y, int w, int h) if (!qemu_console_is_visible(con)) { return; } + dpy_gfx_update_texture(con, con->surface, x, y, w, h); QLIST_FOREACH(dcl, &s->listeners, next) { if (con != (dcl->con ? dcl->con : active_console)) { continue; @@ -1681,12 +1707,14 @@ void dpy_gfx_replace_surface(QemuConsole *con, con->scanout.kind = SCANOUT_SURFACE; con->surface = surface; + dpy_gfx_create_texture(con, surface); QLIST_FOREACH(dcl, &s->listeners, next) { if (con != (dcl->con ? dcl->con : active_console)) { continue; } displaychangelistener_gfx_switch(dcl, surface, FALSE); } + dpy_gfx_destroy_texture(con, old_surface); qemu_free_displaysurface(old_surface); } |