1 /* $XConsortium: miline.h /main/6 1996/08/12 21:51:09 dpw $ */
5 Copyright (c) 1994 X Consortium
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 Except as contained in this notice, the name of the X Consortium shall not be
25 used in advertising or otherwise to promote the sale, use or other dealings
26 in this Software without prior written authorization from the X Consortium.
33 * Public definitions used for configuring basic pixelization aspects
34 * of the sample implementation line-drawing routines provided in
35 * {mfb,mi,cfb*} at run-time.
42 #define OCTANT1 (1 << (YDECREASING))
43 #define OCTANT2 (1 << (YDECREASING|YMAJOR))
44 #define OCTANT3 (1 << (XDECREASING|YDECREASING|YMAJOR))
45 #define OCTANT4 (1 << (XDECREASING|YDECREASING))
46 #define OCTANT5 (1 << (XDECREASING))
47 #define OCTANT6 (1 << (XDECREASING|YMAJOR))
48 #define OCTANT7 (1 << (YMAJOR))
49 #define OCTANT8 (1 << (0))
51 #define XMAJOROCTANTS (OCTANT1 | OCTANT4 | OCTANT5 | OCTANT8)
53 #define DEFAULTZEROLINEBIAS (OCTANT2 | OCTANT3 | OCTANT4 | OCTANT5)
56 * Devices can configure the rendering of routines in mi, mfb, and cfb*
57 * by specifying a thin line bias to be applied to a particular screen
58 * using the following function. The bias parameter is an OR'ing of
59 * the appropriate OCTANT constants defined above to indicate which
60 * octants to bias a line to prefer an axial step when the Bresenham
61 * error term is exactly zero. The octants are mapped as follows:
75 * For more information, see "Ambiguities in Incremental Line Rastering,"
76 * Jack E. Bresenham, IEEE CG&A, May 1987.
79 extern void miSetZeroLineBias(
80 #if NeedFunctionPrototypes
81 ScreenPtr /* pScreen */,
82 unsigned int /* bias */
87 * Private definitions needed for drawing thin (zero width) lines
88 * Used by the mi, mfb, and all cfb* components.
95 #define OUT_RIGHT 0x04
96 #define OUT_ABOVE 0x02
97 #define OUT_BELOW 0x01
99 #define OUTCODES(_result, _x, _y, _pbox) \
100 if ( (_x) < (_pbox)->x1) (_result) |= OUT_LEFT; \
101 else if ( (_x) >= (_pbox)->x2) (_result) |= OUT_RIGHT; \
102 if ( (_y) < (_pbox)->y1) (_result) |= OUT_ABOVE; \
103 else if ( (_y) >= (_pbox)->y2) (_result) |= OUT_BELOW;
105 #define SWAPINT(i, j) \
106 { register int _t = i; i = j; j = _t; }
108 #define SWAPPT(i, j) \
109 { DDXPointRec _t; _t = i; i = j; j = _t; }
111 #define SWAPINT_PAIR(x1, y1, x2, y2)\
112 { int t = x1; x1 = x2; x2 = t;\
113 t = y1; y1 = y2; y2 = t;\
116 #define miGetZeroLineBias(_pScreen) \
117 ((miZeroLineScreenIndex < 0) ? \
118 0 : ((_pScreen)->devPrivates[miZeroLineScreenIndex].uval))
120 #define CalcLineDeltas(_x1,_y1,_x2,_y2,_adx,_ady,_sx,_sy,_SX,_SY,_octant) \
123 if (((_adx) = (_x2) - (_x1)) < 0) { \
126 (_octant) |= XDECREASING; \
129 if (((_ady) = (_y2) - (_y1)) < 0) { \
132 (_octant) |= YDECREASING; \
135 #define SetYMajorOctant(_octant) ((_octant) |= YMAJOR)
137 #define FIXUP_ERROR(_e, _octant, _bias) \
138 (_e) -= (((_bias) >> (_octant)) & 1)
140 #define IsXMajorOctant(_octant) (!((_octant) & YMAJOR))
141 #define IsYMajorOctant(_octant) ((_octant) & YMAJOR)
142 #define IsXDecreasingOctant(_octant) ((_octant) & XDECREASING)
143 #define IsYDecreasingOctant(_octant) ((_octant) & YDECREASING)
145 extern int miZeroLineScreenIndex;
147 extern int miZeroClipLine(
148 #if NeedFunctionPrototypes
157 unsigned int /*adx*/,
158 unsigned int /*ady*/,
159 int * /*pt1_clipped*/,
160 int * /*pt2_clipped*/,
162 unsigned int /*bias*/,
168 #endif /* MILINE_H */