VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/xorg-server-1.14.0/mipoly.h

Last change on this file was 45134, checked in by vboxsync, 12 years ago

Additions/X11: build vboxvideo_drv.so for X.Org Server 1.14.

  • Property svn:eol-style set to native
File size: 7.0 KB
Line 
1/*
2
3Copyright 1987, 1998 The Open Group
4
5Permission to use, copy, modify, distribute, and sell this software and its
6documentation for any purpose is hereby granted without fee, provided that
7the above copyright notice appear in all copies and that both that
8copyright notice and this permission notice appear in supporting
9documentation.
10
11The above copyright notice and this permission notice shall be included
12in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
18OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of The Open Group shall
23not be used in advertising or otherwise to promote the sale, use or
24other dealings in this Software without prior written authorization
25from The Open Group.
26
27*/
28
29/*
30 * fill.h
31 *
32 * Created by Brian Kelleher; Oct 1985
33 *
34 * Include file for filled polygon routines.
35 *
36 * These are the data structures needed to scan
37 * convert regions. Two different scan conversion
38 * methods are available -- the even-odd method, and
39 * the winding number method.
40 * The even-odd rule states that a point is inside
41 * the polygon if a ray drawn from that point in any
42 * direction will pass through an odd number of
43 * path segments.
44 * By the winding number rule, a point is decided
45 * to be inside the polygon if a ray drawn from that
46 * point in any direction passes through a different
47 * number of clockwise and counter-clockwise path
48 * segments.
49 *
50 * These data structures are adapted somewhat from
51 * the algorithm in (Foley/Van Dam) for scan converting
52 * polygons.
53 * The basic algorithm is to start at the top (smallest y)
54 * of the polygon, stepping down to the bottom of
55 * the polygon by incrementing the y coordinate. We
56 * keep a list of edges which the current scanline crosses,
57 * sorted by x. This list is called the Active Edge Table (AET)
58 * As we change the y-coordinate, we update each entry in
59 * in the active edge table to reflect the edges new xcoord.
60 * This list must be sorted at each scanline in case
61 * two edges intersect.
62 * We also keep a data structure known as the Edge Table (ET),
63 * which keeps track of all the edges which the current
64 * scanline has not yet reached. The ET is basically a
65 * list of ScanLineList structures containing a list of
66 * edges which are entered at a given scanline. There is one
67 * ScanLineList per scanline at which an edge is entered.
68 * When we enter a new edge, we move it from the ET to the AET.
69 *
70 * From the AET, we can implement the even-odd rule as in
71 * (Foley/Van Dam).
72 * The winding number rule is a little trickier. We also
73 * keep the EdgeTableEntries in the AET linked by the
74 * nextWETE (winding EdgeTableEntry) link. This allows
75 * the edges to be linked just as before for updating
76 * purposes, but only uses the edges linked by the nextWETE
77 * link as edges representing spans of the polygon to
78 * drawn (as with the even-odd rule).
79 */
80
81/*
82 * for the winding number rule
83 */
84#define CLOCKWISE 1
85#define COUNTERCLOCKWISE -1
86
87typedef struct _EdgeTableEntry {
88 int ymax; /* ycoord at which we exit this edge. */
89 BRESINFO bres; /* Bresenham info to run the edge */
90 struct _EdgeTableEntry *next; /* next in the list */
91 struct _EdgeTableEntry *back; /* for insertion sort */
92 struct _EdgeTableEntry *nextWETE; /* for winding num rule */
93 int ClockWise; /* flag for winding number rule */
94} EdgeTableEntry;
95
96typedef struct _ScanLineList {
97 int scanline; /* the scanline represented */
98 EdgeTableEntry *edgelist; /* header node */
99 struct _ScanLineList *next; /* next in the list */
100} ScanLineList;
101
102typedef struct {
103 int ymax; /* ymax for the polygon */
104 int ymin; /* ymin for the polygon */
105 ScanLineList scanlines; /* header node */
106} EdgeTable;
107
108/*
109 * Here is a struct to help with storage allocation
110 * so we can allocate a big chunk at a time, and then take
111 * pieces from this heap when we need to.
112 */
113#define SLLSPERBLOCK 25
114
115typedef struct _ScanLineListBlock {
116 ScanLineList SLLs[SLLSPERBLOCK];
117 struct _ScanLineListBlock *next;
118} ScanLineListBlock;
119
120/*
121 * number of points to buffer before sending them off
122 * to scanlines() : Must be an even number
123 */
124#define NUMPTSTOBUFFER 200
125
126
127/*
128 *
129 * a few macros for the inner loops of the fill code where
130 * performance considerations don't allow a procedure call.
131 *
132 * Evaluate the given edge at the given scanline.
133 * If the edge has expired, then we leave it and fix up
134 * the active edge table; otherwise, we increment the
135 * x value to be ready for the next scanline.
136 * The winding number rule is in effect, so we must notify
137 * the caller when the edge has been removed so he
138 * can reorder the Winding Active Edge Table.
139 */
140#define EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET) { \
141 if (pAET->ymax == y) { /* leaving this edge */ \
142 pPrevAET->next = pAET->next; \
143 pAET = pPrevAET->next; \
144 fixWAET = 1; \
145 if (pAET) \
146 pAET->back = pPrevAET; \
147 } \
148 else { \
149 BRESINCRPGONSTRUCT(pAET->bres); \
150 pPrevAET = pAET; \
151 pAET = pAET->next; \
152 } \
153}
154
155/*
156 * Evaluate the given edge at the given scanline.
157 * If the edge has expired, then we leave it and fix up
158 * the active edge table; otherwise, we increment the
159 * x value to be ready for the next scanline.
160 * The even-odd rule is in effect.
161 */
162#define EVALUATEEDGEEVENODD(pAET, pPrevAET, y) { \
163 if (pAET->ymax == y) { /* leaving this edge */ \
164 pPrevAET->next = pAET->next; \
165 pAET = pPrevAET->next; \
166 if (pAET) \
167 pAET->back = pPrevAET; \
168 } \
169 else { \
170 BRESINCRPGONSTRUCT(pAET->bres); \
171 pPrevAET = pAET; \
172 pAET = pAET->next; \
173 } \
174}
175
176/* mipolyutil.c */
177
178extern _X_EXPORT Bool miCreateETandAET(int /*count */ ,
179 DDXPointPtr /*pts */ ,
180 EdgeTable * /*ET*/,
181 EdgeTableEntry * /*AET*/,
182 EdgeTableEntry * /*pETEs */ ,
183 ScanLineListBlock * /*pSLLBlock */
184 );
185
186extern _X_EXPORT void miloadAET(EdgeTableEntry * /*AET*/, EdgeTableEntry * /*ETEs */
187 );
188
189extern _X_EXPORT void micomputeWAET(EdgeTableEntry * /*AET*/);
190
191extern _X_EXPORT int miInsertionSort(EdgeTableEntry * /*AET*/);
192
193extern _X_EXPORT void miFreeStorage(ScanLineListBlock * /*pSLLBlock */
194 );
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette