From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxEu2-0002xG-Dr for qemu-devel@nongnu.org; Wed, 18 Jun 2014 08:23:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxEtw-0005xu-8O for qemu-devel@nongnu.org; Wed, 18 Jun 2014 08:23:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32851) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxEtv-0005wh-Sm for qemu-devel@nongnu.org; Wed, 18 Jun 2014 08:23:40 -0400 From: Gerd Hoffmann Date: Wed, 18 Jun 2014 14:23:26 +0200 Message-Id: <1403094208-26235-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1403094208-26235-1-git-send-email-kraxel@redhat.com> References: <1403094208-26235-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 2/4] console: add qemu_default_pixman_format List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , Anthony Liguori Function returning the default pixman format for a given depth. Signed-off-by: Gerd Hoffmann --- include/ui/qemu-pixman.h | 1 + ui/qemu-pixman.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/ui/qemu-pixman.h b/include/ui/qemu-pixman.h index 090a3e2..80ed94a 100644 --- a/include/ui/qemu-pixman.h +++ b/include/ui/qemu-pixman.h @@ -34,6 +34,7 @@ /* -------------------------------------------------------------------- */ 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); diff --git a/ui/qemu-pixman.c b/ui/qemu-pixman.c index bcddc04..20af365 100644 --- a/ui/qemu-pixman.c +++ b/ui/qemu-pixman.c @@ -61,6 +61,31 @@ PixelFormat qemu_pixelformat_from_pixman(pixman_format_code_t format) return pf; } +pixman_format_code_t qemu_default_pixman_format(int bpp, bool native_endian) +{ + if (native_endian) { + switch (bpp) { + case 15: + return PIXMAN_x1r5g5b5; + case 16: + return PIXMAN_r5g6b5; + case 24: + return PIXMAN_r8g8b8; + case 32: + return PIXMAN_x8r8g8b8; + } + } else { + switch (bpp) { + case 24: + return PIXMAN_b8g8r8; + case 32: + return PIXMAN_b8g8r8a8; + break; + } + } + g_assert_not_reached(); +} + int qemu_pixman_get_type(int rshift, int gshift, int bshift) { int type = PIXMAN_TYPE_OTHER; -- 1.8.3.1