| 1 | /************************************************************ |
| 2 | |
| 3 | Copyright 1989, 1998 The Open Group |
| 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. |
| 10 | |
| 11 | The above copyright notice and this permission notice shall be included in |
| 12 | all copies or substantial portions of the Software. |
| 13 | |
| 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 17 | OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 18 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 19 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 20 | |
| 21 | Except as contained in this notice, the name of The Open Group shall not be |
| 22 | used in advertising or otherwise to promote the sale, use or other dealings |
| 23 | in this Software without prior written authorization from The Open Group. |
| 24 | |
| 25 | ********************************************************/ |
| 26 | |
| 27 | #ifndef __MIFILLARC_H__ |
| 28 | #define __MIFILLARC_H__ |
| 29 | |
| 30 | #define FULLCIRCLE (360 * 64) |
| 31 | |
| 32 | typedef struct _miFillArc { |
| 33 | int xorg, yorg; |
| 34 | int y; |
| 35 | int dx, dy; |
| 36 | int e; |
| 37 | int ym, yk, xm, xk; |
| 38 | } miFillArcRec; |
| 39 | |
| 40 | /* could use 64-bit integers */ |
| 41 | typedef struct _miFillArcD { |
| 42 | int xorg, yorg; |
| 43 | int y; |
| 44 | int dx, dy; |
| 45 | double e; |
| 46 | double ym, yk, xm, xk; |
| 47 | } miFillArcDRec; |
| 48 | |
| 49 | #define miFillArcEmpty(arc) (!(arc)->angle2 || \ |
| 50 | !(arc)->width || !(arc)->height || \ |
| 51 | (((arc)->width == 1) && ((arc)->height & 1))) |
| 52 | |
| 53 | #define miCanFillArc(arc) (((arc)->width == (arc)->height) || \ |
| 54 | (((arc)->width <= 800) && ((arc)->height <= 800))) |
| 55 | |
| 56 | #define MIFILLARCSETUP() \ |
| 57 | x = 0; \ |
| 58 | y = info.y; \ |
| 59 | e = info.e; \ |
| 60 | xk = info.xk; \ |
| 61 | xm = info.xm; \ |
| 62 | yk = info.yk; \ |
| 63 | ym = info.ym; \ |
| 64 | dx = info.dx; \ |
| 65 | dy = info.dy; \ |
| 66 | xorg = info.xorg; \ |
| 67 | yorg = info.yorg |
| 68 | |
| 69 | #define MIFILLARCSTEP(slw) \ |
| 70 | e += yk; \ |
| 71 | while (e >= 0) \ |
| 72 | { \ |
| 73 | x++; \ |
| 74 | xk -= xm; \ |
| 75 | e += xk; \ |
| 76 | } \ |
| 77 | y--; \ |
| 78 | yk -= ym; \ |
| 79 | slw = (x << 1) + dx; \ |
| 80 | if ((e == xk) && (slw > 1)) \ |
| 81 | slw-- |
| 82 | |
| 83 | #define MIFILLCIRCSTEP(slw) MIFILLARCSTEP(slw) |
| 84 | #define MIFILLELLSTEP(slw) MIFILLARCSTEP(slw) |
| 85 | |
| 86 | #define miFillArcLower(slw) (((y + dy) != 0) && ((slw > 1) || (e != xk))) |
| 87 | |
| 88 | typedef struct _miSliceEdge { |
| 89 | int x; |
| 90 | int stepx; |
| 91 | int deltax; |
| 92 | int e; |
| 93 | int dy; |
| 94 | int dx; |
| 95 | } miSliceEdgeRec, *miSliceEdgePtr; |
| 96 | |
| 97 | typedef struct _miArcSlice { |
| 98 | miSliceEdgeRec edge1, edge2; |
| 99 | int min_top_y, max_top_y; |
| 100 | int min_bot_y, max_bot_y; |
| 101 | Bool edge1_top, edge2_top; |
| 102 | Bool flip_top, flip_bot; |
| 103 | } miArcSliceRec; |
| 104 | |
| 105 | #define MIARCSLICESTEP(edge) \ |
| 106 | edge.x -= edge.stepx; \ |
| 107 | edge.e -= edge.dx; \ |
| 108 | if (edge.e <= 0) \ |
| 109 | { \ |
| 110 | edge.x -= edge.deltax; \ |
| 111 | edge.e += edge.dy; \ |
| 112 | } |
| 113 | |
| 114 | #define miFillSliceUpper(slice) \ |
| 115 | ((y >= slice.min_top_y) && (y <= slice.max_top_y)) |
| 116 | |
| 117 | #define miFillSliceLower(slice) \ |
| 118 | ((y >= slice.min_bot_y) && (y <= slice.max_bot_y)) |
| 119 | |
| 120 | #define MIARCSLICEUPPER(xl,xr,slice,slw) \ |
| 121 | xl = xorg - x; \ |
| 122 | xr = xl + slw - 1; \ |
| 123 | if (slice.edge1_top && (slice.edge1.x < xr)) \ |
| 124 | xr = slice.edge1.x; \ |
| 125 | if (slice.edge2_top && (slice.edge2.x > xl)) \ |
| 126 | xl = slice.edge2.x; |
| 127 | |
| 128 | #define MIARCSLICELOWER(xl,xr,slice,slw) \ |
| 129 | xl = xorg - x; \ |
| 130 | xr = xl + slw - 1; \ |
| 131 | if (!slice.edge1_top && (slice.edge1.x > xl)) \ |
| 132 | xl = slice.edge1.x; \ |
| 133 | if (!slice.edge2_top && (slice.edge2.x < xr)) \ |
| 134 | xr = slice.edge2.x; |
| 135 | |
| 136 | #define MIWIDEARCSETUP(x,y,dy,slw,e,xk,xm,yk,ym) \ |
| 137 | x = 0; \ |
| 138 | y = slw >> 1; \ |
| 139 | yk = y << 3; \ |
| 140 | xm = 8; \ |
| 141 | ym = 8; \ |
| 142 | if (dy) \ |
| 143 | { \ |
| 144 | xk = 0; \ |
| 145 | if (slw & 1) \ |
| 146 | e = -1; \ |
| 147 | else \ |
| 148 | e = -(y << 2) - 2; \ |
| 149 | } \ |
| 150 | else \ |
| 151 | { \ |
| 152 | y++; \ |
| 153 | yk += 4; \ |
| 154 | xk = -4; \ |
| 155 | if (slw & 1) \ |
| 156 | e = -(y << 2) - 3; \ |
| 157 | else \ |
| 158 | e = - (y << 3); \ |
| 159 | } |
| 160 | |
| 161 | #define MIFILLINARCSTEP(slw) \ |
| 162 | ine += inyk; \ |
| 163 | while (ine >= 0) \ |
| 164 | { \ |
| 165 | inx++; \ |
| 166 | inxk -= inxm; \ |
| 167 | ine += inxk; \ |
| 168 | } \ |
| 169 | iny--; \ |
| 170 | inyk -= inym; \ |
| 171 | slw = (inx << 1) + dx; \ |
| 172 | if ((ine == inxk) && (slw > 1)) \ |
| 173 | slw-- |
| 174 | |
| 175 | #define miFillInArcLower(slw) (((iny + dy) != 0) && \ |
| 176 | ((slw > 1) || (ine != inxk))) |
| 177 | |
| 178 | extern _X_EXPORT void miFillArcSetup(xArc * /*arc */ , |
| 179 | miFillArcRec * /*info */ |
| 180 | ); |
| 181 | |
| 182 | extern _X_EXPORT void miFillArcSliceSetup(xArc * /*arc */ , |
| 183 | miArcSliceRec * /*slice */ , |
| 184 | GCPtr /*pGC */ |
| 185 | ); |
| 186 | |
| 187 | #endif /* __MIFILLARC_H__ */ |