From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42828) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9Vsu-0005xw-Jn for qemu-devel@nongnu.org; Fri, 09 Jan 2015 04:29:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y9Vsq-00016L-EN for qemu-devel@nongnu.org; Fri, 09 Jan 2015 04:29:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40381) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9Vsq-00015v-7Y for qemu-devel@nongnu.org; Fri, 09 Jan 2015 04:29:32 -0500 From: Gerd Hoffmann Date: Fri, 9 Jan 2015 10:28:32 +0100 Message-Id: <1420795717-28966-4-git-send-email-kraxel@redhat.com> In-Reply-To: <1420795717-28966-1-git-send-email-kraxel@redhat.com> References: <1420795717-28966-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 3/8] ui/pixman: add qemu_pixman_check_format List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , Anthony Liguori Convinience check_format function for UIs using pixman. Signed-off-by: Gerd Hoffmann --- include/ui/qemu-pixman.h | 2 ++ ui/qemu-pixman.c | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/ui/qemu-pixman.h b/include/ui/qemu-pixman.h index 381969d..3dee576 100644 --- a/include/ui/qemu-pixman.h +++ b/include/ui/qemu-pixman.h @@ -37,6 +37,8 @@ PixelFormat qemu_pixelformat_from_pixman(pixman_format_code_t format); pixman_format_code_t qemu_default_pixman_format(int bpp, bool native_endian); int qemu_pixman_get_type(int rshift, int gshift, int bshift); pixman_format_code_t qemu_pixman_get_format(PixelFormat *pf); +bool qemu_pixman_check_format(DisplayChangeListener *dcl, + pixman_format_code_t format); pixman_image_t *qemu_pixman_linebuf_create(pixman_format_code_t format, int width); diff --git a/ui/qemu-pixman.c b/ui/qemu-pixman.c index 6a889e9..4116e15 100644 --- a/ui/qemu-pixman.c +++ b/ui/qemu-pixman.c @@ -125,6 +125,33 @@ pixman_format_code_t qemu_pixman_get_format(PixelFormat *pf) return format; } +/* + * Return true for known-good pixman conversions. + * + * UIs using pixman for format conversion can hook this into + * DisplayChangeListenerOps->dpy_gfx_check_format + */ +bool qemu_pixman_check_format(DisplayChangeListener *dcl, + pixman_format_code_t format) +{ + switch (format) { + /* 32 bpp */ + case PIXMAN_x8r8g8b8: + case PIXMAN_a8r8g8b8: + case PIXMAN_b8g8r8x8: + case PIXMAN_b8g8r8a8: + /* 24 bpp */ + case PIXMAN_r8g8b8: + case PIXMAN_b8g8r8: + /* 16 bpp */ + case PIXMAN_x1r5g5b5: + case PIXMAN_r5g6b5: + return true; + default: + return false; + } +} + pixman_image_t *qemu_pixman_linebuf_create(pixman_format_code_t format, int width) { -- 1.8.3.1