From patchwork Tue Sep 2 08:00:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 385004 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8FCE21400D5 for ; Tue, 2 Sep 2014 18:05:52 +1000 (EST) Received: from localhost ([::1]:36436 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOj66-0005m5-Bl for incoming@patchwork.ozlabs.org; Tue, 02 Sep 2014 04:05:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45221) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOj1O-0005i8-3R for qemu-devel@nongnu.org; Tue, 02 Sep 2014 04:01:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XOj1D-0004fU-Lf for qemu-devel@nongnu.org; Tue, 02 Sep 2014 04:00:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9978) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOj1D-0004f5-Da for qemu-devel@nongnu.org; Tue, 02 Sep 2014 04:00:47 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8280hCe013520 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 2 Sep 2014 04:00:45 -0400 Received: from nilsson.home.kraxel.org (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s8280gO6027836; Tue, 2 Sep 2014 04:00:43 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 666B3808B4; Tue, 2 Sep 2014 10:00:41 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 2 Sep 2014 10:00:15 +0200 Message-Id: <1409644827-26317-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1409644827-26317-1-git-send-email-kraxel@redhat.com> References: <1409644827-26317-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann , Anthony Liguori Subject: [Qemu-devel] [PATCH 02/14] console: add qemu_default_pixman_format X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 bdc1439..5d8bd46 100644 --- a/ui/qemu-pixman.c +++ b/ui/qemu-pixman.c @@ -62,6 +62,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;