aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2018-03-06 10:09:51 +0100
committerGerd Hoffmann <kraxel@redhat.com>2018-03-12 09:00:34 +0100
commitf1bd313264925dfb229a2152eb3f60fe55746b83 (patch)
tree8fcddc78bac820798553a28e80b743f334fddbc8 /ui
parent70763fea4fbbe2984fd2a8f6ce9c77114af80792 (diff)
ui/gtk-egl: add cursor_dmabuf support
Add support for cursor dmabufs to gtk-egl. Just blend in the cursor (if we have one) when rendering the dmabuf. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20180306090951.22932-7-kraxel@redhat.com
Diffstat (limited to 'ui')
-rw-r--r--ui/gtk-egl.c40
-rw-r--r--ui/gtk.c2
2 files changed, 41 insertions, 1 deletions
diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
index 2c83c22d04..9390c6762e 100644
--- a/ui/gtk-egl.c
+++ b/ui/gtk-egl.c
@@ -19,6 +19,7 @@
#include "ui/console.h"
#include "ui/gtk.h"
#include "ui/egl-helpers.h"
+#include "ui/shader.h"
#include "sysemu/sysemu.h"
@@ -209,6 +210,35 @@ void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl,
#endif
}
+void gd_egl_cursor_dmabuf(DisplayChangeListener *dcl,
+ QemuDmaBuf *dmabuf, bool have_hot,
+ uint32_t hot_x, uint32_t hot_y)
+{
+#ifdef CONFIG_OPENGL_DMABUF
+ VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
+
+ if (dmabuf) {
+ egl_dmabuf_import_texture(dmabuf);
+ if (!dmabuf->texture) {
+ return;
+ }
+ egl_fb_setup_for_tex(&vc->gfx.cursor_fb, dmabuf->width, dmabuf->height,
+ dmabuf->texture, false);
+ } else {
+ egl_fb_destroy(&vc->gfx.cursor_fb);
+ }
+#endif
+}
+
+void gd_egl_cursor_position(DisplayChangeListener *dcl,
+ uint32_t pos_x, uint32_t pos_y)
+{
+ VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
+
+ vc->gfx.cursor_x = pos_x;
+ vc->gfx.cursor_y = pos_y;
+}
+
void gd_egl_release_dmabuf(DisplayChangeListener *dcl,
QemuDmaBuf *dmabuf)
{
@@ -237,7 +267,15 @@ void gd_egl_scanout_flush(DisplayChangeListener *dcl,
window = gtk_widget_get_window(vc->gfx.drawing_area);
gdk_drawable_get_size(window, &ww, &wh);
egl_fb_setup_default(&vc->gfx.win_fb, ww, wh);
- egl_fb_blit(&vc->gfx.win_fb, &vc->gfx.guest_fb, !vc->gfx.y0_top);
+ if (vc->gfx.cursor_fb.texture) {
+ egl_texture_blit(vc->gfx.gls, &vc->gfx.win_fb, &vc->gfx.guest_fb,
+ vc->gfx.y0_top);
+ egl_texture_blend(vc->gfx.gls, &vc->gfx.win_fb, &vc->gfx.cursor_fb,
+ vc->gfx.y0_top,
+ vc->gfx.cursor_x, vc->gfx.cursor_y);
+ } else {
+ egl_fb_blit(&vc->gfx.win_fb, &vc->gfx.guest_fb, !vc->gfx.y0_top);
+ }
eglSwapBuffers(qemu_egl_display, vc->gfx.esurface);
}
diff --git a/ui/gtk.c b/ui/gtk.c
index cf2061d716..ef5bc42094 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -745,6 +745,8 @@ static const DisplayChangeListenerOps dcl_egl_ops = {
.dpy_gl_scanout_disable = gd_egl_scanout_disable,
.dpy_gl_scanout_texture = gd_egl_scanout_texture,
.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,
.dpy_gl_update = gd_egl_scanout_flush,
};