home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / mfb / mfbhrzvert.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-13  |  3.9 KB  |  151 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: mfbhrzvert.c,v 1.11 89/09/13 18:58:09 rws Exp $ */
  26. #include "X.h"
  27.  
  28. #include "gc.h"
  29. #include "window.h"
  30. #include "pixmap.h"
  31. #include "region.h"
  32.  
  33. #include "mfb.h"
  34. #include "maskbits.h"
  35.  
  36. /* horizontal solid line
  37.    abs(len) > 1
  38. */
  39. mfbHorzS(rop, addrl, nlwidth, x1, y1, len)
  40. int rop;        /* a reduced rasterop */
  41. register int *addrl;    /* pointer to base of bitmap */
  42. register int nlwidth;    /* width in longwords of bitmap */
  43. int x1;            /* initial point */ 
  44. int y1;
  45. int len;        /* length of line */
  46. {
  47.     register int startmask;
  48.     register int endmask;
  49.     register int nlmiddle;
  50.  
  51.  
  52.     /* force the line to go left to right
  53.        but don't draw the last point
  54.     */
  55.     if (len < 0)
  56.     {
  57.     x1 += len;
  58.     x1 += 1;
  59.     len = -len;
  60.     }
  61.  
  62.     addrl = addrl + (y1 * nlwidth) + (x1 >> 5);
  63.  
  64.     /* all bits inside same longword */
  65.     if ( ((x1 & 0x1f) + len) < 32)
  66.     {
  67.     maskpartialbits(x1, len, startmask);
  68.         if (rop == RROP_BLACK)
  69.         {
  70.         *addrl &= ~startmask;
  71.         }
  72.         else if (rop == RROP_WHITE)
  73.         {
  74.         *addrl |= startmask;
  75.         }
  76.         else if (rop == RROP_INVERT)
  77.         {
  78.         *addrl ^= startmask;
  79.         }
  80.     }
  81.     else
  82.     {
  83.     maskbits(x1, len, startmask, endmask, nlmiddle);
  84.         if (rop == RROP_BLACK)
  85.         {
  86.         if (startmask)
  87.         *addrl++ &= ~startmask;
  88.         Duff (nlmiddle, *addrl++ = 0x0);
  89.         if (endmask)
  90.         *addrl &= ~endmask;
  91.         }
  92.         else if (rop == RROP_WHITE)
  93.         {
  94.         if (startmask)
  95.         *addrl++ |= startmask;
  96.         Duff (nlmiddle, *addrl++ = 0xffffffff);
  97.         if (endmask)
  98.         *addrl |= endmask;
  99.         }
  100.         else if (rop == RROP_INVERT)
  101.         {
  102.         if (startmask)
  103.         *addrl++ ^= startmask;
  104.         Duff (nlmiddle, *addrl++ ^= 0xffffffff);
  105.         if (endmask)
  106.         *addrl ^= endmask;
  107.         }
  108.     }
  109. }
  110.  
  111. /* vertical solid line
  112.    this uses do loops because pcc (Ultrix 1.2, bsd 4.2) generates
  113.    better code.  sigh.  we know that len will never be 0 or 1, so
  114.    it's OK to use it.
  115. */
  116.  
  117. mfbVertS(rop, addrl, nlwidth, x1, y1, len)
  118. int rop;        /* a reduced rasterop */
  119. register int *addrl;    /* pointer to base of bitmap */
  120. register int nlwidth;    /* width in longwords of bitmap */
  121. int x1, y1;        /* initial point */
  122. register int len;    /* length of line */
  123. {
  124.     register int bitmask;
  125.  
  126.     addrl = addrl + (y1 * nlwidth) + (x1 >> 5);
  127.  
  128.     if (len < 0)
  129.     {
  130.     nlwidth = -nlwidth;
  131.     len = -len;
  132.     }
  133.  
  134.     if (rop == RROP_BLACK)
  135.     {
  136.     bitmask = rmask[x1&0x1f];
  137.         Duff(len, *addrl &= bitmask; addrl += nlwidth );
  138.     }
  139.     else if (rop == RROP_WHITE)
  140.     {
  141.     bitmask = mask[x1&0x1f];
  142.         Duff(len, *addrl |= bitmask; addrl += nlwidth );
  143.     }
  144.     else if (rop == RROP_INVERT)
  145.     {
  146.     bitmask = mask[x1&0x1f];
  147.         Duff(len, *addrl ^= bitmask; addrl += nlwidth );
  148.     }
  149. }
  150.  
  151.