ui/console: Use qemu_dmabuf_get_..() helpers instead
This commit updates all instances where fields within the QemuDmaBuf
struct are directly accessed, replacing them with calls to these new
helper functions.
v6: fix typos in helper names in ui/spice-display.c
v7: removed prefix, "dpy_gl_" from all helpers
v8: Introduction of helpers was removed as those were already added
by the previous commit
v11: -- Use new qemu_dmabuf_close() instead of close(qemu_dmabuf_get_fd()).
(Daniel P. Berrangé <berrange@redhat.com>)
-- Use new qemu_dmabuf_dup_fd() instead of dup(qemu_dmabuf_get_fd()).
(Daniel P. Berrangé <berrange@redhat.com>)
Suggested-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
Cc: Daniel P. Berrangé <berrange@redhat.com>
Cc: Vivek Kasireddy <vivek.kasireddy@intel.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
Message-Id: <20240508175403.3399895-4-dongwon.kim@intel.com>
diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
index bceeeb0..5d7744a 100644
--- a/ui/gtk-egl.c
+++ b/ui/gtk-egl.c
@@ -70,6 +70,7 @@
QemuDmaBuf *dmabuf = vc->gfx.guest_fb.dmabuf;
#endif
int ww, wh, ws;
+ int fence_fd;
if (!vc->gfx.gls) {
return;
@@ -83,7 +84,7 @@
if (vc->gfx.scanout_mode) {
#ifdef CONFIG_GBM
if (dmabuf) {
- if (!dmabuf->draw_submitted) {
+ if (!qemu_dmabuf_get_draw_submitted(dmabuf)) {
return;
} else {
dmabuf->draw_submitted = false;
@@ -99,8 +100,9 @@
#ifdef CONFIG_GBM
if (dmabuf) {
egl_dmabuf_create_fence(dmabuf);
- if (dmabuf->fence_fd >= 0) {
- qemu_set_fd_handler(dmabuf->fence_fd, gd_hw_gl_flushed, NULL, vc);
+ fence_fd = qemu_dmabuf_get_fence_fd(dmabuf);
+ if (fence_fd >= 0) {
+ qemu_set_fd_handler(fence_fd, gd_hw_gl_flushed, NULL, vc);
return;
}
graphic_hw_gl_block(vc->gfx.dcl.con, false);
@@ -149,7 +151,8 @@
gd_update_monitor_refresh_rate(
vc, vc->window ? vc->window : vc->gfx.drawing_area);
- if (vc->gfx.guest_fb.dmabuf && vc->gfx.guest_fb.dmabuf->draw_submitted) {
+ if (vc->gfx.guest_fb.dmabuf &&
+ qemu_dmabuf_get_draw_submitted(vc->gfx.guest_fb.dmabuf)) {
gd_egl_draw(vc);
return;
}
@@ -265,22 +268,30 @@
{
#ifdef CONFIG_GBM
VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
+ uint32_t x, y, width, height, backing_width, backing_height, texture;
+ bool y0_top;
eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
vc->gfx.esurface, vc->gfx.ectx);
egl_dmabuf_import_texture(dmabuf);
- if (!dmabuf->texture) {
+ texture = qemu_dmabuf_get_texture(dmabuf);
+ if (!texture) {
return;
}
- gd_egl_scanout_texture(dcl, dmabuf->texture,
- dmabuf->y0_top,
- dmabuf->backing_width, dmabuf->backing_height,
- dmabuf->x, dmabuf->y, dmabuf->width,
- dmabuf->height, NULL);
+ x = qemu_dmabuf_get_x(dmabuf);
+ y = qemu_dmabuf_get_y(dmabuf);
+ width = qemu_dmabuf_get_width(dmabuf);
+ height = qemu_dmabuf_get_height(dmabuf);
+ backing_width = qemu_dmabuf_get_backing_width(dmabuf);
+ backing_height = qemu_dmabuf_get_backing_height(dmabuf);
+ y0_top = qemu_dmabuf_get_y0_top(dmabuf);
- if (dmabuf->allow_fences) {
+ gd_egl_scanout_texture(dcl, texture, y0_top, backing_width, backing_height,
+ x, y, width, height, NULL);
+
+ if (qemu_dmabuf_get_allow_fences(dmabuf)) {
vc->gfx.guest_fb.dmabuf = dmabuf;
}
#endif
@@ -292,15 +303,19 @@
{
#ifdef CONFIG_GBM
VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
+ uint32_t backing_width, backing_height, texture;
if (dmabuf) {
egl_dmabuf_import_texture(dmabuf);
- if (!dmabuf->texture) {
+ texture = qemu_dmabuf_get_texture(dmabuf);
+ if (!texture) {
return;
}
- egl_fb_setup_for_tex(&vc->gfx.cursor_fb,
- dmabuf->backing_width, dmabuf->backing_height,
- dmabuf->texture, false);
+
+ backing_width = qemu_dmabuf_get_backing_width(dmabuf);
+ backing_height = qemu_dmabuf_get_backing_height(dmabuf);
+ egl_fb_setup_for_tex(&vc->gfx.cursor_fb, backing_width, backing_height,
+ texture, false);
} else {
egl_fb_destroy(&vc->gfx.cursor_fb);
}
@@ -364,7 +379,8 @@
VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
GtkWidget *area = vc->gfx.drawing_area;
- if (vc->gfx.guest_fb.dmabuf && !vc->gfx.guest_fb.dmabuf->draw_submitted) {
+ if (vc->gfx.guest_fb.dmabuf &&
+ !qemu_dmabuf_get_draw_submitted(vc->gfx.guest_fb.dmabuf)) {
graphic_hw_gl_block(vc->gfx.dcl.con, true);
vc->gfx.guest_fb.dmabuf->draw_submitted = true;
gtk_egl_set_scanout_mode(vc, true);