1
/* $XFree86: xc/programs/Xserver/ilbm/ilbmply1rct.c,v 3.0 1996/08/18 01:54:02 dawes Exp $ */
3
* $XConsortium: ilbmply1rct.c,v 1.9 94/04/17 20:28:28 dpw Exp $
5
Copyright (c) 1990 X Consortium
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:
14
The above copyright notice and this permission notice shall be included in
15
all copies or substantial portions of the Software.
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.
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.
28
* Author: Keith Packard, MIT X Consortium
31
/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
32
to use interleaved bitplanes instead of normal bitplanes */
34
#ifdef HAVE_DIX_CONFIG_H
35
#include <dix-config.h>
41
#include "windowstr.h"
42
#include "pixmapstr.h"
43
#include "regionstr.h"
44
#include "scrnintstr.h"
50
#if defined(mips) || defined(sparc)
51
#define GetHighWord(x) (((int)(x)) >> 16)
53
#define GetHighWord(x) (((int)(x)) / 65536)
56
#if IMAGE_BYTE_ORDER == MSBFirst
57
#define intToCoord(i,x,y) (((x) = GetHighWord(i)), ((y) = (int)((short) (i))))
58
#define coordToInt(x,y) (((x) << 16) | (y))
59
#define intToX(i) (GetHighWord(i))
60
#define intToY(i) ((int)((short) i))
62
#define intToCoord(i,x,y) (((x) = (int)((short) (i))), ((y) = GetHighWord(i)))
63
#define coordToInt(x,y) (((y) << 16) | (x))
64
#define intToX(i) ((int)((short) (i)))
65
#define intToY(i) (GetHighWord(i))
69
ilbmFillPolygonSolid (pDrawable, pGC, shape, mode, count, ptsIn)
70
DrawablePtr pDrawable;
77
ilbmPrivGCPtr devPriv;
79
PixelType *addrl, *addr;
82
register int vertex1, vertex2;
87
int *vertex1p, *vertex2p;
97
PixelType mask, bits = ~((PixelType)0);
99
register unsigned char *rrops;
104
register PixelType *pdst;
106
devPriv = (ilbmPrivGC *)(pGC->devPrivates[ilbmGCPrivateIndex].ptr);
108
if (mode == CoordModePrevious || shape != Convex ||
109
REGION_NUM_RECTS(pGC->pCompositeClip) != 1) {
110
miFillPolygon (pDrawable, pGC, shape, mode, count, ptsIn);
113
origin = *((int *) &pDrawable->x);
114
origin -= (origin & 0x8000) << 1;
115
extents = &pGC->pCompositeClip->extents;
116
vertex1 = *((int *) &extents->x1) - origin;
117
vertex2 = *((int *) &extents->x2) - origin - 0x00010001;
121
vertex2p = (int *) ptsIn;
122
endp = vertex2p + count;
125
clip |= (c - vertex1) | (vertex2 - c);
138
if (clip & 0x80008000) {
139
miFillPolygon (pDrawable, pGC, shape, mode, vertex2p - (int *) ptsIn, ptsIn);
143
ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, nlwidth, auxDst, depthDst,
145
rrops = devPriv->rrops;
146
addrl = ilbmScanlineDelta(addrl, y + pDrawable->y, auxDst);
147
origin = intToX(origin);
149
vertex2 = vertex1 = *vertex2p++;
150
if (vertex2p == endp)
151
vertex2p = (int *) ptsIn;
152
#define Setup(c,x,vertex,dx,dy,e,sign,step) {\
153
x = intToX(vertex); \
154
if (dy = intToY(c) - y) { \
155
dx = intToX(c) - x; \
169
step = - (dx / dy); \
178
#define Step(x,dx,dy,e,sign,step) {\
180
if ((e += dx) > 0) { \
186
if (y == intToY(vertex1)) {
188
if (vertex1p == (int *) ptsIn)
191
Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1)
192
} while (y >= intToY(vertex1));
195
Step(x1,dx1,dy1,e1,sign1,step1)
196
h = intToY(vertex1) - y;
198
if (y == intToY(vertex2)) {
201
if (vertex2p == endp)
202
vertex2p = (int *) ptsIn;
203
Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2)
204
} while (y >= intToY(vertex2));
208
Step(x2,dx2,dy2,e2,sign2,step2)
209
if ((c = (intToY(vertex2) - y)) < h)
212
/* fill spans for this segment */
227
if (c + nmiddle < PPW) {
228
mask = SCRRIGHT (bits,c) ^ SCRRIGHT (bits,c+nmiddle);
229
for (pdst = addr, d = 0; d < depthDst; d++, pdst += nlwidth) { /* @@@ NEXT PLANE @@@ */
246
mask = SCRRIGHT(bits, c);
247
for (pdst = addr, d = 0; d < depthDst; d++, pdst += nlwidth) { /* @@@ NEXT PLANE @@@ */
266
mask = ~SCRRIGHT(bits, r & PIM);
268
for (d = 0; d < depthDst; d++, addr += nlwidth) { /* @@@ NEXT PLANE @@@ */
274
Duff (n, *pdst++ = 0;)
279
Duff (n, *pdst++ = ~0;);
284
Duff (n, *pdst++ ^= ~0;);
295
ilbmScanlineInc(addrl, auxDst);
296
Step(x1,dx1,dy1,e1,sign1,step1)
297
Step(x2,dx2,dy2,e2,sign2,step2)
301
ilbmScanlineInc(addrl, auxDst);