1 /************************************************************
3 Copyright (c) 1989 X Consortium
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 Except as contained in this notice, the name of the X Consortium shall not be
23 used in advertising or otherwise to promote the sale, use or other dealings
24 in this Software without prior written authorization from the X Consortium.
26 ********************************************************/
28 /* $XConsortium: cfbpolypnt.c,v 5.17 94/04/17 20:28:57 dpw Exp $ */
29 /* $XFree86: xc/programs/Xserver/cfb/cfbpolypnt.c,v 3.0 1996/06/29 09:05:47 dawes Exp $ */
33 #include "windowstr.h"
34 #include "pixmapstr.h"
35 #include "regionstr.h"
36 #include "scrnintstr.h"
38 #include "cfbmskbits.h"
40 #define isClipped(c,ul,lr) ((((c) - (ul)) | ((lr) - (c))) & ClipMask)
42 /* WARNING: pbox contains two shorts. This code assumes they are packed
43 * and can be referenced together as an INT32.
46 #define PointLoop(fill) { \
47 for (nbox = REGION_NUM_RECTS(cclip), pbox = REGION_RECTS(cclip); \
51 c1 = *((INT32 *) &pbox->x1) - off; \
52 c2 = *((INT32 *) &pbox->x2) - off - 0x00010001; \
53 for (ppt = (INT32 *) pptInit, i = npt; --i >= 0;) \
56 if (!isClipped(pt,c1,c2)) { \
64 # include "cfbrrop24.h"
68 cfbPolyPoint(pDrawable, pGC, mode, npt, pptInit)
69 DrawablePtr pDrawable;
76 register INT32 c1, c2;
77 register unsigned long ClipMask = 0x80008000;
78 register unsigned long xor;
80 register PixelType *addrp;
84 register unsigned long *addrl;
87 unsigned long *addrlt;
92 register PixelType *p;
102 cfbPrivGCPtr devPriv;
105 devPriv =cfbGetGCPrivate(pGC);
109 cclip = devPriv->pCompositeClip;
111 if ((mode == CoordModePrevious) && (npt > 1))
113 for (pptPrev = pptInit + 1, i = npt - 1; --i >= 0; pptPrev++)
115 pptPrev->x += (pptPrev-1)->x;
116 pptPrev->y += (pptPrev-1)->y;
119 off = *((int *) &pDrawable->x);
120 off -= (off & 0x8000) << 1;
122 cfbGetPixelWidthAndPointer(pDrawable, npwidth, addrp);
124 addrp = addrp + pDrawable->y * npwidth;
126 addrp = addrp + pDrawable->y * npwidth + pDrawable->x;
133 if (!(npwidth & (npwidth - 1)))
135 npwidth = ffs(npwidth) - 1;
138 xtmp = pDrawable->x + intToX(pt);
139 p = addrp + (intToY(pt) << npwidth) + ((xtmp * 3) >>2);
140 RROP_SOLID24_COPY(p, xtmp))
142 PointLoop(*(addrp + (intToY(pt) << npwidth) + intToX(pt)) = xor;)
146 else if (npwidth == 1152)
149 PointLoop(y = intToY(pt); *(addrp + (y << 10) + (y << 7) + intToX(pt)) = xor;)
156 xtmp = pDrawable->x + intToX(pt);
157 p = addrp + intToY(pt) * npwidth + ((xtmp * 3) >> 2);
158 RROP_SOLID24_COPY(p, xtmp))
160 PointLoop(*(addrp + intToY(pt) * npwidth + intToX(pt)) = xor;)
168 RROP_SET_SETUP(xor, and)
170 xtmp = pDrawable->x + intToX(pt);
171 p = addrp + intToY(pt) * npwidth + ((xtmp * 3) >> 2);
172 RROP_SOLID24_SET(p, xtmp))
174 PointLoop( addrpt = addrp + intToY(pt) * npwidth + intToX(pt);
175 *addrpt = DoRRop (*addrpt, and, xor);)
178 #else /* !PIXEL_ADDR */
179 cfbGetLongWidthAndPointer(pDrawable, nlwidth, addrl);
180 addrl = addrl + pDrawable->y * nlwidth + (pDrawable->x >> PWSH);
181 xoffset = pDrawable->x & PIM;
184 PointLoop( addrlt = addrl + intToY(pt) * nlwidth
185 + ((intToX(pt) + xoffset) >> PWSH);
186 *addrlt = DoRRop (*addrlt,
187 and | ~cfbmask[(intToX(pt) + xoffset) & PIM],
188 xor & cfbmask[(intToX(pt) + xoffset) & PIM]);
191 PointLoop( addrlt = addrl + intToY(pt) * nlwidth
192 + ((intToX(pt) + xoffset) >> PWSH);
193 *addrlt = DoRRop (*addrlt,
194 and | ~cfbmask[((intToX(pt) + xoffset) & 3)<<1],
195 xor & cfbmask[((intToX(pt) + xoffset) & 3)<<1]);
198 #endif /* PIXEL_ADDR */