1 /* $XConsortium: spaces.h,v 1.4 94/02/06 16:27:06 gildea Exp $ */
2 /* Copyright International Business Machines, Corp. 1991
4 * Copyright Lexmark International, Inc. 1991
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.
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
32 #define IDENTITY t1_Identity
34 #define Context(d,u) t1_Context(d,u)
35 #define Transform(o,f1,f2,f3,f4) t1_Transform(o,f1,f2,f3,f4)
36 #define Rotate(o,d) t1_Rotate(o,d)
37 #define Scale(o,sx,sy) t1_Scale(o,sx,sy)
38 #define QuerySpace(S,f1,f2,f3,f4) t1_QuerySpace(S,f1,f2,f3,f4)
39 #define Warp(s1,o,s2) t1_Warp(s1,o,s2)
41 struct XYspace *t1_Context(); /* creates a coordinate space for a device */
42 struct xobject *t1_Transform(); /* transform an object */
43 struct xobject *t1_Rotate(); /* rotate an object */
44 struct xobject *t1_Scale(); /* scale an object */
45 struct xobject *t1_Warp(); /* transform like delta of two spaces */
46 void t1_QuerySpace(); /* returns coordinate space matrix */
51 #define DeviceResolution t1_DeviceResolution
52 #define InitSpaces() t1_InitSpaces()
53 #define CopySpace(s) t1_CopySpace(s)
54 #define Xform(o,M) t1_Xform(o,M)
55 #define UnConvert(S,pt,xp,yp) t1_UnConvert(S,pt,xp,yp)
56 #define MatrixMultiply(A,B,C) t1_MMultiply(A,B,C)
57 #define MatrixInvert(A,B) t1_MInvert(A,B)
58 #define PseudoSpace(S,M) t1_PseudoSpace(S,M)
59 #define FindContext(M) t1_FindContext(M)
61 void t1_InitSpaces(); /* initialize pre-defined coordinate spaces */
62 struct XYspace *t1_CopySpace(); /* duplicate a coordinate space */
63 struct xobject *t1_Xform(); /* transform object by matrix */
64 void t1_UnConvert(); /* return user coordinates from device coordinates */
65 void t1_MMultiply(); /* multiply two matrices */
66 void t1_MInvert(); /* invert a matrix */
67 void t1_PseudoSpace(); /* force a coordinate space from a matrix */
68 int t1_FindContext(); /* return the "context" represented by a matrix */
73 /* #define KillSpace(s) Free(s)
74 Note - redefined KillSpace() to check references !
77 #define KillSpace(s) if ( (--(s->references) == 0) ||\
78 ( (s->references == 1) && ISPERMANENT(s->flag) ) )\
81 #define ConsumeSpace(s) MAKECONSUME(s,KillSpace(s))
82 #define UniqueSpace(s) MAKEUNIQUE(s,CopySpace(s))
87 typedef short pel; /* integer pel locations */
88 typedef long fractpel; /* fractional pel locations */
90 #define FRACTBITS 16 /* number of fractional bits in 'fractpel' */
92 We define the following macros to convert from 'fractpel' to 'pel' and
95 #define TOFRACTPEL(p) (((fractpel)p)<<FRACTBITS)
96 #define FPHALF (1<<(FRACTBITS-1))
97 #define NEARESTPEL(fp) (((fp)+FPHALF)>>FRACTBITS)
98 #define FRACTFLOAT (double)(1L<<FRACTBITS)
103 struct doublematrix {
105 double inverse[2][2];
112 XOBJ_COMMON /* xobject common data define 3-26-91 PNM */
113 /* type = SPACETYPE */
114 void (*convert)(); /* calculate "fractpoint" X,Y from float X,Y */
115 void (*iconvert)(); /* calculate "fractpoint" X,Y from int X,Y */
116 fractpel (*xconvert)(); /* subroutine of convert */
117 fractpel (*yconvert)(); /* subroutine of convert */
118 fractpel (*ixconvert)(); /* subroutine of iconvert */
119 fractpel (*iyconvert)(); /* subroutine of iconvert */
120 int ID; /* unique identifier (used in font caching) */
121 unsigned char context; /* device context of coordinate space */
122 struct doublematrix tofract; /* xform to get to fractional pels */
123 fractpel itofract[2][2]; /* integer version of "tofract.normal" */
126 #define INVALIDID 0 /* no valid space will have this ID */
138 #define NULLCONTEXT 0