3 Copyright (c) 1990 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 * Author: Keith Packard, MIT X Consortium
29 #ifdef HAVE_DIX_CONFIG_H
30 #include <dix-config.h>
38 #include "windowstr.h"
39 #include "pixmapstr.h"
40 #include "regionstr.h"
41 #include "scrnintstr.h"
47 #if defined(mips) || defined(sparc)
48 #define GetHighWord(x) (((int)(x)) >> 16)
50 #define GetHighWord(x) (((int)(x)) / 65536)
53 #if IMAGE_BYTE_ORDER == MSBFirst
54 #define intToCoord(i,x,y) (((x) = GetHighWord(i)), ((y) = (int)((short) (i))))
55 #define coordToInt(x,y) (((x) << 16) | (y))
56 #define intToX(i) (GetHighWord(i))
57 #define intToY(i) ((int)((short) i))
59 #define intToCoord(i,x,y) (((x) = (int)((short) (i))), ((y) = GetHighWord(i)))
60 #define coordToInt(x,y) (((y) << 16) | (x))
61 #define intToX(i) ((int)((short) (i)))
62 #define intToY(i) (GetHighWord(i))
66 afbFillPolygonSolid (pDrawable
, pGC
, shape
, mode
, count
, ptsIn
)
67 DrawablePtr pDrawable
;
76 PixelType
*addrl
, *addr
;
79 register int vertex1
, vertex2
;
84 int *vertex1p
= NULL
, *vertex2p
;
90 int step1
= 0, step2
= 0;
91 int sign1
= 0, sign2
= 0;
94 PixelType mask
, bits
= ~((PixelType
)0);
96 register unsigned char *rrops
;
101 register PixelType
*pdst
;
103 devPriv
= (afbPrivGC
*)(pGC
->devPrivates
[afbGCPrivateIndex
].ptr
);
105 if (mode
== CoordModePrevious
|| shape
!= Convex
||
106 REGION_NUM_RECTS(pGC
->pCompositeClip
) != 1) {
107 miFillPolygon (pDrawable
, pGC
, shape
, mode
, count
, ptsIn
);
110 origin
= *((int *) &pDrawable
->x
);
111 origin
-= (origin
& 0x8000) << 1;
112 extents
= &pGC
->pCompositeClip
->extents
;
113 vertex1
= *((int *) &extents
->x1
) - origin
;
114 vertex2
= *((int *) &extents
->x2
) - origin
- 0x00010001;
118 vertex2p
= (int *) ptsIn
;
119 endp
= vertex2p
+ count
;
122 clip
|= (c
- vertex1
) | (vertex2
- c
);
135 if (clip
& 0x80008000) {
136 miFillPolygon (pDrawable
, pGC
, shape
, mode
, vertex2p
- (int *) ptsIn
, ptsIn
);
140 afbGetPixelWidthSizeDepthAndPointer(pDrawable
, nlwidth
, sizeDst
, depthDst
,
142 rrops
= devPriv
->rrops
;
143 addrl
= afbScanlineDelta(addrl
, y
+ pDrawable
->y
, nlwidth
);
144 origin
= intToX(origin
);
146 vertex2
= vertex1
= *vertex2p
++;
147 if (vertex2p
== endp
)
148 vertex2p
= (int *) ptsIn
;
149 #define Setup(c,x,vertex,dx,dy,e,sign,step) {\
150 x = intToX(vertex); \
151 if ((dy = intToY(c) - y)) { \
152 dx = intToX(c) - x; \
166 step = - (dx / dy); \
175 #define Step(x,dx,dy,e,sign,step) {\
177 if ((e += dx) > 0) { \
183 if (y
== intToY(vertex1
)) {
185 if (vertex1p
== (int *) ptsIn
)
188 Setup (c
,x1
,vertex1
,dx1
,dy1
,e1
,sign1
,step1
)
189 } while (y
>= intToY(vertex1
));
192 Step(x1
,dx1
,dy1
,e1
,sign1
,step1
)
193 h
= intToY(vertex1
) - y
;
195 if (y
== intToY(vertex2
)) {
198 if (vertex2p
== endp
)
199 vertex2p
= (int *) ptsIn
;
200 Setup (c
,x2
,vertex2
,dx2
,dy2
,e2
,sign2
,step2
)
201 } while (y
>= intToY(vertex2
));
205 Step(x2
,dx2
,dy2
,e2
,sign2
,step2
)
206 if ((c
= (intToY(vertex2
) - y
)) < h
)
209 /* fill spans for this segment */
224 if (c
+ nmiddle
< PPW
) {
225 mask
= SCRRIGHT (bits
,c
) ^ SCRRIGHT (bits
,c
+nmiddle
);
226 for (pdst
= addr
, d
= 0; d
< depthDst
; d
++, pdst
+= sizeDst
) { /* @@@ NEXT PLANE @@@ */
243 mask
= SCRRIGHT(bits
, c
);
244 for (pdst
= addr
, d
= 0; d
< depthDst
; d
++, pdst
+= sizeDst
) { /* @@@ NEXT PLANE @@@ */
263 mask
= ~SCRRIGHT(bits
, r
& PIM
);
265 for (d
= 0; d
< depthDst
; d
++, addr
+= sizeDst
) { /* @@@ NEXT PLANE @@@ */
271 Duff (n
, *pdst
++ = 0;)
276 Duff (n
, *pdst
++ = ~0;);
281 Duff (n
, *pdst
++ ^= ~0;);
292 afbScanlineInc(addrl
, nlwidth
);
293 Step(x1
,dx1
,dy1
,e1
,sign1
,step1
)
294 Step(x2
,dx2
,dy2
,e2
,sign2
,step2
)
298 afbScanlineInc(addrl
, nlwidth
);