home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / cfb / cfbzerarc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-10  |  5.2 KB  |  196 lines

  1. /************************************************************
  2. Copyright 1989 by The Massachusetts Institute of Technology
  3.  
  4. Permission to use, copy, modify, and distribute this
  5. software and its documentation for any purpose and without
  6. fee is hereby granted, provided that the above copyright
  7. notice appear in all copies and that both that copyright
  8. notice and this permission notice appear in supporting
  9. documentation, and that the name of MIT not be used in
  10. advertising or publicity pertaining to distribution of the
  11. software without specific prior written permission.
  12. M.I.T. makes no representation about the suitability of
  13. this software for any purpose. It is provided "as is"
  14. without any express or implied warranty.
  15.  
  16. ********************************************************/
  17.  
  18. /* $XConsortium: cfbzerarc.c,v 5.18 91/04/10 11:41:47 keith Exp $ */
  19.  
  20. /* Derived from:
  21.  * "Algorithm for drawing ellipses or hyperbolae with a digital plotter"
  22.  * by M. L. V. Pitteway
  23.  * The Computer Journal, November 1967, Volume 10, Number 3, pp. 282-289
  24.  */
  25.  
  26. #include "X.h"
  27. #include "Xprotostr.h"
  28. #include "miscstruct.h"
  29. #include "gcstruct.h"
  30. #include "pixmapstr.h"
  31. #include "scrnintstr.h"
  32. #include "cfb.h"
  33. #include "cfbmskbits.h"
  34. #include "mizerarc.h"
  35. #include "cfbrrop.h"
  36.  
  37. #if PPW == 4
  38.  
  39. extern void miPolyArc(), miZeroPolyArc();
  40.  
  41. static void
  42. RROP_NAME(cfbZeroArcSS8) (pDraw, pGC, arc)
  43.     DrawablePtr pDraw;
  44.     GCPtr pGC;
  45.     xArc *arc;
  46. {
  47.     miZeroArcRec info;
  48.     Bool do360;
  49.     register int x;
  50.     unsigned char *addrb;
  51.     register unsigned char *yorgb, *yorgob;
  52.     RROP_DECLARE
  53.     register int yoffset;
  54.     int nbwidth, dyoffset;
  55.     register int y, a, b, d, mask;
  56.     register int k1, k3, dx, dy;
  57.  
  58.     cfbGetByteWidthAndPointer(pDraw,nbwidth, addrb)
  59.  
  60.     RROP_FETCH_GC (pGC);
  61.     do360 = miZeroArcSetup(arc, &info, TRUE);
  62.     yorgb = addrb + ((info.yorg + pDraw->y) * nbwidth);
  63.     yorgob = addrb + ((info.yorgo + pDraw->y) * nbwidth);
  64.     info.xorg += pDraw->x;
  65.     info.xorgo += pDraw->x;
  66.     MIARCSETUP();
  67.     yoffset = y ? nbwidth : 0;
  68.     dyoffset = 0;
  69.     mask = info.initialMask;
  70.     if (!(arc->width & 1))
  71.     {
  72.     if (mask & 2)
  73.         RROP_SOLID((yorgb + info.xorgo));
  74.     if (mask & 8)
  75.         RROP_SOLID((yorgob + info.xorgo));
  76.     }
  77.     if (!info.end.x || !info.end.y)
  78.     {
  79.     mask = info.end.mask;
  80.     info.end = info.altend;
  81.     }
  82.     if (do360 && (arc->width == arc->height) && !(arc->width & 1))
  83.     {
  84.     register int xoffset = nbwidth;
  85.     unsigned char *yorghb = yorgb + (info.h * nbwidth) + info.xorg;
  86.     unsigned char *yorgohb = yorghb - info.h;
  87.  
  88.     yorgb += info.xorg;
  89.     yorgob += info.xorg;
  90.     yorghb += info.h;
  91.     while (1)
  92.     {
  93.         RROP_SOLID(yorgb + yoffset + x);
  94.         RROP_SOLID(yorgb + yoffset - x);
  95.         RROP_SOLID(yorgob - yoffset - x);
  96.         RROP_SOLID(yorgob - yoffset + x);
  97.         if (a < 0)
  98.         break;
  99.         RROP_SOLID(yorghb - xoffset - y);
  100.         RROP_SOLID(yorgohb - xoffset + y);
  101.         RROP_SOLID(yorgohb + xoffset + y);
  102.         RROP_SOLID(yorghb + xoffset - y);
  103.         xoffset += nbwidth;
  104.         MIARCCIRCLESTEP(yoffset += nbwidth;);
  105.     }
  106.     yorgb -= info.xorg;
  107.     yorgob -= info.xorg;
  108.     x = info.w;
  109.     yoffset = info.h * nbwidth;
  110.     }
  111.     else if (do360)
  112.     {
  113.     while (y < info.h || x < info.w)
  114.     {
  115.         MIARCOCTANTSHIFT(dyoffset = nbwidth;);
  116.         RROP_SOLID(yorgb + yoffset + info.xorg + x);
  117.         RROP_SOLID(yorgb + yoffset + info.xorgo - x);
  118.         RROP_SOLID(yorgob - yoffset + info.xorgo - x);
  119.         RROP_SOLID(yorgob - yoffset + info.xorg + x);
  120.         MIARCSTEP(yoffset += dyoffset;, yoffset += nbwidth;);
  121.     }
  122.     }
  123.     else
  124.     {
  125.     while (y < info.h || x < info.w)
  126.     {
  127.         MIARCOCTANTSHIFT(dyoffset = nbwidth;);
  128.         if ((x == info.start.x) || (y == info.start.y))
  129.         {
  130.         mask = info.start.mask;
  131.         info.start = info.altstart;
  132.         }
  133.         if (mask & 1)
  134.         RROP_SOLID(yorgb + yoffset + info.xorg + x);
  135.         if (mask & 2)
  136.         RROP_SOLID(yorgb + yoffset + info.xorgo - x);
  137.         if (mask & 4)
  138.         RROP_SOLID(yorgob - yoffset + info.xorgo - x);
  139.         if (mask & 8)
  140.         RROP_SOLID(yorgob - yoffset + info.xorg + x);
  141.         if ((x == info.end.x) || (y == info.end.y))
  142.         {
  143.         mask = info.end.mask;
  144.         info.end = info.altend;
  145.         }
  146.         MIARCSTEP(yoffset += dyoffset;, yoffset += nbwidth;);
  147.     }
  148.     }
  149.     if ((x == info.start.x) || (y == info.start.y))
  150.     mask = info.start.mask;
  151.     if (mask & 1)
  152.     RROP_SOLID(yorgb + yoffset + info.xorg + x);
  153.     if (mask & 4)
  154.     RROP_SOLID(yorgob - yoffset + info.xorgo - x);
  155.     if (arc->height & 1)
  156.     {
  157.     if (mask & 2)
  158.         RROP_SOLID(yorgb + yoffset + info.xorgo - x);
  159.     if (mask & 8)
  160.         RROP_SOLID(yorgob - yoffset + info.xorg + x);
  161.     }
  162. }
  163.  
  164. void
  165. RROP_NAME (cfbZeroPolyArcSS8) (pDraw, pGC, narcs, parcs)
  166.     register DrawablePtr    pDraw;
  167.     GCPtr    pGC;
  168.     int        narcs;
  169.     xArc    *parcs;
  170. {
  171.     register xArc *arc;
  172.     register int i;
  173.     BoxRec box;
  174.     RegionPtr cclip;
  175.  
  176.     cclip = ((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip;
  177.     for (arc = parcs, i = narcs; --i >= 0; arc++)
  178.     {
  179.     if (miCanZeroArc(arc))
  180.     {
  181.         box.x1 = arc->x + pDraw->x;
  182.         box.y1 = arc->y + pDraw->y;
  183.         box.x2 = box.x1 + (int)arc->width + 1;
  184.         box.y2 = box.y1 + (int)arc->height + 1;
  185.         if ((*pDraw->pScreen->RectIn)(cclip, &box) == rgnIN)
  186.         RROP_NAME (cfbZeroArcSS8) (pDraw, pGC, arc);
  187.         else
  188.         miZeroPolyArc(pDraw, pGC, 1, arc);
  189.     }
  190.     else
  191.         miPolyArc(pDraw, pGC, 1, arc);
  192.     }
  193. }
  194.  
  195. #endif
  196.