diff options
| author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2024-10-08 16:50:18 +0400 |
|---|---|---|
| committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2024-10-14 17:34:09 +0400 |
| commit | 1bfb726112ea4fda07c988f08df32d1eebb9abec (patch) | |
| tree | ba97103395d10619e18f1929700a83f75798c2e0 /ui/qemu-pixman.c | |
| parent | c90204b65400d77a918844889ad6789858406203 (diff) | |
| download | focaccia-qemu-1bfb726112ea4fda07c988f08df32d1eebb9abec.tar.gz focaccia-qemu-1bfb726112ea4fda07c988f08df32d1eebb9abec.zip | |
ui/pixman: generalize shared_image_destroy
Learn to free memfd-allocated shared memory. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> Message-ID: <20241008125028.1177932-10-marcandre.lureau@redhat.com>
Diffstat (limited to 'ui/qemu-pixman.c')
| -rw-r--r-- | ui/qemu-pixman.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/ui/qemu-pixman.c b/ui/qemu-pixman.c index 3870e1a215..46a91e7f7a 100644 --- a/ui/qemu-pixman.c +++ b/ui/qemu-pixman.c @@ -6,6 +6,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "ui/console.h" +#include "qemu/memfd.h" #include "standard-headers/drm/drm_fourcc.h" #include "trace.h" @@ -269,16 +270,19 @@ void qemu_pixman_glyph_render(pixman_image_t *glyph, } #endif /* CONFIG_PIXMAN */ -#ifdef WIN32 void -qemu_pixman_win32_image_destroy(pixman_image_t *image, void *data) +qemu_pixman_shared_image_destroy(pixman_image_t *image, void *data) { + void *ptr = pixman_image_get_data(image); + +#ifdef WIN32 HANDLE handle = data; - qemu_win32_map_free( - pixman_image_get_data(image), - handle, - &error_warn - ); -} + qemu_win32_map_free(ptr, handle, &error_warn); +#else + int shmfd = GPOINTER_TO_INT(data); + size_t size = pixman_image_get_height(image) * pixman_image_get_stride(image); + + qemu_memfd_free(ptr, size, shmfd); #endif +} |