]> git.ipfire.org Git - thirdparty/cups.git/blob - pstoraster/gdev8bcm.h
Import cups.org releases
[thirdparty/cups.git] / pstoraster / gdev8bcm.h
1 /* Copyright (C) 1994 Aladdin Enterprises. All rights reserved.
2
3 This file is part of GNU Ghostscript.
4
5 GNU Ghostscript is distributed in the hope that it will be useful, but
6 WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
7 to anyone for the consequences of using it or for whether it serves any
8 particular purpose or works at all, unless he says so in writing. Refer
9 to the GNU General Public License for full details.
10
11 Everyone is granted permission to copy, modify and redistribute GNU
12 Ghostscript, but only under the conditions described in the GNU General
13 Public License. A copy of this license is supposed to have been given
14 to you along with GNU Ghostscript so you can know your rights and
15 responsibilities. It should be in a file named COPYING. Among other
16 things, the copyright notice and this notice must be preserved on all
17 copies.
18
19 Aladdin Enterprises supports the work of the GNU Project, but is not
20 affiliated with the Free Software Foundation or the GNU Project. GNU
21 Ghostscript, as distributed by Aladdin Enterprises, does not require any
22 GNU software to build or run it.
23 */
24
25 /*$Id$ */
26 /* Requires gxdevice.h (for gx_color_value) */
27
28 #ifndef gdev8bcm_INCLUDED
29 # define gdev8bcm_INCLUDED
30
31 /*
32 * The MS-DOS, MS Windows, and X Windows drivers all use (at least on
33 * some platforms) an 8-bit color map in which some fraction is reserved
34 * for a pre-allocated cube and some or all of the remainder is
35 * allocated dynamically. Since looking up colors in this map can be
36 * a major performance bottleneck, we provide an efficient implementation
37 * that can be shared among drivers.
38 *
39 * As a performance compromise, we only look up the top 5 bits of the
40 * RGB value in the color map. This compromises color quality very little,
41 * and allows substantial optimizations.
42 */
43
44 #define gx_8bit_map_size 323
45 #define gx_8bit_map_spreader 123 /* approx. 323 - (1.618 * 323) */
46 typedef struct gx_8bit_map_entry_s {
47 ushort rgb; /* key = 0rrrrrgggggbbbbb */
48 #define gx_8bit_no_rgb ((ushort)0xffff)
49 #define gx_8bit_rgb_key(r, g, b)\
50 (((r >> (gx_color_value_bits - 5)) << 10) +\
51 ((g >> (gx_color_value_bits - 5)) << 5) +\
52 (b >> (gx_color_value_bits - 5)))
53 short index; /* value */
54 } gx_8bit_map_entry;
55 typedef struct gx_8bit_color_map_s {
56 int count; /* # of occupied entries */
57 int max_count; /* max # of occupied entries */
58 gx_8bit_map_entry map[gx_8bit_map_size + 1];
59 } gx_8bit_color_map;
60
61 /* Initialize an 8-bit color map. */
62 void gx_8bit_map_init(P2(gx_8bit_color_map *, int));
63
64 /* Look up a color in an 8-bit color map. */
65 /* Return -1 if not found. */
66 int gx_8bit_map_rgb_color(P4(const gx_8bit_color_map *, gx_color_value,
67 gx_color_value, gx_color_value));
68
69 /* Test whether an 8-bit color map has room for more entries. */
70 #define gx_8bit_map_is_full(pcm)\
71 ((pcm)->count == (pcm)->max_count)
72
73 /* Add a color to an 8-bit color map. */
74 /* Return -1 if the map is full. */
75 int gx_8bit_add_rgb_color(P4(gx_8bit_color_map *, gx_color_value,
76 gx_color_value, gx_color_value));
77
78 #endif /* gdev8bcm_INCLUDED */