Back to index

tetex-bin  3.0
spaces.h
Go to the documentation of this file.
00001 /* $XConsortium: spaces.h,v 1.3 91/10/10 11:19:22 rws Exp $ */
00002 /* Copyright International Business Machines, Corp. 1991
00003  * All Rights Reserved
00004  * Copyright Lexmark International, Inc. 1991
00005  * All Rights Reserved
00006  *
00007  * License to use, copy, modify, and distribute this software and its
00008  * documentation for any purpose and without fee is hereby granted,
00009  * provided that the above copyright notice appear in all copies and that
00010  * both that copyright notice and this permission notice appear in
00011  * supporting documentation, and that the name of IBM or Lexmark not be
00012  * used in advertising or publicity pertaining to distribution of the
00013  * software without specific, written prior permission.
00014  *
00015  * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
00016  * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
00017  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
00018  * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.  THE ENTIRE RISK AS TO THE
00019  * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
00020  * OR MAINTAIN, BELONGS TO THE LICENSEE.  SHOULD ANY PORTION OF THE
00021  * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
00022  * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION.  IN NO EVENT SHALL
00023  * IBM OR LEXMARK BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
00024  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
00025  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
00026  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
00027  * THIS SOFTWARE.
00028  */
00029 /*SHARED*/
00030 
00031 #include "types.h"
00032 
00033 #define   USER                       t1_User
00034 #define   IDENTITY                   t1_Identity
00035  
00036 #define   Context(d,u)               t1_Context(d,u)
00037 #define   Transform(o,f1,f2,f3,f4)   t1_Transform(o,f1,f2,f3,f4)
00038 #define   Rotate(o,d)                t1_Rotate(o,d)
00039 #define   Scale(o,sx,sy)             t1_Scale(o,sx,sy)
00040 #define   QuerySpace(S,f1,f2,f3,f4)  t1_QuerySpace(S,f1,f2,f3,f4)
00041 #define   Warp(s1,o,s2)              t1_Warp(s1,o,s2)
00042  
00043 struct XYspace *t1_Context(); /* creates a coordinate space for a device      */
00044 struct xobject *t1_Transform();  /* transform an object                       */
00045 struct xobject *t1_Rotate();  /* rotate an object                             */
00046 struct xobject *t1_Scale();   /* scale an object                              */
00047 struct xobject *t1_Warp();    /* transform like delta of two spaces           */
00048 void t1_QuerySpace();         /* returns coordinate space matrix              */
00049  
00050 /*END SHARED*/
00051 /*SHARED*/
00052  
00053 #define   DeviceResolution   t1_DeviceResolution
00054 #define   InitSpaces()       t1_InitSpaces()
00055 #define   CopySpace(s)       t1_CopySpace(s)
00056 #define   Xform(o,M)         t1_Xform(o,M)
00057 #define   UnConvert(S,pt,xp,yp)    t1_UnConvert(S,pt,xp,yp)
00058 #define   MatrixMultiply(A,B,C)    t1_MMultiply(A,B,C)
00059 #define   MatrixInvert(A,B)        t1_MInvert(A,B)
00060 #define   PseudoSpace(S,M)   t1_PseudoSpace(S,M)
00061 #define   FindContext(M)     t1_FindContext(M)
00062  
00063 void t1_InitSpaces();         /* initialize pre-defined coordinate spaces     */
00064 struct XYspace *t1_CopySpace(); /* duplicate a coordinate space               */
00065 struct xobject *t1_Xform();   /* transform object by matrix                   */
00066 void t1_UnConvert();          /* return user coordinates from device coordinates */
00067 void t1_MMultiply();          /* multiply two matrices                        */
00068 void t1_MInvert();            /* invert a matrix                              */
00069 void t1_PseudoSpace();        /* force a coordinate space from a matrix       */
00070 int t1_FindContext();         /* return the "context" represented by a matrix */
00071  
00072 /*END SHARED*/
00073 /*SHARED*/
00074  
00075 /* #define    KillSpace(s)     Free(s)
00076 Note - redefined KillSpace() to check references !
00077 3-26-91 PNM */
00078  
00079 #define KillSpace(s)      if ( (--(s->references) == 0) ||\
00080                       ( (s->references == 1) && ISPERMANENT(s->flag) ) )\
00081                         Free(s)
00082  
00083 #define    ConsumeSpace(s)  MAKECONSUME(s,KillSpace(s))
00084 #define    UniqueSpace(s)   MAKEUNIQUE(s,CopySpace(s))
00085  
00086 /*END SHARED*/
00087 /*SHARED*/
00088  
00089 typedef SHORT pel;           /* integer pel locations                        */
00090 typedef LONG fractpel;       /* fractional pel locations                     */
00091  
00092 #define   FRACTBITS     16   /* number of fractional bits in 'fractpel'      */
00093 /*
00094 We define the following macros to convert from 'fractpel' to 'pel' and
00095 vice versa:
00096 */
00097 #define   TOFRACTPEL(p)   (((fractpel)p)<<FRACTBITS)
00098 #define   FPHALF          (1<<(FRACTBITS-1))
00099 #define   NEARESTPEL(fp)  (((fp)+FPHALF)>>FRACTBITS)
00100 #define   FRACTFLOAT   (DOUBLE)(1L<<FRACTBITS)
00101  
00102 /*END SHARED*/
00103 /*SHARED*/
00104  
00105 struct doublematrix {
00106        DOUBLE normal[2][2];
00107        DOUBLE inverse[2][2];
00108 } ;
00109  
00110 /*END SHARED*/
00111 /*SHARED*/
00112  
00113 struct XYspace {
00114        XOBJ_COMMON           /* xobject common data define 3-26-91 PNM       */
00115                           /* type = SPACETYPE                       */
00116        void (*convert)();     /* calculate "fractpoint" X,Y from float X,Y    */
00117        void (*iconvert)();    /* calculate "fractpoint" X,Y from int X,Y      */
00118        fractpel (*xconvert)();  /* subroutine of convert                     */
00119        fractpel (*yconvert)();  /* subroutine of convert                     */
00120        fractpel (*ixconvert)();  /* subroutine of iconvert                   */
00121        fractpel (*iyconvert)();  /* subroutine of iconvert                   */
00122        int ID;               /* unique identifier (used in font caching)     */
00123        unsigned char context;  /* device context of coordinate space         */
00124        struct doublematrix tofract;  /* xform to get to fractional pels      */
00125        fractpel itofract[2][2];  /* integer version of "tofract.normal"      */
00126 } ;
00127  
00128 #define    INVALIDID  0      /* no valid space will have this ID             */
00129  
00130 /*END SHARED*/
00131 /*SHARED*/
00132  
00133 struct fractpoint {
00134        fractpel x,y;
00135 } ;
00136  
00137 /*END SHARED*/
00138 /*SHARED*/
00139  
00140 #define  NULLCONTEXT   0
00141  
00142 /*END SHARED*/