1 /* $XConsortium: paths.h,v 1.2 91/10/10 11:18:50 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 #include "types.h" 32 33 34 #define XOBJ_COMMON char type; unsigned char flag; short references; 35 #include "spaces_rmz.h" 36 37 38 39 /* 40 41 #define Loc(S,x,y) t1_Loc(S,(DOUBLE)x,(DOUBLE)y) 42 #define ILoc(S,x,y) t1_ILoc(S,x,y) 43 #define Line(P) t1_Line(P) 44 #define Join(p1,p2) t1_Join(p1,p2) 45 #define ClosePath(p) t1_ClosePath(p,0) 46 #define CloseLastSubPath(p) t1_ClosePath(p,1) 47 #define Conic(B,C,s) t1_Conic(B,C,(DOUBLE)s) 48 #define RoundConic(M,C,r) t1_RoundConic(M,C,(DOUBLE)r) 49 #define ArcP3(S,P2,P3) t1_ArcP3(S,P2,P3) 50 #define ArcCA(S,C,d) t1_ArcCA(S,C,(DOUBLE)d) 51 #define Bezier(B,C,D) t1_Bezier(B,C,D) 52 #define Hint(S,r,w,o,h,a,d,l) t1_Hint(S,r,w,o,h,a,d,l) 53 #define Reverse(p) t1_Reverse(p) 54 #define ReverseSubPaths(p) t1_ReverseSubPaths(p) 55 #define AddLoc(p1,p2) t1_Join(p1,p2) 56 #define SubLoc(p1,p2) t1_SubLoc(p1,p2) 57 #define DropSegment(p) t1_DropSegment(p) 58 #define HeadSegment(p) t1_HeadSegment(p) 59 #define QueryLoc(P,S,x,y) t1_QueryLoc(P,S,x,y) 60 #define QueryPath(p,t,B,C,D,r) t1_QueryPath(p,t,B,C,D,r) 61 #define QueryBounds(p,S,x1,y1,x2,y2) t1_QueryBounds(p,S,x1,y1,x2,y2) 62 63 */ 64 65 /* 66 struct segment *t1_Loc(); 67 struct segment *t1_ILoc(); 68 struct segment *t1_Line(); 69 struct segment *t1_Join(); 70 struct segment *t1_ClosePath(); 71 struct conicsegment *t1_Conic(); 72 struct conicsegment *t1_RoundConic(); 73 struct conicsegment *t1_ArcP3(); 74 struct conicsegment *t1_ArcCA(); 75 struct beziersegment *t1_Bezier(); 76 struct hintsegment *t1_Hint(); 77 struct segment *t1_Reverse(); 78 struct segment *t1_ReverseSubPaths(); 79 struct segment *t1_SubLoc(); 80 struct segment *t1_DropSegment(); 81 struct segment *t1_HeadSegment(); 82 void t1_QueryLoc(); 83 void t1_QueryPath(); 84 void t1_QueryBounds(); 85 86 */ 87 /*END SHARED*/ 88 /*SHARED*/ 89 90 #define CopyPath(p) t1_CopyPath(p) 91 #define KillPath(p) t1_KillPath(p) 92 #define PathTransform(p,m) t1_PathXform(p,m) 93 #define PathDelta(p,pt) t1_PathDelta(p,pt) 94 #define BoundingBox(h,w) t1_BoundingBox(h,w) 95 #define PathSegment(t,x,y) t1_PathSegment(t,(fractpel)x,(fractpel)y) 96 #define JoinSegment(b,t,x,y,a) t1_JoinSegment(b,t,(fractpel)x,(fractpel)y,a) 97 #define Hypoteneuse(dx,dy) t1_Hypoteneuse(dx,dy) 98 #define BoxPath(S,h,w) t1_BoxPath(S,h,w) 99 100 struct segment *t1_CopyPath(); /* duplicate a path */ 101 void t1_KillPath(); /* destroy a path */ 102 struct segment *t1_PathXform(); /* transform a path arbitrarily */ 103 void t1_PathDelta(); /* calculate the ending point of a path */ 104 struct segment *t1_PathSegment(); /* produce a MOVE or LINE segment */ 105 struct segment *t1_JoinSegment(); /* join a MOVE or LINE segment to a path */ 106 DOUBLE t1_Hypoteneuse(); /* returns the length of a line */ 107 struct segment *t1_BoxPath(); /* returns a rectangular path */ 108 109 /*END SHARED*/ 110 /*SHARED*/ 111 112 #define ConsumePath(p) MAKECONSUME(p,KillPath(p)) 113 #define UniquePath(p) MAKEUNIQUE(p,CopyPath(p)) 114 115 /*END SHARED*/ 116 /*SHARED*/ 117 118 struct segment { 119 XOBJ_COMMON /* xobject common data define 3-26-91 PNM */ 120 unsigned char size; /* size of the structure */ 121 unsigned char context; /* index to device context */ 122 struct segment *link; /* pointer to next structure in linked list */ 123 struct segment *last; /* pointer to last structure in list */ 124 struct fractpoint dest; /* relative ending location of path segment */ 125 } ; 126 127 #define ISCLOSED(flag) ((flag)&0x80) /* subpath is closed */ 128 #define LASTCLOSED(flag) ((flag)&0x40) /* last segment in closed subpath */ 129 130 /* 131 NOTE: The ISCLOSED flag is set on the MOVETYPE segment before the 132 subpath proper; the LASTCLOSED flag is set on the last segment (LINETYPE) 133 in the subpath 134 135 We define the ISPATHANCHOR predicate to test that a path handle 136 passed by the user is valid: 137 */ 138 139 #define ISPATHANCHOR(p) (ISPATHTYPE(p->type)&&p->last!=NULL) 140 141 /* 142 For performance reasons, a user's "location" object is identical to 143 a path whose only segment is a move segment. We define a predicate 144 to test for this case. See also :hdref refid=location.. 145 */ 146 147 #define ISLOCATION(p) ((p)->type == MOVETYPE && (p)->link == NULL) 148 149 /*END SHARED*/ 150 /*SHARED*/ 151 152 struct conicsegment { 153 XOBJ_COMMON /* xobject common data define 3-26-91 PNM */ 154 /* type = CONICTYPE */ 155 unsigned char size; /* as with any 'segment' type */ 156 unsigned char context; /* as with any 'segment' type */ 157 struct segment *link; /* as with any 'segment' type */ 158 struct segment *last; /* as with any 'segment' type */ 159 struct fractpoint dest; /* Ending point (C point) */ 160 struct fractpoint M; /* "midpoint" of conic explained above */ 161 float roundness; /* explained above */ 162 } ; 163 /*END SHARED*/ 164 /*SHARED*/ 165 166 struct beziersegment { 167 XOBJ_COMMON /* xobject common data define 3-26-91 PNM */ 168 /* type = BEZIERTYPE */ 169 unsigned char size; /* as with any 'segment' type */ 170 unsigned char context; /* as with any 'segment' type */ 171 struct segment *link; /* as with any 'segment' type */ 172 struct segment *last; /* as with any 'segment' type */ 173 struct fractpoint dest; /* ending point (D) */ 174 struct fractpoint B; /* control point B */ 175 struct fractpoint C; /* control point C */ 176 } ; 177 178 /*END SHARED*/ 179 /*SHARED*/ 180 181 struct hintsegment { 182 XOBJ_COMMON /* xobject common data define 3-26-91 PNM */ 183 /* type = HINTTYPE */ 184 unsigned char size; /* size of the structure */ 185 unsigned char context; /* device context */ 186 struct segment *link; /* pointer to next structure in linked list */ 187 struct segment *last; /* pointer to last structure in list */ 188 struct fractpoint dest; /* ALWAYS 0,0 */ 189 struct fractpoint ref; 190 struct fractpoint width; 191 char orientation; 192 char hinttype; 193 char adjusttype; 194 char direction; 195 int label; 196 } ; 197 198 /*END SHARED*/ 199 /*SHARED*/ 200 201 /* 202 CONCAT links the 'p2' path chain on the end of the 'p1' chain. (This macro 203 is also used by the STROKES module.) 204 */ 205 #define CONCAT(p1, p2) { \ 206 (struct segment *)(p1)->last->link = (struct segment *)p2; \ 207 (struct segment *)(p1)->last = p2->last; \ 208 (struct segment *)(p2)->last = NULL; } 209 210 /*END SHARED*/ 211