ui: refactor using a common qemu_pixman_shareable

Use a common shareable type for win32 & unix, and helper functions.
This simplify the code as it avoids a lot of #ifdef'ery.

Note: if it helps review, commits could be reordered to introduce the
common type before introducing shareable memory for unix.

Suggested-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-ID: <20241008125028.1177932-19-marcandre.lureau@redhat.com>
This commit is contained in:
Marc-André Lureau 2024-10-08 16:50:27 +04:00
parent 5f899c34af
commit 1ff788db97
7 changed files with 145 additions and 143 deletions

View file

@ -336,13 +336,13 @@ static bool dbus_scanout_map(DBusDisplayListener *ddl)
return true;
}
if (!ddl->can_share_map || !ddl->ds->handle) {
if (!ddl->can_share_map || !ddl->ds->share_handle) {
return false;
}
success = DuplicateHandle(
GetCurrentProcess(),
ddl->ds->handle,
ddl->ds->share_handle,
ddl->peer_process,
&target_handle,
FILE_MAP_READ | SECTION_QUERY,
@ -359,7 +359,7 @@ static bool dbus_scanout_map(DBusDisplayListener *ddl)
if (!qemu_dbus_display1_listener_win32_map_call_scanout_map_sync(
ddl->map_proxy,
GPOINTER_TO_UINT(target_handle),
ddl->ds->handle_offset,
ddl->ds->share_handle_offset,
surface_width(ddl->ds),
surface_height(ddl->ds),
surface_stride(ddl->ds),
@ -453,13 +453,13 @@ static bool dbus_scanout_map(DBusDisplayListener *ddl)
return true;
}
if (!ddl->can_share_map || ddl->ds->shmfd == -1) {
if (!ddl->can_share_map || ddl->ds->share_handle == SHAREABLE_NONE) {
return false;
}
ddl_discard_display_messages(ddl);
fd_list = g_unix_fd_list_new();
if (g_unix_fd_list_append(fd_list, ddl->ds->shmfd, &err) != 0) {
if (g_unix_fd_list_append(fd_list, ddl->ds->share_handle, &err) != 0) {
g_debug("Failed to setup scanout map fdlist: %s", err->message);
ddl->can_share_map = false;
return false;
@ -468,7 +468,7 @@ static bool dbus_scanout_map(DBusDisplayListener *ddl)
if (!qemu_dbus_display1_listener_unix_map_call_scanout_map_sync(
ddl->map_proxy,
g_variant_new_handle(0),
ddl->ds->shmfd_offset,
ddl->ds->share_handle_offset,
surface_width(ddl->ds),
surface_height(ddl->ds),
surface_stride(ddl->ds),