]> git.sesse.net Git - rdpsrv/blob - Xserver/lib/font/Type1/regions.h
Support RDP5 logon packets.
[rdpsrv] / Xserver / lib / font / Type1 / regions.h
1 /* $XConsortium: regions.h,v 1.6 94/04/02 15:49:51 rws Exp $ */
2 /* Copyright International Business Machines, Corp. 1991
3  * All Rights Reserved
4  * Copyright Lexmark International, Inc. 1991
5  * All Rights Reserved
6  *
7  * License to use, copy, modify, and distribute this software and its
8  * documentation for any purpose and without fee is hereby granted,
9  * provided that the above copyright notice appear in all copies and that
10  * both that copyright notice and this permission notice appear in
11  * supporting documentation, and that the name of IBM or Lexmark not be
12  * used in advertising or publicity pertaining to distribution of the
13  * software without specific, written prior permission.
14  *
15  * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
16  * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
17  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
18  * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.  THE ENTIRE RISK AS TO THE
19  * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
20  * OR MAINTAIN, BELONGS TO THE LICENSEE.  SHOULD ANY PORTION OF THE
21  * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
22  * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION.  IN NO EVENT SHALL
23  * IBM OR LEXMARK BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
24  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
25  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
26  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
27  * THIS SOFTWARE.
28  */
29 /*SHARED*/
30  
31 #define   Interior(p,rule)        t1_Interior(p,rule)
32 #define   Union(a1,a2)            t1_Union(a1,a2)
33 #define   Intersect(a1,a2)        t1_Intersect(a1,a2)
34 #define   Complement(area)        t1_Complement(area)
35 #define   Overlap(a1,a2)          t1_OverLap(a1,a2)
36  
37 struct region *t1_Interior(); /* returns the interior of a closed path        */
38 struct region *t1_Union();   /* set union of paths or regions                */
39 struct region *t1_Intersect();  /* set intersection of regions                */
40 struct region *t1_Complement();  /* complement of a region                    */
41 int t1_Overlap();             /* returns a Boolean; TRUE if regions overlap   */
42  
43 #define   INFINITY    t1_Infinity
44  
45 /*END SHARED*/
46 /*SHARED*/
47  
48 #define   ChangeDirection(type,R,x,y,dy)  t1_ChangeDirection(type,R,x,y,dy)
49  
50 void t1_ChangeDirection();    /* called when we change direction in Y         */
51 #define   CD_FIRST         -1  /* enumeration of ChangeDirection type       */
52 #define   CD_CONTINUE       0  /* enumeration of ChangeDirection type        */
53 #define   CD_LAST           1  /* enumeration of ChangeDirection type        */
54  
55 #define    MoreWorkArea(R,x1,y1,x2,y2)     t1_MoreWorkArea(R,x1,y1,x2,y2)
56 #define    KillRegion(area)   t1_KillRegion(area)
57 #define    CopyRegion(area)   t1_CopyRegion(area)
58 #define    BoxClip(R,xmin,ymin,xmax,ymax)  t1_BoxClip(R,xmin,ymin,xmax,ymax)
59 #define    SortSwath(a,p,f)   t1_SortSwath(a,p,f)
60 #define    SwathUnion(b,e)    t1_SwathUnion(b,e)
61 #define    RegionBounds(r)    t1_RegionBounds(r)
62 #define    CoerceRegion(p)    t1_CoerceRegion(p)
63 #define    MoveEdges(R,dx,dy) t1_MoveEdges(R,dx,dy)
64 #define    UnJumble(R)        t1_UnJumble(R)
65  
66 void t1_MoreWorkArea();       /* get longer edge list for stepping            */
67 struct region *t1_CopyRegion();  /* duplicate a region                       */
68 void t1_KillRegion();         /* destroy a region                             */
69 struct region *t1_BoxClip();  /* clip a region to a rectangle                 */
70 struct edgelist *t1_SortSwath();  /* sort edges onto growing edge list        */
71 struct edgelist *t1_SwathUnion();  /* 'union' two edges into a swath          */
72 struct segment *t1_RegionBounds();  /* returns bounding box of a region       */
73 struct region *t1_CoerceRegion();  /* force text to become a true region      */
74 void t1_MoveEdges();          /* moves the edge values in a region            */
75 void t1_UnJumble();           /* sort the edges and reset the jumbled flag    */
76  
77 /*END SHARED*/
78 /*SHARED*/
79  
80 #define GOING_TO(R, x1, y1, x2, y2, dy) { \
81    if (dy < 0) { \
82       if (R->lastdy >= 0) \
83           ChangeDirection(CD_CONTINUE, R, x1, y1, dy); \
84       if (y2 < R->edgeYstop) \
85           MoreWorkArea(R, x1, y1, x2, y2); \
86    } \
87    else if (dy > 0) { \
88       if (R->lastdy <= 0) \
89           ChangeDirection(CD_CONTINUE, R, x1, y1, dy); \
90       if (y2 > R->edgeYstop) \
91           MoreWorkArea(R, x1, y1, x2, y2); \
92    } \
93    else /* dy == 0 */ ChangeDirection(CD_CONTINUE, R, x1, y1, dy); \
94    if (x2 < R->edgexmin) R->edgexmin = x2; \
95    else if (x2 > R->edgexmax) R->edgexmax = x2; \
96 }
97  
98 #ifndef __sxg__
99 #include <limits.h>
100 #endif
101 #ifdef SHRT_MIN
102 #define MINPEL SHRT_MIN
103 #else
104 #define MINPEL ((pel)(-1<<(8*sizeof(pel)-1)))  /* smallest value fitting in a pel */
105 #endif
106 #ifdef SHRT_MAX
107 #define MAXPEL SHRT_MAX
108 #else
109 #define MAXPEL ((pel)((1<<(8*sizeof(pel)-1))-1))/* largest value fitting in a pel */
110 #endif
111  
112 /*
113 The "Unique"-type macro is different (unique?) for regions, because some
114 regions structures are shared among several objects, and might have
115 to be made unique for that reason (i.e., references > 1).
116 */
117  
118 #define    ConsumeRegion(R)   MAKECONSUME(R,KillRegion(R))
119 #define    UniqueRegion(R)    MAKEUNIQUE(R,CopyRegion(R))
120  
121  
122 /*END SHARED*/
123 /*SHARED*/
124  
125 struct region {
126        XOBJ_COMMON           /* xobject common data define 3-26-91 PNM    */
127                              /* type = REGIONTYPE                         */
128        struct fractpoint origin;    /* beginning handle:  X,Y origin of region      */
129        struct fractpoint ending;    /* ending handle:  X,Y change after painting region */
130        pel xmin,ymin;        /* minimum X,Y of region                        */
131        pel xmax,ymax;        /* mat1_mum X,Y of region                        */
132        struct edgelist *anchor;  /* list of edges that bound the region      */
133        struct picture *thresholded;  /* region defined by thresholded picture*/
134 /*
135 Note that the ending handle and the bounding box values are stored
136 relative to 'origin'.
137  
138 The above elements describe a region.  The following elements are
139 scratchpad areas used while the region is being built:
140 */
141        fractpel lastdy;      /* direction of last segment                    */
142        fractpel firstx,firsty;    /* starting point of current edge          */
143        fractpel edgexmin,edgexmax;  /* x extent of current edge              */
144        struct edgelist *lastedge,*firstedge;  /* last and first edges in subpath */
145        pel *edge;            /* pointer to array of X values for edge        */
146        fractpel edgeYstop;   /* Y value where 'edges' array ends             */
147        void (*newedgefcn)();  /* function to use when building a new edge    */
148        struct strokeinfo *strokeinfo;  /* scratchpad info during stroking only */
149 } ;
150 /*
151 The ISCOMPLEMENT flag indicates the region is reversed--it is the
152 "outside" of the nominal region.
153 */
154 #define   ISCOMPLEMENT(flag)   ((flag)&0x80)
155 /*
156 The ISJUMBLED flag indicates the region is not sorted top-to-bottom.
157 */
158 #define   ISJUMBLED(flag)      ((flag)&0x40)
159 /*
160 The ISINFINITE flag allows a quick check for an INFINITE region, which
161 is frequently intersected.
162 */
163 #define   ISINFINITE(flag)     ((flag)&0x20)
164  
165 /*END SHARED*/
166 /*SHARED*/
167  
168 #define   ISRECTANGULAR(flag)  ((flag)&0x08)
169  
170 /*END SHARED*/
171 /*SHARED*/
172  
173 #define  EmptyRegion   t1_EmptyRegion
174  
175 /*END SHARED*/
176 /*SHARED*/
177  
178 struct edgelist {
179        XOBJ_COMMON          /* xobject common data define 3-26-91 PNM        */
180                             /* type = EDGETYPE                               */
181        struct edgelist *link;  /* pointer to next in linked list             */
182        struct edgelist *subpath;  /* informational link for "same subpath"   */
183        pel xmin,xmax;        /* range of edge in X                           */
184        pel ymin,ymax;        /* range of edge in Y                           */
185        pel *xvalues;         /* pointer to ymax-ymin X values                */
186 } ;
187 /*
188 The end of the list is marked by either "link" being NULL, or by
189 ymin == ymax.  See :hdref refid=discard..  We define the VALIDEDGE
190 predicate to test for the opposite of these conditions:
191 */
192  
193 #define   VALIDEDGE(p)    ((p)!=NULL&&(p)->ymin<(p)->ymax)
194  
195 /*END SHARED*/
196 /*SHARED*/
197  
198 #define   ISDOWN(f)       ((f)&0x80)
199  
200 #define   ISAMBIGUOUS(f)  ((f)&0x40)
201  
202 /*END SHARED*/
203 /*SHARED*/
204  
205 /*
206 Interior() rule enumerations:
207 */
208 #define   WINDINGRULE -2
209 #define   EVENODDRULE -3
210  
211 #define   CONTINUITY  0x80   /* can be added to above rules; e.g. WINDINGRULE+CONTINUITY */
212  
213 /*END SHARED*/