summaryrefslogtreecommitdiffstats
path: root/ui/gtk.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui/gtk.c')
-rw-r--r--ui/gtk.c43
1 files changed, 33 insertions, 10 deletions
diff --git a/ui/gtk.c b/ui/gtk.c
index 26665cd2e6..79dc240120 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -623,9 +623,20 @@ static const DisplayChangeListenerOps dcl_ops = {
#if defined(CONFIG_OPENGL)
-/** DisplayState Callbacks (opengl version) **/
+static bool gd_has_dmabuf(DisplayChangeListener *dcl)
+{
+ VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
-#if defined(CONFIG_OPENGL)
+ if (gtk_use_gl_area && !gtk_widget_get_realized(vc->gfx.drawing_area)) {
+ /* FIXME: Assume it will work, actual check done after realize */
+ /* fixing this would require delaying listener registration */
+ return true;
+ }
+
+ return vc->gfx.has_dmabuf;
+}
+
+/** DisplayState Callbacks (opengl version) **/
static const DisplayChangeListenerOps dcl_gl_area_ops = {
.dpy_name = "gtk-egl",
@@ -639,13 +650,13 @@ static const DisplayChangeListenerOps dcl_gl_area_ops = {
.dpy_gl_ctx_create = gd_gl_area_create_context,
.dpy_gl_ctx_destroy = gd_gl_area_destroy_context,
.dpy_gl_ctx_make_current = gd_gl_area_make_current,
- .dpy_gl_ctx_get_current = gd_gl_area_get_current_context,
.dpy_gl_scanout_texture = gd_gl_area_scanout_texture,
+ .dpy_gl_scanout_disable = gd_gl_area_scanout_disable,
.dpy_gl_update = gd_gl_area_scanout_flush,
+ .dpy_gl_scanout_dmabuf = gd_gl_area_scanout_dmabuf,
+ .dpy_has_dmabuf = gd_has_dmabuf,
};
-#endif /* CONFIG_OPENGL */
-
static const DisplayChangeListenerOps dcl_egl_ops = {
.dpy_name = "gtk-egl",
.dpy_gfx_update = gd_egl_update,
@@ -658,7 +669,6 @@ static const DisplayChangeListenerOps dcl_egl_ops = {
.dpy_gl_ctx_create = gd_egl_create_context,
.dpy_gl_ctx_destroy = qemu_egl_destroy_context,
.dpy_gl_ctx_make_current = gd_egl_make_current,
- .dpy_gl_ctx_get_current = qemu_egl_get_current_context,
.dpy_gl_scanout_disable = gd_egl_scanout_disable,
.dpy_gl_scanout_texture = gd_egl_scanout_texture,
.dpy_gl_scanout_dmabuf = gd_egl_scanout_dmabuf,
@@ -666,6 +676,7 @@ static const DisplayChangeListenerOps dcl_egl_ops = {
.dpy_gl_cursor_position = gd_egl_cursor_position,
.dpy_gl_release_dmabuf = gd_egl_release_dmabuf,
.dpy_gl_update = gd_egl_scanout_flush,
+ .dpy_has_dmabuf = gd_has_dmabuf,
};
#endif /* CONFIG_OPENGL */
@@ -1980,6 +1991,18 @@ static GtkWidget *gd_create_menu_machine(GtkDisplayState *s)
return machine_menu;
}
+#if defined(CONFIG_OPENGL)
+static void gl_area_realize(GtkGLArea *area, VirtualConsole *vc)
+{
+ gtk_gl_area_make_current(area);
+ qemu_egl_display = eglGetCurrentDisplay();
+ vc->gfx.has_dmabuf = qemu_egl_has_dmabuf();
+ if (!vc->gfx.has_dmabuf) {
+ error_report("GtkGLArea console lacks DMABUF support.");
+ }
+}
+#endif
+
static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
QemuConsole *con, int idx,
GSList *group, GtkWidget *view_menu)
@@ -1993,13 +2016,12 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
#if defined(CONFIG_OPENGL)
if (display_opengl) {
-#if defined(CONFIG_OPENGL)
if (gtk_use_gl_area) {
vc->gfx.drawing_area = gtk_gl_area_new();
+ g_signal_connect(vc->gfx.drawing_area, "realize",
+ G_CALLBACK(gl_area_realize), vc);
vc->gfx.dcl.ops = &dcl_gl_area_ops;
- } else
-#endif /* CONFIG_OPENGL */
- {
+ } else {
vc->gfx.drawing_area = gtk_drawing_area_new();
/*
* gtk_widget_set_double_buffered() was deprecated in 3.14.
@@ -2012,6 +2034,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
gtk_widget_set_double_buffered(vc->gfx.drawing_area, FALSE);
#pragma GCC diagnostic pop
vc->gfx.dcl.ops = &dcl_egl_ops;
+ vc->gfx.has_dmabuf = qemu_egl_has_dmabuf();
}
} else
#endif