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>
56 #include "windowstr.h"
57 #include "regionstr.h"
58 #include "pixmapstr.h"
59 #include "scrnintstr.h"
65 the solid fillers are called for rectangles and window backgrounds.
66 the boxes are already translated.
67 maybe this should always take a pixmap instead of a drawable?
70 iy = ++iy < tileHeight ? iy : 0
71 is equivalent to iy%= tileheight, and saves a division.
76 afbSolidFillArea (pDraw
, nbox
, pbox
, rrops
)
80 register unsigned char *rrops
;
82 int nlwidth
; /* width in longwords of the drawable */
83 int w
; /* width of current box */
84 register int h
; /* height of current box */
85 register PixelType
*p
; /* pointer to bits we're writing */
86 register int nlw
; /* loop version of nlwMiddle */
87 register PixelType startmask
;
88 register PixelType endmask
;
89 /* masks for reggedy bits at either end of line */
90 register int nlwExtra
;
91 /* to get from right of box to left of next span */
92 int nlwMiddle
; /* number of longwords between sides of boxes */
93 PixelType
*pbits
; /* pointer to start of drawable */
100 afbGetPixelWidthSizeDepthAndPointer(pDraw
, nlwidth
, sizeDst
, depthDst
,
104 w
= pbox
->x2
- pbox
->x1
;
105 saveH
= pbox
->y2
- pbox
->y1
;
107 saveP
= afbScanline(pbits
, pbox
->x1
, pbox
->y1
, nlwidth
);
109 if ( ((pbox
->x1
& PIM
) + w
) < PPW
) {
110 for (d
= 0; d
< depthDst
; d
++) {
113 saveP
+= sizeDst
; /* @@@ NEXT PLANE @@@ */
114 maskpartialbits(pbox
->x1
, w
, startmask
);
119 Duff(h
, *p
&= ~startmask
; afbScanlineInc(p
, nlwExtra
));
122 Duff(h
, *p
|= startmask
; afbScanlineInc(p
, nlwExtra
));
125 Duff(h
, *p
^= startmask
; afbScanlineInc(p
, nlwExtra
));
132 maskbits(pbox
->x1
, w
, startmask
, endmask
, nlwMiddle
);
134 for (d
= 0; d
< depthDst
; d
++) {
137 saveP
+= sizeDst
; /* @@@ NEXT PLANE @@@ */
138 nlwExtra
= nlwidth
- nlwMiddle
;
140 if (startmask
&& endmask
) {
150 afbScanlineInc(p
, nlwExtra
);
158 Duff(nlw
, *p
++ = ~0);
160 afbScanlineInc(p
, nlwExtra
);
168 Duff(nlw
, *p
++ ^= ~0);
170 afbScanlineInc(p
, nlwExtra
);
176 } else if (startmask
&& !endmask
) {
185 afbScanlineInc(p
, nlwExtra
);
193 Duff(nlw
, *p
++ = ~0);
194 afbScanlineInc(p
, nlwExtra
);
202 Duff(nlw
, *p
++ ^= ~0);
203 afbScanlineInc(p
, nlwExtra
);
209 } else if (!startmask
&& endmask
) {
216 afbScanlineInc(p
, nlwExtra
);
222 Duff(nlw
, *p
++ = ~0);
224 afbScanlineInc(p
, nlwExtra
);
230 Duff(nlw
, *p
++ ^= ~0);
232 afbScanlineInc(p
, nlwExtra
);
237 } else { /* no ragged bits at either end */
243 afbScanlineInc(p
, nlwExtra
);
249 Duff(nlw
, *p
++ = ~0);
250 afbScanlineInc(p
, nlwExtra
);
256 Duff(nlw
, *p
++ ^= ~0);
257 afbScanlineInc(p
, nlwExtra
);
264 } /* for (d = 0 ... ) */
270 /* stipple a list of boxes -
272 you can use the reduced rasterop for stipples. if rrop is
273 black, AND the destination with (not stipple pattern). if rrop is
274 white OR the destination with the stipple pattern. if rrop is invert,
275 XOR the destination with the stipple pattern.
280 afbStippleAreaPPW (pDraw
, nbox
, pbox
, pstipple
, rrops
)
285 unsigned char *rrops
;
287 register PixelType
*psrc
;
288 /* pointer to bits in tile, if needed */
289 int tileHeight
; /* height of the tile */
290 register PixelType srcpix
;
292 int nlwidth
; /* width in longwords of the drawable */
293 int w
; /* width of current box */
294 register int nlw
; /* loop version of nlwMiddle */
295 register PixelType
*p
; /* pointer to bits we're writing */
296 register int h
; /* height of current box */
298 PixelType endmask
; /* masks for reggedy bits at either end of line */
299 int nlwMiddle
; /* number of longwords between sides of boxes */
300 int nlwExtra
; /* to get from right of box to left of next span */
305 register int iy
; /* index of current scanline in tile */
306 PixelType
*pbits
; /* pointer to start of drawable */
309 afbGetPixelWidthSizeDepthAndPointer(pDraw
, nlwidth
, sizeDst
, depthDst
,
312 tileHeight
= pstipple
->drawable
.height
;
313 psrc
= (PixelType
*)(pstipple
->devPrivate
.ptr
);
316 w
= pbox
->x2
- pbox
->x1
;
317 saveIy
= pbox
->y1
% tileHeight
;
320 if ( ((pbox
->x1
& PIM
) + w
) < PPW
) {
321 maskpartialbits(pbox
->x1
, w
, startmask
);
323 for (d
= 0; d
< depthDst
; d
++) {
324 p
= afbScanline(pbits
, pbox
->x1
, pbox
->y1
, nlwidth
);
325 pbits
+= sizeDst
; /* @@@ NEXT PLANE @@@ */
327 h
= pbox
->y2
- pbox
->y1
;
333 iy
= ++iy
< tileHeight
? iy
: 0;
334 *p
&= ~(srcpix
& startmask
);
335 afbScanlineInc(p
, nlwExtra
);
341 iy
= ++iy
< tileHeight
? iy
: 0;
342 *p
|= (srcpix
& startmask
);
343 afbScanlineInc(p
, nlwExtra
);
349 iy
= ++iy
< tileHeight
? iy
: 0;
350 *p
^= (srcpix
& startmask
);
351 afbScanlineInc(p
, nlwExtra
);
357 } /* for (d = ...) */
360 maskbits(pbox
->x1
, w
, startmask
, endmask
, nlwMiddle
);
362 for (d
= 0; d
< depthDst
; d
++) {
363 nlwExtra
= nlwidth
- nlwMiddle
;
364 p
= afbScanline(pbits
, pbox
->x1
, pbox
->y1
, nlwidth
);
365 pbits
+= sizeDst
; /* @@@ NEXT PLANE @@@ */
367 h
= pbox
->y2
- pbox
->y1
;
369 if (startmask
&& endmask
) {
375 iy
= ++iy
< tileHeight
? iy
: 0;
377 *p
&= ~(srcpix
& startmask
);
379 Duff (nlw
, *p
++ &= ~srcpix
);
380 *p
&= ~(srcpix
& endmask
);
381 afbScanlineInc(p
, nlwExtra
);
387 iy
= ++iy
< tileHeight
? iy
: 0;
389 *p
|= (srcpix
& startmask
);
391 Duff (nlw
, *p
++ |= srcpix
);
392 *p
|= (srcpix
& endmask
);
393 afbScanlineInc(p
, nlwExtra
);
399 iy
= ++iy
< tileHeight
? iy
: 0;
401 *p
^= (srcpix
& startmask
);
403 Duff (nlw
, *p
++ ^= srcpix
);
404 *p
^= (srcpix
& endmask
);
405 afbScanlineInc(p
, nlwExtra
);
411 } else if (startmask
&& !endmask
) {
417 iy
= ++iy
< tileHeight
? iy
: 0;
419 *p
&= ~(srcpix
& startmask
);
421 Duff(nlw
, *p
++ &= ~srcpix
);
422 afbScanlineInc(p
, nlwExtra
);
428 iy
= ++iy
< tileHeight
? iy
: 0;
430 *p
|= (srcpix
& startmask
);
432 Duff(nlw
, *p
++ |= srcpix
);
433 afbScanlineInc(p
, nlwExtra
);
439 iy
= ++iy
< tileHeight
? iy
: 0;
441 *p
^= (srcpix
& startmask
);
443 Duff(nlw
, *p
++ ^= srcpix
);
444 afbScanlineInc(p
, nlwExtra
);
450 } else if (!startmask
&& endmask
) {
455 iy
= ++iy
< tileHeight
? iy
: 0;
457 Duff(nlw
, *p
++ &= ~srcpix
);
458 *p
&= ~(srcpix
& endmask
);
459 afbScanlineInc(p
, nlwExtra
);
465 iy
= ++iy
< tileHeight
? iy
: 0;
467 Duff(nlw
, *p
++ |= srcpix
);
468 *p
|= (srcpix
& endmask
);
469 afbScanlineInc(p
, nlwExtra
);
475 iy
= ++iy
< tileHeight
? iy
: 0;
477 Duff(nlw
, *p
++ ^= srcpix
);
478 *p
^= (srcpix
& endmask
);
479 afbScanlineInc(p
, nlwExtra
);
485 } else { /* no ragged bits at either end */
490 iy
= ++iy
< tileHeight
? iy
: 0;
492 Duff(nlw
, *p
++ &= ~srcpix
);
493 afbScanlineInc(p
, nlwExtra
);
499 iy
= ++iy
< tileHeight
? iy
: 0;
501 Duff(nlw
, *p
++ |= srcpix
);
502 afbScanlineInc(p
, nlwExtra
);
508 iy
= ++iy
< tileHeight
? iy
: 0;
510 Duff(nlw
, *p
++ ^= srcpix
);
511 afbScanlineInc(p
, nlwExtra
);
516 } /* for (d = ...) */
523 afbStippleArea (pDraw
, nbox
, pbox
, pTile
, xOff
, yOff
, rrops
)
530 unsigned char *rrops
;
532 register PixelType
*psrc
; /* pointer to bits in tile, if needed */
533 int nlwidth
; /* width in longwords of the drawable */
534 register int h
; /* height of current box */
535 register PixelType
*pdst
; /* pointer to bits we're writing */
540 int w
, width
, x
, xSrc
, ySrc
, srcStartOver
, nend
;
541 int tlwidth
, rem
, tileWidth
, tileHeight
, endinc
;
548 PixelType endmask
; /* masks for reggedy bits at either end of line */
549 int nlMiddle
; /* number of longwords between sides of boxes */
551 PixelType
*pBase
; /* pointer to start of drawable */
553 PixelType
*pStartDst
;
554 PixelType
*pStartTile
;
557 afbGetPixelWidthSizeDepthAndPointer(pDraw
, nlwidth
, sizeDst
, depthDst
,
560 tileHeight
= pTile
->drawable
.height
;
561 tileWidth
= pTile
->drawable
.width
;
562 tlwidth
= pTile
->devKind
/ sizeof (PixelType
);
564 xSrc
= pDraw
->x
+ ((xOff
% tileWidth
) - tileWidth
);
565 ySrc
= pDraw
->y
+ ((yOff
% tileHeight
) - tileHeight
);
568 saveW
= pbox
->x2
- pbox
->x1
;
569 iline
= (pbox
->y1
- ySrc
) % tileHeight
;
570 psrcT
= (PixelType
*) pTile
->devPrivate
.ptr
;
571 tileLine
= iline
* tlwidth
;
572 saveH
= pbox
->y2
- pbox
->y1
;
573 saveP
= afbScanline(pBase
, pbox
->x1
, pbox
->y1
, nlwidth
);
575 for (d
= 0; d
< depthDst
; d
++, saveP
+= sizeDst
) { /* @@@ NEXT PLANE @@@ */
578 pStartTile
= psrcT
+ tileLine
;
589 w
= min(tileWidth
, width
);
590 if((rem
= (x
- xSrc
) % tileWidth
) != 0) {
591 /* if we're in the middle of the tile, get
592 as many bits as will finish the span, or
593 as many as will get to the left edge of the tile,
594 or a longword worth, starting at the appropriate
597 w
= min(min(tileWidth
- rem
, width
), BITMAP_SCANLINE_PAD
);
598 endinc
= rem
/ BITMAP_SCANLINE_PAD
;
599 getandputrrop((psrc
+ endinc
), (rem
& PIM
), (x
& PIM
),
601 if((x
& PIM
) + w
>= PPW
)
603 } else if(((x
& PIM
) + w
) < PPW
) {
604 /* doing < PPW bits is easy, and worth special-casing */
605 putbitsrrop(*psrc
, x
& PIM
, w
, pdst
, rop
);
607 /* start at the left edge of the tile,
608 and put down as much as we can
610 maskbits(x
, w
, startmask
, endmask
, nlMiddle
);
613 nstart
= PPW
- (x
& PIM
);
617 nend
= (x
+ w
) & PIM
;
621 srcStartOver
= nstart
> PLST
;
624 putbitsrrop(*psrc
, (x
& PIM
), nstart
, pdst
, rop
);
631 getandputrrop0(psrc
, nstart
, PPW
, pdst
, rop
);
637 getandputrrop0(psrc
, nstart
, nend
, pdst
, rop
);
642 } /* while (width > 0) */
644 pStartDst
+= nlwidth
;
645 if (++iy
>= tileHeight
) {
649 pStartTile
+= tlwidth
;
652 } /* for (d = ... ) */