Debian Codegraph @

texk/ps2pk/spaces.h

raw
1 /* $XConsortium: spaces.h,v 1.3 91/10/10 11:19:22 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 #define USER t1_User
34 #define IDENTITY t1_Identity
35
36 typedef SHORT pel; /* integer pel locations */
37 typedef int32_t fractpel; /* fractional pel locations */
38
39 #define FRACTBITS 16 /* number of fractional bits in 'fractpel' */
40 /*
41 We define the following macros to convert from 'fractpel' to 'pel' and
42 vice versa:
43 */
44 #define TOFRACTPEL(p) (((fractpel)p)<<FRACTBITS)
45 #define FPHALF (1<<(FRACTBITS-1))
46 #define NEARESTPEL(fp) (((fp)+FPHALF)>>FRACTBITS)
47 #define FRACTFLOAT (DOUBLE)(1L<<FRACTBITS)
48
49 /*END SHARED*/
50 /*SHARED*/
51
52 struct doublematrix {
53 DOUBLE normal[2][2];
54 DOUBLE inverse[2][2];
55 } ;
56
57 /*END SHARED*/
58 /*SHARED*/
59
60 struct fractpoint {
61 fractpel x,y;
62 } ;
63
64 /*END SHARED*/
65 /*SHARED*/
66
67 struct XYspace {
68 XOBJ_COMMON /* xobject common data define 3-26-91 PNM */
69 /* type = SPACETYPE */
70 void (*convert)(struct fractpoint*,struct XYspace*,DOUBLE,DOUBLE);
71 /* calculate "fractpoint" X,Y from float X,Y */
72 void (*iconvert)(struct fractpoint*,struct XYspace*,int32_t,int32_t);
73 /* calculate "fractpoint" X,Y from int X,Y */
74 fractpel (*xconvert)(DOUBLE,DOUBLE,DOUBLE,DOUBLE);
75 /* subroutine of convert */
76 fractpel (*yconvert)(DOUBLE,DOUBLE,DOUBLE,DOUBLE);
77 /* subroutine of convert */
78 fractpel (*ixconvert)(int32_t,int32_t,int32_t,int32_t);
79 /* subroutine of iconvert */
80 fractpel (*iyconvert)(int32_t,int32_t,int32_t,int32_t);
81 /* subroutine of iconvert */
82 int ID; /* unique identifier (used in font caching) */
83 unsigned char context; /* device context of coordinate space */
84 struct doublematrix tofract; /* xform to get to fractional pels */
85 fractpel itofract[2][2]; /* integer version of "tofract.normal" */
86 } ;
87
88 #define INVALIDID 0 /* no valid space will have this ID */
89
90 /*END SHARED*/
91 /*SHARED*/
92
93 extern struct XYspace *IDENTITY;
94 extern struct XYspace *USER;
95
96 /*END SHARED*/
97 /*SHARED*/
98
99 #define Context(d,u) t1_Context(d,u)
100 #define Transform(o,f1,f2,f3,f4) t1_Transform(o,f1,f2,f3,f4)
101 #define Rotate(o,d) t1_Rotate(o,d)
102 #define Scale(o,sx,sy) t1_Scale(o,sx,sy)
103 #define QuerySpace(S,f1,f2,f3,f4) t1_QuerySpace(S,f1,f2,f3,f4)
104 #define Warp(s1,o,s2) t1_Warp(s1,o,s2)
105
106 struct XYspace *t1_Context(); /* creates a coordinate space for a device */
107 struct xobject *t1_Transform(struct xobject *, DOUBLE, DOUBLE, DOUBLE,
108 DOUBLE); /* transform an object */
109 struct xobject *t1_Rotate(); /* rotate an object */
110 struct xobject *t1_Scale(struct xobject *, DOUBLE, DOUBLE); /* scale an object */
111 struct xobject *t1_Warp(); /* transform like delta of two spaces */
112 void t1_QuerySpace(struct XYspace *, DOUBLE *, DOUBLE *, DOUBLE *, DOUBLE *);
113 /* returns coordinate space matrix */
114
115 /*END SHARED*/
116 /*SHARED*/
117
118 #define DeviceResolution t1_DeviceResolution
119 #define InitSpaces t1_InitSpaces
120 #define CopySpace(s) t1_CopySpace(s)
121 #define Xform(o,M) t1_Xform(o,M)
122 #define UnConvert(S,pt,xp,yp) t1_UnConvert(S,pt,xp,yp)
123 #define MatrixMultiply(A,B,C) t1_MMultiply(A,B,C)
124 #define MatrixInvert(A,B) t1_MInvert(A,B)
125 #define FindContext(M) t1_FindContext(M)
126
127 void t1_InitSpaces(void); /* initialize pre-defined coordinate spaces */
128 struct XYspace *t1_CopySpace(struct XYspace *);
129 /* duplicate a coordinate space */
130 struct xobject *t1_Xform(struct xobject *, DOUBLE[2][2]);
131 /* transform object by matrix */
132 void t1_UnConvert(struct XYspace *, struct fractpoint *, DOUBLE *, DOUBLE *);
133 /* return user coordinates from device coordinates */
134 void t1_MMultiply(DOUBLE[2][2], DOUBLE[2][2], DOUBLE[2][2]);
135 /* multiply two matrices */
136 void t1_MInvert(DOUBLE[2][2], DOUBLE[2][2]); /* invert a matrix */
137 int t1_FindContext(); /* return the "context" represented by a matrix */
138
139 /*END SHARED*/
140 /*SHARED*/
141
142 /* #define KillSpace(s) Free(s)
143 Note - redefined KillSpace() to check references !
144 3-26-91 PNM */
145
146 #define KillSpace(s) if ( (--(s->references) == 0) ||\
147 ( (s->references == 1) && ISPERMANENT(s->flag) ) )\
148 Free(s)
149
150 #define ConsumeSpace(s) MAKECONSUME(s,KillSpace(s))
151 #define UniqueSpace(s) MAKEUNIQUE(s,CopySpace(s))
152
153 /*END SHARED*/
154 /*SHARED*/
155
156 #define NULLCONTEXT 0
157
158 /*END SHARED*/