45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/*
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncCopyright 1994, 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#ifndef MILINE_H
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include "screenint.h"
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/*
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Public definitions used for configuring basic pixelization aspects
45e9809aff7304721fddb95654901b32195c9c7avboxsync * of the sample implementation line-drawing routines provided in
45e9809aff7304721fddb95654901b32195c9c7avboxsync * {mfb,mi,cfb*} at run-time.
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define XDECREASING 4
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define YDECREASING 2
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define YMAJOR 1
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define OCTANT1 (1 << (YDECREASING))
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define OCTANT2 (1 << (YDECREASING|YMAJOR))
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define OCTANT3 (1 << (XDECREASING|YDECREASING|YMAJOR))
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define OCTANT4 (1 << (XDECREASING|YDECREASING))
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define OCTANT5 (1 << (XDECREASING))
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define OCTANT6 (1 << (XDECREASING|YMAJOR))
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define OCTANT7 (1 << (YMAJOR))
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define OCTANT8 (1 << (0))
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define XMAJOROCTANTS (OCTANT1 | OCTANT4 | OCTANT5 | OCTANT8)
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define DEFAULTZEROLINEBIAS (OCTANT2 | OCTANT3 | OCTANT4 | OCTANT5)
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/*
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Devices can configure the rendering of routines in mi, mfb, and cfb*
45e9809aff7304721fddb95654901b32195c9c7avboxsync * by specifying a thin line bias to be applied to a particular screen
45e9809aff7304721fddb95654901b32195c9c7avboxsync * using the following function. The bias parameter is an OR'ing of
45e9809aff7304721fddb95654901b32195c9c7avboxsync * the appropriate OCTANT constants defined above to indicate which
45e9809aff7304721fddb95654901b32195c9c7avboxsync * octants to bias a line to prefer an axial step when the Bresenham
45e9809aff7304721fddb95654901b32195c9c7avboxsync * error term is exactly zero. The octants are mapped as follows:
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * \ | /
45e9809aff7304721fddb95654901b32195c9c7avboxsync * \ 3 | 2 /
45e9809aff7304721fddb95654901b32195c9c7avboxsync * \ | /
45e9809aff7304721fddb95654901b32195c9c7avboxsync * 4 \ | / 1
45e9809aff7304721fddb95654901b32195c9c7avboxsync * \|/
45e9809aff7304721fddb95654901b32195c9c7avboxsync * -----------
45e9809aff7304721fddb95654901b32195c9c7avboxsync * /|\
45e9809aff7304721fddb95654901b32195c9c7avboxsync * 5 / | \ 8
45e9809aff7304721fddb95654901b32195c9c7avboxsync * / | \
45e9809aff7304721fddb95654901b32195c9c7avboxsync * / 6 | 7 \
45e9809aff7304721fddb95654901b32195c9c7avboxsync * / | \
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * For more information, see "Ambiguities in Incremental Line Rastering,"
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Jack E. Bresenham, IEEE CG&A, May 1987.
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern void miSetZeroLineBias(
45e9809aff7304721fddb95654901b32195c9c7avboxsync ScreenPtr /* pScreen */,
45e9809aff7304721fddb95654901b32195c9c7avboxsync unsigned int /* bias */
45e9809aff7304721fddb95654901b32195c9c7avboxsync);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/*
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Private definitions needed for drawing thin (zero width) lines
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Used by the mi, mfb, and all cfb* components.
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define X_AXIS 0
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define Y_AXIS 1
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define OUT_LEFT 0x08
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define OUT_RIGHT 0x04
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define OUT_ABOVE 0x02
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define OUT_BELOW 0x01
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define OUTCODES(_result, _x, _y, _pbox) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync if ( (_x) < (_pbox)->x1) (_result) |= OUT_LEFT; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync else if ( (_x) >= (_pbox)->x2) (_result) |= OUT_RIGHT; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync if ( (_y) < (_pbox)->y1) (_result) |= OUT_ABOVE; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync else if ( (_y) >= (_pbox)->y2) (_result) |= OUT_BELOW;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MIOUTCODES(outcode, x, y, xmin, ymin, xmax, ymax) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync{\
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (x < xmin) outcode |= OUT_LEFT;\
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (x > xmax) outcode |= OUT_RIGHT;\
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (y < ymin) outcode |= OUT_ABOVE;\
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (y > ymax) outcode |= OUT_BELOW;\
45e9809aff7304721fddb95654901b32195c9c7avboxsync}
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define SWAPINT(i, j) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync{ int _t = i; i = j; j = _t; }
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define SWAPPT(i, j) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync{ DDXPointRec _t; _t = i; i = j; j = _t; }
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define SWAPINT_PAIR(x1, y1, x2, y2)\
45e9809aff7304721fddb95654901b32195c9c7avboxsync{ int t = x1; x1 = x2; x2 = t;\
45e9809aff7304721fddb95654901b32195c9c7avboxsync t = y1; y1 = y2; y2 = t;\
45e9809aff7304721fddb95654901b32195c9c7avboxsync}
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define miGetZeroLineBias(_pScreen) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync ((miZeroLineScreenIndex < 0) ? \
45e9809aff7304721fddb95654901b32195c9c7avboxsync 0 : ((_pScreen)->devPrivates[miZeroLineScreenIndex].uval))
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define CalcLineDeltas(_x1,_y1,_x2,_y2,_adx,_ady,_sx,_sy,_SX,_SY,_octant) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync (_octant) = 0; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync (_sx) = (_SX); \
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (((_adx) = (_x2) - (_x1)) < 0) { \
45e9809aff7304721fddb95654901b32195c9c7avboxsync (_adx) = -(_adx); \
45e9809aff7304721fddb95654901b32195c9c7avboxsync (_sx = -(_sx)); \
45e9809aff7304721fddb95654901b32195c9c7avboxsync (_octant) |= XDECREASING; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync } \
45e9809aff7304721fddb95654901b32195c9c7avboxsync (_sy) = (_SY); \
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (((_ady) = (_y2) - (_y1)) < 0) { \
45e9809aff7304721fddb95654901b32195c9c7avboxsync (_ady) = -(_ady); \
45e9809aff7304721fddb95654901b32195c9c7avboxsync (_sy = -(_sy)); \
45e9809aff7304721fddb95654901b32195c9c7avboxsync (_octant) |= YDECREASING; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync }
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define SetYMajorOctant(_octant) ((_octant) |= YMAJOR)
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define FIXUP_ERROR(_e, _octant, _bias) \
45e9809aff7304721fddb95654901b32195c9c7avboxsync (_e) -= (((_bias) >> (_octant)) & 1)
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define IsXMajorOctant(_octant) (!((_octant) & YMAJOR))
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define IsYMajorOctant(_octant) ((_octant) & YMAJOR)
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define IsXDecreasingOctant(_octant) ((_octant) & XDECREASING)
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define IsYDecreasingOctant(_octant) ((_octant) & YDECREASING)
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern int miZeroLineScreenIndex;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern int miZeroClipLine(
45e9809aff7304721fddb95654901b32195c9c7avboxsync int /*xmin*/,
45e9809aff7304721fddb95654901b32195c9c7avboxsync int /*ymin*/,
45e9809aff7304721fddb95654901b32195c9c7avboxsync int /*xmax*/,
45e9809aff7304721fddb95654901b32195c9c7avboxsync int /*ymax*/,
45e9809aff7304721fddb95654901b32195c9c7avboxsync int * /*new_x1*/,
45e9809aff7304721fddb95654901b32195c9c7avboxsync int * /*new_y1*/,
45e9809aff7304721fddb95654901b32195c9c7avboxsync int * /*new_x2*/,
45e9809aff7304721fddb95654901b32195c9c7avboxsync int * /*new_y2*/,
45e9809aff7304721fddb95654901b32195c9c7avboxsync unsigned int /*adx*/,
45e9809aff7304721fddb95654901b32195c9c7avboxsync unsigned int /*ady*/,
45e9809aff7304721fddb95654901b32195c9c7avboxsync int * /*pt1_clipped*/,
45e9809aff7304721fddb95654901b32195c9c7avboxsync int * /*pt2_clipped*/,
45e9809aff7304721fddb95654901b32195c9c7avboxsync int /*octant*/,
45e9809aff7304721fddb95654901b32195c9c7avboxsync unsigned int /*bias*/,
45e9809aff7304721fddb95654901b32195c9c7avboxsync int /*oc1*/,
45e9809aff7304721fddb95654901b32195c9c7avboxsync int /*oc2*/
45e9809aff7304721fddb95654901b32195c9c7avboxsync);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif /* MILINE_H */