summary refs log tree commit diff stats
path: root/ui/egl-helpers.c
diff options
context:
space:
mode:
authorWeifeng Liu <weifeng.liu.z@gmail.com>2025-05-11 15:33:19 +0800
committerMarc-André Lureau <marcandre.lureau@redhat.com>2025-05-24 17:04:09 +0200
commitf05e1a93f48729b568fdf86a12d56ee142cee5e1 (patch)
treec7e8dbc79b70b26d3da2ce03f4092dcd93c0e838 /ui/egl-helpers.c
parentfdc09b028fde9d2ec70418735f354b51c8295d0f (diff)
downloadfocaccia-qemu-f05e1a93f48729b568fdf86a12d56ee142cee5e1.tar.gz
focaccia-qemu-f05e1a93f48729b568fdf86a12d56ee142cee5e1.zip
ui/gtk-egl: Render guest content with padding in fixed-scale mode
Scaling was not respected when rendering frames in gtk-egl.c (used if
gl=on and X11 mode). To fix this, add fields x and y to struct egl_fb
for x offset and y offset so we can add padding to window.

Signed-off-by: Weifeng Liu <weifeng.liu.z@gmail.com>
Message-ID: <20250511073337.876650-10-weifeng.liu.z@gmail.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Diffstat (limited to 'ui/egl-helpers.c')
-rw-r--r--ui/egl-helpers.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c
index 9cda2bbbee..5503a795e4 100644
--- a/ui/egl-helpers.c
+++ b/ui/egl-helpers.c
@@ -93,14 +93,18 @@ void egl_fb_destroy(egl_fb *fb)
 
     fb->width = 0;
     fb->height = 0;
+    fb->x = 0;
+    fb->y = 0;
     fb->texture = 0;
     fb->framebuffer = 0;
 }
 
-void egl_fb_setup_default(egl_fb *fb, int width, int height)
+void egl_fb_setup_default(egl_fb *fb, int width, int height, int x, int y)
 {
     fb->width = width;
     fb->height = height;
+    fb->x = x;
+    fb->y = y;
     fb->framebuffer = 0; /* default framebuffer */
 }
 
@@ -145,6 +149,7 @@ void egl_fb_blit(egl_fb *dst, egl_fb *src, bool flip)
     glBindFramebuffer(GL_READ_FRAMEBUFFER, src->framebuffer);
     glBindFramebuffer(GL_DRAW_FRAMEBUFFER, dst->framebuffer);
     glViewport(0, 0, dst->width, dst->height);
+    glClear(GL_COLOR_BUFFER_BIT);
 
     if (src->dmabuf) {
         x1 = qemu_dmabuf_get_x(src->dmabuf);
@@ -161,7 +166,8 @@ void egl_fb_blit(egl_fb *dst, egl_fb *src, bool flip)
     x2 = x1 + w;
 
     glBlitFramebuffer(x1, y1, x2, y2,
-                      0, 0, dst->width, dst->height,
+                      dst->x, dst->y,
+                      dst->x + dst->width, dst->y + dst->height,
                       GL_COLOR_BUFFER_BIT, GL_LINEAR);
 }