45e9809aff7304721fddb95654901b32195c9c7avboxsync * Copyright © 1998 Keith Packard
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Permission to use, copy, modify, distribute, and sell this software and its
45e9809aff7304721fddb95654901b32195c9c7avboxsync * documentation for any purpose is hereby granted without fee, provided that
45e9809aff7304721fddb95654901b32195c9c7avboxsync * the above copyright notice appear in all copies and that both that
45e9809aff7304721fddb95654901b32195c9c7avboxsync * copyright notice and this permission notice appear in supporting
45e9809aff7304721fddb95654901b32195c9c7avboxsync * documentation, and that the name of Keith Packard not be used in
45e9809aff7304721fddb95654901b32195c9c7avboxsync * advertising or publicity pertaining to distribution of the software without
45e9809aff7304721fddb95654901b32195c9c7avboxsync * specific, written prior permission. Keith Packard makes no
45e9809aff7304721fddb95654901b32195c9c7avboxsync * representations about the suitability of this software for any purpose. It
45e9809aff7304721fddb95654901b32195c9c7avboxsync * is provided "as is" without express or implied warranty.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
45e9809aff7304721fddb95654901b32195c9c7avboxsync * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
45e9809aff7304721fddb95654901b32195c9c7avboxsync * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
45e9809aff7304721fddb95654901b32195c9c7avboxsync * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
45e9809aff7304721fddb95654901b32195c9c7avboxsync * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
45e9809aff7304721fddb95654901b32195c9c7avboxsync * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
45e9809aff7304721fddb95654901b32195c9c7avboxsync * PERFORMANCE OF THIS SOFTWARE.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * This file defines functions for drawing some primitives using
45e9809aff7304721fddb95654901b32195c9c7avboxsync * underlying datatypes instead of masks
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define isClipped(c,ul,lr) ((((c) - (ul)) | ((lr) - (c))) & 0x80008000)
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define RROP(b,a,x) WRITE((b), FbDoRRop (READ(b), (a), (x)))
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Define the following before including this file:
45e9809aff7304721fddb95654901b32195c9c7avboxsync * BRESSOLID name of function for drawing a solid segment
45e9809aff7304721fddb95654901b32195c9c7avboxsync * BRESDASH name of function for drawing a dashed segment
45e9809aff7304721fddb95654901b32195c9c7avboxsync * DOTS name of function for drawing dots
45e9809aff7304721fddb95654901b32195c9c7avboxsync * ARC name of function for drawing a solid arc
45e9809aff7304721fddb95654901b32195c9c7avboxsync * BITS type of underlying unit
45e9809aff7304721fddb95654901b32195c9c7avboxsync fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
45e9809aff7304721fddb95654901b32195c9c7avboxsync bits = ((UNIT *) (dst + ((y1 + dstYoff) * dstStride))) + (x1 + dstXoff) * MUL;
45e9809aff7304721fddb95654901b32195c9c7avboxsync bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (e >= 0)
45e9809aff7304721fddb95654901b32195c9c7avboxsync fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
45e9809aff7304721fddb95654901b32195c9c7avboxsync FbDashInit (pGC, pPriv, dashOffset, dashlen, even);
45e9809aff7304721fddb95654901b32195c9c7avboxsync bits = ((UNIT *) (dst + ((y1 + dstYoff) * dstStride))) + (x1 + dstXoff) * MUL;
45e9809aff7304721fddb95654901b32195c9c7avboxsync bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
45e9809aff7304721fddb95654901b32195c9c7avboxsync if ((e += e1) >= 0)
45e9809aff7304721fddb95654901b32195c9c7avboxsync if ((e += e1) >= 0)
45e9809aff7304721fddb95654901b32195c9c7avboxsync if ((e += e1) >= 0)
45e9809aff7304721fddb95654901b32195c9c7avboxsync if ((e += e1) >= 0)
45e9809aff7304721fddb95654901b32195c9c7avboxsync FbStride bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
45e9809aff7304721fddb95654901b32195c9c7avboxsync lr = coordToInt(pBox->x2 - xorg - 1, pBox->y2 - yorg - 1);
45e9809aff7304721fddb95654901b32195c9c7avboxsync bits += bitsStride * (yorg + yoff) + (xorg + xoff) * MUL;
45e9809aff7304721fddb95654901b32195c9c7avboxsync point = bits + intToY(pt) * bitsStride + intToX(pt) * MUL;
45e9809aff7304721fddb95654901b32195c9c7avboxsync point = bits + intToY(pt) * bitsStride + intToX(pt) * MUL;
45e9809aff7304721fddb95654901b32195c9c7avboxsync bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
45e9809aff7304721fddb95654901b32195c9c7avboxsync yorgop = bits + ((info.yorgo + drawY) * bitsStride);
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (do360 && (arc->width == arc->height) && !(arc->width & 1))
45e9809aff7304721fddb95654901b32195c9c7avboxsync UNIT *yorghb = yorgp + (info.h * bitsStride) + info.xorg;
45e9809aff7304721fddb95654901b32195c9c7avboxsync MIARCSTEP(yoffset += dyoffset;, yoffset += bitsStride;);
45e9809aff7304721fddb95654901b32195c9c7avboxsync MIARCSTEP(yoffset += dyoffset;, yoffset += bitsStride;);
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define WRITE1(d,n,fg) WRITE(d + WRITE_ADDR1(n), (BITS) (fg))
45e9809aff7304721fddb95654901b32195c9c7avboxsync# define WRITE2(d,n,fg) WRITE((BITS2 *) &((d)[WRITE_ADDR2(n)]), (BITS2) (fg))
45e9809aff7304721fddb95654901b32195c9c7avboxsync# define WRITE2(d,n,fg) (WRITE1(d,n,fg), WRITE1(d,(n)+1,fg))
45e9809aff7304721fddb95654901b32195c9c7avboxsync# define WRITE4(d,n,fg) WRITE((BITS4 *) &((d)[WRITE_ADDR4(n)]), (BITS4) (fg))
45e9809aff7304721fddb95654901b32195c9c7avboxsync# define WRITE4(d,n,fg) (WRITE2(d,n,fg), WRITE2(d,(n)+2,fg))
45e9809aff7304721fddb95654901b32195c9c7avboxsync switch (FbStipMoveLsb (FbLeftStipBits (bits, n), 4, n)) {
45e9809aff7304721fddb95654901b32195c9c7avboxsync unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
45e9809aff7304721fddb95654901b32195c9c7avboxsync BoxPtr pBox = REGION_EXTENTS (pDrawable->pScreen, fbGetCompositeClip (pGC));
45e9809aff7304721fddb95654901b32195c9c7avboxsync fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
45e9809aff7304721fddb95654901b32195c9c7avboxsync bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
45e9809aff7304721fddb95654901b32195c9c7avboxsync bitsBase = ((UNIT *) dst) + (yoff + dstYoff) * bitsStride + (xoff + dstXoff) * MUL;
45e9809aff7304721fddb95654901b32195c9c7avboxsync lr = coordToInt(pBox->x2 - xoff - 1, pBox->y2 - yoff - 1);
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (isClipped (pt1, ul, lr) | isClipped (pt2, ul, lr))
45e9809aff7304721fddb95654901b32195c9c7avboxsync bits = bitsBase + intToY(pt1) * bitsStride + intToX(pt1) * MUL;
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (e >= 0)
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (e >= 0)
45e9809aff7304721fddb95654901b32195c9c7avboxsync unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
45e9809aff7304721fddb95654901b32195c9c7avboxsync BoxPtr pBox = REGION_EXTENTS (pDrawable->pScreen, fbGetCompositeClip (pGC));
45e9809aff7304721fddb95654901b32195c9c7avboxsync fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
45e9809aff7304721fddb95654901b32195c9c7avboxsync bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
45e9809aff7304721fddb95654901b32195c9c7avboxsync bitsBase = ((UNIT *) dst) + (yoff + dstYoff) * bitsStride + (xoff + dstXoff) * MUL;
45e9809aff7304721fddb95654901b32195c9c7avboxsync lr = coordToInt(pBox->x2 - xoff - 1, pBox->y2 - yoff - 1);
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (isClipped (pt1, ul, lr) | isClipped (pt2, ul, lr))
45e9809aff7304721fddb95654901b32195c9c7avboxsync dstX = (x1 + xoff + dstXoff) * (sizeof (UNIT) * 8 * MUL);
45e9809aff7304721fddb95654901b32195c9c7avboxsync dstLine = dst + (intToY(pt1) + yoff + dstYoff) * dstStride;
45e9809aff7304721fddb95654901b32195c9c7avboxsync FbMaskBits (dstX, width, startmask, nmiddle, endmask);
45e9809aff7304721fddb95654901b32195c9c7avboxsync WRITE(dstLine, FbDoMaskRRop (READ(dstLine), andBits, xorBits, startmask));
45e9809aff7304721fddb95654901b32195c9c7avboxsync WRITE(dstLine, FbDoRRop (READ(dstLine), andBits, xorBits));
45e9809aff7304721fddb95654901b32195c9c7avboxsync WRITE(dstLine, FbDoMaskRRop (READ(dstLine), andBits, xorBits, endmask));
45e9809aff7304721fddb95654901b32195c9c7avboxsync bits = bitsBase + intToY(pt1) * bitsStride + intToX(pt1) * MUL;
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (e >= 0)
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (e >= 0)