~ubuntu-branches/ubuntu/edgy/xorg-server/edgy-updates

« back to all changes in this revision

Viewing changes to iplan2p4/iplply1rct.c

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Parra Novo
  • Date: 2006-07-25 20:06:28 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060725200628-gjmmd9gxfxdc4ejs
Tags: 1:1.1.1-0ubuntu1
* New Upstream version
* Changed Build-Depends from mesa-swrast-source to mesa-swx11-source,
  following Debian package nomenclature
* Re-did 12_security_policy_in_etc.diff for 1.1.1
* Dropped 15_security_allocate_local.diff (applied upstream)
* Dropped 16_SECURITY_setuid.diff (applied upstream)
* Dropped 000_ubuntu_fix_read_kernel_mapping.patch (applied upstream)
* Dropped 002_ubuntu_fix_for_certain_intel_chipsets.patch (applied upstream)
* Updated versioned Build-Depends on mesa-swx11-source to version
  6.5.0.cvs.20060725-0ubuntu1
* Added arrayobj.c, arrayobj.h, bitset.h & rbadaptors.h to
  GL/symlink-mesa.sh (linked from mesa-swx11-source)
* Added arrayobj.c to default build target on GL/mesa/main

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $XFree86: xc/programs/Xserver/iplan2p4/iplply1rct.c,v 3.0 1996/08/18 01:55:00 dawes Exp $ */
2
 
/*
3
 
 * $XConsortium: iplply1rct.c,v 1.14 94/04/17 20:28:56 dpw Exp $
4
 
 *
5
 
Copyright (c) 1990  X Consortium
6
 
 
7
 
Permission is hereby granted, free of charge, to any person obtaining a copy
8
 
of this software and associated documentation files (the "Software"), to deal
9
 
in the Software without restriction, including without limitation the rights
10
 
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
 
copies of the Software, and to permit persons to whom the Software is
12
 
furnished to do so, subject to the following conditions:
13
 
 
14
 
The above copyright notice and this permission notice shall be included in
15
 
all copies or substantial portions of the Software.
16
 
 
17
 
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
 
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
 
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
20
 
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21
 
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22
 
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
 
 
24
 
Except as contained in this notice, the name of the X Consortium shall not be
25
 
used in advertising or otherwise to promote the sale, use or other dealings
26
 
in this Software without prior written authorization from the X Consortium.
27
 
 *
28
 
 * Author:  Keith Packard, MIT X Consortium
29
 
 */
30
 
 
31
 
/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
32
 
interleaved planes */
33
 
 
34
 
#ifdef HAVE_DIX_CONFIG_H
35
 
#include <dix-config.h>
36
 
#endif
37
 
 
38
 
#include <X11/X.h>
39
 
 
40
 
#include "gcstruct.h"
41
 
#include "windowstr.h"
42
 
#include "pixmapstr.h"
43
 
#include "regionstr.h"
44
 
#include "scrnintstr.h"
45
 
#include "mistruct.h"
46
 
 
47
 
#include "ipl.h"
48
 
#include "iplrrop.h"
49
 
 
50
 
#include "iplmskbits.h"
51
 
 
52
 
void
53
 
INTER_RROP_NAME(iplFillPoly1Rect) (pDrawable, pGC, shape, mode, count, ptsIn)
54
 
    DrawablePtr pDrawable;
55
 
    GCPtr       pGC;
56
 
    int         count;
57
 
    DDXPointPtr ptsIn;
58
 
