home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / mfb / mfbtile.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-15  |  5.2 KB  |  223 lines

  1. /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
  2. /***********************************************************
  3. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  4. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  5.  
  6.                         All Rights Reserved
  7.  
  8. Permission to use, copy, modify, and distribute this software and its 
  9. documentation for any purpose and without fee is hereby granted, 
  10. provided that the above copyright notice appear in all copies and that
  11. both that copyright notice and this permission notice appear in 
  12. supporting documentation, and that the names of Digital or MIT not be
  13. used in advertising or publicity pertaining to distribution of the
  14. software without specific, written prior permission.  
  15.  
  16. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  17. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  18. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  19. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  20. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  21. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  22. SOFTWARE.
  23.  
  24. ******************************************************************/
  25. /* $XConsortium: mfbtile.c,v 5.3 90/05/15 18:38:21 keith Exp $ */
  26. #include "X.h"
  27.  
  28. #include "windowstr.h"
  29. #include "regionstr.h"
  30. #include "pixmapstr.h"
  31. #include "scrnintstr.h"
  32.  
  33. #include "mfb.h"
  34. #include "maskbits.h"
  35.  
  36. #include "mergerop.h"
  37. /* 
  38.  
  39.    the boxes are already translated.
  40.  
  41.    NOTE:
  42.    iy = ++iy < tileHeight ? iy : 0
  43. is equivalent to iy%= tileheight, and saves a division.
  44. */
  45.  
  46. /* 
  47.     tile area with a 32 bit wide pixmap 
  48. */
  49. void
  50. MROP_NAME(mfbTileArea32)(pDraw, nbox, pbox, alu, ptile)
  51.     DrawablePtr pDraw;
  52.     int nbox;
  53.     BoxPtr pbox;
  54.     int alu;
  55.     PixmapPtr ptile;
  56. {
  57.     register unsigned int *psrc;
  58.             /* pointer to bits in tile, if needed */
  59.     int tileHeight;    /* height of the tile */
  60.     register unsigned int srcpix;    
  61.  
  62.     int nlwidth;    /* width in longwords of the drawable */
  63.     int w;        /* width of current box */
  64.     MROP_DECLARE_REG ()
  65.     register int h;    /* height of current box */
  66.     register int nlw;    /* loop version of nlwMiddle */
  67.     register unsigned int *p;    /* pointer to bits we're writing */
  68.     int startmask;
  69.     int endmask;    /* masks for reggedy bits at either end of line */
  70.     int nlwMiddle;    /* number of longwords between sides of boxes */
  71.     int nlwExtra;    /* to get from right of box to left of next span */
  72.     
  73.     register int iy;    /* index of current scanline in tile */
  74.  
  75.  
  76.     unsigned int *pbits;    /* pointer to start of drawable */
  77.  
  78.     if (pDraw->type == DRAWABLE_WINDOW)
  79.     {
  80.     pbits = (unsigned int *)
  81.         (((PixmapPtr)(pDraw->pScreen->devPrivate))->devPrivate.ptr);
  82.     nlwidth = (int)
  83.         (((PixmapPtr)(pDraw->pScreen->devPrivate))->devKind) >> 2;
  84.     }
  85.     else
  86.     {
  87.     pbits = (unsigned int *)(((PixmapPtr)pDraw)->devPrivate.ptr);
  88.     nlwidth = (int)(((PixmapPtr)pDraw)->devKind) >> 2;
  89.     }
  90.  
  91.     MROP_INITIALIZE(alu,~0)
  92.  
  93.     tileHeight = ptile->drawable.height;
  94.     psrc = (unsigned int *)(ptile->devPrivate.ptr);
  95.  
  96.     while (nbox--)
  97.     {
  98.     w = pbox->x2 - pbox->x1;
  99.     h = pbox->y2 - pbox->y1;
  100.     iy = pbox->y1 % tileHeight;
  101.     p = pbits + (pbox->y1 * nlwidth) + (pbox->x1 >> 5);
  102.  
  103.     if ( ((pbox->x1 & 0x1f) + w) < 32)
  104.     {
  105.         maskpartialbits(pbox->x1, w, startmask);
  106.         nlwExtra = nlwidth;
  107.         while (h--)
  108.         {
  109.         srcpix = psrc[iy];
  110.         iy++;
  111.         if (iy == tileHeight)
  112.             iy = 0;
  113.         *p = MROP_MASK(srcpix,*p,startmask);
  114.         p += nlwExtra;
  115.         }
  116.     }
  117.     else
  118.     {
  119.         maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
  120.         nlwExtra = nlwidth - nlwMiddle;
  121.  
  122.         if (startmask && endmask)
  123.         {
  124.         nlwExtra -= 1;
  125.         while (h--)
  126.         {
  127.             srcpix = psrc[iy];
  128.             iy++;
  129.             if (iy == tileHeight)
  130.             iy = 0;
  131.             nlw = nlwMiddle;
  132.             *p = MROP_MASK (srcpix,*p,startmask);
  133.             p++;
  134.             while (nlw--)
  135.             {
  136.             *p = MROP_SOLID(srcpix,*p);
  137.             p++;
  138.             }
  139.  
  140.             *p = MROP_MASK(srcpix,*p,endmask);
  141.             p += nlwExtra;
  142.         }
  143.         }
  144.         else if (startmask && !endmask)
  145.         {
  146.         nlwExtra -= 1;
  147.         while (h--)
  148.         {
  149.             srcpix = psrc[iy];
  150.             iy++;
  151.             if (iy == tileHeight)
  152.             iy = 0;
  153.             nlw = nlwMiddle;
  154.             *p = MROP_MASK(srcpix,*p,startmask);
  155.             p++;
  156.             while (nlw--)
  157.             {
  158.             *p = MROP_SOLID(srcpix,*p);
  159.             p++;
  160.             }
  161.             p += nlwExtra;
  162.         }
  163.         }
  164.         else if (!startmask && endmask)
  165.         {
  166.         while (h--)
  167.         {
  168.             srcpix = psrc[iy];
  169.             iy++;
  170.             if (iy == tileHeight)
  171.             iy = 0;
  172.             nlw = nlwMiddle;
  173.             while (nlw--)
  174.             {
  175.             *p = MROP_SOLID(srcpix,*p);
  176.             p++;
  177.             }
  178.  
  179.             *p = MROP_MASK(srcpix,*p,endmask);
  180.             p += nlwExtra;
  181.         }
  182.         }
  183.         else /* no ragged bits at either end */
  184.         {
  185.         while (h--)
  186.         {
  187.             srcpix = psrc[iy];
  188.             iy++;
  189.             if (iy == tileHeight)
  190.             iy = 0;
  191.             nlw = nlwMiddle;
  192.             while (nlw--)
  193.             {
  194.             *p = MROP_SOLID (srcpix,*p);
  195.             p++;
  196.             }
  197.             p += nlwExtra;
  198.         }
  199.         }
  200.     }
  201.         pbox++;
  202.     }
  203. }
  204.  
  205. #if (MROP) == 0
  206. void
  207. mfbTileArea32 (pDraw, nbox, pbox, alu, ptile)
  208.     DrawablePtr pDraw;
  209.     int nbox;
  210.     BoxPtr pbox;
  211.     int alu;
  212.     PixmapPtr ptile;
  213. {
  214.     void    (*f)(), mfbTileArea32Copy(), mfbTileArea32General();
  215.     
  216.     if (alu == GXcopy)
  217.     f = mfbTileArea32Copy;
  218.     else
  219.     f = mfbTileArea32General;
  220.     (*f) (pDraw, nbox, pbox, alu, ptile);
  221. }
  222. #endif
  223.