fbpoint.c revision 35c4bbdf
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) { 6435c4bbdfSmrg x = (x + xoff) * dstBpp; 6535c4bbdfSmrg d = dst + ((y + yoff) * dstStride) + (x >> FB_STIP_SHIFT); 6635c4bbdfSmrg x &= FB_STIP_MASK; 6735c4bbdfSmrg if (dstBpp == 24) { 6835c4bbdfSmrg FbStip leftMask, rightMask; 6935c4bbdfSmrg int n, rot; 7035c4bbdfSmrg FbStip andT, xorT; 7135c4bbdfSmrg 7235c4bbdfSmrg rot = FbFirst24Rot(x); 7335c4bbdfSmrg andT = FbRot24Stip(and, rot); 7435c4bbdfSmrg xorT = FbRot24Stip(xor, rot); 7535c4bbdfSmrg FbMaskStip(x, 24, leftMask, n, rightMask); 7635c4bbdfSmrg if (leftMask) { 7735c4bbdfSmrg WRITE(d, FbDoMaskRRop(READ(d), andT, xorT, leftMask)); 7835c4bbdfSmrg andT = FbNext24Stip(andT); 7935c4bbdfSmrg xorT = FbNext24Stip(xorT); 8035c4bbdfSmrg d++; 8135c4bbdfSmrg } 8235c4bbdfSmrg if (rightMask) 8335c4bbdfSmrg WRITE(d, FbDoMaskRRop(READ(d), andT, xorT, rightMask)); 8435c4bbdfSmrg } 8535c4bbdfSmrg else { 8635c4bbdfSmrg FbStip mask; 8735c4bbdfSmrg 8835c4bbdfSmrg mask = FbStipMask(x, dstBpp); 8935c4bbdfSmrg WRITE(d, FbDoMaskRRop(READ(d), and, xor, mask)); 9035c4bbdfSmrg } 9135c4bbdfSmrg } 9205b261ecSmrg } 9305b261ecSmrg} 9405b261ecSmrg 9505b261ecSmrgvoid 9635c4bbdfSmrgfbPolyPoint(DrawablePtr pDrawable, 9735c4bbdfSmrg GCPtr pGC, int mode, int nptInit, xPoint * pptInit) 9805b261ecSmrg{ 9935c4bbdfSmrg FbGCPrivPtr pPriv = fbGetGCPrivate(pGC); 10035c4bbdfSmrg RegionPtr pClip = fbGetCompositeClip(pGC); 10135c4bbdfSmrg FbBits *dst; 10235c4bbdfSmrg FbStride dstStride; 10335c4bbdfSmrg int dstBpp; 10435c4bbdfSmrg int dstXoff, dstYoff; 10535c4bbdfSmrg FbDots dots; 10635c4bbdfSmrg FbBits and, xor; 10735c4bbdfSmrg xPoint *ppt; 10835c4bbdfSmrg int npt; 10935c4bbdfSmrg BoxPtr pBox; 11035c4bbdfSmrg int nBox; 11135c4bbdfSmrg 11205b261ecSmrg /* make pointlist origin relative */ 11305b261ecSmrg ppt = pptInit; 11405b261ecSmrg npt = nptInit; 11535c4bbdfSmrg if (mode == CoordModePrevious) { 11635c4bbdfSmrg npt--; 11735c4bbdfSmrg while (npt--) { 11835c4bbdfSmrg ppt++; 11935c4bbdfSmrg ppt->x += (ppt - 1)->x; 12035c4bbdfSmrg ppt->y += (ppt - 1)->y; 12135c4bbdfSmrg } 12205b261ecSmrg } 12335c4bbdfSmrg fbGetDrawable(pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); 12405b261ecSmrg and = pPriv->and; 12505b261ecSmrg xor = pPriv->xor; 12605b261ecSmrg dots = fbDots; 12705b261ecSmrg switch (dstBpp) { 12835c4bbdfSmrg case 8: 12935c4bbdfSmrg dots = fbDots8; 13035c4bbdfSmrg break; 13135c4bbdfSmrg case 16: 13235c4bbdfSmrg dots = fbDots16; 13335c4bbdfSmrg break; 13435c4bbdfSmrg case 24: 13535c4bbdfSmrg dots = fbDots24; 13635c4bbdfSmrg break; 13735c4bbdfSmrg case 32: 13835c4bbdfSmrg dots = fbDots32; 13935c4bbdfSmrg break; 14005b261ecSmrg } 14135c4bbdfSmrg for (nBox = RegionNumRects(pClip), pBox = RegionRects(pClip); 14235c4bbdfSmrg nBox--; pBox++) 14335c4bbdfSmrg (*dots) (dst, dstStride, dstBpp, pBox, pptInit, nptInit, 14435c4bbdfSmrg pDrawable->x, pDrawable->y, dstXoff, dstYoff, and, xor); 14535c4bbdfSmrg fbFinishAccess(pDrawable); 14605b261ecSmrg} 147