From patchwork Tue Apr 16 09:39:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 236882 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 756A12C00EC for ; Tue, 16 Apr 2013 19:43:33 +1000 (EST) Received: from localhost ([::1]:56449 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1US2QF-0006Cp-N4 for incoming@patchwork.ozlabs.org; Tue, 16 Apr 2013 05:43:31 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47395) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1US2Ma-0001Sm-L7 for qemu-devel@nongnu.org; Tue, 16 Apr 2013 05:39:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1US2MY-0006ta-2B for qemu-devel@nongnu.org; Tue, 16 Apr 2013 05:39:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51038) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1US2MX-0006tQ-QF for qemu-devel@nongnu.org; Tue, 16 Apr 2013 05:39:41 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3G9dfo8000753 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 16 Apr 2013 05:39:41 -0400 Received: from rincewind.home.kraxel.org (ovpn-116-37.ams2.redhat.com [10.36.116.37]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r3G9deAQ011868; Tue, 16 Apr 2013 05:39:40 -0400 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 8843140E93; Tue, 16 Apr 2013 11:39:38 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 16 Apr 2013 11:39:19 +0200 Message-Id: <1366105178-26744-6-git-send-email-kraxel@redhat.com> In-Reply-To: <1366105178-26744-1-git-send-email-kraxel@redhat.com> References: <1366105178-26744-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Anthony Liguori , Gerd Hoffmann Subject: [Qemu-devel] [PATCH 05/24] pixman: add qemu_pixman_color() 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 Helper function to map qemu colors (32bit integer + matching PixelFormat) into pixman_color_t. Signed-off-by: Gerd Hoffmann --- include/ui/qemu-pixman.h | 2 ++ ui/qemu-pixman.c | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/ui/qemu-pixman.h b/include/ui/qemu-pixman.h index b032f52..b0f09b5 100644 --- a/include/ui/qemu-pixman.h +++ b/include/ui/qemu-pixman.h @@ -43,4 +43,6 @@ pixman_image_t *qemu_pixman_mirror_create(pixman_format_code_t format, pixman_image_t *image); void qemu_pixman_image_unref(pixman_image_t *image); +pixman_color_t qemu_pixman_color(PixelFormat *pf, uint32_t color); + #endif /* QEMU_PIXMAN_H */ diff --git a/ui/qemu-pixman.c b/ui/qemu-pixman.c index 6dcbe90..be551e0 100644 --- a/ui/qemu-pixman.c +++ b/ui/qemu-pixman.c @@ -79,3 +79,14 @@ void qemu_pixman_image_unref(pixman_image_t *image) } pixman_image_unref(image); } + +pixman_color_t qemu_pixman_color(PixelFormat *pf, uint32_t color) +{ + pixman_color_t c; + + c.red = ((color & pf->rmask) >> pf->rshift) << (16 - pf->rbits); + c.green = ((color & pf->gmask) >> pf->gshift) << (16 - pf->gbits); + c.blue = ((color & pf->bmask) >> pf->bshift) << (16 - pf->bbits); + c.alpha = ((color & pf->amask) >> pf->ashift) << (16 - pf->abits); + return c; +}