/libX11/src/DrLine.c

https://github.com/ArcticaProject/vcxsrv · C · 85 lines · 47 code · 11 blank · 27 comment · 9 complexity · 84ebea53c0b8f26be306383cc4929342 MD5 · raw file

  1. /*
  2. Copyright 1986, 1998 The Open Group
  3. Permission to use, copy, modify, distribute, and sell this software and its
  4. documentation for any purpose is hereby granted without fee, provided that
  5. the above copyright notice appear in all copies and that both that
  6. copyright notice and this permission notice appear in supporting
  7. documentation.
  8. The above copyright notice and this permission notice shall be included in
  9. all copies or substantial portions of the Software.
  10. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  13. OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  14. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  15. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  16. Except as contained in this notice, the name of The Open Group shall not be
  17. used in advertising or otherwise to promote the sale, use or other dealings
  18. in this Software without prior written authorization from The Open Group.
  19. */
  20. #ifdef HAVE_CONFIG_H
  21. #include <config.h>
  22. #endif
  23. #include "Xlibint.h"
  24. /* precompute the maximum size of batching request allowed */
  25. #define wsize (SIZEOF(xPolySegmentReq) + WLNSPERBATCH * SIZEOF(xSegment))
  26. #define zsize (SIZEOF(xPolySegmentReq) + ZLNSPERBATCH * SIZEOF(xSegment))
  27. int
  28. XDrawLine (
  29. register Display *dpy,
  30. Drawable d,
  31. GC gc,
  32. int x1,
  33. int y1,
  34. int x2,
  35. int y2)
  36. {
  37. register xSegment *segment;
  38. LockDisplay(dpy);
  39. FlushGC(dpy, gc);
  40. {
  41. register xPolySegmentReq *req = (xPolySegmentReq *) dpy->last_req;
  42. /* if same as previous request, with same drawable, batch requests */
  43. if (
  44. (req->reqType == X_PolySegment)
  45. && (req->drawable == d)
  46. && (req->gc == gc->gid)
  47. && ((dpy->bufptr + SIZEOF(xSegment)) <= dpy->bufmax)
  48. && (((char *)dpy->bufptr - (char *)req) < (gc->values.line_width ?
  49. wsize : zsize)) ) {
  50. req->length += SIZEOF(xSegment) >> 2;
  51. segment = (xSegment *) dpy->bufptr;
  52. dpy->bufptr += SIZEOF(xSegment);
  53. }
  54. else {
  55. GetReqExtra (PolySegment, SIZEOF(xSegment), req);
  56. req->drawable = d;
  57. req->gc = gc->gid;
  58. segment = (xSegment *) NEXTPTR(req,xPolySegmentReq);
  59. }
  60. segment->x1 = x1;
  61. segment->y1 = y1;
  62. segment->x2 = x2;
  63. segment->y2 = y2;
  64. UnlockDisplay(dpy);
  65. SyncHandle();
  66. }
  67. return 1;
  68. }