gtk: add dmabuf support
cover gtk: add dmabuf support
This series adds dmabuf support to the gtk ui.
Gerd Hoffmann (4):
opengl: split up dpy_gl_cursor ops
gtk: make GtkGlArea usage a runtime option
gtk: use GtkGlArea on wayland only
gtk-egl: add dmabuf support
include/ui/console.h | 10 +++++--- include/ui/gtk.h | 13 ++++++++++ ui/console.c | 15 ++++++++--- ui/egl-headless.c | 16 ++++++++---- ui/gtk-egl.c | 64 +++++++++++++++++++++++++++++++++++++++++++++-- ui/gtk.c | 70 +++++++++++++++++++++++++++++++--------------------- ui/Makefile.objs | 3 +-- 7 files changed, 147 insertions(+), 44 deletions(-)
Signature · 1 line
2.9.3
PATCH 1/4 opengl: split up dpy_gl_cursor ops
Add a separate callback to set the position of the cursor dmabuf. Note that the position is the upper left corner not the hotspot.
--- include/ui/console.h | 10 ++++++---- ui/console.c | 15 ++++++++++++--- ui/egl-headless.c | 16 +++++++++++----- 3 files changed, 29 insertions(+), 12 deletions(-)
include/ui/console.h +6 -4
@@ -234,8 +234,9 @@ typedef struct DisplayChangeListenerOps {void (*dpy_gl_scanout_dmabuf)(DisplayChangeListener *dcl,QemuDmaBuf *dmabuf);void (*dpy_gl_cursor_dmabuf)(DisplayChangeListener *dcl, -QemuDmaBuf *dmabuf, -uint32_t pos_x,uint32_t pos_y); +QemuDmaBuf *dmabuf); +void (*dpy_gl_cursor_position)(DisplayChangeListener *dcl, +uint32_t pos_x,uint32_t pos_y);void (*dpy_gl_release_dmabuf)(DisplayChangeListener *dcl,QemuDmaBuf *dmabuf); void (*dpy_gl_update)(DisplayChangeListener *dcl,
@@ -309,8 +310,9 @@ void dpy_gl_scanout_texture(QemuConsole *con,void dpy_gl_scanout_dmabuf (QemuConsole *con,QemuDmaBuf *dmabuf);void dpy_gl_cursor_dmabuf (QemuConsole *con, -QemuDmaBuf *dmabuf, -uint32_t pos_x,uint32_t pos_y); +QemuDmaBuf *dmabuf); +void dpy_gl_cursor_position (QemuConsole *con, +uint32_t pos_x,uint32_t pos_y);void dpy_gl_release_dmabuf (QemuConsole *con,QemuDmaBuf *dmabuf); void dpy_gl_update(QemuConsole *con,
ui/console.c +12 -3
@@ -1758,13 +1758,22 @@ void dpy_gl_scanout_dmabuf(QemuConsole *con, }void dpy_gl_cursor_dmabuf (QemuConsole *con, -QemuDmaBuf *dmabuf, -uint32_t pos_x,uint32_t pos_y) +QemuDmaBuf *dmabuf) {assert (con->gl);if (con->gl->ops->dpy_gl_cursor_dmabuf) { - con->gl->ops->dpy_gl_cursor_dmabuf (con->gl, dmabuf, pos_x, pos_y); + con->gl->ops->dpy_gl_cursor_dmabuf (con->gl, dmabuf); + } +} + +void dpy_gl_cursor_position (QemuConsole *con, +uint32_t pos_x,uint32_t pos_y) +{ +assert (con->gl); + +if (con->gl->ops->dpy_gl_cursor_position) { + con->gl->ops->dpy_gl_cursor_position (con->gl, pos_x, pos_y); } }
ui/egl-headless.c +11 -5
@@ -84,14 +84,10 @@ static void egl_scanout_dmabuf(DisplayChangeListener *dcl, }static void egl_cursor_dmabuf (DisplayChangeListener *dcl, -QemuDmaBuf *dmabuf, -uint32_t pos_x,uint32_t pos_y) +QemuDmaBuf *dmabuf) {egl_dpy *edpy =container_of (dcl, egl_dpy, dcl); - edpy->pos_x = pos_x; - edpy->pos_y = pos_y; -egl_dmabuf_import_texture (dmabuf);if (!dmabuf->texture) {return ;
@@ -101,6 +97,15 @@ static void egl_cursor_dmabuf(DisplayChangeListener *dcl, dmabuf->texture, false); } +static void egl_cursor_position (DisplayChangeListener *dcl, +uint32_t pos_x,uint32_t pos_y) +{ +egl_dpy *edpy =container_of (dcl, egl_dpy, dcl); + + edpy->pos_x = pos_x; + edpy->pos_y = pos_y; +} +static void egl_release_dmabuf (DisplayChangeListener *dcl,QemuDmaBuf *dmabuf) {
@@ -150,6 +155,7 @@ static const DisplayChangeListenerOps egl_ops = { .dpy_gl_scanout_texture = egl_scanout_texture, .dpy_gl_scanout_dmabuf = egl_scanout_dmabuf, .dpy_gl_cursor_dmabuf = egl_cursor_dmabuf, + .dpy_gl_cursor_position = egl_cursor_position, .dpy_gl_release_dmabuf = egl_release_dmabuf, .dpy_gl_update = egl_scanout_flush, };
Signature · 1 line
2.9.3
PATCH 2/4 gtk: make GtkGlArea usage a runtime option
In reply to Gerd HoffmannCompile gtk with both opengl code variants (GtkGlArea widget and egl context). This allows to select the code path at runtime.
--- include/ui/gtk.h | 2 ++ ui/gtk.c | 53 +++++++++++++++++++++++++++++------------------------ ui/Makefile.objs | 3 +-- 3 files changed, 32 insertions(+), 26 deletions(-)
include/ui/gtk.h +2 -0
@@ -90,6 +90,8 @@ typedef struct VirtualConsole { }; } VirtualConsole; +extern bool gtk_use_gl_area; +/* ui/gtk.c */ void gd_update_windowsize (VirtualConsole *vc);
ui/gtk.c +29 -24
108 lines not on this page · raw message
ui/Makefile.objs +1 -2
@@ -37,10 +37,9 @@ common-obj-y += egl-context.o common-obj-$(CONFIG_OPENGL_DMABUF) += egl-headless.o ifeq ($(CONFIG_GTK_GL),y) common-obj-$(CONFIG_GTK) += gtk-gl-area.o -else +endif common-obj-$(CONFIG_GTK) += gtk-egl.o endif -endif gtk.o-cflags := $(GTK_CFLAGS) $(VTE_CFLAGS) gtk-egl.o-cflags := $(GTK_CFLAGS) $(VTE_CFLAGS)
Signature · 1 line
2.9.3
PATCH 3/4 gtk: use GtkGlArea on wayland only
In reply to Gerd HoffmannFor dma-buf imports we need a egl context. The GtkGlArea widget uses glx though when running on X11. So use the GtkGlArea code on wayland only.
--- ui/gtk.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
ui/gtk.c +8 -5
@@ -2374,12 +2374,15 @@ void early_gtk_display_init(int opengl)break ;case 1 :/* on */ #if defined(CONFIG_OPENGL ) -#if defined(CONFIG_GTK_GL ) - gtk_use_gl_area = true; -gtk_gl_area_init (); -#else -gtk_egl_init (); +#if defined(CONFIG_GTK_GL ) && defined(GDK_WINDOWING_WAYLAND ) +if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ())) { + gtk_use_gl_area = true; +gtk_gl_area_init (); + }#endif + { +gtk_egl_init (); + }#endif break ;default :
Signature · 1 line
2.9.3
PATCH 4/4 gtk-egl: add dmabuf support
In reply to Gerd HoffmannAdd support for the new dmabuf interface.
--- include/ui/gtk.h | 11 ++++++++++ ui/gtk-egl.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- ui/gtk.c | 6 ++++++ 3 files changed, 79 insertions(+), 2 deletions(-)
include/ui/gtk.h +11 -0
@@ -54,6 +54,9 @@ typedef struct VirtualGfxConsole {int x, y, w, h;egl_fb guest_fb;egl_fb win_fb; +egl_fb cursor_fb; +int cursor_x; +int cursor_y;bool y0_top;bool scanout_mode;#endif
@@ -113,6 +116,14 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl,uint32_t backing_height, uint32_t x, uint32_t y, uint32_t w, uint32_t h); +void gd_egl_scanout_dmabuf (DisplayChangeListener *dcl, +QemuDmaBuf *dmabuf); +void gd_egl_cursor_dmabuf (DisplayChangeListener *dcl, +QemuDmaBuf *dmabuf); +void gd_egl_cursor_position (DisplayChangeListener *dcl, +uint32_t pos_x,uint32_t pos_y); +void gd_egl_release_dmabuf (DisplayChangeListener *dcl, +QemuDmaBuf *dmabuf);void gd_egl_scanout_flush (DisplayChangeListener *dcl,uint32_t x,uint32_t y,uint32_t w,uint32_t h);void gtk_egl_init (void );
ui/gtk-egl.c +62 -2
82 lines not on this page · raw message
ui/gtk.c +6 -0
@@ -692,6 +692,12 @@ static const DisplayChangeListenerOps dcl_egl_ops = { .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, +#ifdef CONFIG_OPENGL_DMABUF + .dpy_gl_scanout_dmabuf = gd_egl_scanout_dmabuf, + .dpy_gl_cursor_dmabuf = gd_egl_cursor_dmabuf, + .dpy_gl_cursor_position = gd_egl_cursor_position, + .dpy_gl_release_dmabuf = gd_egl_release_dmabuf, +#endif .dpy_gl_update = gd_egl_scanout_flush, };
Signature · 1 line
2.9.3