2 * $XConsortium: mfbply1rct.c /main/10 1996/08/23 10:35:13 dpw $
4 Copyright (c) 1990 X Consortium
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 Except as contained in this notice, the name of the X Consortium shall not be
24 used in advertising or otherwise to promote the sale, use or other dealings
25 in this Software without prior written authorization from the X Consortium.
27 * Author: Keith Packard, MIT X Consortium
33 #include "windowstr.h"
34 #include "pixmapstr.h"
35 #include "regionstr.h"
36 #include "scrnintstr.h"
42 #if defined(mips) || defined(sparc)
43 #define GetHighWord(x) (((int) (x)) >> 16)
45 #define GetHighWord(x) (((int) (x)) / 65536)
48 #if IMAGE_BYTE_ORDER == MSBFirst
49 #define intToCoord(i,x,y) (((x) = GetHighWord(i)), ((y) = (int) ((short) (i))))
50 #define coordToInt(x,y) (((x) << 16) | (y))
51 #define intToX(i) (GetHighWord(i))
52 #define intToY(i) ((int) ((short) i))
54 #define intToCoord(i,x,y) (((x) = (int) ((short) (i))), ((y) = GetHighWord(i)))
55 #define coordToInt(x,y) (((y) << 16) | (x))
56 #define intToX(i) ((int) ((short) (i)))
57 #define intToY(i) (GetHighWord(i))
61 MFBFILLPOLY1RECT (pDrawable, pGC, shape, mode, count, ptsIn)
62 DrawablePtr pDrawable;
69 PixelType *addrl, *addr;
72 register int vertex1, vertex2;
77 int *vertex1p, *vertex2p;
87 PixelType mask, bits = ~((PixelType)0);
90 devPriv = (mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr);
91 if (mode == CoordModePrevious || shape != Convex ||
92 REGION_NUM_RECTS(devPriv->pCompositeClip) != 1)
94 miFillPolygon (pDrawable, pGC, shape, mode, count, ptsIn);
97 origin = *((int *) &pDrawable->x);
98 vertex2 = origin - ((origin & 0x8000) << 1);
99 extents = &devPriv->pCompositeClip->extents;
100 vertex1 = *((int *) &extents->x1) - vertex2;
101 vertex2 = *((int *) &extents->x2) - vertex2 - 0x00010001;
105 vertex2p = (int *) ptsIn;
106 endp = vertex2p + count;
110 clip |= (c - vertex1) | (vertex2 - c);
124 if (clip & 0x80008000)
126 miFillPolygon (pDrawable, pGC, shape, mode, vertex2p - (int *) ptsIn, ptsIn);
130 mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrl);
131 addrl = mfbScanlineDelta(addrl, y + pDrawable->y, nlwidth);
132 origin = intToX(origin);
134 vertex2 = vertex1 = *vertex2p++;
135 if (vertex2p == endp)
136 vertex2p = (int *) ptsIn;
137 #define Setup(c,x,vertex,dx,dy,e,sign,step) {\
138 x = intToX(vertex); \
139 if (dy = intToY(c) - y) { \
140 dx = intToX(c) - x; \
157 step = - (dx / dy); \
166 #define Step(x,dx,dy,e,sign,step) {\
176 if (y == intToY(vertex1))
180 if (vertex1p == (int *) ptsIn)
183 Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1)
184 } while (y >= intToY(vertex1));
189 Step(x1,dx1,dy1,e1,sign1,step1)
190 h = intToY(vertex1) - y;
192 if (y == intToY(vertex2))
197 if (vertex2p == endp)
198 vertex2p = (int *) ptsIn;
199 Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2)
200 } while (y >= intToY(vertex2));
206 Step(x2,dx2,dy2,e2,sign2,step2)
207 if ((c = (intToY(vertex2) - y)) < h)
210 /* fill spans for this segment */
227 if (c + nmiddle < PPW)
229 mask = SCRRIGHT (bits,c) ^ SCRRIGHT (bits,c+nmiddle);
236 mask = SCRRIGHT(bits, c);
242 Duff (nmiddle, *addr++ EQWHOLEWORD)
243 if (mask = ~SCRRIGHT(bits, r & PIM))
248 mfbScanlineInc(addrl, nlwidth);
249 Step(x1,dx1,dy1,e1,sign1,step1)
250 Step(x2,dx2,dy2,e2,sign2,step2)
254 mfbScanlineInc(addrl, nlwidth);