{
59
 
    iplPrivGCPtr    devPriv;
60
 
    int             ngwidth;
61
 
    unsigned short  *addrl, *addr;
62
 
    int             maxy;
63
 
    int             origin;
64
 
    register int    vertex1, vertex2;
65
 
    int             c;
66
 
    BoxPtr          extents;
67
 
    int             clip;
68
 
    int             y;
69
 
    int             *vertex1p, *vertex2p;
70
 
    int             *endp;
71
 
    int             x1, x2;
72
 
    int             dx1, dx2;
73
 
    int             dy1, dy2;
74
 
    int             e1, e2;
75
 
    int             step1, step2;
76
 
    int             sign1, sign2;
77
 
    int             h;
78
 
    int             l, r;
79
 
    INTER_DECLAREG(mask); 
80
 
    INTER_DECLAREG(bits);
81
 
    int             nmiddle;
82
 
    INTER_RROP_DECLARE
83
 
    bits=~0;
84
 
 
85
 
    if (mode == CoordModePrevious)
86
 
    {
87
 
        miFillPolygon (pDrawable, pGC, shape, mode, count, ptsIn);
88
 
        return;
89
 
    }
90
 
    
91
 
    devPriv = iplGetGCPrivate(pGC);
92
 
#ifdef NO_ONE_RECT
93
 
    if (REGION_NUM_RECTS(pGC->pCompositeClip) != 1)
94
 
    {
95
 
        miFillPolygon (pDrawable, pGC, shape, mode, count, ptsIn);
96
 
        return;
97
 
    }
98
 
#endif
99
 
    origin = *((int *) &pDrawable->x);
100
 
    origin -= (origin & 0x8000) << 1;
101
 
    extents = &pGC->pCompositeClip->extents;
102
 
    INTER_RROP_FETCH_GCPRIV(devPriv);
103
 
    vertex1 = *((int *) &extents->x1) - origin;
104
 
    vertex2 = *((int *) &extents->x2) - origin - 0x00010001;
105
 
    clip = 0;
106
 
    y = 32767;
107
 
    maxy = 0;
108
 
    vertex2p = (int *) ptsIn;
109
 
    endp = vertex2p + count;
110
 
    if (shape == Convex)
111
 
    {
112
 
        while (count--)
113
 
        {
114
 
            c = *vertex2p;
115
 
            clip |= (c - vertex1) | (vertex2 - c);
116
 
            c = intToY(c);
117
 
            if (c < y) 
118
 
            {
119
 
                y = c;
120
 
                vertex1p = vertex2p;
121
 
            }
122
 
            vertex2p++;
123
 
            if (c > maxy)
124
 
                maxy = c;
125
 
        }
126
 
    }
127
 
    else
128
 
    {
129
 
        int yFlip = 0;
130
 
        dx1 = 1;
131
 
        x2 = -1;
132
 
        x1 = -1;
133
 
        while (count--)
134
 
        {
135
 
            c = *vertex2p;
136
 
            clip |= (c - vertex1) | (vertex2 - c);
137
 
            c = intToY(c);
138
 
            if (c < y) 
139
 
            {
140
 
                y = c;
141
 
                vertex1p = vertex2p;
142
 
            }
143
 
            vertex2p++;
144
 
            if (c > maxy)
145
 
                maxy = c;
146
 
            if (c == x1)
147
 
                continue;
148
 
            if (dx1 > 0)
149
 
            {
150
 
                if (x2 < 0)
151
 
                    x2 = c;
152
 
                else
153
 
                    dx2 = dx1 = (c - x1) >> 31;
154
 
            }
155
 
            else
156
 
                if ((c - x1) >> 31 != dx1) 
157
 
                {
158
 
                    dx1 = ~dx1;
159
 
                    yFlip++;
160
 
                }
161
 
            x1 = c;
162
 
        }
163
 
        x1 = (x2 - c) >> 31;
164
 
        if (x1 != dx1)
165
 
            yFlip++;
166
 
        if (x1 != dx2)
167
 
            yFlip++;
168
 
        if (yFlip != 2) 
169
 
            clip = 0x8000;
170
 
    }
171
 
    if (y == maxy)
172
 
        return;
173
 
 
174
 
    if (clip & 0x80008000)
175
 
    {
176
 
        miFillPolygon (pDrawable, pGC, shape, mode, vertex2p - (int *) ptsIn, ptsIn);
177
 
        return;
178
 
    }
179
 
 
180
 
#define AddrYPlus(a,y)  ((a) + (y) * ngwidth)
181
 
 
182
 
    iplGetGroupWidthAndPointer(pDrawable, ngwidth, addrl);
183
 
    addrl = AddrYPlus(addrl,y + pDrawable->y);
184
 
    origin = intToX(origin);
185
 
    vertex2p = vertex1p;
186
 
    vertex2 = vertex1 = *vertex2p++;
187
 
    if (vertex2p == endp)
188
 
        vertex2p = (int *) ptsIn;
189
 
#define Setup(c,x,vertex,dx,dy,e,sign,step) {\
190
 
    x = intToX(vertex); \
191
 
    if (dy = intToY(c) - y) { \
192
 
        dx = intToX(c) - x; \
193
 
        step = 0; \
194
 
        if (dx >= 0) \
195
 
        { \
196
 
            e = 0; \
197
 
            sign = 1; \
198
 
            if (dx >= dy) {\
199
 
                step = dx / dy; \
200
 
                dx = dx % dy; \
201
 
            } \
202
 
        } \
203
 
        else \
204
 
        { \
205
 
            e = 1 - dy; \
206
 
            sign = -1; \
207
 
            dx = -dx; \
208
 
            if (dx >= dy) { \
209
 
                step = - (dx / dy); \
210
 
                dx = dx % dy; \
211
 
            } \
212
 
        } \
213
 
    } \
214
 
    x += origin; \
215
 
    vertex = c; \
216
 
}
217
 
 
218
 
