fbpoint.c revision 706f2543
1/* 2 * Copyright © 1998 Keith Packard 3 * 4 * Permission to use, copy, modify, distribute, and sell this software and its 5 * documentation for any purpose is hereby granted without fee, provided that 6 * the above copyright notice appear in all copies and that both that 7 * copyright notice and this permission notice appear in supporting 8 * documentation, and that the name of Keith Packard not be used in 9 * advertising or publicity pertaining to distribution of the software without 10 * specific, written prior permission. Keith Packard makes no 11 * representations about the suitability of this software for any purpose. It 12 * is provided "as is" without express or implied warranty. 13 * 14 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 20 * PERFORMANCE OF THIS SOFTWARE. 21 */ 22 23#ifdef HAVE_DIX_CONFIG_H 24#include <dix-config.h> 25#endif 26 27#include "fb.h" 28 29typedef void (*FbDots) (FbBits *dst, 30 FbStride dstStride, 31 int dstBpp, 32 BoxPtr pBox, 33 xPoint *pts, 34 int npt, 35 int xorg, 36 int yorg, 37 int xoff, 38 int yoff, 39 FbBits and, 40 FbBits xor); 41 42void 43fbDots (FbBits *dstOrig, 44 FbStride dstStride, 45 int dstBpp, 46 BoxPtr pBox, 47 xPoint *pts, 48 int npt, 49 int xorg, 50 int yorg, 51 int xoff, 52 int yoff, 53 FbBits andOrig, 54 FbBits xorOrig) 55{ 56 FbStip *dst = (FbStip *) dstOrig; 57 int x1, y1, x2, y2; 58 int x, y; 59 FbStip *d; 60 FbStip and = andOrig; 61 FbStip xor = xorOrig; 62 63 dstStride = FbBitsStrideToStipStride (dstStride); 64 x1 = pBox->x1; 65 y1 = pBox->y1; 66 x2 = pBox->x2; 67 y2 = pBox->y2; 68 while (npt--) 69 { 70 x = pts->x + xorg; 71 y = pts->y + yorg; 72 pts++; 73 if (x1 <= x && x < x2 && y1 <= y && y < y2) 74 { 75 x = (x + xoff) * dstBpp; 76 d = dst + ((y + yoff) * dstStride) + (x >> FB_STIP_SHIFT); 77 x &= FB_STIP_MASK; 78#ifdef FB_24BIT 79 if (dstBpp == 24) 80 { 81 FbStip leftMask, rightMask; 82 int n, rot; 83 FbStip andT, xorT; 84 85 rot = FbFirst24Rot (x); 86 andT = FbRot24Stip(and,rot); 87 xorT = FbRot24Stip(xor,rot); 88 FbMaskStip (x, 24, leftMask, n, rightMask); 89 if (leftMask) 90 { 91 WRITE(d, FbDoMaskRRop (READ(d), andT, xorT, leftMask)); 92 andT = FbNext24Stip(andT); 93 xorT = FbNext24Stip(xorT); 94 d++; 95 } 96 if (rightMask) 97 WRITE(d, FbDoMaskRRop(READ(d), andT, xorT, rightMask)); 98 } 99 else 100#endif 101 { 102 FbStip mask; 103 mask = FbStipMask(x, dstBpp); 104 WRITE(d, FbDoMaskRRop (READ(d), and, xor, mask)); 105 } 106 } 107 } 108} 109 110void 111fbPolyPoint (DrawablePtr pDrawable, 112 GCPtr pGC, 113 int mode, 114 int nptInit, 115 xPoint *pptInit) 116{ 117 FbGCPrivPtr pPriv = fbGetGCPrivate (pGC); 118 RegionPtr pClip = fbGetCompositeClip(pGC); 119 FbBits *dst; 120 FbStride dstStride; 121 int dstBpp; 122 int dstXoff, dstYoff; 123 FbDots dots; 124 FbBits and, xor; 125 xPoint *ppt; 126 int npt; 127 BoxPtr pBox; 128 int nBox; 129 130 /* make pointlist origin relative */ 131 ppt = pptInit; 132 npt = nptInit; 133 if (mode == CoordModePrevious) 134 { 135 npt--; 136 while(npt--) 137 { 138 ppt++; 139 ppt->x += (ppt-1)->x; 140 ppt->y += (ppt-1)->y; 141 } 142 } 143 fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); 144 and = pPriv->and; 145 xor = pPriv->xor; 146 dots = fbDots; 147#ifndef FBNOPIXADDR 148 switch (dstBpp) { 149 case 8: dots = fbDots8; break; 150 case 16: dots = fbDots16; break; 151#ifdef FB_24BIT 152 case 24: dots = fbDots24; break; 153#endif 154 case 32: dots = fbDots32; break; 155 } 156#endif 157 for (nBox = RegionNumRects (pClip), pBox = RegionRects (pClip); 158 nBox--; pBox++) 159 (*dots) (dst, dstStride, dstBpp, pBox, pptInit, nptInit, 160 pDrawable->x, pDrawable->y, dstXoff, dstYoff, and, xor); 161 fbFinishAccess (pDrawable); 162} 163