home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / lib / X / XDrLine.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-01-29  |  2.3 KB  |  83 lines

  1. /* $XConsortium: XDrLine.c,v 11.15 91/01/06 11:45:13 rws Exp $ */
  2. /* Copyright    Massachusetts Institute of Technology    1986    */
  3.  
  4. /*
  5. Permission to use, copy, modify, distribute, and sell this software and its
  6. documentation for any purpose is hereby granted without fee, provided that
  7. the above copyright notice appear in all copies and that both that
  8. copyright notice and this permission notice appear in supporting
  9. documentation, and that the name of M.I.T. not be used in advertising or
  10. publicity pertaining to distribution of the software without specific,
  11. written prior permission.  M.I.T. makes no representations about the
  12. suitability of this software for any purpose.  It is provided "as is"
  13. without express or implied warranty.
  14. */
  15.  
  16. #include "Xlibint.h"
  17.  
  18. /* precompute the maximum size of batching request allowed */
  19.  
  20. #define wsize (SIZEOF(xPolySegmentReq) + WLNSPERBATCH * SIZEOF(xSegment))
  21. #define zsize (SIZEOF(xPolySegmentReq) + ZLNSPERBATCH * SIZEOF(xSegment))
  22.  
  23. XDrawLine (dpy, d, gc, x1, y1, x2, y2)
  24.     register Display *dpy;
  25.     Drawable d;
  26.     GC gc;
  27.     int x1, y1, x2, y2;
  28. {
  29.     register xSegment *segment;
  30. #ifdef MUSTCOPY
  31.     xSegment segmentdata;
  32.     long len = SIZEOF(xSegment);
  33.  
  34.     segment = &segmentdata;
  35. #endif /* not MUSTCOPY */
  36.  
  37.     LockDisplay(dpy);
  38.     FlushGC(dpy, gc);
  39.  
  40.     {
  41.     register xPolySegmentReq *req = (xPolySegmentReq *) dpy->last_req;
  42.  
  43.     /* if same as previous request, with same drawable, batch requests */
  44.     if (
  45.           (req->reqType == X_PolySegment)
  46.        && (req->drawable == d)
  47.        && (req->gc == gc->gid)
  48.        && ((dpy->bufptr + SIZEOF(xSegment)) <= dpy->bufmax)
  49.        && (((char *)dpy->bufptr - (char *)req) < (gc->values.line_width ?
  50.                           wsize : zsize)) ) {
  51.      req->length += SIZEOF(xSegment) >> 2;
  52. #ifndef MUSTCOPY
  53.          segment = (xSegment *) dpy->bufptr;
  54.      dpy->bufptr += SIZEOF(xSegment);
  55. #endif /* not MUSTCOPY */
  56.      }
  57.  
  58.     else {
  59.     GetReqExtra (PolySegment, SIZEOF(xSegment), req);
  60.     req->drawable = d;
  61.     req->gc = gc->gid;
  62. #ifdef MUSTCOPY
  63.     dpy->bufptr -= SIZEOF(xSegment);
  64. #else
  65.     segment = (xSegment *) NEXTPTR(req,xPolySegmentReq);
  66. #endif /* MUSTCOPY */
  67.     }
  68.  
  69.     segment->x1 = x1;
  70.     segment->y1 = y1;
  71.     segment->x2 = x2;
  72.     segment->y2 = y2;
  73.  
  74. #ifdef MUSTCOPY
  75.     Data (dpy, (char *) &segmentdata, len);
  76. #endif /* MUSTCOPY */
  77.  
  78.     UnlockDisplay(dpy);
  79.     SyncHandle();
  80.     }
  81. }
  82.  
  83.