1 /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
2 /***********************************************************
4 Copyright 1987, 1998 The Open Group
6 Permission to use, copy, modify, distribute, and sell this software and its
7 documentation for any purpose is hereby granted without fee, provided that
8 the above copyright notice appear in all copies and that both that
9 copyright notice and this permission notice appear in supporting
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 Except as contained in this notice, the name of The Open Group shall not be
23 used in advertising or otherwise to promote the sale, use or other dealings
24 in this Software without prior written authorization from The Open Group.
27 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
31 Permission to use, copy, modify, and distribute this software and its
32 documentation for any purpose and without fee is hereby granted,
33 provided that the above copyright notice appear in all copies and that
34 both that copyright notice and this permission notice appear in
35 supporting documentation, and that the name of Digital not be
36 used in advertising or publicity pertaining to distribution of the
37 software without specific, written prior permission.
39 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
42 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
47 ******************************************************************/
49 #ifdef HAVE_DIX_CONFIG_H
50 #include <dix-config.h>
57 #include "regionstr.h"
59 #include "windowstr.h"
60 #include "pixmapstr.h"
61 #include "scrnintstr.h"
69 /* mfbSetScanline -- copies the bits from psrc to the drawable starting at
70 * (xStart, y) and continuing to (xEnd, y). xOrigin tells us where psrc
71 * starts on the scanline. (I.e., if this scanline passes through multiple
72 * boxes, we may not want to start grabbing bits at psrc but at some offset
76 mfbSetScanline(y
, xOrigin
, xStart
, xEnd
, psrc
, alu
, pdstBase
, widthDst
)
78 int xOrigin
; /* where this scanline starts */
79 int xStart
; /* first bit to use from scanline */
80 int xEnd
; /* last bit to use from scanline + 1 */
81 register PixelType
*psrc
;
82 register int alu
; /* raster op */
83 PixelType
*pdstBase
; /* start of the drawable */
84 int widthDst
; /* width of drawable in words */
86 int w
; /* width of scanline in bits */
87 register PixelType
*pdst
; /* where to put the bits */
88 register PixelType tmpSrc
; /* scratch buffer to collect bits in */
89 int dstBit
; /* offset in bits from beginning of
91 register int nstart
; /* number of bits from first partial */
92 register int nend
; /* " " last partial word */
94 PixelType startmask
, endmask
;
97 pdst
= mfbScanline(pdstBase
, xStart
, y
, widthDst
);
98 psrc
+= (xStart
- xOrigin
) >> PWSH
;
99 offSrc
= (xStart
- xOrigin
) & PIM
;
101 dstBit
= xStart
& PIM
;
103 if (dstBit
+ w
<= PPW
)
105 getandputrop(psrc
, offSrc
, dstBit
, w
, pdst
, alu
)
110 maskbits(xStart
, w
, startmask
, endmask
, nlMiddle
);
112 nstart
= PPW
- dstBit
;
121 getandputrop(psrc
, offSrc
, dstBit
, nstart
, pdst
, alu
)
133 getbits(psrc
, offSrc
, PPW
, tmpSrc
);
134 DoRop(*pdst
, alu
, tmpSrc
, *pdst
);
140 getandputrop0(psrc
, offSrc
, nend
, pdst
, alu
);
148 /* SetSpans -- for each span copy pwidth[i] bits from psrc to pDrawable at
149 * ppt[i] using the raster op from the GC. If fSorted is TRUE, the scanlines
150 * are in increasing Y order.
151 * Source bit lines are server scanline padded so that they always begin
152 * on a word boundary.
155 mfbSetSpans(pDrawable
, pGC
, pcharsrc
, ppt
, pwidth
, nspans
, fSorted
)
156 DrawablePtr pDrawable
;
159 register DDXPointPtr ppt
;
164 PixelType
*psrc
= (PixelType
*)(pointer
)pcharsrc
;
165 PixelType
*pdstBase
; /* start of dst bitmap */
166 int widthDst
; /* width of bitmap in words */
167 register BoxPtr pbox
, pboxLast
, pboxTest
;
168 register DDXPointPtr pptLast
;
175 prgnDst
= pGC
->pCompositeClip
;
177 pptLast
= ppt
+ nspans
;
179 yMax
= pDrawable
->y
+ (int) pDrawable
->height
;
180 mfbGetPixelWidthAndPointer(pDrawable
, widthDst
, pdstBase
);
182 pbox
= REGION_RECTS(prgnDst
);
183 pboxLast
= pbox
+ REGION_NUM_RECTS(prgnDst
);
187 /* scan lines sorted in ascending order. Because they are sorted, we
188 * don't have to check each scanline against each clip box. We can be
189 * sure that this scanline only has to be clipped to boxes at or after the
190 * beginning of this y-band
198 while(pbox
< pboxLast
)
200 if(pbox
->y1
> ppt
->y
)
202 /* scanline is before clip box */
205 else if(pbox
->y2
<= ppt
->y
)
207 /* clip box is before scanline */
211 else if(pbox
->x1
> ppt
->x
+ *pwidth
)
213 /* clip box is to right of scanline */
216 else if(pbox
->x2
<= ppt
->x
)
218 /* scanline is to right of clip box */
223 /* at least some of the scanline is in the current clip box */
224 xStart
= max(pbox
->x1
, ppt
->x
);
225 xEnd
= min(ppt
->x
+ *pwidth
, pbox
->x2
);
226 mfbSetScanline(ppt
->y
, ppt
->x
, xStart
, xEnd
, psrc
, alu
,
228 if(ppt
->x
+ *pwidth
<= pbox
->x2
)
230 /* End of the line, as it were */
236 /* We've tried this line against every box; it must be outside them
237 * all. move on to the next point */
239 psrc
+= PixmapWidthInPadUnits(*pwidth
, 1);
245 /* scan lines not sorted. We must clip each line against all the boxes */
248 if(ppt
->y
>= 0 && ppt
->y
< yMax
)
251 for(pbox
= REGION_RECTS(prgnDst
); pbox
< pboxLast
; pbox
++)
253 if(pbox
->y1
> ppt
->y
)
255 /* rest of clip region is above this scanline,
259 if(pbox
->y2
<= ppt
->y
)
261 /* clip box is below scanline */
265 if(pbox
->x1
<= ppt
->x
+ *pwidth
&&
268 xStart
= max(pbox
->x1
, ppt
->x
);
269 xEnd
= min(pbox
->x2
, ppt
->x
+ *pwidth
);
270 mfbSetScanline(ppt
->y
, ppt
->x
, xStart
, xEnd
,
271 psrc
, alu
, pdstBase
, widthDst
);
276 psrc
+= PixmapWidthInPadUnits(*pwidth
, 1);