1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
4
This software is provided AS-IS with no warranty, either express or
7
This software is distributed under license and may not be copied, modified
8
or distributed except as expressly authorized under the terms of that
9
license. Refer to licensing information at http://www.artifex.com/
10
or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
11
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
14
/* $Id: gdevxcmp.h 8022 2007-06-05 22:23:38Z giles $ */
15
/* X driver color mapping structure */
17
#ifndef gdevxcmp_INCLUDED
18
# define gdevxcmp_INCLUDED
21
* The structure defined in this file is used in only one place, in the
22
* gx_device_X structure defined in gdevx.h. We define it as a separate
23
* structure because its function is logically separate from the rest of the
24
* X driver, and because this function (color mapping / management) accounts
25
* for the single largest piece of the driver.
28
/* Define pixel value to RGB mapping */
29
typedef struct x11_rgb_s {
30
gx_color_value rgb[3];
34
/* Define dynamic color hash table structure */
35
typedef struct x11_color_s x11_color_t;
42
* Define X color values. Fortuitously, these are the same as Ghostscript
43
* color values; in gdevxcmp.c, we are pretty sloppy about aliasing the
46
typedef ushort X_color_value;
47
#define X_max_color_value 0xffff
49
#if HaveStdCMap /* Standard colormap stuff is only in X11R4 and later. */
51
/* Define the structure for values computed from a standard cmap component. */
52
typedef struct x11_cmap_values_s {
53
int cv_shift; /* 16 - log2(max_value + 1) */
54
X_color_value nearest[64]; /* [i] = i * 0xffff / max_value */
55
int pixel_shift; /* log2(mult) */
60
typedef struct x11_cman_s {
63
* num_rgb is the number of possible R/G/B values, i.e.,
64
* 1 << the bits_per_rgb of the X visual.
69
* color_mask is a mask that selects the high-order N bits of an
70
* X color value, where N may be the mask width for TrueColor or
71
* StaticGray and is bits_per_rgb for the other visual classes.
73
* match_mask is the mask used for comparing colors. It may have
74
* fewer bits than color_mask if the device is not using halftones.
77
X_color_value red, green, blue;
78
} color_mask, match_mask;
80
#if HaveStdCMap /* Standard colormap stuff is only in X11R4 and later. */
85
* map is the X standard colormap for the display and screen,
86
* if one is available.
88
XStandardColormap *map;
91
* When possible, we precompute shift values and tables that replace
92
* some multiplies and divides.
95
x11_cmap_values_t red, green, blue;
98
* If free_map is true, we allocated the map ourselves (to
99
* represent a TrueColor or Static Gray visual), and must free it
100
* when closing the device.
106
#endif /* HaveStdCmap */
109
* color_to_rgb is a reverse map from pixel values to RGB values. It
110
* only maps pixels values up to 255: pixel values above this must go
111
* through the standard colormap or query the server.
114
int size; /* min(1 << depth, 256) */
115
x11_rgb_t *values; /* [color_to_rgb.size] */
119
* For systems with writable colormaps and no suitable standard
120
* colormap, dither_ramp is a preallocated ramp or cube used for
123
#define CUBE_INDEX(r,g,b) (((r) * xdev->color_info.dither_colors + (g)) * \
124
xdev->color_info.dither_colors + (b))
125
x_pixel *dither_ramp; /* [color_info.dither_colors^3] if color,
126
[color_info.dither_grays] if gray */
129
* For systems with writable colormaps, dynamic.colors is a chained
130
* hash table that maps RGB values (masked with color_mask) to
131
* pixel values. Entries are added dynamically.
135
x11_color_t **colors; /* [size] */
136
int shift; /* 16 - log2(size) */
143
#endif /* gdevxcmp_INCLUDED */