Initial commit
[xorg_rtime.git] / xorg-server-1.4 / cfb / cfbpolypnt.c
blob06a768e8df57767616f8d10aebe9f3a56e77c473
1 /************************************************************
3 Copyright 1989, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
9 documentation.
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
25 ********************************************************/
28 #ifdef HAVE_DIX_CONFIG_H
29 #include <dix-config.h>
30 #endif
32 #include <X11/X.h>
33 #include "gcstruct.h"
34 #include "windowstr.h"
35 #include "pixmapstr.h"
36 #include "regionstr.h"
37 #include "scrnintstr.h"
38 #include "cfb.h"
39 #include "cfbmskbits.h"
41 #define isClipped(c,ul,lr) ((((c) - (ul)) | ((lr) - (c))) & ClipMask)
43 /* WARNING: pbox contains two shorts. This code assumes they are packed
44 * and can be referenced together as an INT32.
47 #define PointLoop(fill) { \
48 for (nbox = REGION_NUM_RECTS(cclip), pbox = REGION_RECTS(cclip); \
49 --nbox >= 0; \
50 pbox++) \
51 { \
52 c1 = *((INT32 *) &pbox->x1) - off; \
53 c2 = *((INT32 *) &pbox->x2) - off - 0x00010001; \
54 for (ppt = (INT32 *) pptInit, i = npt; --i >= 0;) \
55 { \
56 pt = *ppt++; \
57 if (!isClipped(pt,c1,c2)) { \
58 fill \
59 } \
60 } \
61 } \
64 #if PSZ == 24
65 # include "cfbrrop24.h"
66 #endif
68 void
69 cfbPolyPoint(pDrawable, pGC, mode, npt, pptInit)
70 DrawablePtr pDrawable;
71 GCPtr pGC;
72 int mode;
73 int npt;
74 xPoint *pptInit;
76 register INT32 pt;
77 register INT32 c1, c2;
78 register CARD32 ClipMask = 0x80008000;
79 register CfbBits xor;
80 #ifdef PIXEL_ADDR
81 register PixelType *addrp;
82 register int npwidth;
83 #if PSZ != 24
84 PixelType *addrpt;
85 #endif
86 #else
87 register CfbBits *addrl;
88 register int nlwidth;
89 register int xoffset;
90 CfbBits *addrlt;
91 #endif
92 #if PSZ == 24
93 RROP_DECLARE
94 register int xtmp;
95 register PixelType *p;
96 #endif
97 register INT32 *ppt;
98 RegionPtr cclip;
99 int nbox;
100 register int i;
101 register BoxPtr pbox;
102 CfbBits and;
103 int rop = pGC->alu;
104 int off;
105 cfbPrivGCPtr devPriv;
106 xPoint *pptPrev;
108 devPriv =cfbGetGCPrivate(pGC);
109 rop = devPriv->rop;
110 if (rop == GXnoop)
111 return;
112 cclip = pGC->pCompositeClip;
113 xor = devPriv->xor;
114 if ((mode == CoordModePrevious) && (npt > 1))
116 for (pptPrev = pptInit + 1, i = npt - 1; --i >= 0; pptPrev++)
118 pptPrev->x += (pptPrev-1)->x;
119 pptPrev->y += (pptPrev-1)->y;
122 off = *((int *) &pDrawable->x);
123 off -= (off & 0x8000) << 1;
124 #ifdef PIXEL_ADDR
125 cfbGetPixelWidthAndPointer(pDrawable, npwidth, addrp);
126 #if PSZ == 24
127 addrp = addrp + pDrawable->y * npwidth;
128 #else
129 addrp = addrp + pDrawable->y * npwidth + pDrawable->x;
130 #endif
131 if (rop == GXcopy)
133 #if PSZ == 24
134 RROP_COPY_SETUP(xor)
135 #endif
136 if (!(npwidth & (npwidth - 1)))
138 npwidth = ffs(npwidth) - 1;
139 #if PSZ == 24
140 PointLoop(
141 xtmp = pDrawable->x + intToX(pt);
142 p = addrp + (intToY(pt) << npwidth) + ((xtmp * 3) >>2);
143 RROP_SOLID24_COPY(p, xtmp))
144 #else
145 PointLoop(*(addrp + (intToY(pt) << npwidth) + intToX(pt)) = xor;)
146 #endif
148 #ifdef sun
149 else if (npwidth == 1152)
151 register int y;
152 PointLoop(y = intToY(pt); *(addrp + (y << 10) + (y << 7) + intToX(pt)) = xor;)
154 #endif
155 else
157 #if PSZ == 24
158 PointLoop(
159 xtmp = pDrawable->x + intToX(pt);
160 p = addrp + intToY(pt) * npwidth + ((xtmp * 3) >> 2);
161 RROP_SOLID24_COPY(p, xtmp))
162 #else
163 PointLoop(*(addrp + intToY(pt) * npwidth + intToX(pt)) = xor;)
164 #endif
167 else
169 and = devPriv->and;
170 #if PSZ == 24
171 RROP_SET_SETUP(xor, and)
172 PointLoop(
173 xtmp = pDrawable->x + intToX(pt);
174 p = addrp + intToY(pt) * npwidth + ((xtmp * 3) >> 2);
175 RROP_SOLID24_SET(p, xtmp))
176 #else
177 PointLoop( addrpt = addrp + intToY(pt) * npwidth + intToX(pt);
178 *addrpt = DoRRop (*addrpt, and, xor);)
179 #endif
181 #else /* !PIXEL_ADDR */
182 cfbGetLongWidthAndPointer(pDrawable, nlwidth, addrl);
183 addrl = addrl + pDrawable->y * nlwidth + (pDrawable->x >> PWSH);
184 xoffset = pDrawable->x & PIM;
185 and = devPriv->and;
186 #if PSZ == 24
187 PointLoop( addrlt = addrl + intToY(pt) * nlwidth
188 + ((intToX(pt) + xoffset) >> PWSH);
189 *addrlt = DoRRop (*addrlt,
190 and | ~cfbmask[(intToX(pt) + xoffset) & PIM],
191 xor & cfbmask[(intToX(pt) + xoffset) & PIM]);
193 #else
194 PointLoop( addrlt = addrl + intToY(pt) * nlwidth
195 + ((intToX(pt) + xoffset) >> PWSH);
196 *addrlt = DoRRop (*addrlt,
197 and | ~cfbmask[((intToX(pt) + xoffset) & 3)<<1],
198 xor & cfbmask[((intToX(pt) + xoffset) & 3)<<1]);
200 #endif
201 #endif /* PIXEL_ADDR */