Initial commit
[xorg_rtime.git] / xorg-server-1.4 / hw / xfree86 / xf4bpp / mfbzerarc.c
blobc7a8c4d560defba927cef3520fcf116ae7bac3c9
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 ********************************************************/
27 /* GJA -- Took mfb code and modified it. */
29 /* Derived from:
30 * "Algorithm for drawing ellipses or hyperbolae with a digital plotter"
31 * by M. L. V. Pitteway
32 * The Computer Journal, November 1967, Volume 10, Number 3, pp. 282-289
35 #ifdef HAVE_XORG_CONFIG_H
36 #include <xorg-config.h>
37 #endif
39 #include "xf4bpp.h"
40 #include "OScompiler.h"
41 #include "mfbmap.h"
42 #include "mfb.h"
43 #include "maskbits.h"
44 #include "mi.h"
45 #include "mizerarc.h"
46 #include "wm3.h"
48 #include "xf86str.h" /* for pScrn->vtSema */
49 extern ScrnInfoPtr *xf86Screens;
52 * Note, LEFTMOST must be the bit leftmost in the actual screen
53 * representation. This depends on both BITMAP_BIT_ORDER and
54 * IMAGE_BYTE_ORDER
55 * DHD 10/92
58 #if (BITMAP_BIT_ORDER == MSBFirst)
59 #if (IMAGE_BYTE_ORDER == MSBFirst)
60 #define LEFTMOST ((unsigned int) 0x80000000)
61 #else
62 #define LEFTMOST ((unsigned int) 0x80)
63 #endif
64 #else
65 #if (IMAGE_BYTE_ORDER == LSBFirst)
66 #define LEFTMOST ((unsigned int) 1)
67 #else
68 #define LEFTMOST ((unsigned int) 0x1000000)
69 #endif
70 #endif
72 #define PixelateWhite(addr,off) \
73 { \
74 register int *tmpaddr = &((addr)[(off)>>PWSH]); \
75 UPDRW(tmpaddr,SCRRIGHT (LEFTMOST, ((off) & PIM))); \
77 #define PixelateBlack(addr,off) \
78 { \
79 register int *tmpaddr = &((addr)[(off)>>PWSH]); \
80 UPDRW(tmpaddr,~(SCRRIGHT (LEFTMOST, ((off) & PIM)))); \
83 #define Pixelate(base,off) \
84 { \
85 paddr = base + ((off)>>PWSH); \
86 pmask = SCRRIGHT(LEFTMOST, (off) & PIM); \
87 UPDRW(paddr,(pixel & pmask)); \
90 #define DoPix(bit,base,off) if (msk & bit) Pixelate(base,off);
92 static void
93 v16ZeroArcSS
95 DrawablePtr pDraw,
96 GCPtr pGC,
97 xArc *arc
100 miZeroArcRec info;
101 Bool do360;
102 register int x, y, a, b, d, msk;
103 register int k1, k3, dx, dy;
104 int *addrl;
105 int *yorgl, *yorgol;
106 unsigned long pixel;
107 int nlwidth, yoffset, dyoffset;
108 int pmask;
109 register int *paddr;
111 if (((mfbPrivGC *)(pGC->devPrivates[mfbGetGCPrivateIndex()].ptr))->rop ==
112 RROP_BLACK)
113 pixel = 0;
114 else
115 pixel = ~0UL;
117 if (pDraw->type == DRAWABLE_WINDOW)
119 addrl = (int *)
120 (((PixmapPtr)(pDraw->pScreen->devPrivate))->devPrivate.ptr);
121 nlwidth = (int)
122 (((PixmapPtr)(pDraw->pScreen->devPrivate))->devKind) >> 2;
124 else
126 addrl = (int *)(((PixmapPtr)pDraw)->devPrivate.ptr);
127 nlwidth = (int)(((PixmapPtr)pDraw)->devKind) >> 2;
130 do360 = miZeroArcSetup(arc, &info, TRUE);
131 yorgl = addrl + ((info.yorg + pDraw->y) * nlwidth);
132 yorgol = addrl + ((info.yorgo + pDraw->y) * nlwidth);
133 info.xorg += pDraw->x;
134 info.xorgo += pDraw->x;
135 MIARCSETUP();
136 yoffset = y ? nlwidth : 0;
137 dyoffset = 0;
138 msk = info.initialMask;
139 if (!(arc->width & 1))
141 DoPix(2, yorgl, info.xorgo);
142 DoPix(8, yorgol, info.xorgo);
144 if (!info.end.x || !info.end.y)
146 msk = info.end.mask;
147 info.end = info.altend;
149 if (do360 && (arc->width == arc->height) && !(arc->width & 1))
151 int xoffset = nlwidth;
152 int *yorghl = yorgl + (info.h * nlwidth);
153 int xorghp = info.xorg + info.h;
154 int xorghn = info.xorg - info.h;
156 while (1)
158 PixelateWhite(yorgl + yoffset, info.xorg + x);
159 PixelateWhite(yorgl + yoffset, info.xorg - x);
160 PixelateWhite(yorgol- yoffset, info.xorg - x);
161 PixelateWhite(yorgol - yoffset, info.xorg + x);
162 if (a < 0)
163 break;
164 PixelateWhite(yorghl - xoffset, xorghp - y);
165 PixelateWhite(yorghl - xoffset, xorghn + y);
166 PixelateWhite(yorghl + xoffset, xorghn + y);
167 PixelateWhite(yorghl + xoffset, xorghp - y);
168 xoffset += nlwidth;
169 MIARCCIRCLESTEP(yoffset += nlwidth;);
171 x = info.w;
172 yoffset = info.h * nlwidth;
174 else if (do360)
176 while (y < info.h || x < info.w)
178 MIARCOCTANTSHIFT(dyoffset = nlwidth;);
179 Pixelate(yorgl + yoffset, info.xorg + x);
180 Pixelate(yorgl + yoffset, info.xorgo - x);
181 Pixelate(yorgol - yoffset, info.xorgo - x);
182 Pixelate(yorgol - yoffset, info.xorg + x);
183 MIARCSTEP(yoffset += dyoffset;, yoffset += nlwidth;);
186 else
188 while (y < info.h || x < info.w)
190 MIARCOCTANTSHIFT(dyoffset = nlwidth;);
191 if ((x == info.start.x) || (y == info.start.y))
193 msk = info.start.mask;
194 info.start = info.altstart;
196 DoPix(1, yorgl + yoffset, info.xorg + x);
197 DoPix(2, yorgl + yoffset, info.xorgo - x);
198 DoPix(4, yorgol - yoffset, info.xorgo - x);
199 DoPix(8, yorgol - yoffset, info.xorg + x);
200 if ((x == info.end.x) || (y == info.end.y))
202 msk = info.end.mask;
203 info.end = info.altend;
205 MIARCSTEP(yoffset += dyoffset;, yoffset += nlwidth;);
208 if ((x == info.start.x) || (y == info.start.y))
209 msk = info.start.mask;
210 DoPix(1, yorgl + yoffset, info.xorg + x);
211 DoPix(4, yorgol - yoffset, info.xorgo - x);
212 if (arc->height & 1)
214 DoPix(2, yorgl + yoffset, info.xorgo - x);
215 DoPix(8, yorgol - yoffset, info.xorg + x);
219 static void
220 xf4bppZeroPolyArcSS
222 DrawablePtr pDraw,
223 GCPtr pGC,
224 int narcs,
225 xArc *parcs
228 register xArc *arc;
229 register int i;
230 BoxRec box;
231 RegionPtr cclip;
233 if (!pGC->planemask & 0x0F)
234 return;
235 cclip = pGC->pCompositeClip;
236 for (arc = parcs, i = narcs; --i >= 0; arc++)
238 if (miCanZeroArc(arc))
240 box.x1 = arc->x + pDraw->x;
241 box.y1 = arc->y + pDraw->y;
242 box.x2 = box.x1 + (int)arc->width + 1;
243 box.y2 = box.y1 + (int)arc->height + 1;
244 if (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN)
245 v16ZeroArcSS(pDraw, pGC, arc);
246 else
247 miZeroPolyArc(pDraw, pGC, 1, arc);
249 else
250 miPolyArc(pDraw, pGC, 1, arc);
254 void
255 xf4bppZeroPolyArc(pDraw, pGC, narcs, parcs)
256 DrawablePtr pDraw;
257 GCPtr pGC;
258 int narcs;
259 xArc *parcs;
261 if ( !xf86Screens[pDraw->pScreen->myNum]->vtSema ) {
262 miZeroPolyArc(pDraw, pGC, narcs, parcs);
263 } else {
264 DO_WM3(pGC,xf4bppZeroPolyArcSS(pDraw, pGC, narcs, parcs));