1
/* $Xorg: miClrApLUT.c,v 1.4 2001/02/09 02:04:12 xorgcvs Exp $ */
4
Copyright 1990, 1991, 1998 The Open Group
6
Permission to use, copy, modify, distribute, and sell this software and its
7
documentation for any purpose is hereby granted without fee, provided that
8
the above copyright notice appear in all copies and that both that
9
copyright notice and this permission notice appear in supporting
12
The above copyright notice and this permission notice shall be included
13
in all copies or substantial portions of the Software.
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
19
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21
OTHER DEALINGS IN THE SOFTWARE.
23
Except as contained in this notice, the name of The Open Group shall
24
not be used in advertising or otherwise to promote the sale, use or
25
other dealings in this Software without prior written authorization
29
Copyright 1990, 1991 by Sun Microsystems, Inc.
32
Permission to use, copy, modify, and distribute this software and its
33
documentation for any purpose and without fee is hereby granted,
34
provided that the above copyright notice appear in all copies and that
35
both that copyright notice and this permission notice appear in
36
supporting documentation, and that the name of Sun Microsystems
37
not be used in advertising or publicity pertaining to distribution
38
of the software without specific, written prior permission.
40
SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
41
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
42
SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
43
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
49
/* $XFree86: xc/programs/Xserver/PEX5/ddpex/mi/shared/miClrApLUT.c,v 1.9 2001/12/14 19:57:37 dawes Exp $ */
55
#include "PEXprotost.h"
59
/* Level 4 Shared Resources */
60
/* Lookup Table Procedures */
62
/* definitions used by miLUTProcs.ci */
63
#define LUT_TYPE PEXColourApproxLUT
65
/* devPriv data structure */
66
#define DD_LUT_ENTRY_STR ddColourApproxEntry
67
/* table entry data structure */
68
#define MI_LUT_ENTRY_STR miColourApproxEntry
70
#define PEX_LUT_ENTRY_STR pexColourApproxEntry
72
#define LUT_REND_DYN_BIT PEXDynColourApproxContents
74
#define LUT_START_INDEX 0
75
#define LUT_DEFAULT_INDEX 0
76
#define LUT_0_DEFINABLE_ENTRIES 6
77
#define LUT_0_NUM_PREDEFINED 0
78
#define LUT_0_PREDEFINED_MIN 0
79
#define LUT_0_PREDEFINED_MAX 0
81
#define LUT_TABLE_START(pheader) (pheader)->plut.colourApprox
83
#define DYNAMIC COLOUR_APPROX_TABLE_DYNAMIC
85
/* predefined entries table: change this to work with your devPriv data */
86
/* there are no predefined entries, but define 1 entry for default */
87
static DD_LUT_ENTRY_STR pdeColourApproxEntry[1];
88
#define LUT_PDE_ENTRIES pdeColourApproxEntry[0]
89
#define LUT_SET_PDE_ENTRY(pentry, pdeentry) \
90
(pentry)->entry = *(pdeentry)
92
/* predefined entry 0 is set to the default values
93
* change the XXX_DEFAULT_YYY macros below to use something else
94
* if you don't want the default values defined in the pde table
96
#define PDE_DEFAULT_ENTRY_NUM 0
97
#define LUT_DEFAULT_VALUES pdeColourApproxEntry[PDE_DEFAULT_ENTRY_NUM]
98
#define LUT_SET_DEFAULT_VALUES(pentry) \
99
(pentry)->entry = LUT_DEFAULT_VALUES
101
/* which procedure definitions in miLUTProcs.h to use and their names
102
* take out USE flags if you're defining those procs in here
103
* but leave the name definitions
107
#define LUT_USE_INQ_PREDEF
108
#define LUT_USE_INQ_ENTRIES
110
#define LUT_USE_INQ_INFO
111
#define LUT_USE_INQ_IND
112
#define LUT_USE_INQ_ENTRY
113
#define LUT_USE_SET_ENTRIES
114
#define LUT_USE_DEL_ENTRIES
115
#define LUT_USE_INQ_ENTRY_ADDRESS
116
#define LUT_USE_CREATE
117
#define LUT_USE_MOD_CALL_BACK
119
/* these three are redefined in miLUTProcs.h
120
#define LUT_FREE ColourApproxLUT_free
121
#define LUT_INQ_PREDEF ColourApproxLUT_inq_predef
122
#define LUT_INQ_ENTRIES ColourApproxLUT_inq_entries
124
#define LUT_COPY ColourApproxLUT_copy
125
#define LUT_INQ_INFO ColourApproxLUT_inq_info
126
#define LUT_INQ_IND ColourApproxLUT_inq_ind
127
#define LUT_INQ_ENTRY ColourApproxLUT_inq_entry
128
#define LUT_SET_ENTRIES ColourApproxLUT_set_entries
129
#define LUT_DEL_ENTRIES ColourApproxLUT_del_entries
130
#define LUT_INQ_ENTRY_ADDRESS ColourApproxLUT_inq_entry_address
131
#define LUT_CREATE ColourApproxLUT_create
132
#define LUT_ENTRY_CHECK ColourApproxLUT_entry_check
133
#define LUT_COPY_PEX_MI ColourApproxLUT_copy_pex_to_mi
134
#define LUT_COPY_MI_PEX ColourApproxLUT_copy_mi_to_pex
135
#define LUT_MOD_CALL_BACK ColourApproxLUT_mod_call_back
137
/* copy from an mi entry to a pex entry and increment ppbuf */
139
LUT_COPY_MI_PEX( pheader, valueType, pentry, ppbuf )
140
miLUTHeader *pheader;
142
MI_LUT_ENTRY_STR *pentry;
146
mibcopy(&(LUT_DEFAULT_VALUES), *ppbuf, sizeof(PEX_LUT_ENTRY_STR));
147
else if (pentry->entry_info.status == MILUT_UNDEFINED)
148
mibcopy(&(LUT_DEFAULT_VALUES), *ppbuf, sizeof(PEX_LUT_ENTRY_STR));
150
mibcopy(&pentry->entry, *ppbuf, sizeof(PEX_LUT_ENTRY_STR));
152
*ppbuf += sizeof(PEX_LUT_ENTRY_STR);
157
/* copy from a pex entry to an mi entry and increment ppsrc */
159
LUT_COPY_PEX_MI( pheader, ppsrc, pentry )
160
miLUTHeader *pheader;
162
MI_LUT_ENTRY_STR *pentry;
164
mibcopy(*ppsrc, &(pentry->entry), sizeof(PEX_LUT_ENTRY_STR));
165
*ppsrc += sizeof(PEX_LUT_ENTRY_STR);
170
/* check for bad values and increment ppPexEntry */
173
LUT_ENTRY_CHECK (pheader, ppPexEntry)
174
miLUTHeader *pheader;
175
PEX_LUT_ENTRY_STR **ppPexEntry;
177
extern miEnumType miColourApproxTypeET[][SI_CLR_APPROX_TYPE_NUM];
178
extern miEnumType miColourApproxModelET[][SI_CLR_APPROX_MODEL_NUM];
180
if (((*ppPexEntry)->approxType < miColourApproxTypeET[pheader->drawType][0].index) ||
181
((*ppPexEntry)->approxType > miColourApproxTypeET[pheader->drawType][SI_CLR_APPROX_TYPE_NUM - 1].index))
183
if (((*ppPexEntry)->approxModel < miColourApproxModelET[pheader->drawType][0].index) ||
184
((*ppPexEntry)->approxModel > miColourApproxModelET[pheader->drawType][SI_CLR_APPROX_MODEL_NUM - 1].index))
186
if (((*ppPexEntry)->dither != PEXOff) && ((*ppPexEntry)->dither != PEXOn))
194
ColourApproxLUT_init_pde()
196
/* Having default values for this makes absolutely no sense.
197
* There is no way for this to know what colors are defined in
198
* the coloramp, and therefor no way to know how to map to them.
199
* This is provided only because something has to be done, but
200
* the likelyhood of this turning out correct colors is small.
201
* The client side MUST set at least one entry in this table
202
* for correct functionality.
203
* These are the sample values in the protocol spec.
204
* They assume a 6x6x6 color cube beginning at location 16.
206
pdeColourApproxEntry [0].approxType = PEXColourSpace;
207
pdeColourApproxEntry [0].approxModel = PEXColourApproxRGB;
208
pdeColourApproxEntry [0].max1 = 5;
209
pdeColourApproxEntry [0].max2 = 5;
210
pdeColourApproxEntry [0].max3 = 5;
211
pdeColourApproxEntry [0].dither = PEXOff;
212
pdeColourApproxEntry [0].mult1 = 1;
213
pdeColourApproxEntry [0].mult2 = 6;
214
pdeColourApproxEntry [0].mult3 = 36;
215
pdeColourApproxEntry [0].weight1 = 1.0;
216
pdeColourApproxEntry [0].weight2 = 1.0;
217
pdeColourApproxEntry [0].weight3 = 1.0;
218
pdeColourApproxEntry [0].basePixel = 16;
221
#include "miLUTProcs.ci"