1 /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
2 /***********************************************************
4 Copyright (c) 1987 X Consortium
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:
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
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.
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.
28 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
32 Permission to use, copy, modify, and distribute this software and its
33 documentation for any purpose and without fee is hereby granted,
34 provided that the above copyright notice appear in all copies and that
35 both that copyright notice and this permission notice appear in
36 supporting documentation, and that the name of Digital not be
37 used in advertising or publicity pertaining to distribution of the
38 software without specific, written prior permission.
40 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
48 ******************************************************************/
50 #ifdef HAVE_DIX_CONFIG_H
51 #include <dix-config.h>
58 #include "regionstr.h"
60 #include "windowstr.h"
61 #include "pixmapstr.h"
62 #include "scrnintstr.h"
70 /* afbSetScanline -- copies the bits from psrc to the drawable starting at
71 * (xStart, y) and continuing to (xEnd, y). xOrigin tells us where psrc
72 * starts on the scanline. (I.e., if this scanline passes through multiple
73 * boxes, we may not want to start grabbing bits at psrc but at some offset
77 afbSetScanline(int y
, int xOrigin
, int xStart
, int xEnd
, PixelType
*psrc
,
78 int alu
, PixelType
*pdstBase
, int widthDst
, int sizeDst
,
79 int depthDst
, int sizeSrc
)
81 int w
; /* width of scanline in bits */
82 register PixelType
*pdst
; /* where to put the bits */
83 register PixelType tmpSrc
; /* scratch buffer to collect bits in */
84 int dstBit
; /* offset in bits from beginning of
86 register int nstart
; /* number of bits from first partial */
87 register int nend
; /* " " last partial word */
89 PixelType startmask
, endmask
;
90 PixelType
*savePsrc
= psrc
+ ((xStart
- xOrigin
) >> PWSH
);
94 for (d
= 0; d
< depthDst
; d
++) {
95 pdst
= afbScanline(pdstBase
, xStart
, y
, widthDst
) + sizeDst
* d
; /* @@@ NEXT PLANE @@@ */
96 psrc
= savePsrc
+ sizeSrc
* d
; /* @@@ NEXT PLANE @@@ */
97 offSrc
= (xStart
- xOrigin
) & PIM
;
99 dstBit
= xStart
& PIM
;
101 if (dstBit
+ w
<= PPW
) {
102 getandputrop(psrc
, offSrc
, dstBit
, w
, pdst
, alu
)
104 maskbits(xStart
, w
, startmask
, endmask
, nlMiddle
);
106 nstart
= PPW
- dstBit
;
114 getandputrop(psrc
, offSrc
, dstBit
, nstart
, pdst
, alu
)
124 getbits(psrc
, offSrc
, PPW
, tmpSrc
);
125 DoRop(*pdst
, alu
, tmpSrc
, *pdst
);
130 getandputrop0(psrc
, offSrc
, nend
, pdst
, alu
);
138 /* SetSpans -- for each span copy pwidth[i] bits from psrc to pDrawable at
139 * ppt[i] using the raster op from the GC. If fSorted is TRUE, the scanlines
140 * are in increasing Y order.
141 * Source bit lines are server scanline padded so that they always begin
142 * on a word boundary.
145 afbSetSpans(pDrawable
, pGC
, pcharsrc
, ppt
, pwidth
, nspans
, fSorted
)
146 DrawablePtr pDrawable
;
149 register DDXPointPtr ppt
;
154 PixelType
*psrc
= (PixelType
*)pcharsrc
;
155 PixelType
*pdstBase
; /* start of dst bitmap */
156 int widthDst
; /* width of bitmap in words */
160 register BoxPtr pbox
, pboxLast
, pboxTest
;
161 register DDXPointPtr pptLast
;
168 prgnDst
= pGC
->pCompositeClip
;
170 pptLast
= ppt
+ nspans
;
172 yMax
= pDrawable
->y
+ (int) pDrawable
->height
;
173 afbGetPixelWidthSizeDepthAndPointer(pDrawable
, widthDst
, sizeDst
, depthDst
,
176 pbox
= REGION_RECTS(prgnDst
);
177 pboxLast
= pbox
+ REGION_NUM_RECTS(prgnDst
);
180 /* scan lines sorted in ascending order. Because they are sorted, we
181 * don't have to check each scanline against each clip box. We can be
182 * sure that this scanline only has to be clipped to boxes at or after the
183 * beginning of this y-band
186 while(ppt
< pptLast
) {
190 while(pbox
< pboxLast
) {
191 if(pbox
->y1
> ppt
->y
) {
192 /* scanline is before clip box */
194 } else if(pbox
->y2
<= ppt
->y
) {
195 /* clip box is before scanline */
198 } else if(pbox
->x1
> ppt
->x
+ *pwidth
) {
199 /* clip box is to right of scanline */
201 } else if(pbox
->x2
<= ppt
->x
) {
202 /* scanline is to right of clip box */
207 /* at least some of the scanline is in the current clip box */
208 xStart
= max(pbox
->x1
, ppt
->x
);
209 xEnd
= min(ppt
->x
+ *pwidth
, pbox
->x2
);
210 sizeSrc
= PixmapWidthInPadUnits(*pwidth
, 1);
211 afbSetScanline(ppt
->y
, ppt
->x
, xStart
, xEnd
, psrc
, alu
, pdstBase
,
212 widthDst
, sizeDst
, depthDst
, sizeSrc
);
213 if(ppt
->x
+ *pwidth
<= pbox
->x2
) {
214 /* End of the line, as it were */
219 /* We've tried this line against every box; it must be outside them
220 * all. move on to the next point */
222 psrc
+= sizeSrc
* depthDst
;
226 /* scan lines not sorted. We must clip each line against all the boxes */
227 while(ppt
< pptLast
) {
228 if(ppt
->y
>= 0 && ppt
->y
< yMax
) {
229 for(pbox
= REGION_RECTS(prgnDst
); pbox
< pboxLast
; pbox
++) {
230 if(pbox
->y1
> ppt
->y
) {
231 /* rest of clip region is above this scanline,
235 if(pbox
->y2
<= ppt
->y
) {
236 /* clip box is below scanline */
240 if(pbox
->x1
<= ppt
->x
+ *pwidth
&&
242 xStart
= max(pbox
->x1
, ppt
->x
);
243 xEnd
= min(pbox
->x2
, ppt
->x
+ *pwidth
);
244 sizeSrc
= PixmapWidthInPadUnits(*pwidth
, 1);
245 afbSetScanline(ppt
->y
, ppt
->x
, xStart
, xEnd
, psrc
, alu
,
246 pdstBase
, widthDst
, sizeDst
, depthDst
,
252 psrc
+= sizeSrc
* depthDst
;