1/* 2 * Copyright © 1998 Keith Packard 3 * Copyright © 2012 Intel Corporation 4 * 5 * Permission to use, copy, modify, distribute, and sell this software and its 6 * documentation for any purpose is hereby granted without fee, provided that 7 * the above copyright notice appear in all copies and that both that 8 * copyright notice and this permission notice appear in supporting 9 * documentation, and that the name of Keith Packard not be used in 10 * advertising or publicity pertaining to distribution of the software without 11 * specific, written prior permission. Keith Packard makes no 12 * representations about the suitability of this software for any purpose. It 13 * is provided "as is" without express or implied warranty. 14 * 15 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 17 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR 18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 19 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 20 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 21 * PERFORMANCE OF THIS SOFTWARE. 22 */ 23 24#include "fb.h" 25#include <micoord.h> 26 27#define DOTS fbDots8 28#define DOTS__SIMPLE fbDots8__simple 29#define BITS BYTE 30#include "fbpointbits.h" 31#undef BITS 32#undef DOTS__SIMPLE 33#undef DOTS 34 35#define DOTS fbDots16 36#define DOTS__SIMPLE fbDots16__simple 37#define BITS CARD16 38#include "fbpointbits.h" 39#undef BITS 40#undef DOTS__SIMPLE 41#undef DOTS 42 43#define DOTS fbDots32 44#define DOTS__SIMPLE fbDots32__simple 45#define BITS CARD32 46#include "fbpointbits.h" 47#undef BITS 48#undef DOTS__SIMPLE 49#undef DOTS 50 51static void 52fbDots(FbBits *dstOrig, FbStride dstStride, int dstBpp, 53 RegionPtr clip, 54 xPoint *pts, int n, 55 int xorg, int yorg, 56 int xoff, int yoff, 57 FbBits andOrig, FbBits xorOrig) 58{ 59 FbStip *dst = (FbStip *) dstOrig; 60 FbStip and = andOrig; 61 FbStip xor = xorOrig; 62 63 while (n--) { 64 int x = pts->x + xorg; 65 int y = pts->y + yorg; 66 pts++; 67 if (RegionContainsPoint(clip, x, y, NULL)) { 68 FbStip mask; 69 FbStip *d; 70 71 x = (x + xoff) * dstBpp; 72 d = dst + ((y + yoff) * dstStride) + (x >> FB_STIP_SHIFT); 73 x &= FB_STIP_MASK; 74 75 mask = FbStipMask(x, dstBpp); 76 WRITE(d, FbDoMaskRRop(READ(d), and, xor, mask)); 77 } 78 } 79} 80 81void 82fbPolyPoint(DrawablePtr drawable, GCPtr gc, 83 int mode, int n, xPoint *pt, unsigned flags) 84{ 85 FbBits *dst; 86 FbStride dstStride; 87 int dstBpp; 88 int dstXoff, dstYoff; 89 void (*dots)(FbBits *dst, FbStride dstStride, int dstBpp, 90 RegionPtr clip, 91 xPoint *pts, int n, 92 int xorg, int yorg, 93 int xoff, int yoff, 94 FbBits and, FbBits xor); 95 96 DBG(("%s x %d, clip=[(%d, %d), (%d, %d)]x%d\n", __FUNCTION__, n, 97 gc->pCompositeClip->extents.x1, gc->pCompositeClip->extents.y1, 98 gc->pCompositeClip->extents.x2, gc->pCompositeClip->extents.y2, 99 region_num_rects(gc->pCompositeClip))); 100 101 if (mode == CoordModePrevious) 102 fbFixCoordModePrevious(n, pt); 103 104 fbGetDrawable(drawable, dst, dstStride, dstBpp, dstXoff, dstYoff); 105 dots = fbDots; 106 if ((flags & 2) == 0 && fb_gc(gc)->and == 0) { 107 switch (dstBpp) { 108 case 8: 109 dots = fbDots8__simple; 110 break; 111 case 16: 112 dots = fbDots16__simple; 113 break; 114 case 32: 115 dots = fbDots32__simple; 116 break; 117 } 118 } else { 119 switch (dstBpp) { 120 case 8: 121 dots = fbDots8; 122 break; 123 case 16: 124 dots = fbDots16; 125 break; 126 case 32: 127 dots = fbDots32; 128 break; 129 } 130 } 131 dots(dst, dstStride, dstBpp, gc->pCompositeClip, pt, n, 132 drawable->x, drawable->y, dstXoff, dstYoff, 133 fb_gc(gc)->and, fb_gc(gc)->xor); 134} 135