root / ui / vnc-palette.h @ 0e326109
History | View | Annotate | Download (2.5 kB)
1 | 5136a052 | Corentin Chary | /*
|
---|---|---|---|
2 | 5136a052 | Corentin Chary | * QEMU VNC display driver: palette hash table
|
3 | 5136a052 | Corentin Chary | *
|
4 | 5136a052 | Corentin Chary | * From libvncserver/libvncserver/tight.c
|
5 | 5136a052 | Corentin Chary | * Copyright (C) 2000, 2001 Const Kaplinsky. All Rights Reserved.
|
6 | 5136a052 | Corentin Chary | * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
|
7 | 5136a052 | Corentin Chary | *
|
8 | 5136a052 | Corentin Chary | * Copyright (C) 2010 Corentin Chary <corentin.chary@gmail.com>
|
9 | 5136a052 | Corentin Chary | *
|
10 | 5136a052 | Corentin Chary | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
11 | 5136a052 | Corentin Chary | * of this software and associated documentation files (the "Software"), to deal
|
12 | 5136a052 | Corentin Chary | * in the Software without restriction, including without limitation the rights
|
13 | 5136a052 | Corentin Chary | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
14 | 5136a052 | Corentin Chary | * copies of the Software, and to permit persons to whom the Software is
|
15 | 5136a052 | Corentin Chary | * furnished to do so, subject to the following conditions:
|
16 | 5136a052 | Corentin Chary | *
|
17 | 5136a052 | Corentin Chary | * The above copyright notice and this permission notice shall be included in
|
18 | 5136a052 | Corentin Chary | * all copies or substantial portions of the Software.
|
19 | 5136a052 | Corentin Chary | *
|
20 | 5136a052 | Corentin Chary | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
21 | 5136a052 | Corentin Chary | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
22 | 5136a052 | Corentin Chary | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
23 | 5136a052 | Corentin Chary | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
24 | 5136a052 | Corentin Chary | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
25 | 5136a052 | Corentin Chary | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
26 | 5136a052 | Corentin Chary | * THE SOFTWARE.
|
27 | 5136a052 | Corentin Chary | */
|
28 | 5136a052 | Corentin Chary | |
29 | 5136a052 | Corentin Chary | #ifndef VNC_PALETTE_H
|
30 | 5136a052 | Corentin Chary | #define VNC_PALETTE_H
|
31 | 5136a052 | Corentin Chary | |
32 | 5136a052 | Corentin Chary | #include "qlist.h" |
33 | 5136a052 | Corentin Chary | #include "qemu-queue.h" |
34 | 5136a052 | Corentin Chary | #include <stdint.h> |
35 | 5136a052 | Corentin Chary | |
36 | 5136a052 | Corentin Chary | #define VNC_PALETTE_HASH_SIZE 256 |
37 | e31e3694 | Corentin Chary | #define VNC_PALETTE_MAX_SIZE 256 |
38 | 5136a052 | Corentin Chary | |
39 | 5136a052 | Corentin Chary | typedef struct VncPaletteEntry { |
40 | 5136a052 | Corentin Chary | int idx;
|
41 | 5136a052 | Corentin Chary | uint32_t color; |
42 | 5136a052 | Corentin Chary | QLIST_ENTRY(VncPaletteEntry) next; |
43 | 5136a052 | Corentin Chary | } VncPaletteEntry; |
44 | 5136a052 | Corentin Chary | |
45 | 5136a052 | Corentin Chary | typedef struct VncPalette { |
46 | e31e3694 | Corentin Chary | VncPaletteEntry pool[VNC_PALETTE_MAX_SIZE]; |
47 | 5136a052 | Corentin Chary | size_t size; |
48 | 5136a052 | Corentin Chary | size_t max; |
49 | 5136a052 | Corentin Chary | int bpp;
|
50 | 5136a052 | Corentin Chary | QLIST_HEAD(,VncPaletteEntry) table[VNC_PALETTE_HASH_SIZE]; |
51 | 5136a052 | Corentin Chary | } VncPalette; |
52 | 5136a052 | Corentin Chary | |
53 | 5136a052 | Corentin Chary | VncPalette *palette_new(size_t max, int bpp);
|
54 | 72aefb76 | Corentin Chary | void palette_init(VncPalette *palette, size_t max, int bpp); |
55 | 5136a052 | Corentin Chary | void palette_destroy(VncPalette *palette);
|
56 | 5136a052 | Corentin Chary | |
57 | 5136a052 | Corentin Chary | int palette_put(VncPalette *palette, uint32_t color);
|
58 | 5136a052 | Corentin Chary | int palette_idx(const VncPalette *palette, uint32_t color); |
59 | 5136a052 | Corentin Chary | size_t palette_size(const VncPalette *palette);
|
60 | 5136a052 | Corentin Chary | |
61 | 5136a052 | Corentin Chary | void palette_iter(const VncPalette *palette, |
62 | 5136a052 | Corentin Chary | void (*iter)(int idx, uint32_t color, void *opaque), |
63 | 5136a052 | Corentin Chary | void *opaque);
|
64 | f8562e32 | Corentin Chary | uint32_t palette_color(const VncPalette *palette, int idx, bool *found); |
65 | f8562e32 | Corentin Chary | size_t palette_fill(const VncPalette *palette,
|
66 | f8562e32 | Corentin Chary | uint32_t colors[VNC_PALETTE_MAX_SIZE]); |
67 | 5136a052 | Corentin Chary | |
68 | 5136a052 | Corentin Chary | #endif /* VNC_PALETTE_H */ |