65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync/*
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncCopyright 1994, 1998 The Open Group
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncPermission to use, copy, modify, distribute, and sell this software and its
65fea56f17cd614bc8908264df980a62e1931468vboxsyncdocumentation for any purpose is hereby granted without fee, provided that
65fea56f17cd614bc8908264df980a62e1931468vboxsyncthe above copyright notice appear in all copies and that both that
65fea56f17cd614bc8908264df980a62e1931468vboxsynccopyright notice and this permission notice appear in supporting
65fea56f17cd614bc8908264df980a62e1931468vboxsyncdocumentation.
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncThe above copyright notice and this permission notice shall be included in
65fea56f17cd614bc8908264df980a62e1931468vboxsyncall copies or substantial portions of the Software.
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
65fea56f17cd614bc8908264df980a62e1931468vboxsyncIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
65fea56f17cd614bc8908264df980a62e1931468vboxsyncFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
65fea56f17cd614bc8908264df980a62e1931468vboxsyncOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
65fea56f17cd614bc8908264df980a62e1931468vboxsyncAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
65fea56f17cd614bc8908264df980a62e1931468vboxsyncCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncExcept as contained in this notice, the name of The Open Group shall not be
65fea56f17cd614bc8908264df980a62e1931468vboxsyncused in advertising or otherwise to promote the sale, use or other dealings
65fea56f17cd614bc8908264df980a62e1931468vboxsyncin this Software without prior written authorization from The Open Group.
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync*/
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifndef MILINE_H
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#include "screenint.h"
65fea56f17cd614bc8908264df980a62e1931468vboxsync#include "privates.h"
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync/*
65fea56f17cd614bc8908264df980a62e1931468vboxsync * Public definitions used for configuring basic pixelization aspects
65fea56f17cd614bc8908264df980a62e1931468vboxsync * of the sample implementation line-drawing routines provided in
65fea56f17cd614bc8908264df980a62e1931468vboxsync * {mfb,mi,cfb*} at run-time.
65fea56f17cd614bc8908264df980a62e1931468vboxsync */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define XDECREASING 4
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define YDECREASING 2
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define YMAJOR 1
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define OCTANT1 (1 << (YDECREASING))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define OCTANT2 (1 << (YDECREASING|YMAJOR))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define OCTANT3 (1 << (XDECREASING|YDECREASING|YMAJOR))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define OCTANT4 (1 << (XDECREASING|YDECREASING))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define OCTANT5 (1 << (XDECREASING))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define OCTANT6 (1 << (XDECREASING|YMAJOR))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define OCTANT7 (1 << (YMAJOR))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define OCTANT8 (1 << (0))
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define XMAJOROCTANTS (OCTANT1 | OCTANT4 | OCTANT5 | OCTANT8)
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define DEFAULTZEROLINEBIAS (OCTANT2 | OCTANT3 | OCTANT4 | OCTANT5)
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync/*
65fea56f17cd614bc8908264df980a62e1931468vboxsync * Devices can configure the rendering of routines in mi, mfb, and cfb*
65fea56f17cd614bc8908264df980a62e1931468vboxsync * by specifying a thin line bias to be applied to a particular screen
65fea56f17cd614bc8908264df980a62e1931468vboxsync * using the following function. The bias parameter is an OR'ing of
65fea56f17cd614bc8908264df980a62e1931468vboxsync * the appropriate OCTANT constants defined above to indicate which
65fea56f17cd614bc8908264df980a62e1931468vboxsync * octants to bias a line to prefer an axial step when the Bresenham
65fea56f17cd614bc8908264df980a62e1931468vboxsync * error term is exactly zero. The octants are mapped as follows:
65fea56f17cd614bc8908264df980a62e1931468vboxsync *
65fea56f17cd614bc8908264df980a62e1931468vboxsync * \ | /
65fea56f17cd614bc8908264df980a62e1931468vboxsync * \ 3 | 2 /
65fea56f17cd614bc8908264df980a62e1931468vboxsync * \ | /
65fea56f17cd614bc8908264df980a62e1931468vboxsync * 4 \ | / 1
65fea56f17cd614bc8908264df980a62e1931468vboxsync * \|/
65fea56f17cd614bc8908264df980a62e1931468vboxsync * -----------
65fea56f17cd614bc8908264df980a62e1931468vboxsync * /|\
65fea56f17cd614bc8908264df980a62e1931468vboxsync * 5 / | \ 8
65fea56f17cd614bc8908264df980a62e1931468vboxsync * / | \
65fea56f17cd614bc8908264df980a62e1931468vboxsync * / 6 | 7 \
65fea56f17cd614bc8908264df980a62e1931468vboxsync * / | \
65fea56f17cd614bc8908264df980a62e1931468vboxsync *
65fea56f17cd614bc8908264df980a62e1931468vboxsync * For more information, see "Ambiguities in Incremental Line Rastering,"
65fea56f17cd614bc8908264df980a62e1931468vboxsync * Jack E. Bresenham, IEEE CG&A, May 1987.
65fea56f17cd614bc8908264df980a62e1931468vboxsync */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void miSetZeroLineBias(ScreenPtr /* pScreen */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned int /* bias */
65fea56f17cd614bc8908264df980a62e1931468vboxsync );
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync/*
65fea56f17cd614bc8908264df980a62e1931468vboxsync * Private definitions needed for drawing thin (zero width) lines
65fea56f17cd614bc8908264df980a62e1931468vboxsync * Used by the mi, mfb, and all cfb* components.
65fea56f17cd614bc8908264df980a62e1931468vboxsync */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define X_AXIS 0
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define Y_AXIS 1
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define OUT_LEFT 0x08
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define OUT_RIGHT 0x04
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define OUT_ABOVE 0x02
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define OUT_BELOW 0x01
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define OUTCODES(_result, _x, _y, _pbox) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync if ( (_x) < (_pbox)->x1) (_result) |= OUT_LEFT; \
65fea56f17cd614bc8908264df980a62e1931468vboxsync else if ( (_x) >= (_pbox)->x2) (_result) |= OUT_RIGHT; \
65fea56f17cd614bc8908264df980a62e1931468vboxsync if ( (_y) < (_pbox)->y1) (_result) |= OUT_ABOVE; \
65fea56f17cd614bc8908264df980a62e1931468vboxsync else if ( (_y) >= (_pbox)->y2) (_result) |= OUT_BELOW;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define MIOUTCODES(outcode, x, y, xmin, ymin, xmax, ymax) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync{\
65fea56f17cd614bc8908264df980a62e1931468vboxsync if (x < xmin) outcode |= OUT_LEFT;\
65fea56f17cd614bc8908264df980a62e1931468vboxsync if (x > xmax) outcode |= OUT_RIGHT;\
65fea56f17cd614bc8908264df980a62e1931468vboxsync if (y < ymin) outcode |= OUT_ABOVE;\
65fea56f17cd614bc8908264df980a62e1931468vboxsync if (y > ymax) outcode |= OUT_BELOW;\
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define SWAPINT(i, j) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync{ int _t = i; i = j; j = _t; }
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define SWAPPT(i, j) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync{ DDXPointRec _t; _t = i; i = j; j = _t; }
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define SWAPINT_PAIR(x1, y1, x2, y2)\
65fea56f17cd614bc8908264df980a62e1931468vboxsync{ int t = x1; x1 = x2; x2 = t;\
65fea56f17cd614bc8908264df980a62e1931468vboxsync t = y1; y1 = y2; y2 = t;\
65fea56f17cd614bc8908264df980a62e1931468vboxsync}
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define miGetZeroLineBias(_pScreen) ((unsigned long) (unsigned long*)\
65fea56f17cd614bc8908264df980a62e1931468vboxsync dixLookupPrivate(&(_pScreen)->devPrivates, miZeroLineScreenKey))
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define CalcLineDeltas(_x1,_y1,_x2,_y2,_adx,_ady,_sx,_sy,_SX,_SY,_octant) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync (_octant) = 0; \
65fea56f17cd614bc8908264df980a62e1931468vboxsync (_sx) = (_SX); \
65fea56f17cd614bc8908264df980a62e1931468vboxsync if (((_adx) = (_x2) - (_x1)) < 0) { \
65fea56f17cd614bc8908264df980a62e1931468vboxsync (_adx) = -(_adx); \
65fea56f17cd614bc8908264df980a62e1931468vboxsync (_sx = -(_sx)); \
65fea56f17cd614bc8908264df980a62e1931468vboxsync (_octant) |= XDECREASING; \
65fea56f17cd614bc8908264df980a62e1931468vboxsync } \
65fea56f17cd614bc8908264df980a62e1931468vboxsync (_sy) = (_SY); \
65fea56f17cd614bc8908264df980a62e1931468vboxsync if (((_ady) = (_y2) - (_y1)) < 0) { \
65fea56f17cd614bc8908264df980a62e1931468vboxsync (_ady) = -(_ady); \
65fea56f17cd614bc8908264df980a62e1931468vboxsync (_sy = -(_sy)); \
65fea56f17cd614bc8908264df980a62e1931468vboxsync (_octant) |= YDECREASING; \
65fea56f17cd614bc8908264df980a62e1931468vboxsync }
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define SetYMajorOctant(_octant) ((_octant) |= YMAJOR)
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define FIXUP_ERROR(_e, _octant, _bias) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync (_e) -= (((_bias) >> (_octant)) & 1)
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define IsXMajorOctant(_octant) (!((_octant) & YMAJOR))
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define IsYMajorOctant(_octant) ((_octant) & YMAJOR)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define IsXDecreasingOctant(_octant) ((_octant) & XDECREASING)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define IsYDecreasingOctant(_octant) ((_octant) & YDECREASING)
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT DevPrivateKeyRec miZeroLineScreenKeyRec;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define miZeroLineScreenKey (&miZeroLineScreenKeyRec)
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT int miZeroClipLine(int /*xmin */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsync int /*ymin */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsync int /*xmax */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsync int /*ymax */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsync int * /*new_x1 */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsync int * /*new_y1 */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsync int * /*new_x2 */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsync int * /*new_y2 */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned int /*adx */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned int /*ady */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsync int * /*pt1_clipped */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsync int * /*pt2_clipped */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsync int /*octant */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsync unsigned int /*bias */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsync int /*oc1 */ ,
65fea56f17cd614bc8908264df980a62e1931468vboxsync int /*oc2 */
65fea56f17cd614bc8908264df980a62e1931468vboxsync );
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* MILINE_H */