VirtualBox

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

Last change on this file was 51223, checked in by vboxsync, 11 years ago

Additions/x11/x11include: added header files for X.Org Server 1.0 and 1.1.

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