105b261ecSmrg/* 205b261ecSmrg * Copyright © 1998 Keith Packard 305b261ecSmrg * 405b261ecSmrg * Permission to use, copy, modify, distribute, and sell this software and its 505b261ecSmrg * documentation for any purpose is hereby granted without fee, provided that 605b261ecSmrg * the above copyright notice appear in all copies and that both that 705b261ecSmrg * copyright notice and this permission notice appear in supporting 805b261ecSmrg * documentation, and that the name of Keith Packard not be used in 905b261ecSmrg * advertising or publicity pertaining to distribution of the software without 1005b261ecSmrg * specific, written prior permission. Keith Packard makes no 1105b261ecSmrg * representations about the suitability of this software for any purpose. It 1205b261ecSmrg * is provided "as is" without express or implied warranty. 1305b261ecSmrg * 1405b261ecSmrg * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 1505b261ecSmrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 1605b261ecSmrg * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR 1705b261ecSmrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 1805b261ecSmrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 1905b261ecSmrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 2005b261ecSmrg * PERFORMANCE OF THIS SOFTWARE. 2105b261ecSmrg */ 2205b261ecSmrg 2305b261ecSmrg#ifdef HAVE_DIX_CONFIG_H 2405b261ecSmrg#include <dix-config.h> 2505b261ecSmrg#endif 2605b261ecSmrg 2705b261ecSmrg#include "fb.h" 2805b261ecSmrg 2935c4bbdfSmrgtypedef void (*FbDots) (FbBits * dst, 3035c4bbdfSmrg FbStride dstStride, 3135c4bbdfSmrg int dstBpp, 3235c4bbdfSmrg BoxPtr pBox, 3335c4bbdfSmrg xPoint * pts, 3435c4bbdfSmrg int npt, 3535c4bbdfSmrg int xorg, 3635c4bbdfSmrg int yorg, int xoff, int yoff, FbBits and, FbBits xor); 3705b261ecSmrg 3835c4bbdfSmrgstatic void 3935c4bbdfSmrgfbDots(FbBits * dstOrig, 4035c4bbdfSmrg FbStride dstStride, 4135c4bbdfSmrg int dstBpp, 4235c4bbdfSmrg BoxPtr pBox, 4335c4bbdfSmrg xPoint * pts, 4435c4bbdfSmrg int npt, 4535c4bbdfSmrg int xorg, int yorg, int xoff, int yoff, FbBits andOrig, FbBits xorOrig) 4605b261ecSmrg{ 4735c4bbdfSmrg FbStip *dst = (FbStip *) dstOrig; 4835c4bbdfSmrg int x1, y1, x2, y2; 4935c4bbdfSmrg int x, y; 5035c4bbdfSmrg FbStip *d; 5135c4bbdfSmrg FbStip and = andOrig; 5235c4bbdfSmrg FbStip xor = xorOrig; 5305b261ecSmrg 5435c4bbdfSmrg dstStride = FbBitsStrideToStipStride(dstStride); 5505b261ecSmrg x1 = pBox->x1; 5605b261ecSmrg y1 = pBox->y1; 5705b261ecSmrg x2 = pBox->x2; 5805b261ecSmrg y2 = pBox->y2; 5935c4bbdfSmrg while (npt--) { 6035c4bbdfSmrg x = pts->x + xorg; 6135c4bbdfSmrg y = pts->y + yorg; 6235c4bbdfSmrg pts++; 6335c4bbdfSmrg if (x1 <= x && x < x2 && y1 <= y && y < y2) { 641b5d61b8Smrg FbStip mask; 6535c4bbdfSmrg x = (x + xoff) * dstBpp; 6635c4bbdfSmrg d = dst + ((y + yoff) * dstStride) + (x >> FB_STIP_SHIFT); 6735c4bbdfSmrg x &= FB_STIP_MASK; 6835c4bbdfSmrg 691b5d61b8Smrg mask = FbStipMask(x, dstBpp); 701b5d61b8Smrg WRITE(d, FbDoMaskRRop(READ(d), and, xor, mask)); 7135c4bbdfSmrg } 7205b261ecSmrg } 7305b261ecSmrg} 7405b261ecSmrg 7505b261ecSmrgvoid 7635c4bbdfSmrgfbPolyPoint(DrawablePtr pDrawable, 7735c4bbdfSmrg GCPtr pGC, int mode, int nptInit, xPoint * pptInit) 7805b261ecSmrg{ 7935c4bbdfSmrg FbGCPrivPtr pPriv = fbGetGCPrivate(pGC); 8035c4bbdfSmrg RegionPtr pClip = fbGetCompositeClip(pGC); 8135c4bbdfSmrg FbBits *dst; 8235c4bbdfSmrg FbStride dstStride; 8335c4bbdfSmrg int dstBpp; 8435c4bbdfSmrg int dstXoff, dstYoff; 8535c4bbdfSmrg FbDots dots; 8635c4bbdfSmrg FbBits and, xor; 8735c4bbdfSmrg xPoint *ppt; 8835c4bbdfSmrg int npt; 8935c4bbdfSmrg BoxPtr pBox; 9035c4bbdfSmrg int nBox; 9135c4bbdfSmrg 9205b261ecSmrg /* make pointlist origin relative */ 9305b261ecSmrg ppt = pptInit; 9405b261ecSmrg npt = nptInit; 9535c4bbdfSmrg if (mode == CoordModePrevious) { 9635c4bbdfSmrg npt--; 9735c4bbdfSmrg while (npt--) { 9835c4bbdfSmrg ppt++; 9935c4bbdfSmrg ppt->x += (ppt - 1)->x; 10035c4bbdfSmrg ppt->y += (ppt - 1)->y; 10135c4bbdfSmrg } 10205b261ecSmrg } 10335c4bbdfSmrg fbGetDrawable(pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); 10405b261ecSmrg and = pPriv->and; 10505b261ecSmrg xor = pPriv->xor; 10605b261ecSmrg dots = fbDots; 10705b261ecSmrg switch (dstBpp) { 10835c4bbdfSmrg case 8: 10935c4bbdfSmrg dots = fbDots8; 11035c4bbdfSmrg break; 11135c4bbdfSmrg case 16: 11235c4bbdfSmrg dots = fbDots16; 11335c4bbdfSmrg break; 11435c4bbdfSmrg case 32: 11535c4bbdfSmrg dots = fbDots32; 11635c4bbdfSmrg break; 11705b261ecSmrg } 11835c4bbdfSmrg for (nBox = RegionNumRects(pClip), pBox = RegionRects(pClip); 11935c4bbdfSmrg nBox--; pBox++) 12035c4bbdfSmrg (*dots) (dst, dstStride, dstBpp, pBox, pptInit, nptInit, 12135c4bbdfSmrg pDrawable->x, pDrawable->y, dstXoff, dstYoff, and, xor); 12235c4bbdfSmrg fbFinishAccess(pDrawable); 12305b261ecSmrg} 124