From patchwork Thu Nov 11 16:56:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Chary X-Patchwork-Id: 70830 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 EB92AB713A for ; Fri, 12 Nov 2010 03:58:45 +1100 (EST) Received: from localhost ([127.0.0.1]:55311 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PGaTx-00007v-Px for incoming@patchwork.ozlabs.org; Thu, 11 Nov 2010 11:58:41 -0500 Received: from [140.186.70.92] (port=52119 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PGaSY-00005C-SG for qemu-devel@nongnu.org; Thu, 11 Nov 2010 11:57:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PGaSX-0005Zv-21 for qemu-devel@nongnu.org; Thu, 11 Nov 2010 11:57:14 -0500 Received: from relay2-v.mail.gandi.net ([217.70.178.76]:43528) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PGaSW-0005Ze-Qh for qemu-devel@nongnu.org; Thu, 11 Nov 2010 11:57:13 -0500 X-Originating-IP: 217.70.178.41 Received: from mfilter1-d.gandi.net (mfilter1-d.gandi.net [217.70.178.41]) by relay2-v.mail.gandi.net (Postfix) with ESMTP id 16DAD135E3; Thu, 11 Nov 2010 17:57:12 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at gandi.net Received: from relay2-v.mail.gandi.net ([217.70.178.76]) by mfilter1-d.gandi.net (mfilter1-d.gandi.net [217.70.178.41]) (amavisd-new, port 10024) with ESMTP id XDJaNmbRrEJn; Thu, 11 Nov 2010 17:57:09 +0100 (CET) X-Originating-IP: 82.241.209.44 Received: from localhost.localdomain (falgoret.iksaif.net [82.241.209.44]) (Authenticated sender: fake@iksaif.net) by relay2-v.mail.gandi.net (Postfix) with ESMTPSA id 64E6B135E2; Thu, 11 Nov 2010 17:57:07 +0100 (CET) From: Corentin Chary To: Qemu-development List Date: Thu, 11 Nov 2010 17:56:56 +0100 Message-Id: <1289494624-12807-8-git-send-email-corentincj@iksaif.net> X-Mailer: git-send-email 1.7.3.2 In-Reply-To: <1289494624-12807-1-git-send-email-corentincj@iksaif.net> References: <1289494624-12807-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 v2 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 */