~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to afb/afbzerarc.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
ImportĀ upstreamĀ versionĀ 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $XFree86: xc/programs/Xserver/afb/afbzerarc.c,v 3.2 2001/10/28 03:32:59 tsi Exp $ */
 
2
/************************************************************
 
3
 
 
4
Copyright (c) 1989  X Consortium
 
5
 
 
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:
 
12
 
 
13
The above copyright notice and this permission notice shall be included in
 
14
all copies or substantial portions of the Software.
 
15
 
 
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.
 
22
 
 
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.
 
26
 
 
27
********************************************************/
 
28
 
 
29
/* $XConsortium: afbzerarc.c,v 5.19 94/04/17 20:28:37 dpw Exp $ */
 
30
 
 
31
/* Derived from:
 
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
 
35
 */
 
36
 
 
37
#ifdef HAVE_DIX_CONFIG_H
 
38
#include <dix-config.h>
 
39
#endif
 
40
 
 
41
#include <X11/X.h>
 
42
#include <X11/Xprotostr.h>
 
43
#include "regionstr.h"
 
44
#include "gcstruct.h"
 
45
#include "pixmapstr.h"
 
46
#include "scrnintstr.h"
 
47
#include "afb.h"
 
48
#include "maskbits.h"
 
49
#include "mizerarc.h"
 
50
#include "mi.h"
 
51
 
 
52
/*
 
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)
 
56
 */
 
57
#if (BITMAP_BIT_ORDER == MSBFirst)
 
58
#define LEFTMOST                ((PixelType) LONG2CHARS((1 << PLST)))
 
59
#else
 
60
#define LEFTMOST                ((PixelType) LONG2CHARS(1))
 
61
#endif
 
62
 
 
63
#define Pixelate(base,yoff,xoff) \
 
64
{ \
 
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]) { \
 
69
                        case RROP_BLACK: \
 
70
                                *paddr &= ~pmask; \
 
71
                                break; \
 
72
                        case RROP_WHITE: \
 
73
                                *paddr |= pmask; \
 
74
                                break; \
 
75
                        case RROP_INVERT: \
 
76
                                *paddr ^= pmask; \
 
77
                                break; \
 
78
                        case RROP_NOP: \
 
79
                                break; \
 
80
                } \
 
81
}
 
82
 
 
83
#define DoPix(bit,base,yoff,xoff) if (mask & bit) Pixelate(base,yoff,xoff);
 
84
 
 
85
static void
 
86
afbZeroArcSS(pDraw, pGC, arc)
 
87
        DrawablePtr pDraw;
 
88
        GCPtr pGC;
 
89
        xArc *arc;
 
90
{
 
91
        miZeroArcRec info;
 
92
        Bool do360;
 
93
        register int de;
 
94
        register int x, y, a, b, d, mask;
 
95
        register int k1, k3, dx, dy;
 
96
        PixelType *addrl;
 
97
        PixelType *yorgl, *yorgol;
 
98
        int nlwidth, yoffset, dyoffset;
 
99
        int sizeDst, depthDst;
 
100
        PixelType pmask;
 
101
        register PixelType *paddr;
 
102
        register unsigned char *rrops;
 
103
 
 
104
        rrops = ((afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr))->rrops;
 
105
 
 
106
        afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
 
107
                                                                                                         addrl);
 
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;
 
113
        MIARCSETUP();
 
114
        yoffset = y ? nlwidth : 0;
 
115
        dyoffset = 0;
 
116
        mask = info.initialMask;
 
117
        if (!(arc->width & 1)) {
 
118
                DoPix(2, yorgl, 0, info.xorgo);
 
119
                DoPix(8, yorgol, 0, info.xorgo);
 
120
        }
 
121
        if (!info.end.x || !info.end.y) {
 
122
                mask = info.end.mask;
 
123
                info.end = info.altend;
 
124
        }
 
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;
 
130
 
 
131
                while (1) {
 
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);
 
136
                        if (a < 0)
 
137
                                break;
 
138
                        Pixelate(yorghl, -xoffset, xorghp - y);
 
139
                        Pixelate(yorghl, -xoffset, xorghn + y);
 
140
                        Pixelate(yorghl, xoffset, xorghn + y);
 
141
                        Pixelate(yorghl, xoffset, xorghp - y);
 
142
                        xoffset += nlwidth;
 
143
                        MIARCCIRCLESTEP(yoffset += nlwidth;);
 
144
                }
 
145
                x = info.w;
 
146
                yoffset = info.h * nlwidth;
 
147
        } else if (do360) {
 
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;);
 
155
                }
 
156
        } else {
 
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;
 
162
                        }
 
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;
 
170
                        }
 
171
                        MIARCSTEP(yoffset += dyoffset;, yoffset += nlwidth;);
 
172
                }
 
173
        }
 
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);
 
181
        }
 
182
}
 
183
 
 
184
void
 
185
afbZeroPolyArcSS(pDraw, pGC, narcs, parcs)
 
186
        DrawablePtr             pDraw;
 
187
        GCPtr           pGC;
 
188
        int                             narcs;
 
189
        xArc            *parcs;
 
190
{
 
191
        register xArc *arc;
 
192
        register int i;
 
193
        BoxRec box;
 
194
        RegionPtr cclip;
 
195
 
 
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);
 
205
                        else
 
206
                                miZeroPolyArc(pDraw, pGC, 1, arc);
 
207
                } else
 
208
                        miPolyArc(pDraw, pGC, 1, arc);
 
209
        }
 
210
}