home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / mfb / mfbgetsp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-14  |  4.1 KB  |  140 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: mfbgetsp.c,v 5.5 89/09/14 16:26:46 rws Exp $ */
  26. #include "X.h"
  27. #include "Xmd.h"
  28.  
  29. #include "misc.h"
  30. #include "region.h"
  31. #include "gc.h"
  32. #include "windowstr.h"
  33. #include "pixmapstr.h"
  34. #include "scrnintstr.h"
  35.  
  36. #include "mfb.h"
  37. #include "maskbits.h"
  38.  
  39. #include "servermd.h"
  40.  
  41. /* GetSpans -- for each span, gets bits from drawable starting at ppt[i]
  42.  * and continuing for pwidth[i] bits
  43.  * Each scanline returned will be server scanline padded, i.e., it will come
  44.  * out to an integral number of words.
  45.  */
  46. /*ARGSUSED*/
  47. void
  48. mfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart)
  49.     DrawablePtr        pDrawable;    /* drawable from which to get bits */
  50.     int            wMax;        /* largest value of all *pwidths */
  51.     register DDXPointPtr ppt;        /* points to start copying from */
  52.     int            *pwidth;    /* list of number of bits to copy */
  53.     int            nspans;        /* number of scanlines to copy */
  54.     unsigned int    *pdstStart;    /* where to put the bits */
  55. {
  56.     register unsigned int    *pdst;    /* where to put the bits */
  57.     register unsigned int    *psrc;    /* where to get the bits */
  58.     register unsigned int    tmpSrc;    /* scratch buffer for bits */
  59.     unsigned int        *psrcBase;    /* start of src bitmap */
  60.     int            widthSrc;    /* width of pixmap in bytes */
  61.     register DDXPointPtr pptLast;    /* one past last point to get */
  62.     int             xEnd;        /* last pixel to copy from */
  63.     register int    nstart; 
  64.     int             nend; 
  65.     int             srcStartOver; 
  66.     int             startmask, endmask, nlMiddle, nl, srcBit;
  67.     int            w;
  68.   
  69.     pptLast = ppt + nspans;
  70.  
  71.     if (pDrawable->type == DRAWABLE_WINDOW)
  72.     {
  73.     psrcBase = (unsigned int *)
  74.         (((PixmapPtr)(pDrawable->pScreen->devPrivate))->devPrivate.ptr);
  75.     widthSrc = (int)
  76.            ((PixmapPtr)(pDrawable->pScreen->devPrivate))->devKind;
  77.     }
  78.     else
  79.     {
  80.     psrcBase = (unsigned int *)(((PixmapPtr)pDrawable)->devPrivate.ptr);
  81.     widthSrc = (int)(((PixmapPtr)pDrawable)->devKind);
  82.     }
  83.     pdst = pdstStart;
  84.  
  85.     while(ppt < pptLast)
  86.     {
  87.     xEnd = min(ppt->x + *pwidth, widthSrc << 3);
  88.     pwidth++;
  89.     psrc = psrcBase + (ppt->y * (widthSrc >> 2)) + (ppt->x >> 5); 
  90.     w = xEnd - ppt->x;
  91.     srcBit = ppt->x & 0x1f;
  92.  
  93.     if (srcBit + w <= 32) 
  94.     { 
  95.         getandputbits0(psrc, srcBit, w, pdst);
  96.         pdst++;
  97.     } 
  98.     else 
  99.     { 
  100.  
  101.         maskbits(ppt->x, w, startmask, endmask, nlMiddle);
  102.         if (startmask) 
  103.         nstart = 32 - srcBit; 
  104.         else 
  105.         nstart = 0; 
  106.         if (endmask) 
  107.         nend = xEnd & 0x1f; 
  108.         srcStartOver = srcBit + nstart > 31;
  109.         if (startmask) 
  110.         { 
  111.         getandputbits0(psrc, srcBit, nstart, pdst);
  112.         if(srcStartOver)
  113.             psrc++;
  114.         } 
  115.         nl = nlMiddle; 
  116. #ifdef FASTPUTBITS
  117.         Duff(nl, putbits(*psrc, nstart, 32, pdst); psrc++; pdst++;);
  118. #else
  119.         while (nl--) 
  120.         { 
  121.         tmpSrc = *psrc;
  122.         putbits(tmpSrc, nstart, 32, pdst);
  123.         psrc++;
  124.         pdst++;
  125.         } 
  126. #endif
  127.         if (endmask) 
  128.         { 
  129.         putbits(*psrc, nstart, nend, pdst);
  130.         if(nstart + nend > 32)
  131.             pdst++;
  132.         } 
  133.         if (startmask || endmask)
  134.         pdst++; 
  135.     } 
  136.         ppt++;
  137.     }
  138. }
  139.  
  140.