3 Copyright 1990, 1998 The Open Group
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
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
25 * Author: Keith Packard, MIT X Consortium
28 #ifdef HAVE_DIX_CONFIG_H
29 #include <dix-config.h>
37 #include "windowstr.h"
38 #include "pixmapstr.h"
39 #include "regionstr.h"
40 #include "scrnintstr.h"
44 #include "cfbmskbits.h"
48 RROP_NAME(cfbFillPoly1Rect
) (pDrawable
, pGC
, shape
, mode
, count
, ptsIn
)
49 DrawablePtr pDrawable
;
58 CfbBits
*addrl
, *addr
;
60 CfbBits startmask
, endmask
;
64 CfbBits mask
, bits
= ~((CfbBits
)0);
69 register int vertex1
, vertex2
;
74 int *vertex1p
= NULL
, *vertex2p
;
80 int step1
= 0, step2
= 0;
81 int sign1
= 0, sign2
= 0;
84 #if PSZ != 24 && PPW > 1
90 if (mode
== CoordModePrevious
)
92 miFillPolygon (pDrawable
, pGC
, shape
, mode
, count
, ptsIn
);
96 devPriv
= cfbGetGCPrivate(pGC
);
98 if (REGION_NUM_RECTS(pGC
->pCompositeClip
) != 1)
100 miFillPolygon (pDrawable
, pGC
, shape
, mode
, count
, ptsIn
);
104 origin
= *((int *) &pDrawable
->x
);
105 vertex2
= origin
- ((origin
& 0x8000) << 1);
106 extents
= &pGC
->pCompositeClip
->extents
;
107 RROP_FETCH_GCPRIV(devPriv
);
108 vertex1
= *((int *) &extents
->x1
) - vertex2
;
109 vertex2
= *((int *) &extents
->x2
) - vertex2
- 0x00010001;
113 vertex2p
= (int *) ptsIn
;
114 endp
= vertex2p
+ count
;
120 clip
|= (c
- vertex1
) | (vertex2
- c
);
141 clip
|= (c
- vertex1
) | (vertex2
- c
);
158 dx2
= dx1
= (c
- x1
) >> 31;
161 if ((c
- x1
) >> 31 != dx1
)
179 if (clip
& 0x80008000)
181 miFillPolygon (pDrawable
, pGC
, shape
, mode
, vertex2p
- (int *) ptsIn
, ptsIn
);
185 #define AddrYPlus(a,y) (CfbBits *) (((unsigned char *) (a)) + (y) * nwidth)
187 cfbGetTypedWidthAndPointer(pDrawable
, nwidth
, addrl
, unsigned char, CfbBits
);
188 addrl
= AddrYPlus(addrl
,y
+ pDrawable
->y
);
189 origin
= intToX(origin
);
191 vertex2
= vertex1
= *vertex2p
++;
192 if (vertex2p
== endp
)
193 vertex2p
= (int *) ptsIn
;
194 #define Setup(c,x,vertex,dx,dy,e,sign,step) {\
195 x = intToX(vertex); \
196 if ((dy = intToY(c) - y)) { \
197 dx = intToX(c) - x; \
214 step = - (dx / dy); \
223 #define Step(x,dx,dy,e,sign,step) {\
233 if (y
== intToY(vertex1
))
237 if (vertex1p
== (int *) ptsIn
)
240 Setup (c
,x1
,vertex1
,dx1
,dy1
,e1
,sign1
,step1
)
241 } while (y
>= intToY(vertex1
));
246 Step(x1
,dx1
,dy1
,e1
,sign1
,step1
)
247 h
= intToY(vertex1
) - y
;
249 if (y
== intToY(vertex2
))
254 if (vertex2p
== endp
)
255 vertex2p
= (int *) ptsIn
;
256 Setup (c
,x2
,vertex2
,dx2
,dy2
,e2
,sign2
,step2
)
257 } while (y
>= intToY(vertex2
));
263 Step(x2
,dx2
,dy2
,e2
,sign2
,step2
)
264 if ((c
= (intToY(vertex2
) - y
)) < h
)
267 /* fill spans for this segment */
272 #if PSZ != 24 && PPW > 1
280 #if PSZ != 24 && PPW > 1
291 #else /* PGSZ == 64 */
296 addr
= (CfbBits
*)((char *)addrl
+ ((l
* 3) & ~0x03));
299 RROP_SOLID24(addr
, l
);
301 maskbits(l
, nmiddle
, startmask
, endmask
, nmiddle
);
304 RROP_SOLID_MASK(addr
, startmask
, pidx
-1);
309 while (--nmiddle
>= 0){
310 RROP_SOLID(addr
, pidx
);
316 RROP_SOLID_MASK(addr
, endmask
, pidx
);
318 #else /* PSZ == 24 */
319 #if PWSH > LWRD_SHIFT
320 l
= l
>> (PWSH
- LWRD_SHIFT
);
322 #if PWSH < LWRD_SHIFT
323 l
= l
<< (LWRD_SHIFT
- PWSH
);
325 addr
= (CfbBits
*) (((char *) addrl
) + l
);
327 if (c
+ nmiddle
< PPW
)
329 mask
= SCRRIGHT (bits
,c
) ^ SCRRIGHT (bits
,c
+nmiddle
);
330 RROP_SOLID_MASK(addr
,mask
);
336 mask
= SCRRIGHT(bits
, c
);
337 RROP_SOLID_MASK(addr
,mask
);
343 while (--nmiddle
>= 0) {
344 RROP_SOLID(addr
); addr
++;
347 if ((mask
= ~SCRRIGHT(bits
, r
& PIM
)))
348 RROP_SOLID_MASK(addr
,mask
);
351 #endif /* PSZ == 24 */
354 addrl
= AddrYPlus (addrl
, 1);
355 Step(x1
,dx1
,dy1
,e1
,sign1
,step1
)
356 Step(x2
,dx2
,dy2
,e2
,sign2
,step2
)
360 addrl
= AddrYPlus (addrl
, 1);