1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
|
/* $XConsortium: mipex.h,v 5.4 93/09/03 14:57:01 hersh Exp $ */
/***********************************************************
Copyright (c) 1989, 1990, 1991 X Consortium
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the X Consortium shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the X Consortium.
Copyright (c) 1989, 1990, 1991 by Sun Microsystems, Inc.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Sun Microsystems,
and the X Consortium, not be used in advertising or publicity
pertaining to distribution of the software without specific, written
prior permission.
SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
#ifndef MI_H
#define MI_H
#include "ddpex.h"
#include "X.h"
#include "scrnintstr.h"
#define MI_TRUE 1
#define MI_FALSE 0
#define MI_MAXUSHORT 65535 /* max value for unsigned short int: 2**16 */
#define MI_PI 3.14159265358979323846 /* from values.h */
#define MI_FIRSTTABLETYPE 1 /* a useful constant that's not in PEX.h */
#define MI_BACKGROUND 0
#define MI_FOREGROUND 1
/* high bit mask for proprietary OCs */
#define MI_OC_HIGHBIT 0x8000
/* a redefinable location for use in branching on proprietary OCs */
#define MI_OC_PROP 0
/* see if propietary bit is set in OC Type */
#define MI_HIGHBIT_ON(octype) ((octype) & MI_OC_HIGHBIT)
/* see if OC Type (or element) is in range of PEX OCs */
#define MI_IS_PEX_OC(octype) (((octype) > PEXOCAll) && ((octype) <= PEXMaxOC))
/** redefine ASSURE even if it's already defined **/
#ifdef ASSURE
#undef ASSURE
#endif
typedef void (*destroyTableType)();
#ifdef DDTEST
#define ASSURE(test) \
if (!(test)) { \
ErrorF( "test \n"); \
ErrorF( "Failed: Line %d, File %s\n\n", __LINE__, __FILE__); \
}
#else
#define ASSURE(test)
#endif /* DDTEST */
/* the WHICDRAW macro looks at the given drawable and determines which
* of the suported drawable types it matches
* WHICHDRAW should compare the data in the given drawable with the
* drawable types defined here to define a impe dep drawable type id
* For now, only one drawable type is supported and it
* handles all drawables.
*/
#define MI_MAXDRAWABLES 1
/* type depth rootDepth rootVisual */
#define MI_DRAWABLE0 0/*ANY ANY ANY ANY */
#define MI_SETDRAWEXAMPLE( pdraw, peg ) \
(peg)->type = (pdraw)->type; \
(peg)->class = (pdraw)->class; \
(peg)->depth = (pdraw)->depth; \
(peg)->bitsPerPixel = (pdraw)->bitsPerPixel; \
(peg)->rootDepth = (pdraw)->pScreen->rootDepth; \
(peg)->rootVisual = (pdraw)->pScreen->rootVisual
#define MI_WHICHDRAW( pdraw, type ) \
type = MI_DRAWABLE0
/* dd internal error codes */
#define MI_SUCCESS 0
#define MI_ALLOCERR 1
#define MI_EXISTERR 2
#define MI_DEFAULT_COLOUR_FORMAT PEXRgbFloatColour
/* only do indexed & rgb floats now */
#define MI_BADCOLOURTYPE( format ) \
( (format!=PEXIndexedColour) && \
(format!=PEXRgbFloatColour) ) /* && \
(format!=PEXCieFloatColour) && \
(format!=PEXHsvFloatColour) && \
(format!=PEXHlsFloatColour) && \
(format!=PEXRgbInt8Colour) && \
(format!=PEXRgbInt16Colour) )
*/
/* JSH - assuming copy may overlap */
#define mibcopy(pfrom, pto, size) \
memmove( (char *)(pto), (char *)(pfrom), (int)(size))
extern int PexErrorBase;
#define PEXERR( pexerrnum ) (pexerrnum) + PexErrorBase
#ifndef ABS
#define ABS(x) ((x) < 0 ? -(x) : (x))
#endif
#define MI_ZERO_TOLERANCE 1.0e-30
#define MI_NEAR_ZERO( s ) (ABS(s) < MI_ZERO_TOLERANCE)
#define MI_ZERO_MAG( s ) ((s) < MI_ZERO_TOLERANCE)
#define MI_MAT_IDENTITY( mat, dim ) \
{ register int i,j; \
for (i=0; i<dim; i++) \
for (j=0; j<dim; j++) \
(mat)[i][j] = ( (i==j) ? 1.0 : 0.0 ); \
}
typedef struct {
ddEnumTypeIndex index;
char *name;
} miEnumType;
typedef enum {
VIEW_REP_DYNAMIC=0,
MARKER_BUNDLE_DYNAMIC=1,
TEXT_BUNDLE_DYNAMIC=2,
LINE_BUNDLE_DYNAMIC=3,
INTERIOR_BUNDLE_DYNAMIC=4,
EDGE_BUNDLE_DYNAMIC=5,
COLOUR_TABLE_DYNAMIC=6,
PATTERN_TABLE_DYNAMIC=7,
WKS_TRANSFORM_DYNAMIC=8,
HIGH_FILTER_DYNAMIC=9,
INVIS_FILTER_DYNAMIC=10,
HLHSR_MODE_DYNAMIC=11,
STR_MODIFY_DYNAMIC=12,
POST_STR_DYNAMIC=13,
UNPOST_STR_DYNAMIC=14,
DELETE_STR_DYNAMIC=15,
REF_MODIFY_DYNAMIC=16,
BUFFER_MODIFY_DYNAMIC=17,
LIGHT_TABLE_DYNAMIC=18,
DEPTH_CUE_DYNAMIC=19,
COLOUR_APPROX_TABLE_DYNAMIC=20,
MAX_DYNAMIC = 21
} ddDynamic;
#ifdef DDTEST
#define PRINTOC( ptr ) { \
ddUSHORT elType, length; \
\
elType = ((pexElementInfo *)ptr)->elementType; \
length = ((pexElementInfo *)ptr)->length; \
\
ErrorF("Element Type: %3d - %s Length: %d\n", \
elType, ocNames[elType], length ); \
}
#else /* DDTEST */
#define PRINTOC( ptr )
#endif
/* dd clip routine status returns */
#define MI_CLIP_LEFT (1<<0)
#define MI_CLIP_TOP (1<<2)
#define MI_CLIP_RIGHT (1<<1)
#define MI_CLIP_BOTTOM (1<<3)
#define MI_CLIP_FRONT (1<<4)
#define MI_CLIP_BACK (1<<5)
#define MI_CLIP_TRIVIAL_ACCEPT 0
#define MI_CLIP_POINT_1 1
#define MI_CLIP_POINT_2 2
#define MI_CLIP_TRIVIAL_REJECT 4
/*
* Memory management macros for use with data lists in static ddcontext
*/
/*
* MI_ROUND_LISTHEADERCOUNT is used by the clip routines to round up the
* header block count by 16 - in other words to allocated headerblocks
* in increment of 16 and thus reduce calls to Xrealloc.
* Note that this doesn't work for beans w/ negative numbers (although
* allocating a negative number of header blocks doesn't work well either!).
*/
#define MI_ROUND_LISTHEADERCOUNT(val) (((val) + 15) & ~15)
/*
* MI_ALLOCLISTHEADER insures that there are numlists headers in the
* header array. It also returns either a pointer to the base of the
* new header array, or 0 in the event of an Xrealloc error.
*/
#define MI_ALLOCLISTHEADER(list, numlists) \
if ((list)->maxLists < (numlists)) { \
int i; \
listofddPoint *listptr; \
if ((list)->maxLists) \
(list)->ddList = \
(listofddPoint *)xrealloc((list)->ddList, \
(numlists)*sizeof(listofddPoint)); \
else \
(list)->ddList = \
(listofddPoint *)xalloc((numlists)*sizeof(listofddPoint)); \
listptr = &(list)->ddList[(list)->maxLists]; \
for (i = (list)->maxLists; i < (numlists); i++) { \
listptr->numPoints = listptr->maxData = 0; \
(listptr++)->pts.p2Dpt = 0; \
} \
(list)->maxLists=(numlists); \
}
/*
* MI_FREELISTHEADER Xfree's all allocated data associated with
* a ListHeader data structure.
*/
#define MI_FREELISTHEADER(list) \
if ((list)->maxLists) \
{ \
ddULONG maxlists = (list)->maxLists; \
listofddPoint *listptr = (list)->ddList; \
int mi_freelistheader_counter; \
for (mi_freelistheader_counter = 0; \
mi_freelistheader_counter < maxlists; \
mi_freelistheader_counter++) { \
if (listptr->maxData) xfree(listptr->pts.p2Dpt); \
listptr++; \
} \
xfree((list)->ddList); \
(list)->maxLists = 0; \
}
/*
* MI_ALLOCLISTOFDDPOINT insures that there are numpoints in the
* vertex array of type type. It also returns either a pointer
* to the base of the new data array, or 0 in the event of
* an Xrealloc error.
*/
#define MI_ALLOCLISTOFDDPOINT(buff, numpoints, bytes_per_vert) \
if ((buff)->maxData) { \
if ((buff)->maxData < (numpoints)*bytes_per_vert) { \
(buff)->maxData = (numpoints) * bytes_per_vert; \
(buff)->pts.p2Dpt=(ddCoord2D *)xrealloc((buff)->pts.p2Dpt, \
(buff)->maxData); \
} \
} else { \
(buff)->maxData = (numpoints) * bytes_per_vert; \
(buff)->pts.p2Dpt=(ddCoord2D *)xalloc((buff)->maxData); \
}
/*
* MI_FREELISTOFDDPOINT frees the data area associated with
* the specified list header.
* It also sets the list pointer to 0, and the max data count to 0.
*/
#define MI_FREELISTOFDDPOINT(buff, numpoints, bytes_per_vert) \
if (buff) \
{ \
xfree((buff)->pts.p2Dpt); \
(buff)->pts.p2Dpt = 0; \
(buff)->maxData = 0; \
}
/*
* Memory management macros for use with facet lists in static ddcontext
*/
/*
* MI_ALLOCLISTOFDDFACET insures that there are numfacets in the
* facet array of type type. It also returns either a pointer
* to the base of the new data array, or 0 in the event of
* an Xrealloc error.
*/
#define MI_ALLOCLISTOFDDFACET(buff, numfacets, bytes_per_facet) \
if ((buff)->maxData) { \
if ((buff)->maxData < (numfacets)*bytes_per_facet) { \
(buff)->maxData = (numfacets) * bytes_per_facet; \
(buff)->facets.pFacetRgbFloatN = \
(ddRgbFloatNormal *)xrealloc((buff)->facets.pFacetRgbFloatN, \
(buff)->maxData); \
} \
} else { \
(buff)->maxData = (numfacets) * bytes_per_facet; \
(buff)->facets.pFacetRgbFloatN = \
(ddRgbFloatNormal *)xalloc((buff)->maxData); \
}
/*
* MI_FREELISTOFDDFACET frees the data area associated with
* the specified facet list.
* It also sets the list pointer to 0, and the max data count to 0.
*/
#define MI_FREELISTOFDDFACET(buff) \
if (buff) \
{ \
xfree((buff)->pts.p2Dpt); \
(buff)->facets.pFacetRgbFloatN = 0; \
(buff)->maxData = 0; \
}
/* bit handling macros for renderer dynamics change flags */
#define MI_SET_ALL_CHANGES(prend) \
prend->tablesChanges = ~0; \
prend->namesetsChanges = ~0; \
prend->attrsChanges = ~0
#define MI_ZERO_ALL_CHANGES(prend) \
prend->tablesChanges = 0; \
prend->namesetsChanges = 0; \
prend->attrsChanges = 0
/* Inverse transform validation routines */
#define VALIDATEINVTRMCTOWCXFRM(pddc) \
if (pddc->Static.misc.flags & INVTRMCTOWCXFRMFLAG) { \
miMatCopy(pddc->Dynamic->mc_to_wc_xform, \
pddc->Static.misc.inv_tr_mc_to_wc_xform); \
miMatInverseTranspose(pddc->Static.misc.inv_tr_mc_to_wc_xform);\
pddc->Static.misc.flags &= ~INVTRMCTOWCXFRMFLAG; \
}
#define VALIDATEINVTRWCTOCCXFRM(pddc) \
if (pddc->Static.misc.flags & INVTRWCTOCCXFRMFLAG) { \
miMatCopy(pddc->Dynamic->wc_to_cc_xform, \
pddc->Static.misc.inv_tr_wc_to_cc_xform); \
miMatInverseTranspose(pddc->Static.misc.inv_tr_wc_to_cc_xform);\
pddc->Static.misc.flags &= ~INVTRWCTOCCXFRMFLAG; \
}
#define VALIDATEINVTRMCTOCCXFRM(pddc) \
if (pddc->Static.misc.flags & INVTRMCTOCCXFRMFLAG) { \
miMatCopy(pddc->Dynamic->mc_to_cc_xform, \
pddc->Static.misc.inv_tr_mc_to_cc_xform); \
miMatInverseTranspose(pddc->Static.misc.inv_tr_mc_to_cc_xform);\
pddc->Static.misc.flags &= ~INVTRMCTOCCXFRMFLAG; \
}
#define VALIDATEINVTRCCTODCXFRM(pddc) \
if (pddc->Static.misc.flags & INVTRCCTODCXFRMFLAG) { \
miMatCopy(pddc->Dynamic->cc_to_dc_xform, \
pddc->Static.misc.inv_tr_cc_to_dc_xform); \
miMatInverseTranspose(pddc->Static.misc.inv_tr_cc_to_dc_xform);\
pddc->Static.misc.flags &= ~INVTRCCTODCXFRMFLAG; \
}
#endif /* MI_H */
|