From patchwork Fri Feb 4 08:06:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Chary X-Patchwork-Id: 81816 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 13586B70E7 for ; Fri, 4 Feb 2011 19:07:10 +1100 (EST) Received: from localhost ([127.0.0.1]:33608 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PlGh9-0003nX-FJ for incoming@patchwork.ozlabs.org; Fri, 04 Feb 2011 03:07:07 -0500 Received: from [140.186.70.92] (port=49447 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PlGfF-0003l6-GS for qemu-devel@nongnu.org; Fri, 04 Feb 2011 03:05:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PlGfD-0001lz-SE for qemu-devel@nongnu.org; Fri, 04 Feb 2011 03:05:09 -0500 Received: from smtp5-g21.free.fr ([212.27.42.5]:51940) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PlGfD-0001lV-7W for qemu-devel@nongnu.org; Fri, 04 Feb 2011 03:05:07 -0500 Received: from localhost.localdomain (unknown [82.241.209.44]) by smtp5-g21.free.fr (Postfix) with ESMTP id C77B9D4828D; Fri, 4 Feb 2011 09:05:01 +0100 (CET) From: Corentin Chary To: Anthony Liguori Date: Fri, 4 Feb 2011 09:06:00 +0100 Message-Id: <1296806768-27787-9-git-send-email-corentincj@iksaif.net> X-Mailer: git-send-email 1.7.4 In-Reply-To: <1296806768-27787-1-git-send-email-corentincj@iksaif.net> References: <1296806768-27787-1-git-send-email-corentincj@iksaif.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 212.27.42.5 Cc: Corentin Chary , Andre Przywara , Qemu-development List , Alexander Graf Subject: [Qemu-devel] [PATCH v3 08/16] 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 | 32 ++++++++++++++++++++++++++++++++ ui/vnc-palette.h | 3 +++ 2 files changed, 35 insertions(+), 0 deletions(-) diff --git a/ui/vnc-palette.c b/ui/vnc-palette.c index f93250b..c478060 100644 --- a/ui/vnc-palette.c +++ b/ui/vnc-palette.c @@ -126,3 +126,35 @@ 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 */