From f8562e326bb8bf084b7519a53c6f30627b80ac1e Mon Sep 17 00:00:00 2001 From: Corentin Chary Date: Fri, 4 Feb 2011 09:06:00 +0100 Subject: vnc: palette: and fill and color calls. These two helpers are needed for zrle and zywrle. Signed-off-by: Corentin Chary Signed-off-by: Anthony Liguori --- ui/vnc-palette.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'ui/vnc-palette.c') diff --git a/ui/vnc-palette.c b/ui/vnc-palette.c index f93250b18..c47806086 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); +} -- cgit v1.2.3