qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] ui/gtk: Scale OpenGL content on GTK frontend on HiDPI


From: James
Subject: [PATCH] ui/gtk: Scale OpenGL content on GTK frontend on HiDPI
Date: Wed, 26 May 2021 23:03:18 +1000

This patch will make Qemu's GTK frontend scales the rendered OpenGL content
by an integer scaling factor given by GDK. Without this patch, guest's
content will be rendered at bottom left corner when both HiDPI scaling and
OpenGL is enabled.

Signed-off-by: James <j1@ionbox.in>
---
 ui/gtk-egl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
index 2a2e6d3a17..a6b24c1e2d 100644
--- a/ui/gtk-egl.c
+++ b/ui/gtk-egl.c
@@ -62,7 +62,7 @@ void gd_egl_init(VirtualConsole *vc)
 void gd_egl_draw(VirtualConsole *vc)
 {
     GdkWindow *window;
-    int ww, wh;
+    int ww, wh, wsf;
 
     if (!vc->gfx.gls) {
         return;
@@ -71,6 +71,7 @@ void gd_egl_draw(VirtualConsole *vc)
     window = gtk_widget_get_window(vc->gfx.drawing_area);
     ww = gdk_window_get_width(window);
     wh = gdk_window_get_height(window);
+    wsf = gdk_window_get_scale_factor(window);
 
     if (vc->gfx.scanout_mode) {
         gd_egl_scanout_flush(&vc->gfx.dcl, 0, 0, vc->gfx.w, vc->gfx.h);
@@ -84,7 +85,7 @@ void gd_egl_draw(VirtualConsole *vc)
         eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
                        vc->gfx.esurface, vc->gfx.ectx);
 
-        surface_gl_setup_viewport(vc->gfx.gls, vc->gfx.ds, ww, wh);
+        surface_gl_setup_viewport(vc->gfx.gls, vc->gfx.ds, ww * wsf, wh * wsf);
         surface_gl_render_texture(vc->gfx.gls, vc->gfx.ds);
 
         eglSwapBuffers(qemu_egl_display, vc->gfx.esurface);
-- 
2.25.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]