Initial commit
[xorg_rtime.git] / xorg-server-1.4 / hw / xfree86 / xf4bpp / mfbfillarc.c
blobd5b5372f58d2fec686d62a2a5e65fec5c8b3ba81
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 ********************************************************/
28 /* GJA -- Took mfb code and modified it. */
30 #ifdef HAVE_XORG_CONFIG_H
31 #include <xorg-config.h>
32 #endif
34 #include "xf4bpp.h"
35 #include "OScompiler.h"
36 #include "mfbmap.h"
37 #include "mfb.h"
38 #include "maskbits.h"
39 #include "mi.h"
40 #include "mifillarc.h"
41 #include "wm3.h"
43 #include "xf86str.h" /* for pScrn->vtSema */
44 extern ScrnInfoPtr *xf86Screens;
46 static void
47 v16FillEllipseSolid
49 DrawablePtr pDraw,
50 xArc *arc
53 int x, y, e;
54 int yk, xk, ym, xm, dx, dy, xorg, yorg;
55 register int slw;
56 miFillArcRec info;
57 int *addrlt, *addrlb;
58 register int *addrl;
59 register int n;
60 int nlwidth;
61 register int xpos;
62 int startmask, endmask, nlmiddle;
64 if (pDraw->type == DRAWABLE_WINDOW)
66 addrlt = (int *)
67 (((PixmapPtr)(pDraw->pScreen->devPrivate))->devPrivate.ptr);
68 nlwidth = (int)
69 (((PixmapPtr)(pDraw->pScreen->devPrivate))->devKind) >> 2;
71 else
73 addrlt = (int *)(((PixmapPtr)pDraw)->devPrivate.ptr);
74 nlwidth = (int)(((PixmapPtr)pDraw)->devKind) >> 2;
77 miFillArcSetup(arc, &info);
78 MIFILLARCSETUP();
79 xorg += pDraw->x;
80 yorg += pDraw->y;
81 addrlb = addrlt;
82 addrlt += nlwidth * (yorg - y);
83 addrlb += nlwidth * (yorg + y + dy);
84 while (y)
86 addrlt += nlwidth;
87 addrlb -= nlwidth;
88 MIFILLARCSTEP(slw);
89 if (!slw)
90 continue;
91 xpos = xorg - x;
92 addrl = addrlt + (xpos >> PWSH);
93 if (((xpos & PIM) + slw) < PPW)
95 maskpartialbits(xpos, slw, startmask);
96 UPDRW(addrl,startmask);
97 if (miFillArcLower(slw))
99 addrl = addrlb + (xpos >> PWSH);
100 UPDRW(addrl,startmask);
102 continue;
104 maskbits(xpos, slw, startmask, endmask, nlmiddle);
105 if (startmask)
107 UPDRW(addrl,startmask); addrl++;
109 n = nlmiddle;
110 while (n--) {
111 UPDRW(addrl,~0); addrl++;
113 if (endmask)
115 UPDRW(addrl,endmask);
117 if (!miFillArcLower(slw))
118 continue;
119 addrl = addrlb + (xpos >> PWSH);
120 if (startmask)
122 UPDRW(addrl,startmask); addrl++;
124 n = nlmiddle;
125 while (n--) {
126 UPDRW(addrl,~0); addrl++;
128 if (endmask)
130 UPDRW(addrl,endmask);
135 #define FILLSPAN(xl,xr,addr) \
136 if (xr >= xl) \
138 width = xr - xl + 1; \
139 addrl = addr + (xl >> PWSH); \
140 if (((xl & PIM) + width) < PPW) \
142 maskpartialbits(xl, width, startmask); \
143 UPDRW(addrl,startmask); \
145 else \
147 maskbits(xl, width, startmask, endmask, nlmiddle); \
148 if (startmask) \
150 UPDRW(addrl,startmask); addrl++; \
152 n = nlmiddle; \
153 while (n--) { \
154 UPDRW(addrl,~0); addrl++; \
156 if (endmask) \
158 UPDRW(addrl,endmask); \
163 #define FILLSLICESPANS(flip,addr) \
164 if (!flip) \
166 FILLSPAN(xl, xr, addr); \
168 else \
170 xc = xorg - x; \
171 FILLSPAN(xc, xr, addr); \
172 xc += slw - 1; \
173 FILLSPAN(xl, xc, addr); \
176 static void
177 v16FillArcSliceSolidCopy
179 DrawablePtr pDraw,
180 GCPtr pGC,
181 xArc *arc
184 register int *addrl;
185 register int n;
186 int yk, xk, ym, xm, dx, dy, xorg, yorg, slw;
187 register int x, y, e;
188 miFillArcRec info;
189 miArcSliceRec slice;
190 int xl, xr, xc;
191 int *addrlt, *addrlb;
192 int nlwidth;
193 int width;
194 int startmask, endmask, nlmiddle;
196 if (pDraw->type == DRAWABLE_WINDOW)
198 addrlt = (int *)
199 (((PixmapPtr)(pDraw->pScreen->devPrivate))->devPrivate.ptr);
200 nlwidth = (int)
201 (((PixmapPtr)(pDraw->pScreen->devPrivate))->devKind) >> 2;
203 else
205 addrlt = (int *)(((PixmapPtr)pDraw)->devPrivate.ptr);
206 nlwidth = (int)(((PixmapPtr)pDraw)->devKind) >> 2;
209 miFillArcSetup(arc, &info);
210 miFillArcSliceSetup(arc, &slice, pGC);
211 MIFILLARCSETUP();
212 xorg += pDraw->x;
213 yorg += pDraw->y;
214 addrlb = addrlt;
215 addrlt += nlwidth * (yorg - y);
216 addrlb += nlwidth * (yorg + y + dy);
217 slice.edge1.x += pDraw->x;
218 slice.edge2.x += pDraw->x;
219 while (y > 0)
221 addrlt += nlwidth;
222 addrlb -= nlwidth;
223 MIFILLARCSTEP(slw);
224 MIARCSLICESTEP(slice.edge1);
225 MIARCSLICESTEP(slice.edge2);
226 if (miFillSliceUpper(slice))
228 MIARCSLICEUPPER(xl, xr, slice, slw);
229 FILLSLICESPANS(slice.flip_top, addrlt);
231 if (miFillSliceLower(slice))
233 MIARCSLICELOWER(xl, xr, slice, slw);
234 FILLSLICESPANS(slice.flip_bot, addrlb);
239 static void
240 xf4bppPolyFillArcSolid
242 register DrawablePtr pDraw,
243 GCPtr pGC,
244 int narcs,
245 xArc *parcs
248 register xArc *arc;
249 register int i;
250 BoxRec box;
251 RegionPtr cclip;
252 #if 0
253 mfbPrivGC *priv;
254 int rop;
256 priv = (mfbPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr;
257 rop = priv->rop;
258 if ((rop == RROP_NOP) || !(pGC->planemask & 1))
259 #else
260 if ( !(pGC->planemask & 0x0F))
261 #endif
262 return;
263 cclip = pGC->pCompositeClip;
264 for (arc = parcs, i = narcs; --i >= 0; arc++)
266 if (miFillArcEmpty(arc))
267 continue;
268 if (miCanFillArc(arc))
270 box.x1 = arc->x + pDraw->x;
271 box.y1 = arc->y + pDraw->y;
272 box.x2 = box.x1 + (int)arc->width + 1;
273 box.y2 = box.y1 + (int)arc->height + 1;
274 if (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN)
276 if ((arc->angle2 >= FULLCIRCLE) ||
277 (arc->angle2 <= -FULLCIRCLE))
278 DO_WM3(pGC,v16FillEllipseSolid(pDraw, arc))
279 else
280 DO_WM3(pGC,v16FillArcSliceSolidCopy(pDraw, pGC, arc))
281 continue;
284 miPolyFillArc(pDraw, pGC, 1, arc);
288 void
289 xf4bppPolyFillArc(pDraw, pGC, narcs, parcs)
290 register DrawablePtr pDraw;
291 GCPtr pGC;
292 int narcs;
293 xArc *parcs;
295 if ( !xf86Screens[pDraw->pScreen->myNum]->vtSema || (pGC->fillStyle != FillSolid) ) {
296 miPolyFillArc(pDraw, pGC, narcs, parcs);
297 } else {
298 xf4bppPolyFillArcSolid(pDraw, pGC, narcs, parcs);