fbpoint.c revision 05b261ec
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 2905b261ecSmrgtypedef void (*FbDots) (FbBits *dst, 3005b261ecSmrg FbStride dstStride, 3105b261ecSmrg int dstBpp, 3205b261ecSmrg BoxPtr pBox, 3305b261ecSmrg xPoint *pts, 3405b261ecSmrg int npt, 3505b261ecSmrg int xorg, 3605b261ecSmrg int yorg, 3705b261ecSmrg int xoff, 3805b261ecSmrg int yoff, 3905b261ecSmrg FbBits and, 4005b261ecSmrg FbBits xor); 4105b261ecSmrg 4205b261ecSmrgvoid 4305b261ecSmrgfbDots (FbBits *dstOrig, 4405b261ecSmrg FbStride dstStride, 4505b261ecSmrg int dstBpp, 4605b261ecSmrg BoxPtr pBox, 4705b261ecSmrg xPoint *pts, 4805b261ecSmrg int npt, 4905b261ecSmrg int xorg, 5005b261ecSmrg int yorg, 5105b261ecSmrg int xoff, 5205b261ecSmrg int yoff, 5305b261ecSmrg FbBits andOrig, 5405b261ecSmrg FbBits xorOrig) 5505b261ecSmrg{ 5605b261ecSmrg FbStip *dst = (FbStip *) dstOrig; 5705b261ecSmrg int x1, y1, x2, y2; 5805b261ecSmrg int x, y; 5905b261ecSmrg FbStip *d; 6005b261ecSmrg FbStip and = andOrig; 6105b261ecSmrg FbStip xor = xorOrig; 6205b261ecSmrg 6305b261ecSmrg dstStride = FbBitsStrideToStipStride (dstStride); 6405b261ecSmrg x1 = pBox->x1; 6505b261ecSmrg y1 = pBox->y1; 6605b261ecSmrg x2 = pBox->x2; 6705b261ecSmrg y2 = pBox->y2; 6805b261ecSmrg while (npt--) 6905b261ecSmrg { 7005b261ecSmrg x = pts->x + xorg; 7105b261ecSmrg y = pts->y + yorg; 7205b261ecSmrg pts++; 7305b261ecSmrg if (x1 <= x && x < x2 && y1 <= y && y < y2) 7405b261ecSmrg { 7505b261ecSmrg x = (x + xoff) * dstBpp; 7605b261ecSmrg d = dst + ((y + yoff) * dstStride) + (x >> FB_STIP_SHIFT); 7705b261ecSmrg x &= FB_STIP_MASK; 7805b261ecSmrg#ifdef FB_24BIT 7905b261ecSmrg if (dstBpp == 24) 8005b261ecSmrg { 8105b261ecSmrg FbStip leftMask, rightMask; 8205b261ecSmrg int n, rot; 8305b261ecSmrg FbStip andT, xorT; 8405b261ecSmrg 8505b261ecSmrg rot = FbFirst24Rot (x); 8605b261ecSmrg andT = FbRot24Stip(and,rot); 8705b261ecSmrg xorT = FbRot24Stip(xor,rot); 8805b261ecSmrg FbMaskStip (x, 24, leftMask, n, rightMask); 8905b261ecSmrg if (leftMask) 9005b261ecSmrg { 9105b261ecSmrg WRITE(d, FbDoMaskRRop (READ(d), andT, xorT, leftMask)); 9205b261ecSmrg andT = FbNext24Stip(andT); 9305b261ecSmrg xorT = FbNext24Stip(xorT); 9405b261ecSmrg d++; 9505b261ecSmrg } 9605b261ecSmrg if (rightMask) 9705b261ecSmrg WRITE(d, FbDoMaskRRop(READ(d), andT, xorT, rightMask)); 9805b261ecSmrg } 9905b261ecSmrg else 10005b261ecSmrg#endif 10105b261ecSmrg { 10205b261ecSmrg FbStip mask; 10305b261ecSmrg mask = FbStipMask(x, dstBpp); 10405b261ecSmrg WRITE(d, FbDoMaskRRop (READ(d), and, xor, mask)); 10505b261ecSmrg } 10605b261ecSmrg } 10705b261ecSmrg } 10805b261ecSmrg} 10905b261ecSmrg 11005b261ecSmrgvoid 11105b261ecSmrgfbPolyPoint (DrawablePtr pDrawable, 11205b261ecSmrg GCPtr pGC, 11305b261ecSmrg int mode, 11405b261ecSmrg int nptInit, 11505b261ecSmrg xPoint *pptInit) 11605b261ecSmrg{ 11705b261ecSmrg FbGCPrivPtr pPriv = fbGetGCPrivate (pGC); 11805b261ecSmrg RegionPtr pClip = fbGetCompositeClip(pGC); 11905b261ecSmrg FbBits *dst; 12005b261ecSmrg FbStride dstStride; 12105b261ecSmrg int dstBpp; 12205b261ecSmrg int dstXoff, dstYoff; 12305b261ecSmrg FbDots dots; 12405b261ecSmrg FbBits and, xor; 12505b261ecSmrg xPoint *ppt; 12605b261ecSmrg int npt; 12705b261ecSmrg BoxPtr pBox; 12805b261ecSmrg int nBox; 12905b261ecSmrg 13005b261ecSmrg /* make pointlist origin relative */ 13105b261ecSmrg ppt = pptInit; 13205b261ecSmrg npt = nptInit; 13305b261ecSmrg if (mode == CoordModePrevious) 13405b261ecSmrg { 13505b261ecSmrg npt--; 13605b261ecSmrg while(npt--) 13705b261ecSmrg { 13805b261ecSmrg ppt++; 13905b261ecSmrg ppt->x += (ppt-1)->x; 14005b261ecSmrg ppt->y += (ppt-1)->y; 14105b261ecSmrg } 14205b261ecSmrg } 14305b261ecSmrg fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); 14405b261ecSmrg and = pPriv->and; 14505b261ecSmrg xor = pPriv->xor; 14605b261ecSmrg dots = fbDots; 14705b261ecSmrg#ifndef FBNOPIXADDR 14805b261ecSmrg switch (dstBpp) { 14905b261ecSmrg case 8: dots = fbDots8; break; 15005b261ecSmrg case 16: dots = fbDots16; break; 15105b261ecSmrg#ifdef FB_24BIT 15205b261ecSmrg case 24: dots = fbDots24; break; 15305b261ecSmrg#endif 15405b261ecSmrg case 32: dots = fbDots32; break; 15505b261ecSmrg } 15605b261ecSmrg#endif 15705b261ecSmrg for (nBox = REGION_NUM_RECTS (pClip), pBox = REGION_RECTS (pClip); 15805b261ecSmrg nBox--; pBox++) 15905b261ecSmrg (*dots) (dst, dstStride, dstBpp, pBox, pptInit, nptInit, 16005b261ecSmrg pDrawable->x, pDrawable->y, dstXoff, dstYoff, and, xor); 16105b261ecSmrg fbFinishAccess (pDrawable); 16205b261ecSmrg} 163