home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / dec / qdss / qd.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-26  |  6.0 KB  |  187 lines

  1. /***********************************************************
  2. Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
  3. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  4.  
  5.                         All Rights Reserved
  6.  
  7. Permission 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 names of Digital or MIT not be
  12. used in advertising or publicity pertaining to distribution of the
  13. software without specific, written prior permission.  
  14.  
  15. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  16. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  17. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  18. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  19. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  20. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21. SOFTWARE.
  22.  
  23. ******************************************************************/
  24.  
  25. #ifndef QD_H
  26. #define QD_H
  27.  
  28. #include "pixmapstr.h"
  29. #include "regionstr.h"
  30.  
  31. extern RegionPtr mfbPixmapToRegion();
  32.  
  33. extern Bool qdScreenInit();
  34.  
  35. extern void    qdSaveAreas ();
  36. extern void    qdRestoreAreas ();
  37.  
  38. extern int    DragonPix;    /* max y size for offscreen pixmap */
  39.  
  40. /*
  41.  * On the VAX with pcc
  42.  *      (unsigned)0xffffffff % 2 == 0xffffffff
  43.  * UMOD does not have a discontinuity at 0, as % does
  44.  */
  45. #define UMOD( dend, dor) \
  46.         ( (dend)%(dor) + (((dend) & 0x80000000) ? (dor) : 0))
  47.  
  48. /*
  49.  * private data in a PIXMAP
  50.  * NOTE: format is compatible with mfb pixmaps
  51.  */
  52. typedef struct _QDPix {
  53.     PixmapRec pixmap;
  54.     int planes;
  55.     struct _QDPix *nextLRU, *prevLRU;
  56.     struct PixSlot *slot;
  57. } QDPixRec, *QDPixPtr;
  58. #define    NOTOFFSCREEN    0 /* offscreen.y == 0 if not offscreen */
  59.  
  60. /* If PixmapIsLocked cannot be moved to offscreen.
  61.  * A future version might also disallow moving *from* offscreen memory. */
  62. #define PixmapIsLocked(pix) ((pix)->pixmap.drawable.class)
  63. #define LockPixmap(pix) ((pix)->pixmap.drawable.class = 1)
  64. #define UnlockPixmap(pix) ((pix)->pixmap.drawable.class = 0)
  65.  
  66. /* "data" must be unsigned to to point to bytes in full-depth image */
  67. #define QD_PIX_DATA(p) ((unsigned char*)(p)->devPrivate.ptr)
  68. #define QDWIN_X(win) (win)->drawable.x
  69. #define QDWIN_Y(win) (win)->drawable.y
  70. #define QDWIN_WINSIZE(win) &(win)->winSize
  71. #define QDWIN_CLIPLIST(win) &(win)->clipList
  72. #define QDPIX_WIDTH(pix)  (pix)->drawable.width
  73. #define QDPIX_HEIGHT(pix) (pix)->drawable.height
  74. #define QDPIX_X(qpix) (qpix)->pixmap.drawable.x
  75. #define QDPIX_Y(qpix) (qpix)->pixmap.drawable.y
  76. typedef QDPixRec QDPixmapRec;
  77. typedef QDPixPtr QDPixmapPtr;
  78. #define QD_PIX(pix) ((QDPixPtr)(pix))
  79.  
  80. /*
  81.  * There is only one representation for depth 1 pixmaps (bitmaps).
  82.  *
  83.  * Pad out to 32-bit boundary, like monochrome servers,
  84.  * even though the dragon DMA engine can transfer 16-bit-padded bitmaps.
  85.  */
  86. /*
  87.  * A convenient macro which incorporates the bitmap padding rule:
  88.  */
  89. #define QPPADBYTES( w)    ( ((w)+31)>>3 & ~3)    /* return units of bytes */
  90.  
  91. /*
  92.  * There is only one representation for full-depth pixmaps.
  93.  * This is used when the "format"
  94.  * argument to CreatePixmap() is either XYPixmap or ZPixmap.
  95.  * We can do this because DDX's representation of the pixmap data is hidden
  96.  * DIX code.
  97.  *
  98.  * Pixel data is stored in the order that is natural for
  99.  * the Dragon's DMA engine in Z mode: red bytes, green bytes, then blue bytes.
  100.  * Note that there are no padding bytes whatever.
  101.  */
  102.  
  103.  
  104. #if NPLANES==24
  105. #define RED(p)        (p & 0xff)
  106. #define GREEN(p)    (p>>8 & 0xff)
  107. #define BLUE(p)        (p>>16 & 0xff)
  108. #define    TORED(p)    (p & 0xff)
  109. #define    TOGREEN(p)    (p<<8 & 0xff00)
  110. #define    TOBLUE(p)    (((unsigned long) p)<<16 & 0xff0000)
  111. #else    /* NPLANES == 8 */
  112. #define RED(p)        (p & 0xff)
  113. #define GREEN(p)    (p & 0xff)
  114. #define BLUE(p)        (p & 0xff)
  115. #define    TORED(p)    (p & 0xff)
  116. #define    TOGREEN(p)    (p & 0xff)
  117. #define    TOBLUE(p)    (p & 0xff)
  118. #endif
  119.  
  120.  
  121. /*
  122.  * For fast text output, we need both a depth 1 pixmap containing
  123.  * the strike-order font, and a horizontal offset table.
  124.  */
  125.  
  126. typedef struct {
  127.     PixmapPtr    pPixmap;
  128.     int        log2dx;        /* log2 of x dimension of all char cells */
  129.     short    hasKerning;    /* 1 if kerns (=> unsuitable for ImageText) */
  130.     short    leftKern;    /* maximum left kerning (or 0) */
  131.     int        width;        /* "maximum" width */
  132.     short    ascent, descent;
  133.     short    widths[256];
  134. } QDFontRec, *QDFontPtr;
  135.  
  136. #define QDSLOWFONT    1    /* a QDFontPtr may take this value */
  137.  
  138. #endif    /* QD_H */
  139.  
  140. /* ISDRAGONTILE
  141.  *    sets (int) pow2 = 1 if the pixmap is in [4,512] and a power of 2
  142.  *    in width and height.
  143.  */
  144. #define    ISDRAGONTILE(ppixmap,pow2)    \
  145. {    \
  146.     register int    shifted;    \
  147.     pow2 = 1;    /* Yes, is power of 2 */    \
  148.     /* check if tile w,h (belong-to) [4,512] */    \
  149.     if (QDPIX_WIDTH(ppixmap) > 512 || QDPIX_HEIGHT(ppixmap) > 512 || \
  150.         QDPIX_WIDTH(ppixmap) < 4 || QDPIX_HEIGHT(ppixmap) < 4)  \
  151.         pow2 = 0;    \
  152.     for (shifted = 1; (QDPIX_WIDTH(ppixmap) >> shifted) > 0;    \
  153.         shifted += 1)    \
  154.     {    \
  155.         if ((QDPIX_WIDTH(ppixmap) >> shifted) << shifted    \
  156.             != QDPIX_WIDTH(ppixmap))    \
  157.         pow2 = 0;    \
  158.     }    \
  159.     for (shifted = 1; (QDPIX_HEIGHT(ppixmap) >> shifted) > 0;    \
  160.         shifted += 1)    \
  161.     {    \
  162.         if ((QDPIX_HEIGHT(ppixmap) >> shifted) << shifted    \
  163.             != QDPIX_HEIGHT(ppixmap))    \
  164.         pow2 = 0;    \
  165.     }    \
  166. }
  167.  
  168. /*
  169.  * These two macros are used for a destination that is an offscreen Bitmap.
  170.  * The GC is temporarily patched.
  171.  */
  172. #define SETUP_PIXMAP_AS_WINDOW(pDraw, pGC) \
  173.     extern unsigned int Allplanes;\
  174.     unsigned long planemaskSave = pGC->planemask;\
  175.     int fgPixelSave = pGC->fgPixel;\
  176.     int bgPixelSave = pGC->bgPixel;\
  177.     if ((pDraw)->depth == 1) {\
  178.     pGC->fgPixel = pGC->fgPixel ? Allplanes : 0;\
  179.     pGC->bgPixel = pGC->bgPixel ? Allplanes : 0;\
  180.     }\
  181.     pGC->planemask = ((QDPixPtr)pDraw)->planes;
  182.  
  183. #define CLEANUP_PIXMAP_AS_WINDOW(pGC) \
  184.     pGC->planemask = planemaskSave;\
  185.     pGC->fgPixel = fgPixelSave;\
  186.     pGC->bgPixel = bgPixelSave;
  187.