QEMUGLContext ctx);
int (*dpy_gl_ctx_make_current)(DisplayGLCtx *dgc,
QEMUGLContext ctx);
+ void (*dpy_gl_ctx_create_texture)(DisplayGLCtx *dgc,
+ DisplaySurface *surface);
+ void (*dpy_gl_ctx_destroy_texture)(DisplayGLCtx *dgc,
+ DisplaySurface *surface);
+ void (*dpy_gl_ctx_update_texture)(DisplayGLCtx *dgc,
+ DisplaySurface *surface,
+ int x, int y, int w, int h);
} DisplayGLCtxOps;
struct DisplayGLCtx {
const DisplayGLCtxOps *ops;
+#ifdef CONFIG_OPENGL
+ QemuGLShader *gls; /* optional shared shader */
+#endif
};
DisplayState *init_displaystate(void);
}
}
+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,
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;
}
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);
}
}
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;
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);
}
DisplayChangeListener dcl;
DisplaySurface *ds;
- QemuGLShader *gls;
int gl_updates;
};
{
DBusDisplayListener *ddl = container_of(dcl, DBusDisplayListener, dcl);
- if (ddl->ds) {
- surface_gl_update_texture(ddl->gls, ddl->ds, x, y, w, h);
- }
-
ddl->gl_updates++;
}
{
DBusDisplayListener *ddl = container_of(dcl, DBusDisplayListener, dcl);
- if (ddl->ds) {
- surface_gl_destroy_texture(ddl->gls, ddl->ds);
- }
ddl->ds = new_surface;
if (ddl->ds) {
int width = surface_width(ddl->ds);
int height = surface_height(ddl->ds);
- surface_gl_create_texture(ddl->gls, ddl->ds);
/* TODO: lazy send dmabuf (there are unnecessary sent otherwise) */
dbus_scanout_texture(&ddl->dcl, ddl->ds->texture, false,
width, height, 0, 0, width, height);
g_clear_object(&ddl->conn);
g_clear_pointer(&ddl->bus_name, g_free);
g_clear_object(&ddl->proxy);
- g_clear_pointer(&ddl->gls, qemu_gl_fini_shader);
G_OBJECT_CLASS(dbus_display_listener_parent_class)->dispose(object);
}
DBusDisplayListener *ddl = DBUS_DISPLAY_LISTENER(object);
if (display_opengl) {
- ddl->gls = qemu_gl_init_shader();
ddl->dcl.ops = &dbus_gl_dcl_ops;
} else {
ddl->dcl.ops = &dbus_dcl_ops;
return dcl->ops == &dbus_gl_dcl_ops || dcl->ops == &dbus_console_dcl_ops;
}
+static void
+dbus_create_texture(DisplayGLCtx *ctx, DisplaySurface *surface)
+{
+ surface_gl_create_texture(ctx->gls, surface);
+}
+
+static void
+dbus_destroy_texture(DisplayGLCtx *ctx, DisplaySurface *surface)
+{
+ surface_gl_destroy_texture(ctx->gls, surface);
+}
+
+static void
+dbus_update_texture(DisplayGLCtx *ctx, DisplaySurface *surface,
+ int x, int y, int w, int h)
+{
+ surface_gl_update_texture(ctx->gls, surface, x, y, w, h);
+}
+
static const DisplayGLCtxOps dbus_gl_ops = {
.dpy_gl_ctx_is_compatible_dcl = dbus_is_compatible_dcl,
.dpy_gl_ctx_create = dbus_create_context,
.dpy_gl_ctx_destroy = qemu_egl_destroy_context,
.dpy_gl_ctx_make_current = qemu_egl_make_context_current,
+ .dpy_gl_ctx_create_texture = dbus_create_texture,
+ .dpy_gl_ctx_destroy_texture = dbus_destroy_texture,
+ .dpy_gl_ctx_update_texture = dbus_update_texture,
};
static NotifierList dbus_display_notifiers =
g_autoptr(GDBusObjectSkeleton) vm = NULL;
dd->glctx.ops = &dbus_gl_ops;
+ if (display_opengl) {
+ dd->glctx.gls = qemu_gl_init_shader();
+ }
dd->iface = qemu_dbus_display1_vm_skeleton_new();
dd->consoles = g_ptr_array_new_with_free_func(g_object_unref);
g_clear_object(&dd->iface);
g_free(dd->dbus_addr);
g_free(dd->audiodev);
+ g_clear_pointer(&dd->glctx.gls, qemu_gl_fini_shader);
dbus_display = NULL;
}