From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PULL 8/8] ui/gtk-egl: add cursor_dmabuf support
Date: Thu, 8 Mar 2018 09:32:31 +0100 [thread overview]
Message-ID: <20180308083231.20180-9-kraxel@redhat.com> (raw)
In-Reply-To: <20180308083231.20180-1-kraxel@redhat.com>
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
---
include/ui/gtk.h | 8 ++++++++
ui/gtk-egl.c | 40 +++++++++++++++++++++++++++++++++++++++-
ui/gtk.c | 2 ++
3 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/include/ui/gtk.h b/include/ui/gtk.h
index 84c992c227..2922fc64b2 100644
--- a/include/ui/gtk.h
+++ b/include/ui/gtk.h
@@ -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
@@ -115,6 +118,11 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl,
uint32_t w, uint32_t h);
void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl,
QemuDmaBuf *dmabuf);
+void gd_egl_cursor_dmabuf(DisplayChangeListener *dcl,
+ QemuDmaBuf *dmabuf, bool have_hot,
+ uint32_t hot_x, uint32_t hot_y);
+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,
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,
};
--
2.9.3
next prev parent reply other threads:[~2018-03-08 8:32 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-08 8:32 [Qemu-devel] [PULL 0/8] Ui 20180308 patches Gerd Hoffmann
2018-03-08 8:32 ` [Qemu-devel] [PULL 1/8] make: switch language file build to be gtk module aware Gerd Hoffmann
2018-03-08 8:32 ` [Qemu-devel] [PULL 2/8] sdl: workaround bug in sdl 2.0.8 headers Gerd Hoffmann
2018-03-08 8:32 ` [Qemu-devel] [PULL 3/8] ui/gtk: make GtkGlArea usage a runtime option Gerd Hoffmann
2018-03-08 8:32 ` [Qemu-devel] [PULL 4/8] ui/gtk: group gtk.mo declarations in Makefile Gerd Hoffmann
2018-03-08 8:32 ` [Qemu-devel] [PULL 5/8] ui/opengl: Makefile cleanup Gerd Hoffmann
2018-03-08 8:32 ` [Qemu-devel] [PULL 6/8] ui/gtk: use GtkGlArea on wayland only Gerd Hoffmann
2018-03-08 8:32 ` [Qemu-devel] [PULL 7/8] ui/gtk-egl: add scanout_dmabuf support Gerd Hoffmann
2018-03-08 8:32 ` Gerd Hoffmann [this message]
2018-03-08 17:27 ` [Qemu-devel] [PULL 0/8] Ui 20180308 patches Peter Maydell
2018-03-09 6:52 ` Gerd Hoffmann
2018-03-09 7:50 ` Gerd Hoffmann
2018-03-09 8:46 ` Thomas Huth
2018-03-09 9:15 ` Gerd Hoffmann
2018-03-09 9:44 ` Gerd Hoffmann
2018-03-09 9:48 ` Thomas Huth
2018-03-09 10:41 ` Gerd Hoffmann
2018-03-09 10:46 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180308083231.20180-9-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).