2 * $XConsortium: cfbply1rct.c /main/16 1996/08/12 22:07:31 dpw $
3 * $XFree86: xc/programs/Xserver/cfb/cfbply1rct.c,v 3.3 1996/12/23 06:29:21 dawes Exp $
5 Copyright (c) 1990 X Consortium
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 Except as contained in this notice, the name of the X Consortium shall not be
25 used in advertising or otherwise to promote the sale, use or other dealings
26 in this Software without prior written authorization from the X Consortium.
28 * Author: Keith Packard, MIT X Consortium
34 #include "windowstr.h"
35 #include "pixmapstr.h"
36 #include "regionstr.h"
37 #include "scrnintstr.h"
41 #include "cfbmskbits.h"
45 RROP_NAME(cfbFillPoly1Rect) (pDrawable, pGC, shape, mode, count, ptsIn)
46 DrawablePtr pDrawable;
55 unsigned long *addrl, *addr;
57 unsigned long startmask, endmask;
62 register int vertex1, vertex2;
67 int *vertex1p, *vertex2p;
77 unsigned long mask, bits = ~((unsigned long)0);
81 if (mode == CoordModePrevious)
83 miFillPolygon (pDrawable, pGC, shape, mode, count, ptsIn);
87 devPriv = cfbGetGCPrivate(pGC);
89 if (REGION_NUM_RECTS(devPriv->pCompositeClip) != 1)
91 miFillPolygon (pDrawable, pGC, shape, mode, count, ptsIn);
95 origin = *((int *) &pDrawable->x);
96 vertex2 = origin - ((origin & 0x8000) << 1);
97 extents = &devPriv->pCompositeClip->extents;
98 RROP_FETCH_GCPRIV(devPriv);
99 vertex1 = *((int *) &extents->x1) - vertex2;
100 vertex2 = *((int *) &extents->x2) - vertex2 - 0x00010001;
104 vertex2p = (int *) ptsIn;
105 endp = vertex2p + count;
111 clip |= (c - vertex1) | (vertex2 - c);
132 clip |= (c - vertex1) | (vertex2 - c);
149 dx2 = dx1 = (c - x1) >> 31;
152 if ((c - x1) >> 31 != dx1)
170 if (clip & 0x80008000)
172 miFillPolygon (pDrawable, pGC, shape, mode, vertex2p - (int *) ptsIn, ptsIn);
176 #define AddrYPlus(a,y) (unsigned long *) (((unsigned char *) (a)) + (y) * nwidth)
178 cfbGetTypedWidthAndPointer(pDrawable, nwidth, addrl, unsigned char, unsigned long);
179 addrl = AddrYPlus(addrl,y + pDrawable->y);
180 origin = intToX(origin);
182 vertex2 = vertex1 = *vertex2p++;
183 if (vertex2p == endp)
184 vertex2p = (int *) ptsIn;
185 #define Setup(c,x,vertex,dx,dy,e,sign,step) {\
186 x = intToX(vertex); \
187 if (dy = intToY(c) - y) { \
188 dx = intToX(c) - x; \
205 step = - (dx / dy); \
214 #define Step(x,dx,dy,e,sign,step) {\
224 if (y == intToY(vertex1))
228 if (vertex1p == (int *) ptsIn)
231 Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1)
232 } while (y >= intToY(vertex1));
237 Step(x1,dx1,dy1,e1,sign1,step1)
238 h = intToY(vertex1) - y;
240 if (y == intToY(vertex2))
245 if (vertex2p == endp)
246 vertex2p = (int *) ptsIn;
247 Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2)
248 } while (y >= intToY(vertex2));
254 Step(x2,dx2,dy2,e2,sign2,step2)
255 if ((c = (intToY(vertex2) - y)) < h)
258 /* fill spans for this segment */
278 #else /* PGSZ == 64 */
283 addr = (unsigned long *)((char *)addrl + ((l * 3) & ~0x03));
284 #else /* PSZ == 24 */
285 #if PWSH > LWRD_SHIFT
286 l = l >> (PWSH - LWRD_SHIFT);
288 #if PWSH < LWRD_SHIFT
289 l = l << (LWRD_SHIFT - PWSH);
291 addr = (unsigned long *) (((char *) addrl) + l);
292 #endif /* PSZ == 24 */
296 RROP_SOLID24(addr, l);
298 maskbits(l, nmiddle, startmask, endmask, nmiddle);
301 RROP_SOLID_MASK(addr, startmask, pidx-1);
306 while (--nmiddle >= 0){
307 RROP_SOLID(addr, pidx);
313 RROP_SOLID_MASK(addr, endmask, pidx);
315 #else /* PSZ == 24 */
317 if (c + nmiddle < PPW)
319 mask = SCRRIGHT (bits,c) ^ SCRRIGHT (bits,c+nmiddle);
320 RROP_SOLID_MASK(addr,mask);
326 mask = SCRRIGHT(bits, c);
327 RROP_SOLID_MASK(addr,mask);
333 while (--nmiddle >= 0) {
334 RROP_SOLID(addr); addr++;
337 if (mask = ~SCRRIGHT(bits, r & PIM))
338 RROP_SOLID_MASK(addr,mask);
341 #endif /* PSZ == 24 */
344 addrl = AddrYPlus (addrl, 1);
345 Step(x1,dx1,dy1,e1,sign1,step1)
346 Step(x2,dx2,dy2,e2,sign2,step2)
350 addrl = AddrYPlus (addrl, 1);