home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / dec / qdss / qdpaint.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-02-05  |  5.3 KB  |  173 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. #include "scrnintstr.h"
  26.  
  27. /*
  28.  * this will be the general output writing mode
  29.  */
  30. #if NPLANES==24
  31. # define PAINT_TYPE      X3_PAINT_RGB
  32. #else    /* NPLANES==8 */
  33. # define PAINT_TYPE      X3_PAINT_GREY
  34. #endif
  35.  
  36. extern PaintGC *pPaintGC;
  37.  
  38. /*
  39.  * The point structures are actually the same
  40.  */
  41. #define DDXPointsToPaintPoints( pXPt, pPaintPt)  \
  42.     (pPaintPt) = (X3ScreenPt *)(pXPt);
  43.  
  44. #if NPLANES==24
  45. # define XpixvalTopaintRGBpixel( xpix, RGB)  \
  46.     (RGB).red =   RED(xpix);  \
  47.     (RGB).green = GREEN(xpix);  \
  48.     (RGB).blue =  BLUE(xpix);
  49. #else    /* NPLANES==8 */
  50. # define XpixvalTopaintRGBpixel( xpix, RGB)  \
  51.     (RGB).red =      (xpix) & 0x0000ff;  \
  52.     (RGB).green = (xpix) & 0x0000ff;  \
  53.     (RGB).blue =  (xpix) & 0x0000ff;
  54. #endif
  55.  
  56. /*
  57.  * state setting macros
  58.  */
  59. #if NPLANES==24
  60.  
  61. # define SETPIXVAL( pPaintGC, xpix) \
  62.     { \
  63.     RGBpixel    paintpixel; \
  64.  \
  65.     paintpixel.red = RED( xpix); \
  66.     paintpixel.green = GREEN( xpix); \
  67.     paintpixel.blue = BLUE( xpix); \
  68.     X3SETTypedPixval( (pPaintGC), PAINT_TYPE, &paintpixel); \
  69.     ((QzQdGC *)(pPaintGC)->devptr)->r = pPaintGC->DrawInfo.pixval.red; \
  70.     ((QzQdGC *)(pPaintGC)->devptr)->g = pPaintGC->DrawInfo.pixval.green; \
  71.     ((QzQdGC *)(pPaintGC)->devptr)->b = pPaintGC->DrawInfo.pixval.blue; \
  72.     }
  73. # define SETPAINTGCMASK( pXGC, pPGC) \
  74.     ((QzQdGC *)(pPGC)->devptr)->rmask = RED( (pXGC)->planemask); \
  75.     ((QzQdGC *)(pPGC)->devptr)->gmask = GREEN( (pXGC)->planemask); \
  76.     ((QzQdGC *)(pPGC)->devptr)->bmask = BLUE( (pXGC)->planemask);
  77.  
  78. #else /* NPLANES==8 */
  79.  
  80. # define SETPIXVAL( pPaintGC, xpix) \
  81.     { \
  82.     X3SETTypedPixval( (pPaintGC), PAINT_TYPE, &xpix); \
  83.     ((QzQdGC *)(pPaintGC)->devptr)->r = \
  84.     ((QzQdGC *)(pPaintGC)->devptr)->g = \
  85.     ((QzQdGC *)(pPaintGC)->devptr)->b = *((char *) &xpix); \
  86.     }
  87. # define SETPAINTGCMASK( pXGC, pPGC) \
  88.     ((QzQdGC *)(pPGC)->devptr)->gmask = ( (pXGC)->planemask); \
  89.  
  90. #endif
  91.  
  92.  
  93. /*
  94.  * Use
  95.  *    X3SETUsrSrcPixelType( (pPGC), X3_PAINT_NULL) 
  96.  * when paint routine should get pixel values out of the GC
  97.  */
  98.  
  99. /* fills in the tile filed of a pixmap and returns it */
  100. extern int SetTile(/* pPixmap */);
  101.  
  102. /* state setting macro
  103.  *
  104.  * copy relevant parts of X11 GC to a paintGC
  105.  */
  106. /*
  107.  * The extreme ends of the hardware color map are unusable, therefore the
  108.  * GXclear and GXset rasterops must be coerced into GXcopy operations
  109.  * with the appropriate constant source.
  110.  *
  111.  * According to the definition of rasterops, GXclear and GXset should
  112.  * produce absolute black and white, rather than BlackPixel and WhitePixel,
  113.  * but this would make Alis look bad, hence the hack.
  114.  */
  115.  
  116. #define SETPAINTGC( pXGC, pPGC, transx, transy) \
  117.     { \
  118.     X3ScreenRect *    pP; \
  119.     RGBpixel    forergb; \
  120.     RGBpixel    backrgb; \
  121.       \
  122.     XpixvalTopaintRGBpixel( pXGC->fgPixel, forergb); \
  123.     XpixvalTopaintRGBpixel( pXGC->bgPixel, backrgb); \
  124.     /* \
  125.      * foreground pixel \
  126.      */ \
  127.     SETPIXVAL((pPGC), pXGC->fgPixel); \
  128.     /* \
  129.      * background pixel \
  130.      */ \
  131.     ((QzQdGC *)(pPGC)->devptr)->backpixval.red = backrgb.red; \
  132.     ((QzQdGC *)(pPGC)->devptr)->backpixval.green = backrgb.green; \
  133.     ((QzQdGC *)(pPGC)->devptr)->backpixval.blue = backrgb.blue; \
  134.     /* \
  135.      * clipping state \
  136.      */ \
  137.     pP = (X3ScreenRect *) alloca( \
  138.         ((QDPrivGCPtr)(pXGC)->devPriv)->pCompositeClip->size \
  139.                         * sizeof(X3ScreenRect)); \
  140.     x11clipTopaintclip( \
  141.         ((QDPrivGCPtr)(pXGC)->devPriv)->pCompositeClip->rects, pP, \
  142.         ((QDPrivGCPtr)(pXGC)->devPriv)->pCompositeClip->numRects); \
  143.     X3SETClip( (pPGC), \
  144.         ((QDPrivGCPtr)(pXGC)->devPriv)->pCompositeClip->numRects, pP);\
  145.     /* \
  146.      * translate point \
  147.      */ \
  148.     pPaintGC->Window.translate.y = transy; \
  149.     pPaintGC->Window.translate.x = transx; \
  150.     /* \
  151.      * update method - X11 GX codes are the same as X10 \
  152.      */ \
  153.     if ( (pXGC->alu) == GXclear)  \
  154.     {  \
  155.         SETPIXVAL((pPGC), (pXGC)->pScreen->blackPixel); \
  156.         X3SETPaintMethod((pPGC), umtable[GXcopy]);  \
  157.     }  \
  158.     else if ( (pXGC->alu) == GXset)  \
  159.     {  \
  160.         SETPIXVAL((pPGC), (pXGC)->pScreen->whitePixel); \
  161.         X3SETPaintMethod((pPGC), umtable[GXcopy]);  \
  162.     }  \
  163.     else X3SETPaintMethod((pPGC), umtable[(pXGC->alu)]); \
  164.     /*  \
  165.      * previously called: QzQdValidateGC( pPGC); \
  166.      * plane mask  \
  167.      * \
  168.      * unfortunately QzQdValidateGC doesn't allow single planes to be \
  169.      * masked individually \
  170.      */ \
  171.     SETPAINTGCMASK( pXGC, pPGC) \
  172.     }
  173.