45e9809aff7304721fddb95654901b32195c9c7avboxsync/************************************************************
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncCopyright 1989, 1998 The Open Group
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncPermission to use, copy, modify, distribute, and sell this software and its
45e9809aff7304721fddb95654901b32195c9c7avboxsyncdocumentation for any purpose is hereby granted without fee, provided that
45e9809aff7304721fddb95654901b32195c9c7avboxsyncthe above copyright notice appear in all copies and that both that
45e9809aff7304721fddb95654901b32195c9c7avboxsynccopyright notice and this permission notice appear in supporting
45e9809aff7304721fddb95654901b32195c9c7avboxsyncdocumentation.
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncThe above copyright notice and this permission notice shall be included in
45e9809aff7304721fddb95654901b32195c9c7avboxsyncall copies or substantial portions of the Software.
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45e9809aff7304721fddb95654901b32195c9c7avboxsyncIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45e9809aff7304721fddb95654901b32195c9c7avboxsyncFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45e9809aff7304721fddb95654901b32195c9c7avboxsyncOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
45e9809aff7304721fddb95654901b32195c9c7avboxsyncAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
45e9809aff7304721fddb95654901b32195c9c7avboxsyncCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncExcept as contained in this notice, the name of The Open Group shall not be
45e9809aff7304721fddb95654901b32195c9c7avboxsyncused in advertising or otherwise to promote the sale, use or other dealings
45e9809aff7304721fddb95654901b32195c9c7avboxsyncin this Software without prior written authorization from The Open Group.
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync********************************************************/
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#ifndef __MIFILLARC_H__
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define __MIFILLARC_H__
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define FULLCIRCLE (360 * 64)
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsynctypedef struct _miFillArc {
45e9809aff7304721fddb95654901b32195c9c7avboxsync int xorg, yorg;
45e9809aff7304721fddb95654901b32195c9c7avboxsync int y;
45e9809aff7304721fddb95654901b32195c9c7avboxsync int dx, dy;
45e9809aff7304721fddb95654901b32195c9c7avboxsync int e;
45e9809aff7304721fddb95654901b32195c9c7avboxsync int ym, yk, xm, xk;
45e9809aff7304721fddb95654901b32195c9c7avboxsync} miFillArcRec;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/* could use 64-bit integers */
45e9809aff7304721fddb95654901b32195c9c7avboxsynctypedef struct _miFillArcD {
45e9809aff7304721fddb95654901b32195c9c7avboxsync int xorg, yorg;
45e9809aff7304721fddb95654901b32195c9c7avboxsync int y;
45e9809aff7304721fddb95654901b32195c9c7avboxsync int dx, dy;
45e9809aff7304721fddb95654901b32195c9c7avboxsync double e;
45e9809aff7304721fddb95654901b32195c9c7avboxsync double ym, yk, xm, xk;
45e9809aff7304721fddb95654901b32195c9c7avboxsync} miFillArcDRec;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define miFillArcEmpty(arc) (!(arc)->angle2 || \
45e9809aff7304721fddb95654901b32195c9c7avboxsync !(arc)->width || !(arc)->height || \
45e9809aff7304721fddb95654901b32195c9c7avboxsync (((arc)->width == 1) && ((arc)->height & 1)))
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define miCanFillArc(arc) (((arc)->width == (arc)->height) || \
45e9809aff7304721fddb95654901b32195c9c7avboxsync (((arc)->width <= 800) && ((arc)->height <= 800)))
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MIFILLARCSETUP() \
45e9809aff7304721fddb95654901b32195c9c7avboxsync x = 0; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync y = info.y; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync e = info.e; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync xk = info.xk; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync xm = info.xm; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync yk = info.yk; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync ym = info.ym; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync dx = info.dx; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync dy = info.dy; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync xorg = info.xorg; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync yorg = info.yorg
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MIFILLARCSTEP(slw) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync e += yk; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync while (e >= 0) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync { \
45e9809aff7304721fddb95654901b32195c9c7avboxsync x++; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync xk -= xm; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync e += xk; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync } \
45e9809aff7304721fddb95654901b32195c9c7avboxsync y--; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync yk -= ym; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync slw = (x << 1) + dx; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync if ((e == xk) && (slw > 1)) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync slw--
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MIFILLCIRCSTEP(slw) MIFILLARCSTEP(slw)
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MIFILLELLSTEP(slw) MIFILLARCSTEP(slw)
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define miFillArcLower(slw) (((y + dy) != 0) && ((slw > 1) || (e != xk)))
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsynctypedef struct _miSliceEdge {
45e9809aff7304721fddb95654901b32195c9c7avboxsync int x;
45e9809aff7304721fddb95654901b32195c9c7avboxsync int stepx;
45e9809aff7304721fddb95654901b32195c9c7avboxsync int deltax;
45e9809aff7304721fddb95654901b32195c9c7avboxsync int e;
45e9809aff7304721fddb95654901b32195c9c7avboxsync int dy;
45e9809aff7304721fddb95654901b32195c9c7avboxsync int dx;
45e9809aff7304721fddb95654901b32195c9c7avboxsync} miSliceEdgeRec, *miSliceEdgePtr;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsynctypedef struct _miArcSlice {
45e9809aff7304721fddb95654901b32195c9c7avboxsync miSliceEdgeRec edge1, edge2;
45e9809aff7304721fddb95654901b32195c9c7avboxsync int min_top_y, max_top_y;
45e9809aff7304721fddb95654901b32195c9c7avboxsync int min_bot_y, max_bot_y;
45e9809aff7304721fddb95654901b32195c9c7avboxsync Bool edge1_top, edge2_top;
45e9809aff7304721fddb95654901b32195c9c7avboxsync Bool flip_top, flip_bot;
45e9809aff7304721fddb95654901b32195c9c7avboxsync} miArcSliceRec;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MIARCSLICESTEP(edge) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync edge.x -= edge.stepx; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync edge.e -= edge.dx; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (edge.e <= 0) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync { \
45e9809aff7304721fddb95654901b32195c9c7avboxsync edge.x -= edge.deltax; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync edge.e += edge.dy; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync }
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define miFillSliceUpper(slice) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync ((y >= slice.min_top_y) && (y <= slice.max_top_y))
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define miFillSliceLower(slice) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync ((y >= slice.min_bot_y) && (y <= slice.max_bot_y))
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MIARCSLICEUPPER(xl,xr,slice,slw) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync xl = xorg - x; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync xr = xl + slw - 1; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (slice.edge1_top && (slice.edge1.x < xr)) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync xr = slice.edge1.x; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (slice.edge2_top && (slice.edge2.x > xl)) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync xl = slice.edge2.x;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MIARCSLICELOWER(xl,xr,slice,slw) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync xl = xorg - x; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync xr = xl + slw - 1; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (!slice.edge1_top && (slice.edge1.x > xl)) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync xl = slice.edge1.x; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (!slice.edge2_top && (slice.edge2.x < xr)) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync xr = slice.edge2.x;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MIWIDEARCSETUP(x,y,dy,slw,e,xk,xm,yk,ym) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync x = 0; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync y = slw >> 1; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync yk = y << 3; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync xm = 8; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync ym = 8; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (dy) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync { \
45e9809aff7304721fddb95654901b32195c9c7avboxsync xk = 0; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (slw & 1) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync e = -1; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync else \
45e9809aff7304721fddb95654901b32195c9c7avboxsync e = -(y << 2) - 2; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync } \
45e9809aff7304721fddb95654901b32195c9c7avboxsync else \
45e9809aff7304721fddb95654901b32195c9c7avboxsync { \
45e9809aff7304721fddb95654901b32195c9c7avboxsync y++; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync yk += 4; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync xk = -4; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (slw & 1) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync e = -(y << 2) - 3; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync else \
45e9809aff7304721fddb95654901b32195c9c7avboxsync e = - (y << 3); \
45e9809aff7304721fddb95654901b32195c9c7avboxsync }
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MIFILLINARCSTEP(slw) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync ine += inyk; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync while (ine >= 0) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync { \
45e9809aff7304721fddb95654901b32195c9c7avboxsync inx++; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync inxk -= inxm; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync ine += inxk; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync } \
45e9809aff7304721fddb95654901b32195c9c7avboxsync iny--; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync inyk -= inym; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync slw = (inx << 1) + dx; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync if ((ine == inxk) && (slw > 1)) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync slw--
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define miFillInArcLower(slw) (((iny + dy) != 0) && \
45e9809aff7304721fddb95654901b32195c9c7avboxsync ((slw > 1) || (ine != inxk)))
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern void miFillArcSetup(
45e9809aff7304721fddb95654901b32195c9c7avboxsync xArc * /*arc*/,
45e9809aff7304721fddb95654901b32195c9c7avboxsync miFillArcRec * /*info*/
45e9809aff7304721fddb95654901b32195c9c7avboxsync);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern void miFillArcSliceSetup(
45e9809aff7304721fddb95654901b32195c9c7avboxsync xArc * /*arc*/,
45e9809aff7304721fddb95654901b32195c9c7avboxsync miArcSliceRec * /*slice*/,
45e9809aff7304721fddb95654901b32195c9c7avboxsync GCPtr /*pGC*/
45e9809aff7304721fddb95654901b32195c9c7avboxsync);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif /* __MIFILLARC_H__ */