home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xibm.zip / apa16 / apa16PntA.c < prev    next >
C/C++ Source or Header  |  1991-12-30  |  10KB  |  329 lines

  1. /***********************************************************
  2. Copyright 1987 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.         Copyright IBM Corporation 1987,1988
  26.  
  27.                       All Rights Reserved
  28.  
  29. Permission to use, copy, modify, and distribute this software and its 
  30. documentation for any purpose and without fee is hereby granted, 
  31. provided that the above copyright notice appear in all copies and that
  32. both that copyright notice and this permission notice appear in 
  33. supporting documentation, and that the name of IBM not be
  34. used in advertising or publicity pertaining to distribution of the
  35. software without specific, written prior permission.  
  36.  
  37. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  38. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  39. IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  40. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  41. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  42. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  43. SOFTWARE.
  44.  
  45. ******************************************************************/
  46. /***********************************************************
  47. Copyright 1989 by the Massachusetts Institute of Technology
  48.  
  49.                      All rights reserved.
  50.  
  51. Permission to use, copy, modify, and distribute this software and its
  52. documentation for any purpose and without fee is hereby granted,
  53. provided that the above copyright notice appear in all copies and that
  54. both that copyright notice and this permission notice appear in
  55. supporting documentation, and that the name of the Massachusetts
  56. Institute of Technology (M.I.T.) not be used in advertising or publicity
  57. pertaining to distribution of the software without specific, written
  58. prior permission.
  59.  
  60. M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  61. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  62. M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  63. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  64. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  65. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  66. SOFTWARE.
  67.  
  68. ******************************************************************/
  69.  
  70. /* $Header: /afs/athena.mit.edu/astaff/project/x11r5/src/athena/ibm/apa16/RCS/apa16PntA.c,v 5.0 1991/12/30 19:27:05 jfc Exp $ */
  71. /* $Source: /afs/athena.mit.edu/astaff/project/x11r5/src/athena/ibm/apa16/RCS/apa16PntA.c,v $ */
  72.  
  73. #ifndef lint
  74. static char *rcsid = "$Header: /afs/athena.mit.edu/astaff/project/x11r5/src/athena/ibm/apa16/RCS/apa16PntA.c,v 5.0 1991/12/30 19:27:05 jfc Exp $";
  75. #endif
  76.  
  77. #include "X.h"
  78.  
  79. #include "windowstr.h"
  80. #include "regionstr.h"
  81. #include "pixmapstr.h"
  82. #include "scrnintstr.h"
  83. #include "gcstruct.h"
  84.  
  85. #include "mfb.h"
  86. #include "maskbits.h"
  87.  
  88. #include "OScompiler.h"
  89. #include "ibmTrace.h"
  90.  
  91. #include "apa16Hdwr.h"
  92.  
  93. /* 
  94.    the solid fillers are called for rectangles and window backgrounds.
  95.    the boxes are already translated.
  96.    8/4/87 -- modified for RT/apa16 by erik
  97.  
  98.    NOTE:
  99.    iy = ++iy < tileHeight ? iy : 0
  100. is equivalent to iy%= tileheight, and saves a division.
  101. */
  102.  
  103. void
  104. apa16SolidFillArea(pDraw, nbox, pbox, rrop, nop)
  105.     DrawablePtr pDraw;
  106.     int nbox;
  107.     BoxPtr pbox;
  108.     int rrop;
  109.     PixmapPtr nop;
  110. {
  111.     if (rrop==RROP_NOP)
  112.     return;
  113.     if (pDraw->type != DRAWABLE_WINDOW)
  114.       {
  115.     if (rrop==RROP_BLACK)    
  116.         mfbSolidBlackArea(pDraw,nbox,pbox,rrop,nop);
  117.     else if (rrop==RROP_WHITE)
  118.         mfbSolidWhiteArea(pDraw,nbox,pbox,rrop,nop);
  119.     else if (rrop==RROP_INVERT)
  120.         mfbSolidInvertArea(pDraw,nbox,pbox,rrop,nop);
  121.     return;
  122.       }
  123.  
  124.     /* If the number of rectangles is less than the queue size, it
  125.        is only necessary to check the queue once. */
  126.     if (nbox * 5 < QUEUE_DANGER)
  127.       {
  128.     unsigned short cmd;
  129.  
  130.     RESERVE_QUEUE(nbox * 5);
  131.  
  132.     APA16_GET_CMD_FILL(rrop,cmd);
  133.     cmd |= EXEC_MASK;
  134.  
  135.     while (nbox--)
  136.       {
  137.         register int w,h;
  138.  
  139.         w = pbox->x2 - pbox->x1;
  140.         h = pbox->y2 - pbox->y1;
  141.         if (w > 0 && h > 0)
  142.           {
  143.         FILL_RECT_NOCHECK(cmd,pbox->x2,pbox->y2,w,h);
  144.           }
  145.         pbox++;
  146.       }
  147.       }
  148.     else
  149.       {
  150.     unsigned short cmd;
  151.     /* This contains an upper bound for the queue length:
  152.        it is initialized to the queue size and incremented every
  153.        time something is added to the queue.  */
  154.     int queue_size = QUEUE_CNTR;
  155.  
  156.     APA16_GET_CMD_FILL(rrop,cmd);
  157.     cmd |= EXEC_MASK;
  158.  
  159.     while (nbox--)
  160.       {
  161.         register int w,h;
  162.  
  163.         w = pbox->x2 - pbox->x1;
  164.         h = pbox->y2 - pbox->y1;
  165.         if (w > 0 && h > 0)
  166.           {
  167.         if (apa16Qoffset < 6)
  168.           {
  169.             /* Branch to top of queue. */
  170.             LOAD_QUEUE(QPTR_QUEUE_TOP,0);
  171.             apa16Qoffset= QUEUE_SIZE;
  172.           }
  173.         if (++queue_size >= QUEUE_DANGER)
  174.           queue_size = QUEUE_CNTR;
  175.         if (queue_size >= QUEUE_DANGER)
  176.           while (QUEUE_CNTR >= QUEUE_DANGER);
  177.         FILL_RECT_NOCHECK(cmd,pbox->x2,pbox->y2,w,h);
  178.           }
  179.         pbox++;
  180.       }
  181.       }
  182. }
  183.  
  184.  
  185.  
  186. /* stipple a list of boxes
  187.  
  188. you can use the reduced rasterop for stipples.  if rrop is
  189. black, AND the destination with (not stipple pattern).  if rrop is
  190. white OR the destination with the stipple pattern.  if rrop is invert,
  191. XOR the destination with the stipple pattern.
  192.  
  193. */
  194.  
  195. void
  196. apa16StippleFillArea(pDraw, nbox, pbox, rrop, pstipple)
  197.     DrawablePtr pDraw;
  198.     int nbox;
  199.     BoxPtr pbox;
  200.     int rrop;
  201.     PixmapPtr pstipple;
  202. {
  203.     register unsigned int *psrc;
  204.             /* pointer to bits in tile, if needed */
  205.     int tileHeight;    /* height of the tile */
  206.     register unsigned int srcpix;    
  207.  
  208.     int w;        /* width of current box */
  209.     register int h;    /* height of current box */
  210.     int startmask;
  211.     int endmask;    /* masks for reggedy bits at either end of line */
  212.     int nlwMiddle;    /* number of longwords between sides of boxes */
  213.     register int nlwExtra;    
  214.                 /* to get from right of box to left of next span */
  215.     
  216.     register int nlw;    /* loop version of nlwMiddle */
  217.     register unsigned int *p;    /* pointer to bits we're writing */
  218.     int iy;        /* index of current scanline in tile */
  219.  
  220.  
  221.     if (pDraw->type != DRAWABLE_WINDOW)
  222.       {
  223.      if (rrop==RROP_WHITE)
  224.         mfbStippleWhiteArea(pDraw, nbox, pbox, rrop, pstipple);
  225.     else if (rrop==RROP_BLACK)
  226.         mfbStippleBlackArea(pDraw, nbox, pbox, rrop, pstipple);
  227.     else if (rrop==RROP_INVERT)
  228.         mfbStippleInvertArea(pDraw, nbox, pbox, rrop, pstipple);
  229.     return;
  230.       }
  231.  
  232.     if        (rrop == RROP_BLACK)    { SET_MERGE_MODE(MERGE_BLACK); }
  233.     else if    (rrop == RROP_WHITE)    { SET_MERGE_MODE(MERGE_WHITE); }
  234.     else if    (rrop == RROP_INVERT)    { SET_MERGE_MODE(MERGE_INVERT); }
  235.     else if    (rrop == RROP_NOP)    return;
  236.     else {
  237.     ErrorF("Unexpected rrop %d in apa16StippleFillArea\n",rrop);
  238.     return;
  239.     }
  240.  
  241.     tileHeight = pstipple->drawable.height;
  242.     psrc = (unsigned int *)(pstipple->devPrivate.ptr);
  243.  
  244.     while (nbox--)
  245.     {
  246.     w = pbox->x2 - pbox->x1;
  247.     h = pbox->y2 - pbox->y1;
  248.     iy = pbox->y1 % tileHeight;
  249.     p = (unsigned int *)APA16_BASE + (pbox->y1 * (APA16_WIDTH / 32)) + (pbox->x1 >> 5);
  250.  
  251.     if ( ((pbox->x1 & 0x1f) + w) < 32)
  252.     {
  253.         maskpartialbits(pbox->x1, w, startmask);
  254.         while (h--)
  255.         {
  256.         srcpix = psrc[iy];
  257.         if (++iy >= tileHeight)
  258.           iy = 0;
  259.         *p = (srcpix & startmask);
  260.         p += APA16_WIDTH / 32;
  261.         }
  262.     }
  263.     else
  264.     {
  265.         maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
  266.         nlwExtra = APA16_WIDTH / 32 - nlwMiddle;
  267.  
  268.         if (startmask && endmask)
  269.         {
  270.         nlwExtra -= 1;
  271.         while (h--)
  272.         {
  273.             srcpix = psrc[iy];
  274.             if (++iy >= tileHeight)
  275.               iy = 0;
  276.             nlw = nlwMiddle;
  277.             *p = (srcpix & startmask);
  278.             p++;
  279.             Duff (nlw, *p++ = srcpix);
  280.             *p = (srcpix & endmask);
  281.             p += nlwExtra;
  282.         }
  283.         }
  284.         else if (startmask && !endmask)
  285.         {
  286.         nlwExtra -= 1;
  287.         while (h--)
  288.         {
  289.             srcpix = psrc[iy];
  290.             if (++iy >= tileHeight)
  291.               iy = 0;
  292.             nlw = nlwMiddle;
  293.             *p = (srcpix & startmask);
  294.             p++;
  295.             Duff (nlw, *p++ = srcpix);
  296.             p += nlwExtra;
  297.         }
  298.         }
  299.         else if (!startmask && endmask)
  300.         {
  301.         while (h--)
  302.         {
  303.             srcpix = psrc[iy];
  304.             if (++iy >= tileHeight)
  305.               iy = 0;
  306.             nlw = nlwMiddle;
  307.             Duff(nlw, *p++ = srcpix);
  308.             *p = (srcpix & endmask);
  309.             p += nlwExtra;
  310.         }
  311.         }
  312.         else /* no ragged bits at either end */
  313.         {
  314.         while (h--)
  315.         {
  316.             srcpix = psrc[iy];
  317.             if (++iy >= tileHeight)
  318.               iy = 0;
  319.             nlw = nlwMiddle;
  320.             Duff(nlw, *p++ = srcpix);
  321.             p += nlwExtra;
  322.         }
  323.         }
  324.     }
  325.         pbox++;
  326.     }
  327.     SET_MERGE_MODE(MERGE_COPY);
  328. }
  329.