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 ********************************************************/
29 #ifdef HAVE_DIX_CONFIG_H
30 #include <dix-config.h>
34 #include <X11/Xprotostr.h>
35 #include "regionstr.h"
37 #include "pixmapstr.h"
38 #include "scrnintstr.h"
41 #include "mifillarc.h"
45 afbFillEllipseSolid(DrawablePtr pDraw
, xArc
*arc
, register unsigned char *rrops
)
48 int yk
, xk
, ym
, xm
, dx
, dy
, xorg
, yorg
;
51 PixelType
*addrlt
, *addrlb
;
52 register PixelType
*pdst
;
58 PixelType startmask
, endmask
;
63 afbGetPixelWidthSizeDepthAndPointer(pDraw
, nlwidth
, sizeDst
, depthDst
,
65 miFillArcSetup(arc
, &info
);
70 addrlt
+= nlwidth
* (yorg
- y
);
71 addrlb
+= nlwidth
* (yorg
+ y
+ dy
);
79 pdst
= addrl
= afbScanlineOffset(addrlt
, (xpos
>> PWSH
));
80 if (((xpos
& PIM
) + slw
) < PPW
) {
81 maskpartialbits(xpos
, slw
, startmask
);
82 for (d
= 0; d
< depthDst
; d
++, pdst
+= sizeDst
) { /* @@@ NEXT PLANE @@@ */
97 if (miFillArcLower(slw
)) {
98 pdst
= afbScanlineOffset(addrlb
, (xpos
>> PWSH
));
100 for (d
= 0; d
< depthDst
; d
++, pdst
+= sizeDst
) { /* @@@ NEXT PLANE @@@ */
118 maskbits(xpos
, slw
, startmask
, endmask
, nlmiddle
);
119 for (d
= 0; d
< depthDst
; d
++, addrl
+= sizeDst
) { /* @@@ NEXT PLANE @@@ */
126 *pdst
++ &= ~startmask
;
135 *pdst
++ |= startmask
;
144 *pdst
++ ^= startmask
;
155 if (!miFillArcLower(slw
))
157 addrl
= afbScanlineOffset(addrlb
, (xpos
>> PWSH
));
158 for (d
= 0; d
< depthDst
; d
++, addrl
+= sizeDst
) { /* @@@ NEXT PLANE @@@ */
165 *pdst
++ &= ~startmask
;
174 *pdst
++ |= startmask
;
183 *pdst
++ ^= startmask
;
197 #define FILLSPAN(xl,xr,addr) \
199 width = xr - xl + 1; \
200 addrl = afbScanlineOffset(addr, (xl >> PWSH)); \
201 if (((xl & PIM) + width) < PPW) { \
202 maskpartialbits(xl, width, startmask); \
203 for (pdst = addrl, d = 0; d < depthDst; d++, pdst += sizeDst) { /* @@@ NEXT PLANE @@@ */ \
204 switch (rrops[d]) { \
206 *pdst &= ~startmask; \
209 *pdst |= startmask; \
212 *pdst ^= startmask; \
219 maskbits(xl, width, startmask, endmask, nlmiddle); \
220 for (d = 0; d < depthDst; d++, addrl += sizeDst) { /* @@@ NEXT PLANE @@@ */ \
223 switch (rrops[d]) { \
226 *pdst++ &= ~startmask; \
234 *pdst++ |= startmask; \
242 *pdst++ ^= startmask; \
255 #define FILLSLICESPANS(flip,addr) \
257 FILLSPAN(xl, xr, addr); \
260 FILLSPAN(xc, xr, addr); \
262 FILLSPAN(xl, xc, addr); \
266 afbFillArcSliceSolidCopy(DrawablePtr pDraw
, GCPtr pGC
, xArc
*arc
, register unsigned char *rrops
)
269 register PixelType
*pdst
;
272 int yk
, xk
, ym
, xm
, dx
, dy
, xorg
, yorg
, slw
;
273 register int x
, y
, e
;
277 PixelType
*addrlt
, *addrlb
;
280 PixelType startmask
, endmask
;
285 afbGetPixelWidthSizeDepthAndPointer(pDraw
, nlwidth
, sizeDst
, depthDst
,
287 miFillArcSetup(arc
, &info
);
288 miFillArcSliceSetup(arc
, &slice
, pGC
);
293 addrlt
= afbScanlineDeltaNoBankSwitch(addrlt
, yorg
- y
, nlwidth
);
294 addrlb
= afbScanlineDeltaNoBankSwitch(addrlb
, yorg
+ y
+ dy
, nlwidth
);
295 slice
.edge1
.x
+= pDraw
->x
;
296 slice
.edge2
.x
+= pDraw
->x
;
298 afbScanlineIncNoBankSwitch(addrlt
, nlwidth
);
299 afbScanlineIncNoBankSwitch(addrlb
, -nlwidth
);
301 MIARCSLICESTEP(slice
.edge1
);
302 MIARCSLICESTEP(slice
.edge2
);
303 if (miFillSliceUpper(slice
)) {
304 MIARCSLICEUPPER(xl
, xr
, slice
, slw
);
305 FILLSLICESPANS(slice
.flip_top
, addrlt
);
307 if (miFillSliceLower(slice
)) {
308 MIARCSLICELOWER(xl
, xr
, slice
, slw
);
309 FILLSLICESPANS(slice
.flip_bot
, addrlb
);
315 afbPolyFillArcSolid(register DrawablePtr pDraw
, GCPtr pGC
, int narcs
, xArc
*parcs
)
322 unsigned char *rrops
;
324 priv
= (afbPrivGC
*) pGC
->devPrivates
[afbGCPrivateIndex
].ptr
;
326 cclip
= pGC
->pCompositeClip
;
327 for (arc
= parcs
, i
= narcs
; --i
>= 0; arc
++) {
328 if (miFillArcEmpty(arc
))
330 if (miCanFillArc(arc
)) {
331 box
.x1
= arc
->x
+ pDraw
->x
;
332 box
.y1
= arc
->y
+ pDraw
->y
;
333 box
.x2
= box
.x1
+ (int)arc
->width
+ 1;
334 box
.y2
= box
.y1
+ (int)arc
->height
+ 1;
335 if (RECT_IN_REGION(pDraw
->pScreen
, cclip
, &box
) == rgnIN
) {
336 if ((arc
->angle2
>= FULLCIRCLE
) ||
337 (arc
->angle2
<= -FULLCIRCLE
))
338 afbFillEllipseSolid(pDraw
, arc
, rrops
);
340 afbFillArcSliceSolidCopy(pDraw
, pGC
, arc
, rrops
);
344 miPolyFillArc(pDraw
, pGC
, 1, arc
);