mifillarc.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /************************************************************
  2. Copyright 1989, 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. #ifndef __MIFILLARC_H__
  21. #define __MIFILLARC_H__
  22. #define FULLCIRCLE (360 * 64)
  23. typedef struct _miFillArc {
  24. int xorg, yorg;
  25. int y;
  26. int dx, dy;
  27. int e;
  28. int ym, yk, xm, xk;
  29. } miFillArcRec;
  30. /* could use 64-bit integers */
  31. typedef struct _miFillArcD {
  32. int xorg, yorg;
  33. int y;
  34. int dx, dy;
  35. double e;
  36. double ym, yk, xm, xk;
  37. } miFillArcDRec;
  38. #define miFillArcEmpty(arc) (!(arc)->angle2 || \
  39. !(arc)->width || !(arc)->height || \
  40. (((arc)->width == 1) && ((arc)->height & 1)))
  41. #define miCanFillArc(arc) (((arc)->width == (arc)->height) || \
  42. (((arc)->width <= 800) && ((arc)->height <= 800)))
  43. #define MIFILLARCSETUP() \
  44. x = 0; \
  45. y = info.y; \
  46. e = info.e; \
  47. xk = info.xk; \
  48. xm = info.xm; \
  49. yk = info.yk; \
  50. ym = info.ym; \
  51. dx = info.dx; \
  52. dy = info.dy; \
  53. xorg = info.xorg; \
  54. yorg = info.yorg
  55. #define MIFILLARCSTEP(slw) \
  56. e += yk; \
  57. while (e >= 0) \
  58. { \
  59. x++; \
  60. xk -= xm; \
  61. e += xk; \
  62. } \
  63. y--; \
  64. yk -= ym; \
  65. slw = (x << 1) + dx; \
  66. if ((e == xk) && (slw > 1)) \
  67. slw--
  68. #define MIFILLCIRCSTEP(slw) MIFILLARCSTEP(slw)
  69. #define MIFILLELLSTEP(slw) MIFILLARCSTEP(slw)
  70. #define miFillArcLower(slw) (((y + dy) != 0) && ((slw > 1) || (e != xk)))
  71. typedef struct _miSliceEdge {
  72. int x;
  73. int stepx;
  74. int deltax;
  75. int e;
  76. int dy;
  77. int dx;
  78. } miSliceEdgeRec, *miSliceEdgePtr;
  79. typedef struct _miArcSlice {
  80. miSliceEdgeRec edge1, edge2;
  81. int min_top_y, max_top_y;
  82. int min_bot_y, max_bot_y;
  83. Bool edge1_top, edge2_top;
  84. Bool flip_top, flip_bot;
  85. } miArcSliceRec;
  86. #define MIARCSLICESTEP(edge) \
  87. edge.x -= edge.stepx; \
  88. edge.e -= edge.dx; \
  89. if (edge.e <= 0) \
  90. { \
  91. edge.x -= edge.deltax; \
  92. edge.e += edge.dy; \
  93. }
  94. #define miFillSliceUpper(slice) \
  95. ((y >= slice.min_top_y) && (y <= slice.max_top_y))
  96. #define miFillSliceLower(slice) \
  97. ((y >= slice.min_bot_y) && (y <= slice.max_bot_y))
  98. #define MIARCSLICEUPPER(xl,xr,slice,slw) \
  99. xl = xorg - x; \
  100. xr = xl + slw - 1; \
  101. if (slice.edge1_top && (slice.edge1.x < xr)) \
  102. xr = slice.edge1.x; \
  103. if (slice.edge2_top && (slice.edge2.x > xl)) \
  104. xl = slice.edge2.x;
  105. #define MIARCSLICELOWER(xl,xr,slice,slw) \
  106. xl = xorg - x; \
  107. xr = xl + slw - 1; \
  108. if (!slice.edge1_top && (slice.edge1.x > xl)) \
  109. xl = slice.edge1.x; \
  110. if (!slice.edge2_top && (slice.edge2.x < xr)) \
  111. xr = slice.edge2.x;
  112. #define MIWIDEARCSETUP(x,y,dy,slw,e,xk,xm,yk,ym) \
  113. x = 0; \
  114. y = slw >> 1; \
  115. yk = y << 3; \
  116. xm = 8; \
  117. ym = 8; \
  118. if (dy) \
  119. { \
  120. xk = 0; \
  121. if (slw & 1) \
  122. e = -1; \
  123. else \
  124. e = -(y << 2) - 2; \
  125. } \
  126. else \
  127. { \
  128. y++; \
  129. yk += 4; \
  130. xk = -4; \
  131. if (slw & 1) \
  132. e = -(y << 2) - 3; \
  133. else \
  134. e = - (y << 3); \
  135. }
  136. #define MIFILLINARCSTEP(slw) \
  137. ine += inyk; \
  138. while (ine >= 0) \
  139. { \
  140. inx++; \
  141. inxk -= inxm; \
  142. ine += inxk; \
  143. } \
  144. iny--; \
  145. inyk -= inym; \
  146. slw = (inx << 1) + dx; \
  147. if ((ine == inxk) && (slw > 1)) \
  148. slw--
  149. #define miFillInArcLower(slw) (((iny + dy) != 0) && \
  150. ((slw > 1) || (ine != inxk)))
  151. extern int miFreeArcCache(
  152. pointer /*data*/,
  153. XID /*id*/
  154. );
  155. extern struct finalSpan *realAllocSpan(
  156. void
  157. );
  158. extern void miFillArcSetup(
  159. xArc * /*arc*/,
  160. miFillArcRec * /*info*/
  161. );
  162. extern void miFillArcDSetup(
  163. xArc * /*arc*/,
  164. miFillArcDRec * /*info*/
  165. );
  166. extern void miEllipseAngleToSlope(
  167. int /*angle*/,
  168. int /*width*/,
  169. int /*height*/,
  170. int * /*dxp*/,
  171. int * /*dyp*/,
  172. double * /*d_dxp*/,
  173. double * /*d_dyp*/
  174. );
  175. extern void miFillArcSliceSetup(
  176. xArc * /*arc*/,
  177. miArcSliceRec * /*slice*/,
  178. GCPtr /*pGC*/
  179. );
  180. #endif /* __MIFILLARC_H__ */