From patchwork Wed Aug 11 05:49:37 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Chary X-Patchwork-Id: 61447 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 83F30B6EF2 for ; Wed, 11 Aug 2010 16:03:14 +1000 (EST) Received: from localhost ([127.0.0.1]:35771 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oj4P8-0003nM-0k for incoming@patchwork.ozlabs.org; Wed, 11 Aug 2010 02:03:10 -0400 Received: from [140.186.70.92] (port=37905 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oj4Ct-0005s3-UX for qemu-devel@nongnu.org; Wed, 11 Aug 2010 01:50:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oj4Cs-0007S0-Pc for qemu-devel@nongnu.org; Wed, 11 Aug 2010 01:50:31 -0400 Received: from relay1-v.mail.gandi.net ([217.70.178.75]:50297 helo=mrelay1-v.mgt.gandi.net) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oj4Cs-0007Rt-Ij for qemu-devel@nongnu.org; Wed, 11 Aug 2010 01:50:30 -0400 X-Originating-IP: 217.70.178.36 Received: from mfilter2-v.gandi.net (mfilter2-v.gandi.net [217.70.178.36]) by mrelay1-v.mgt.gandi.net (Postfix) with ESMTP id 2032F362BA; Wed, 11 Aug 2010 07:50:30 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter2-v.gandi.net Received: from mrelay1-v.mgt.gandi.net ([217.70.178.75]) by mfilter2-v.gandi.net (mfilter2-v.gandi.net [217.70.178.36]) (amavisd-new, port 10024) with ESMTP id s0gkZP2ljPhw; Wed, 11 Aug 2010 07:50:29 +0200 (CEST) X-Originating-IP: 82.241.209.44 Received: from tartiflon (falgoret.iksaif.net [82.241.209.44]) (Authenticated sender: fake@iksaif.net) by mrelay1-v.mgt.gandi.net (Postfix) with ESMTPSA id 362B9362C2; Wed, 11 Aug 2010 07:50:27 +0200 (CEST) From: Corentin Chary To: Qemu-development List Date: Wed, 11 Aug 2010 07:49:37 +0200 Message-Id: <1281505785-22523-8-git-send-email-corentincj@iksaif.net> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1281505785-22523-1-git-send-email-corentincj@iksaif.net> References: <1281505785-22523-1-git-send-email-corentincj@iksaif.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: Corentin Chary , Anthony Liguori , Alexander Graf , Andre Przywara Subject: [Qemu-devel] [PATCH 07/15] vnc: palette: and fill and color calls. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org These two helpers are needed for zrle and zywrle. Signed-off-by: Corentin Chary --- ui/vnc-palette.c | 33 +++++++++++++++++++++++++++++++++ ui/vnc-palette.h | 3 +++ 2 files changed, 36 insertions(+), 0 deletions(-) diff --git a/ui/vnc-palette.c b/ui/vnc-palette.c index f93250b..d691a0c 100644 --- a/ui/vnc-palette.c +++ b/ui/vnc-palette.c @@ -126,3 +126,36 @@ void palette_iter(const VncPalette *palette, } } } + +uint32_t palette_color(const VncPalette *palette, int idx, bool *found) +{ + int i; + VncPaletteEntry *entry; + + for (i = 0; i < VNC_PALETTE_HASH_SIZE; i++) { + QLIST_FOREACH(entry, &palette->table[i], next) { + if (entry->idx == idx) { + *found = true; + return entry->color; + } + } + } + + *found = false; + return -1; +} + +static void palette_fill_cb(int idx, uint32_t color, void *opaque) +{ + uint32_t *colors = opaque; + + colors[idx] = color; +} + +size_t palette_fill(const VncPalette *palette, + uint32_t colors[VNC_PALETTE_MAX_SIZE]) +{ + palette_iter(palette, palette_fill_cb, colors); + return palette_size(palette); +} + diff --git a/ui/vnc-palette.h b/ui/vnc-palette.h index c646e4d..3260885 100644 --- a/ui/vnc-palette.h +++ b/ui/vnc-palette.h @@ -61,5 +61,8 @@ size_t palette_size(const VncPalette *palette); void palette_iter(const VncPalette *palette, void (*iter)(int idx, uint32_t color, void *opaque), void *opaque); +uint32_t palette_color(const VncPalette *palette, int idx, bool *found); +size_t palette_fill(const VncPalette *palette, + uint32_t colors[VNC_PALETTE_MAX_SIZE]); #endif /* VNC_PALETTE_H */