mipoly.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /***********************************************************
  2. Copyright 1987, 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. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
  20. All Rights Reserved
  21. Permission to use, copy, modify, and distribute this software and its
  22. documentation for any purpose and without fee is hereby granted,
  23. provided that the above copyright notice appear in all copies and that
  24. both that copyright notice and this permission notice appear in
  25. supporting documentation, and that the name of Digital not be
  26. used in advertising or publicity pertaining to distribution of the
  27. software without specific, written prior permission.
  28. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  29. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  30. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  31. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  32. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  33. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  34. SOFTWARE.
  35. ******************************************************************/
  36. /*
  37. * mipoly.c
  38. *
  39. * Written by Brian Kelleher; June 1986
  40. *
  41. * Draw polygons. This routine translates the point by the
  42. * origin if pGC->miTranslate is non-zero, and calls
  43. * to the appropriate routine to actually scan convert the
  44. * polygon.
  45. */
  46. #ifdef HAVE_DIX_CONFIG_H
  47. #include <dix-config.h>
  48. #endif
  49. #include <X11/X.h>
  50. #include "windowstr.h"
  51. #include "gcstruct.h"
  52. #include "pixmapstr.h"
  53. #include "mi.h"
  54. #include "regionstr.h"
  55. _X_EXPORT void
  56. miFillPolygon(dst, pgc, shape, mode, count, pPts)
  57. DrawablePtr dst;
  58. GCPtr pgc;
  59. int shape, mode;
  60. int count;
  61. DDXPointPtr pPts;
  62. {
  63. int i;
  64. int xorg, yorg;
  65. DDXPointPtr ppt;
  66. if (count == 0)
  67. return;
  68. ppt = pPts;
  69. if (pgc->miTranslate)
  70. {
  71. xorg = dst->x;
  72. yorg = dst->y;
  73. if (mode == CoordModeOrigin)
  74. {
  75. for (i = 0; i<count; i++)
  76. {
  77. ppt->x += xorg;
  78. ppt++->y += yorg;
  79. }
  80. }
  81. else
  82. {
  83. ppt->x += xorg;
  84. ppt++->y += yorg;
  85. for (i = 1; i<count; i++)
  86. {
  87. ppt->x += (ppt-1)->x;
  88. ppt->y += (ppt-1)->y;
  89. ppt++;
  90. }
  91. }
  92. }
  93. else
  94. {
  95. if (mode == CoordModePrevious)
  96. {
  97. ppt++;
  98. for (i = 1; i<count; i++)
  99. {
  100. ppt->x += (ppt-1)->x;
  101. ppt->y += (ppt-1)->y;
  102. ppt++;
  103. }
  104. }
  105. }
  106. if (shape == Convex)
  107. miFillConvexPoly(dst, pgc, count, pPts);
  108. else
  109. miFillGeneralPoly(dst, pgc, count, pPts);
  110. }