]> git.sesse.net Git - rdpsrv/blob - Xserver/programs/Xserver/mi/miline.h
Import X server from vnc-3.3.7.
[rdpsrv] / Xserver / programs / Xserver / mi / miline.h
1 /* $XConsortium: miline.h /main/6 1996/08/12 21:51:09 dpw $ */
2
3 /*
4
5 Copyright (c) 1994  X Consortium
6
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:
13
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
16
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.
23
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.
27
28 */
29
30 #ifndef MILINE_H
31
32 /*
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.
36  */
37
38 #define XDECREASING     4
39 #define YDECREASING     2
40 #define YMAJOR          1
41
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))
50
51 #define XMAJOROCTANTS           (OCTANT1 | OCTANT4 | OCTANT5 | OCTANT8)
52
53 #define DEFAULTZEROLINEBIAS     (OCTANT2 | OCTANT3 | OCTANT4 | OCTANT5)
54
55 /*
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:
62  *
63  *   \    |    /
64  *    \ 3 | 2 /
65  *     \  |  /
66  *    4 \ | / 1
67  *       \|/
68  *   -----------
69  *       /|\
70  *    5 / | \ 8
71  *     /  |  \
72  *    / 6 | 7 \
73  *   /    |    \
74  *
75  * For more information, see "Ambiguities in Incremental Line Rastering,"
76  * Jack E. Bresenham, IEEE CG&A, May 1987.
77  */
78
79 extern void miSetZeroLineBias(
80 #if NeedFunctionPrototypes
81     ScreenPtr /* pScreen */,
82     unsigned int /* bias */
83 #endif
84 );
85
86 /*
87  * Private definitions needed for drawing thin (zero width) lines
88  * Used by the mi, mfb, and all cfb* components.
89  */
90
91 #define X_AXIS  0
92 #define Y_AXIS  1
93
94 #define OUT_LEFT  0x08
95 #define OUT_RIGHT 0x04
96 #define OUT_ABOVE 0x02
97 #define OUT_BELOW 0x01
98
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;
104
105 #define SWAPINT(i, j) \
106 {  register int _t = i;  i = j;  j = _t; }
107
108 #define SWAPPT(i, j) \
109 {  DDXPointRec _t; _t = i;  i = j; j = _t; }
110
111 #define SWAPINT_PAIR(x1, y1, x2, y2)\
112 {   int t = x1;  x1 = x2;  x2 = t;\
113         t = y1;  y1 = y2;  y2 = t;\
114 }
115
116 #define miGetZeroLineBias(_pScreen) \
117     ((miZeroLineScreenIndex < 0) ? \
118                 0 : ((_pScreen)->devPrivates[miZeroLineScreenIndex].uval))
119
120 #define CalcLineDeltas(_x1,_y1,_x2,_y2,_adx,_ady,_sx,_sy,_SX,_SY,_octant) \
121     (_octant) = 0;                              \
122     (_sx) = (_SX);                              \
123     if (((_adx) = (_x2) - (_x1)) < 0) {         \
124         (_adx) = -(_adx);                       \
125         (_sx = -(_sx));                         \
126         (_octant) |= XDECREASING;               \
127     }                                           \
128     (_sy) = (_SY);                              \
129     if (((_ady) = (_y2) - (_y1)) < 0) {         \
130         (_ady) = -(_ady);                       \
131         (_sy = -(_sy));                         \
132         (_octant) |= YDECREASING;               \
133     }
134
135 #define SetYMajorOctant(_octant)        ((_octant) |= YMAJOR)
136
137 #define FIXUP_ERROR(_e, _octant, _bias) \
138     (_e) -= (((_bias) >> (_octant)) & 1)
139
140 #define IsXMajorOctant(_octant)         (!((_octant) & YMAJOR))
141 #define IsYMajorOctant(_octant)         ((_octant) & YMAJOR)
142 #define IsXDecreasingOctant(_octant)    ((_octant) & XDECREASING)
143 #define IsYDecreasingOctant(_octant)    ((_octant) & YDECREASING)
144
145 extern int miZeroLineScreenIndex;
146
147 extern int miZeroClipLine(
148 #if NeedFunctionPrototypes
149     int /*xmin*/,
150     int /*ymin*/,
151     int /*xmax*/,
152     int /*ymax*/,
153     int * /*new_x1*/,
154     int * /*new_y1*/,
155     int * /*new_x2*/,
156     int * /*new_y2*/,
157     unsigned int /*adx*/,
158     unsigned int /*ady*/,
159     int * /*pt1_clipped*/,
160     int * /*pt2_clipped*/,
161     int /*octant*/,
162     unsigned int /*bias*/,
163     int /*oc1*/,
164     int /*oc2*/
165 #endif
166 );
167
168 #endif /* MILINE_H */