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
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>
34 #include "windowstr.h"
35 #include "pixmapstr.h"
36 #include "regionstr.h"
37 #include "scrnintstr.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); \
52 c1 = *((INT32 *) &pbox->x1) - off; \
53 c2 = *((INT32 *) &pbox->x2) - off - 0x00010001; \
54 for (ppt = (INT32 *) pptInit, i = npt; --i >= 0;) \
57 if (!isClipped(pt,c1,c2)) { \
65 # include "cfbrrop24.h"
69 cfbPolyPoint(pDrawable
, pGC
, mode
, npt
, pptInit
)
70 DrawablePtr pDrawable
;
77 register INT32 c1
, c2
;
78 register CARD32 ClipMask
= 0x80008000;
81 register PixelType
*addrp
;
87 register CfbBits
*addrl
;
95 register PixelType
*p
;
101 register BoxPtr pbox
;
105 cfbPrivGCPtr devPriv
;
108 devPriv
=cfbGetGCPrivate(pGC
);
112 cclip
= pGC
->pCompositeClip
;
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;
125 cfbGetPixelWidthAndPointer(pDrawable
, npwidth
, addrp
);
127 addrp
= addrp
+ pDrawable
->y
* npwidth
;
129 addrp
= addrp
+ pDrawable
->y
* npwidth
+ pDrawable
->x
;
136 if (!(npwidth
& (npwidth
- 1)))
138 npwidth
= ffs(npwidth
) - 1;
141 xtmp
= pDrawable
->x
+ intToX(pt
);
142 p
= addrp
+ (intToY(pt
) << npwidth
) + ((xtmp
* 3) >>2);
143 RROP_SOLID24_COPY(p
, xtmp
))
145 PointLoop(*(addrp
+ (intToY(pt
) << npwidth
) + intToX(pt
)) = xor;)
149 else if (npwidth
== 1152)
152 PointLoop(y
= intToY(pt
); *(addrp
+ (y
<< 10) + (y
<< 7) + intToX(pt
)) = xor;)
159 xtmp
= pDrawable
->x
+ intToX(pt
);
160 p
= addrp
+ intToY(pt
) * npwidth
+ ((xtmp
* 3) >> 2);
161 RROP_SOLID24_COPY(p
, xtmp
))
163 PointLoop(*(addrp
+ intToY(pt
) * npwidth
+ intToX(pt
)) = xor;)
171 RROP_SET_SETUP(xor, and)
173 xtmp
= pDrawable
->x
+ intToX(pt
);
174 p
= addrp
+ intToY(pt
) * npwidth
+ ((xtmp
* 3) >> 2);
175 RROP_SOLID24_SET(p
, xtmp
))
177 PointLoop( addrpt
= addrp
+ intToY(pt
) * npwidth
+ intToX(pt
);
178 *addrpt
= DoRRop (*addrpt
, and, xor);)
181 #else /* !PIXEL_ADDR */
182 cfbGetLongWidthAndPointer(pDrawable
, nlwidth
, addrl
);
183 addrl
= addrl
+ pDrawable
->y
* nlwidth
+ (pDrawable
->x
>> PWSH
);
184 xoffset
= pDrawable
->x
& PIM
;
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
]);
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]);
201 #endif /* PIXEL_ADDR */