1
/* $XFree86: xc/programs/Xserver/afb/afbzerarc.c,v 3.2 2001/10/28 03:32:59 tsi Exp $ */
2
/************************************************************
4
Copyright (c) 1989 X Consortium
6
Permission is hereby granted, free of charge, to any person obtaining a copy
7
of this software and associated documentation files (the "Software"), to deal
8
in the Software without restriction, including without limitation the rights
9
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
copies of the Software, and to permit persons to whom the Software is
11
furnished to do so, subject to the following conditions:
13
The above copyright notice and this permission notice shall be included in
14
all copies or substantial portions of the Software.
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
Except as contained in this notice, the name of the X Consortium shall not be
24
used in advertising or otherwise to promote the sale, use or other dealings
25
in this Software without prior written authorization from the X Consortium.
27
********************************************************/
29
/* $XConsortium: afbzerarc.c,v 5.19 94/04/17 20:28:37 dpw Exp $ */
32
* "Algorithm for drawing ellipses or hyperbolae with a digital plotter"
33
* by M. L. V. Pitteway
34
* The Computer Journal, November 1967, Volume 10, Number 3, pp. 282-289
37
#ifdef HAVE_DIX_CONFIG_H
38
#include <dix-config.h>
42
#include <X11/Xprotostr.h>
43
#include "regionstr.h"
45
#include "pixmapstr.h"
46
#include "scrnintstr.h"
53
* Note: LEFTMOST must be the bit leftmost in the actual screen
54
* representation. This depends also on the IMAGE_BYTE_ORDER.
55
* LONG2CHARS() takes care of the re-ordering as required. (DHD)
57
#if (BITMAP_BIT_ORDER == MSBFirst)
58
#define LEFTMOST ((PixelType) LONG2CHARS((1 << PLST)))
60
#define LEFTMOST ((PixelType) LONG2CHARS(1))
63
#define Pixelate(base,yoff,xoff) \
65
paddr = afbScanlineOffset(base, (yoff) + ((xoff)>>PWSH)); \
66
pmask = SCRRIGHT(LEFTMOST, (xoff) & PIM); \
67
for (de = 0; de < depthDst; de++, paddr += sizeDst) /* @@@ NEXT PLANE @@@ */ \
68
switch (rrops[de]) { \
83
#define DoPix(bit,base,yoff,xoff) if (mask & bit) Pixelate(base,yoff,xoff);
86
afbZeroArcSS(pDraw, pGC, arc)
94
register int x, y, a, b, d, mask;
95
register int k1, k3, dx, dy;
97
PixelType *yorgl, *yorgol;
98
int nlwidth, yoffset, dyoffset;
99
int sizeDst, depthDst;
101
register PixelType *paddr;
102
register unsigned char *rrops;
104
rrops = ((afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr))->rrops;
106
afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
108
do360 = miZeroArcSetup(arc, &info, TRUE);
109
yorgl = addrl + ((info.yorg + pDraw->y) * nlwidth);
110
yorgol = addrl + ((info.yorgo + pDraw->y) * nlwidth);
111
info.xorg += pDraw->x;
112
info.xorgo += pDraw->x;
114
yoffset = y ? nlwidth : 0;
116
mask = info.initialMask;
117
if (!(arc->width & 1)) {
118
DoPix(2, yorgl, 0, info.xorgo);
119
DoPix(8, yorgol, 0, info.xorgo);
121
if (!info.end.x || !info.end.y) {
122
mask = info.end.mask;
123
info.end = info.altend;
125
if (do360 && (arc->width == arc->height) && !(arc->width & 1)) {
126
int xoffset = nlwidth;
127
PixelType *yorghl = afbScanlineDeltaNoBankSwitch(yorgl, info.h, nlwidth);
128
int xorghp = info.xorg + info.h;
129
int xorghn = info.xorg - info.h;
132
Pixelate(yorgl, yoffset, info.xorg + x);
133
Pixelate(yorgl, yoffset, info.xorg - x);
134
Pixelate(yorgol, -yoffset, info.xorg - x);
135
Pixelate(yorgol, -yoffset, info.xorg + x);
138
Pixelate(yorghl, -xoffset, xorghp - y);
139
Pixelate(yorghl, -xoffset, xorghn + y);
140
Pixelate(yorghl, xoffset, xorghn + y);
141
Pixelate(yorghl, xoffset, xorghp - y);
143
MIARCCIRCLESTEP(yoffset += nlwidth;);
146
yoffset = info.h * nlwidth;
148
while (y < info.h || x < info.w) {
149
MIARCOCTANTSHIFT(dyoffset = nlwidth;);
150
Pixelate(yorgl, yoffset, info.xorg + x);
151
Pixelate(yorgl, yoffset, info.xorgo - x);
152
Pixelate(yorgol, -yoffset, info.xorgo - x);
153
Pixelate(yorgol, -yoffset, info.xorg + x);
154
MIARCSTEP(yoffset += dyoffset;, yoffset += nlwidth;);
157
while (y < info.h || x < info.w) {
158
MIARCOCTANTSHIFT(dyoffset = nlwidth;);
159
if ((x == info.start.x) || (y == info.start.y)) {
160
mask = info.start.mask;
161
info.start = info.altstart;
163
DoPix(1, yorgl, yoffset, info.xorg + x);
164
DoPix(2, yorgl, yoffset, info.xorgo - x);
165
DoPix(4, yorgol, -yoffset, info.xorgo - x);
166
DoPix(8, yorgol, -yoffset, info.xorg + x);
167
if ((x == info.end.x) || (y == info.end.y)) {
168
mask = info.end.mask;
169
info.end = info.altend;
171
MIARCSTEP(yoffset += dyoffset;, yoffset += nlwidth;);
174
if ((x == info.start.x) || (y == info.start.y))
175
mask = info.start.mask;
176
DoPix(1, yorgl, yoffset, info.xorg + x);
177
DoPix(4, yorgol, -yoffset, info.xorgo - x);
178
if (arc->height & 1) {
179
DoPix(2, yorgl, yoffset, info.xorgo - x);
180
DoPix(8, yorgol, -yoffset, info.xorg + x);
185
afbZeroPolyArcSS(pDraw, pGC, narcs, parcs)
196
cclip = pGC->pCompositeClip;
197
for (arc = parcs, i = narcs; --i >= 0; arc++) {
198
if (miCanZeroArc(arc)) {
199
box.x1 = arc->x + pDraw->x;
200
box.y1 = arc->y + pDraw->y;
201
box.x2 = box.x1 + (int)arc->width + 1;
202
box.y2 = box.y1 + (int)arc->height + 1;
203
if (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN)
204
afbZeroArcSS(pDraw, pGC, arc);
206
miZeroPolyArc(pDraw, pGC, 1, arc);
208
miPolyArc(pDraw, pGC, 1, arc);