From nobody Mon May 6 13:50:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508760356973703.6602504918659; Mon, 23 Oct 2017 05:05:56 -0700 (PDT) Received: from localhost ([::1]:38453 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6bUG-0007xc-3O for importer@patchew.org; Mon, 23 Oct 2017 08:05:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41973) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6bSV-0006nc-Da for qemu-devel@nongnu.org; Mon, 23 Oct 2017 08:03:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e6bST-0000FE-JV for qemu-devel@nongnu.org; Mon, 23 Oct 2017 08:03:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41820) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e6bST-0000EY-Bu for qemu-devel@nongnu.org; Mon, 23 Oct 2017 08:03:53 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 70EEEC058EC1 for ; Mon, 23 Oct 2017 12:03:52 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-195.ams2.redhat.com [10.36.117.195]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF91F60471; Mon, 23 Oct 2017 12:03:20 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D69394FD7B; Mon, 23 Oct 2017 14:03:17 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 70EEEC058EC1 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 23 Oct 2017 14:03:14 +0200 Message-Id: <20171023120317.8296-2-kraxel@redhat.com> In-Reply-To: <20171023120317.8296-1-kraxel@redhat.com> References: <20171023120317.8296-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 23 Oct 2017 12:03:52 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/4] opengl: split up dpy_gl_cursor ops X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a separate callback to set the position of the cursor dmabuf. Note that the position is the upper left corner not the hotspot. Signed-off-by: Gerd Hoffmann --- include/ui/console.h | 10 ++++++---- ui/console.c | 15 ++++++++++++--- ui/egl-headless.c | 16 +++++++++++----- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 580dfc57ee..fa68ba5737 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -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, diff --git a/ui/console.c b/ui/console.c index eca854cbd5..31c14f83d4 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1758,13 +1758,22 @@ void dpy_gl_scanout_dmabuf(QemuConsole *con, } =20 void dpy_gl_cursor_dmabuf(QemuConsole *con, - QemuDmaBuf *dmabuf, - uint32_t pos_x, uint32_t pos_y) + QemuDmaBuf *dmabuf) { assert(con->gl); =20 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); } } =20 diff --git a/ui/egl-headless.c b/ui/egl-headless.c index 5d50226869..c75f5ac655 100644 --- a/ui/egl-headless.c +++ b/ui/egl-headless.c @@ -84,14 +84,10 @@ static void egl_scanout_dmabuf(DisplayChangeListener *d= cl, } =20 static void egl_cursor_dmabuf(DisplayChangeListener *dcl, - QemuDmaBuf *dmabuf, - uint32_t pos_x, uint32_t pos_y) + QemuDmaBuf *dmabuf) { egl_dpy *edpy =3D container_of(dcl, egl_dpy, dcl); =20 - edpy->pos_x =3D pos_x; - edpy->pos_y =3D pos_y; - egl_dmabuf_import_texture(dmabuf); if (!dmabuf->texture) { return; @@ -101,6 +97,15 @@ static void egl_cursor_dmabuf(DisplayChangeListener *dc= l, dmabuf->texture, false); } =20 +static void egl_cursor_position(DisplayChangeListener *dcl, + uint32_t pos_x, uint32_t pos_y) +{ + egl_dpy *edpy =3D container_of(dcl, egl_dpy, dcl); + + edpy->pos_x =3D pos_x; + edpy->pos_y =3D pos_y; +} + static void egl_release_dmabuf(DisplayChangeListener *dcl, QemuDmaBuf *dmabuf) { @@ -150,6 +155,7 @@ static const DisplayChangeListenerOps egl_ops =3D { .dpy_gl_scanout_texture =3D egl_scanout_texture, .dpy_gl_scanout_dmabuf =3D egl_scanout_dmabuf, .dpy_gl_cursor_dmabuf =3D egl_cursor_dmabuf, + .dpy_gl_cursor_position =3D egl_cursor_position, .dpy_gl_release_dmabuf =3D egl_release_dmabuf, .dpy_gl_update =3D egl_scanout_flush, }; --=20 2.9.3 From nobody Mon May 6 13:50:46 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508760604804208.83014218144353; Mon, 23 Oct 2017 05:10:04 -0700 (PDT) Received: from localhost ([::1]:38470 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6bYC-0002YC-PT for importer@patchew.org; Mon, 23 Oct 2017 08:09:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6bSX-0006ni-5F for qemu-devel@nongnu.org; Mon, 23 Oct 2017 08:04:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e6bSS-0000Ei-UG for qemu-devel@nongnu.org; Mon, 23 Oct 2017 08:03:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60030) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e6bSS-0000E0-LT for qemu-devel@nongnu.org; Mon, 23 Oct 2017 08:03:52 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BCC5D81DFF for ; Mon, 23 Oct 2017 12:03:51 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-195.ams2.redhat.com [10.36.117.195]) by smtp.corp.redhat.com (Postfix) with ESMTP id F30CC7A1E7; Mon, 23 Oct 2017 12:03:20 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E82A53F104; Mon, 23 Oct 2017 14:03:17 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BCC5D81DFF Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 23 Oct 2017 14:03:15 +0200 Message-Id: <20171023120317.8296-3-kraxel@redhat.com> In-Reply-To: <20171023120317.8296-1-kraxel@redhat.com> References: <20171023120317.8296-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 23 Oct 2017 12:03:51 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/4] gtk: make GtkGlArea usage a runtime option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Compile gtk with both opengl code variants (GtkGlArea widget and egl context). This allows to select the code path at runtime. Signed-off-by: Gerd Hoffmann --- include/ui/gtk.h | 2 ++ ui/gtk.c | 53 +++++++++++++++++++++++++++++------------------------ ui/Makefile.objs | 3 +-- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/include/ui/gtk.h b/include/ui/gtk.h index 849c896eef..f6dafc5961 100644 --- a/include/ui/gtk.h +++ b/include/ui/gtk.h @@ -90,6 +90,8 @@ typedef struct VirtualConsole { }; } VirtualConsole; =20 +extern bool gtk_use_gl_area; + /* ui/gtk.c */ void gd_update_windowsize(VirtualConsole *vc); =20 diff --git a/ui/gtk.c b/ui/gtk.c index 342e96fbe9..33cd848db3 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -191,6 +191,8 @@ typedef struct VCChardev { #define TYPE_CHARDEV_VC "chardev-vc" #define VC_CHARDEV(obj) OBJECT_CHECK(VCChardev, (obj), TYPE_CHARDEV_VC) =20 +bool gtk_use_gl_area; + static void gd_grab_pointer(VirtualConsole *vc, const char *reason); static void gd_ungrab_pointer(GtkDisplayState *s); static void gd_grab_keyboard(VirtualConsole *vc, const char *reason); @@ -401,7 +403,7 @@ static void gd_update_full_redraw(VirtualConsole *vc) int ww, wh; gdk_drawable_get_size(gtk_widget_get_window(area), &ww, &wh); #if defined(CONFIG_GTK_GL) - if (vc->gfx.gls) { + if (vc->gfx.gls && gtk_use_gl_area) { gtk_gl_area_queue_render(GTK_GL_AREA(vc->gfx.drawing_area)); return; } @@ -673,7 +675,7 @@ static const DisplayChangeListenerOps dcl_gl_area_ops = =3D { .dpy_gl_update =3D gd_gl_area_scanout_flush, }; =20 -#else +#endif /* CONFIG_GTK_GL */ =20 static const DisplayChangeListenerOps dcl_egl_ops =3D { .dpy_name =3D "gtk-egl", @@ -693,7 +695,6 @@ static const DisplayChangeListenerOps dcl_egl_ops =3D { .dpy_gl_update =3D gd_egl_scanout_flush, }; =20 -#endif /* CONFIG_GTK_GL */ #endif /* CONFIG_OPENGL */ =20 /** QEMU Events **/ @@ -787,13 +788,13 @@ static gboolean gd_draw_event(GtkWidget *widget, cair= o_t *cr, void *opaque) =20 #if defined(CONFIG_OPENGL) if (vc->gfx.gls) { -#if defined(CONFIG_GTK_GL) - /* invoke render callback please */ - return FALSE; -#else - gd_egl_draw(vc); - return TRUE; -#endif + if (gtk_use_gl_area) { + /* invoke render callback please */ + return FALSE; + } else { + gd_egl_draw(vc); + return TRUE; + } } #endif =20 @@ -1899,7 +1900,7 @@ static void gd_connect_vc_gfx_signals(VirtualConsole = *vc) g_signal_connect(vc->gfx.drawing_area, "draw", G_CALLBACK(gd_draw_event), vc); #if defined(CONFIG_GTK_GL) - if (display_opengl) { + if (gtk_use_gl_area) { /* wire up GtkGlArea events */ g_signal_connect(vc->gfx.drawing_area, "render", G_CALLBACK(gd_render_event), vc); @@ -2022,26 +2023,29 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, V= irtualConsole *vc, #if defined(CONFIG_OPENGL) if (display_opengl) { #if defined(CONFIG_GTK_GL) - vc->gfx.drawing_area =3D gtk_gl_area_new(); - vc->gfx.dcl.ops =3D &dcl_gl_area_ops; -#else - vc->gfx.drawing_area =3D gtk_drawing_area_new(); - /* - * gtk_widget_set_double_buffered() was deprecated in 3.14. - * It is required for opengl rendering on X11 though. A - * proper replacement (native opengl support) is only - * available in 3.16+. Silence the warning if possible. - */ + if (gtk_use_gl_area) { + vc->gfx.drawing_area =3D gtk_gl_area_new(); + vc->gfx.dcl.ops =3D &dcl_gl_area_ops; + } else +#endif /* CONFIG_GTK_GL */ + { + vc->gfx.drawing_area =3D gtk_drawing_area_new(); + /* + * gtk_widget_set_double_buffered() was deprecated in 3.14. + * It is required for opengl rendering on X11 though. A + * proper replacement (native opengl support) is only + * available in 3.16+. Silence the warning if possible. + */ #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif - gtk_widget_set_double_buffered(vc->gfx.drawing_area, FALSE); + gtk_widget_set_double_buffered(vc->gfx.drawing_area, FALSE); #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE #pragma GCC diagnostic pop #endif - vc->gfx.dcl.ops =3D &dcl_egl_ops; -#endif /* CONFIG_GTK_GL */ + vc->gfx.dcl.ops =3D &dcl_egl_ops; + } } else #endif { @@ -2371,6 +2375,7 @@ void early_gtk_display_init(int opengl) case 1: /* on */ #if defined(CONFIG_OPENGL) #if defined(CONFIG_GTK_GL) + gtk_use_gl_area =3D true; gtk_gl_area_init(); #else gtk_egl_init(); diff --git a/ui/Makefile.objs b/ui/Makefile.objs index ec8533d6d9..45703e7c85 100644 --- a/ui/Makefile.objs +++ b/ui/Makefile.objs @@ -37,10 +37,9 @@ common-obj-y +=3D egl-context.o common-obj-$(CONFIG_OPENGL_DMABUF) +=3D egl-headless.o ifeq ($(CONFIG_GTK_GL),y) common-obj-$(CONFIG_GTK) +=3D gtk-gl-area.o -else +endif common-obj-$(CONFIG_GTK) +=3D gtk-egl.o endif -endif =20 gtk.o-cflags :=3D $(GTK_CFLAGS) $(VTE_CFLAGS) gtk-egl.o-cflags :=3D $(GTK_CFLAGS) $(VTE_CFLAGS) --=20 2.9.3 From nobody Mon May 6 13:50:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508760485457311.623207235559; Mon, 23 Oct 2017 05:08:05 -0700 (PDT) Received: from localhost ([::1]:38463 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6bWP-0001Bi-Kh for importer@patchew.org; Mon, 23 Oct 2017 08:07:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6bSW-0006nd-4e for qemu-devel@nongnu.org; Mon, 23 Oct 2017 08:04:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e6bSS-0000EC-B1 for qemu-devel@nongnu.org; Mon, 23 Oct 2017 08:03:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47626) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e6bSS-0000Dr-59 for qemu-devel@nongnu.org; Mon, 23 Oct 2017 08:03:52 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1705EBBD9 for ; Mon, 23 Oct 2017 12:03:51 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-195.ams2.redhat.com [10.36.117.195]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1AB0E7A208; Mon, 23 Oct 2017 12:03:21 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id EF6FC40549; Mon, 23 Oct 2017 14:03:17 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1705EBBD9 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 23 Oct 2017 14:03:16 +0200 Message-Id: <20171023120317.8296-4-kraxel@redhat.com> In-Reply-To: <20171023120317.8296-1-kraxel@redhat.com> References: <20171023120317.8296-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 23 Oct 2017 12:03:51 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/4] gtk: use GtkGlArea on wayland only X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For 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. Signed-off-by: Gerd Hoffmann --- ui/gtk.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index 33cd848db3..d794fb7fa9 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -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 =3D 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 =3D true; + gtk_gl_area_init(); + } #endif + { + gtk_egl_init(); + } #endif break; default: --=20 2.9.3 From nobody Mon May 6 13:50:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508760362847255.3335031330888; Mon, 23 Oct 2017 05:06:02 -0700 (PDT) Received: from localhost ([::1]:38454 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6bUR-00084r-0v for importer@patchew.org; Mon, 23 Oct 2017 08:05:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41972) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6bSV-0006nb-Da for qemu-devel@nongnu.org; Mon, 23 Oct 2017 08:04:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e6bSU-0000FW-18 for qemu-devel@nongnu.org; Mon, 23 Oct 2017 08:03:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35452) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e6bST-0000Ep-Q1 for qemu-devel@nongnu.org; Mon, 23 Oct 2017 08:03:53 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CB23C356D1 for ; Mon, 23 Oct 2017 12:03:51 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-195.ams2.redhat.com [10.36.117.195]) by smtp.corp.redhat.com (Postfix) with ESMTP id F3D737A20E; Mon, 23 Oct 2017 12:03:20 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 045BC40563; Mon, 23 Oct 2017 14:03:18 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CB23C356D1 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 23 Oct 2017 14:03:17 +0200 Message-Id: <20171023120317.8296-5-kraxel@redhat.com> In-Reply-To: <20171023120317.8296-1-kraxel@redhat.com> References: <20171023120317.8296-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 23 Oct 2017 12:03:51 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 4/4] gtk-egl: add dmabuf support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add support for the new dmabuf interface. Signed-off-by: Gerd Hoffmann --- include/ui/gtk.h | 11 ++++++++++ ui/gtk-egl.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++= ++-- ui/gtk.c | 6 ++++++ 3 files changed, 79 insertions(+), 2 deletions(-) diff --git a/include/ui/gtk.h b/include/ui/gtk.h index f6dafc5961..5d61e69b49 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 @@ -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); diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index eb86c26a1d..30c121c50c 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -7,6 +7,9 @@ * This code handles opengl support on older gtk versions, using egl * to get a opengl context for the X11 window. * + * Also needed on newer gtk versions because the GtkGLArea X11 backend + * uses glx not egl, but for dma-buf imports we need a egl context. + * * This work is licensed under the terms of the GNU GPL, version 2 or late= r. * See the COPYING file in the top-level directory. */ @@ -194,6 +197,52 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl, backing_id, false); } =20 +#ifdef CONFIG_OPENGL_DMABUF + +void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf) +{ + egl_dmabuf_import_texture(dmabuf); + if (!dmabuf->texture) { + return; + } + + gd_egl_scanout_texture(dcl, dmabuf->texture, + false, dmabuf->width, dmabuf->height, + 0, 0, dmabuf->width, dmabuf->height); +} + +void gd_egl_cursor_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf) +{ + VirtualConsole *vc =3D container_of(dcl, VirtualConsole, gfx.dcl); + + 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); +} + +void gd_egl_cursor_position(DisplayChangeListener *dcl, + uint32_t pos_x, uint32_t pos_y) +{ + VirtualConsole *vc =3D container_of(dcl, VirtualConsole, gfx.dcl); + + vc->gfx.cursor_x =3D pos_x; + vc->gfx.cursor_y =3D pos_y; +} + +void gd_egl_release_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf) +{ + egl_dmabuf_release_texture(dmabuf); +} + +#endif + void gd_egl_scanout_flush(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint32_t h) { @@ -213,8 +262,19 @@ void gd_egl_scanout_flush(DisplayChangeListener *dcl, =20 window =3D 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) { + /* have cursor -> render using textures */ + egl_fb_setup_default(&vc->gfx.win_fb, ww, wh); + 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 { + /* no cursor -> use simple framebuffer blit */ + 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); + } =20 eglSwapBuffers(qemu_egl_display, vc->gfx.esurface); } diff --git a/ui/gtk.c b/ui/gtk.c index d794fb7fa9..41753184b8 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -692,6 +692,12 @@ static const DisplayChangeListenerOps dcl_egl_ops =3D { .dpy_gl_ctx_get_current =3D qemu_egl_get_current_context, .dpy_gl_scanout_disable =3D gd_egl_scanout_disable, .dpy_gl_scanout_texture =3D gd_egl_scanout_texture, +#ifdef CONFIG_OPENGL_DMABUF + .dpy_gl_scanout_dmabuf =3D gd_egl_scanout_dmabuf, + .dpy_gl_cursor_dmabuf =3D gd_egl_cursor_dmabuf, + .dpy_gl_cursor_position =3D gd_egl_cursor_position, + .dpy_gl_release_dmabuf =3D gd_egl_release_dmabuf, +#endif .dpy_gl_update =3D gd_egl_scanout_flush, }; =20 --=20 2.9.3