#define Step(x,dx,dy,e,sign,step) {\
219
 
    x += step; \
220
 
    if ((e += dx) > 0) \
221
 
    { \
222
 
        x += sign; \
223
 
        e -= dy; \
224
 
    } \
225
 
}
226
 
    for (;;)
227
 
    {
228
 
        if (y == intToY(vertex1))
229
 
        {
230
 
            do
231
 
            {
232
 
                if (vertex1p == (int *) ptsIn)
233
 
                    vertex1p = endp;
234
 
                c = *--vertex1p;
235
 
                Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1)
236
 
            } while (y >= intToY(vertex1));
237
 
            h = dy1;
238
 
        }
239
 
        else
240
 
        {
241
 
            Step(x1,dx1,dy1,e1,sign1,step1)
242
 
            h = intToY(vertex1) - y;
243
 
        }
244
 
        if (y == intToY(vertex2))
245
 
        {
246
 
            do
247
 
            {
248
 
                c = *vertex2p++;
249
 
                if (vertex2p == endp)
250
 
                    vertex2p = (int *) ptsIn;
251
 
                Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2)
252
 
            } while (y >= intToY(vertex2));
253
 
            if (dy2 < h)
254
 
                h = dy2;
255
 
        }
256
 
        else
257
 
        {
258
 
            Step(x2,dx2,dy2,e2,sign2,step2)
259
 
            if ((c = (intToY(vertex2) - y)) < h)
260
 
                h = c;
261
 
        }
262
 
        /* fill spans for this segment */
263
 
        y += h;
264
 
        for (;;)
265
 
        {
266
 
            l = x1;
267
 
            r = x2;
268
 
            nmiddle = x2 - x1;
269
 
            if (nmiddle < 0)
270
 
            {
271
 
                nmiddle = -nmiddle;
272
 
                l = x2;
273
 
                r = x1;
274
 
            }
275
 
            c = l & INTER_PIM;
276
 
            l -= c;
277
 
 
278
 
            addr = addrl + (l >> INTER_PGSH) * INTER_PLANES;
279
 
            if (c + nmiddle < INTER_PPG)
280
 
            {
281
 
                mask = (bits >> c) ^ (bits >> (c+nmiddle));
282
 
                INTER_RROP_SOLID_MASK(addr,mask);
283
 
            }
284
 
            else
285
 
            {
286
 
                if (c)
287
 
                {
288
 
                    mask = bits >> c;
289
 
                    INTER_RROP_SOLID_MASK(addr,mask);
290
 
                    nmiddle += c - INTER_PPG;
291
 
                    INTER_NEXT_GROUP(addr);
292
 
                }
293
 
                nmiddle >>= INTER_PGSH;
294
 
                while (--nmiddle >= 0) {
295
 
                    INTER_RROP_SOLID(addr); INTER_NEXT_GROUP(addr);
296
 
                }
297
 
                if (mask = ~(bits >> (r & INTER_PIM)))
298
 
                    INTER_RROP_SOLID_MASK(addr,mask);
299
 
            }
300
 
            if (!--h)
301
 
                break;
302
 
            addrl = AddrYPlus (addrl, 1);
303
 
            Step(x1,dx1,dy1,e1,sign1,step1)
304
 
            Step(x2,dx2,dy2,e2,sign2,step2)
305
 
        }
306
 
        if (y == maxy)
307
 
            break;
308
 
        addrl = AddrYPlus (addrl, 1);
309
 
    }
310
 
}