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 ******************************************************************/
49 /* $XConsortium: mfbfillsp.c,v 5.13 94/04/17 20:28:21 dpw Exp $ */
54 #include "pixmapstr.h"
55 #include "scrnintstr.h"
56 #include "windowstr.h"
66 /* scanline filling for monochrome frame buffer
67 written by drewry, oct 1986
69 these routines all clip. they assume that anything that has called
70 them has already translated the points (i.e. pGC->miTranslate is
71 non-zero, which is howit gets set in mfbCreateGC().)
73 the number of new scnalines created by clipping ==
74 MaxRectsPerBand * nSpans.
76 FillSolid is overloaded to be used for OpaqueStipple as well,
77 if fgPixel == bgPixel.
80 FillTiled is overloaded to be used for OpaqueStipple, if
81 fgPixel != bgPixel. based on the fill style, it uses
82 {RotatedPixmap, gc.alu} or {RotatedPixmap, PrivGC.ropOpStip}
87 mfbBlackSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
88 DrawablePtr pDrawable;
90 int nInit; /* number of spans to fill */
91 DDXPointPtr pptInit; /* pointer to list of start points */
92 int *pwidthInit; /* pointer to list of n widths */
95 /* next three parameters are post-clip */
96 int n; /* number of spans to fill */
97 register DDXPointPtr ppt; /* pointer to list of start points */
98 register int *pwidth; /* pointer to list of n widths */
99 PixelType *addrlBase; /* pointer to start of bitmap */
100 int nlwidth; /* width in longwords of bitmap */
101 register PixelType *addrl;/* pointer to current longword in bitmap */
102 register int nlmiddle;
103 register PixelType startmask;
104 register PixelType endmask;
105 int *pwidthFree; /* copies of the pointers to free */
108 if (!(pGC->planemask & 1))
111 n = nInit * miFindMaxBand(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip);
112 pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
113 pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
114 if(!pptFree || !pwidthFree)
116 if (pptFree) DEALLOCATE_LOCAL(pptFree);
117 if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
122 n = miClipSpans(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip,
123 pptInit, pwidthInit, nInit,
124 ppt, pwidth, fSorted);
126 mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrlBase);
130 addrl = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth);
134 if ( ((ppt->x & PIM) + *pwidth) < PPW)
136 /* all bits inside same longword */
137 maskpartialbits(ppt->x, *pwidth, startmask);
138 *addrl &= ~startmask;
142 maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
144 *addrl++ &= ~startmask;
145 Duff (nlmiddle, *addrl++ = 0x0);
153 DEALLOCATE_LOCAL(pptFree);
154 DEALLOCATE_LOCAL(pwidthFree);
160 mfbWhiteSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
161 DrawablePtr pDrawable;
163 int nInit; /* number of spans to fill */
164 DDXPointPtr pptInit; /* pointer to list of start points */
165 int *pwidthInit; /* pointer to list of n widths */
168 /* next three parameters are post-clip */
169 int n; /* number of spans to fill */
170 register DDXPointPtr ppt; /* pointer to list of start points */
171 register int *pwidth; /* pointer to list of n widths */
172 PixelType *addrlBase; /* pointer to start of bitmap */
173 int nlwidth; /* width in longwords of bitmap */
174 register PixelType *addrl;/* pointer to current longword in bitmap */
175 register int nlmiddle;
176 register PixelType startmask;
177 register PixelType endmask;
178 int *pwidthFree; /* copies of the pointers to free */
181 if (!(pGC->planemask & 1))
184 n = nInit * miFindMaxBand(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip);
185 pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
186 pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
187 if(!pptFree || !pwidthFree)
189 if (pptFree) DEALLOCATE_LOCAL(pptFree);
190 if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
195 n = miClipSpans(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip,
196 pptInit, pwidthInit, nInit,
197 ppt, pwidth, fSorted);
199 mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrlBase);
203 addrl = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth);
207 if ( ((ppt->x & PIM) + *pwidth) < PPW)
209 /* all bits inside same longword */
210 maskpartialbits(ppt->x, *pwidth, startmask);
215 maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
217 *addrl++ |= startmask;
218 Duff (nlmiddle, *addrl++ = ~0);
226 DEALLOCATE_LOCAL(pptFree);
227 DEALLOCATE_LOCAL(pwidthFree);
233 mfbInvertSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
234 DrawablePtr pDrawable;
236 int nInit; /* number of spans to fill */
237 DDXPointPtr pptInit; /* pointer to list of start points */
238 int *pwidthInit; /* pointer to list of n widths */
241 /* next three parameters are post-clip */
242 int n; /* number of spans to fill */
243 register DDXPointPtr ppt; /* pointer to list of start points */
244 register int *pwidth; /* pointer to list of n widths */
245 PixelType *addrlBase; /* pointer to start of bitmap */
246 int nlwidth; /* width in longwords of bitmap */
247 register PixelType *addrl;/* pointer to current longword in bitmap */
248 register int nlmiddle;
249 register PixelType startmask;
250 register PixelType endmask;
251 int *pwidthFree; /* copies of the pointers to free */
254 if (!(pGC->planemask & 1))
257 n = nInit * miFindMaxBand(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip);
258 pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
259 pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
260 if(!pptFree || !pwidthFree)
262 if (pptFree) DEALLOCATE_LOCAL(pptFree);
263 if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
268 n = miClipSpans(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip,
269 pptInit, pwidthInit, nInit,
270 ppt, pwidth, fSorted);
272 mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrlBase);
276 addrl = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth);
280 if ( ((ppt->x & PIM) + *pwidth) < PPW)
282 /* all bits inside same longword */
283 maskpartialbits(ppt->x, *pwidth, startmask);
288 maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
290 *addrl++ ^= startmask;
291 Duff (nlmiddle, *addrl++ ^= ~0);
299 DEALLOCATE_LOCAL(pptFree);
300 DEALLOCATE_LOCAL(pwidthFree);
305 mfbWhiteStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
306 DrawablePtr pDrawable;
308 int nInit; /* number of spans to fill */
309 DDXPointPtr pptInit; /* pointer to list of start points */
310 int *pwidthInit; /* pointer to list of n widths */
313 /* next three parameters are post-clip */
314 int n; /* number of spans to fill */
315 register DDXPointPtr ppt; /* pointer to list of start points */
316 register int *pwidth; /* pointer to list of n widths */
317 PixelType *addrlBase; /* pointer to start of bitmap */
318 int nlwidth; /* width in longwords of bitmap */
319 register PixelType *addrl;/* pointer to current longword in bitmap */
320 register PixelType src;
321 register int nlmiddle;
322 register PixelType startmask;
323 register PixelType endmask;
327 int *pwidthFree; /* copies of the pointers to free */
330 if (!(pGC->planemask & 1))
333 n = nInit * miFindMaxBand(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip);
334 pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
335 pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
336 if(!pptFree || !pwidthFree)
338 if (pptFree) DEALLOCATE_LOCAL(pptFree);
339 if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
344 n = miClipSpans(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip,
345 pptInit, pwidthInit, nInit,
346 ppt, pwidth, fSorted);
348 mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrlBase);
350 pStipple = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pRotatedPixmap;
351 tileHeight = pStipple->drawable.height;
352 psrc = (PixelType *)(pStipple->devPrivate.ptr);
356 addrl = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth);
357 src = psrc[ppt->y % tileHeight];
359 /* all bits inside same longword */
360 if ( ((ppt->x & PIM) + *pwidth) < PPW)
362 maskpartialbits(ppt->x, *pwidth, startmask);
363 *addrl |= (src & startmask);
367 maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
369 *addrl++ |= (src & startmask);
370 Duff (nlmiddle, *addrl++ |= src);
372 *addrl |= (src & endmask);
377 DEALLOCATE_LOCAL(pptFree);
378 DEALLOCATE_LOCAL(pwidthFree);
383 mfbBlackStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
384 DrawablePtr pDrawable;
386 int nInit; /* number of spans to fill */
387 DDXPointPtr pptInit; /* pointer to list of start points */
388 int *pwidthInit; /* pointer to list of n widths */
391 /* next three parameters are post-clip */
392 int n; /* number of spans to fill */
393 register DDXPointPtr ppt; /* pointer to list of start points */
394 register int *pwidth; /* pointer to list of n widths */
395 PixelType *addrlBase; /* pointer to start of bitmap */
396 int nlwidth; /* width in longwords of bitmap */
397 register PixelType *addrl; /* pointer to current longword in bitmap */
398 register PixelType src;
399 register int nlmiddle;
400 register PixelType startmask;
401 register PixelType endmask;
405 int *pwidthFree; /* copies of the pointers to free */
408 if (!(pGC->planemask & 1))
411 n = nInit * miFindMaxBand(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip);
412 pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
413 pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
414 if(!pptFree || !pwidthFree)
416 if (pptFree) DEALLOCATE_LOCAL(pptFree);
417 if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
422 n = miClipSpans(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip,
423 pptInit, pwidthInit, nInit,
424 ppt, pwidth, fSorted);
426 mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrlBase);
428 pStipple = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pRotatedPixmap;
429 tileHeight = pStipple->drawable.height;
430 psrc = (PixelType *)(pStipple->devPrivate.ptr);
434 addrl = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth);
435 src = psrc[ppt->y % tileHeight];
437 /* all bits inside same longword */
438 if ( ((ppt->x & PIM) + *pwidth) < PPW)
440 maskpartialbits(ppt->x, *pwidth, startmask);
441 *addrl &= ~(src & startmask);
445 maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
447 *addrl++ &= ~(src & startmask);
448 Duff (nlmiddle, *addrl++ &= ~src);
450 *addrl &= ~(src & endmask);
455 DEALLOCATE_LOCAL(pptFree);
456 DEALLOCATE_LOCAL(pwidthFree);
461 mfbInvertStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
462 DrawablePtr pDrawable;
464 int nInit; /* number of spans to fill */
465 DDXPointPtr pptInit; /* pointer to list of start points */
466 int *pwidthInit; /* pointer to list of n widths */
469 /* next three parameters are post-clip */
470 int n; /* number of spans to fill */
471 register DDXPointPtr ppt; /* pointer to list of start points */
472 register int *pwidth; /* pointer to list of n widths */
473 PixelType *addrlBase; /* pointer to start of bitmap */
474 int nlwidth; /* width in longwords of bitmap */
475 register PixelType *addrl; /* pointer to current longword in bitmap */
476 register PixelType src;
477 register int nlmiddle;
478 register PixelType startmask;
479 register PixelType endmask;
483 int *pwidthFree; /* copies of the pointers to free */
486 if (!(pGC->planemask & 1))
489 n = nInit * miFindMaxBand(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip);
490 pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
491 pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
492 if(!pptFree || !pwidthFree)
494 if (pptFree) DEALLOCATE_LOCAL(pptFree);
495 if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
500 n = miClipSpans(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip,
501 pptInit, pwidthInit, nInit,
502 ppt, pwidth, fSorted);
504 mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrlBase);
506 pStipple = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pRotatedPixmap;
507 tileHeight = pStipple->drawable.height;
508 psrc = (PixelType *)(pStipple->devPrivate.ptr);
512 addrl = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth);
513 src = psrc[ppt->y % tileHeight];
515 /* all bits inside same longword */
516 if ( ((ppt->x & PIM) + *pwidth) < PPW)
518 maskpartialbits(ppt->x, *pwidth, startmask);
519 *addrl ^= (src & startmask);
523 maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
525 *addrl++ ^= (src & startmask);
526 Duff(nlmiddle, *addrl++ ^= src);
528 *addrl ^= (src & endmask);
533 DEALLOCATE_LOCAL(pptFree);
534 DEALLOCATE_LOCAL(pwidthFree);
538 /* this works with tiles of width == PPW */
539 #define FILLSPANPPW(ROP) \
544 addrl = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth); \
545 src = psrc[ppt->y % tileHeight]; \
546 if ( ((ppt->x & PIM) + *pwidth) < PPW) \
548 maskpartialbits(ppt->x, *pwidth, startmask); \
549 *addrl = (*addrl & ~startmask) | \
550 (ROP(src, *addrl) & startmask); \
554 maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle); \
557 *addrl = (*addrl & ~startmask) | \
558 (ROP(src, *addrl) & startmask); \
563 *addrl = ROP(src, *addrl); \
567 *addrl = (*addrl & ~endmask) | \
568 (ROP(src, *addrl) & endmask); \
578 mfbTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
579 DrawablePtr pDrawable;
581 int nInit; /* number of spans to fill */
582 DDXPointPtr pptInit; /* pointer to list of start points */
583 int *pwidthInit; /* pointer to list of n widths */
586 /* next three parameters are post-clip */
587 int n; /* number of spans to fill */
588 register DDXPointPtr ppt; /* pointer to list of start points */
589 register int *pwidth; /* pointer to list of n widths */
590 PixelType *addrlBase; /* pointer to start of bitmap */
591 int nlwidth; /* width in longwords of bitmap */
592 register PixelType *addrl; /* pointer to current longword in bitmap */
593 register PixelType src;
594 register int nlmiddle;
595 register PixelType startmask;
596 register PixelType endmask;
601 int *pwidthFree; /* copies of the pointers to free */
606 if (!(pGC->planemask & 1))
609 n = nInit * miFindMaxBand(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip);
610 pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
611 pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
612 if(!pptFree || !pwidthFree)
614 if (pptFree) DEALLOCATE_LOCAL(pptFree);
615 if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
620 n = miClipSpans(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip,
621 pptInit, pwidthInit, nInit,
622 ppt, pwidth, fSorted);
624 mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrlBase);
626 pTile = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pRotatedPixmap;
627 tileHeight = pTile->drawable.height;
628 psrc = (PixelType *)(pTile->devPrivate.ptr);
629 if (pGC->fillStyle == FillTiled)
632 rop = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->ropOpStip;
637 case GXcopyInverted: /* for opaque stipples */
642 #define DoMaskCopyRop(src,dst,mask) ((dst) & ~(mask) | (src) & (mask))
648 addrl = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth);
649 src = psrc[ppt->y % tileHeight] ^ flip;
650 if ( ((ppt->x & PIM) + *pwidth) < PPW)
652 maskpartialbits(ppt->x, *pwidth, startmask);
653 *addrl = DoMaskCopyRop (src, *addrl, startmask);
657 maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
660 *addrl = DoMaskCopyRop (src, *addrl, startmask);
669 *addrl = DoMaskCopyRop (src, *addrl, endmask);
679 register DeclareMergeRop ();
681 InitializeMergeRop(rop,~0);
686 addrl = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth);
687 src = psrc[ppt->y % tileHeight];
688 if ( ((ppt->x & PIM) + *pwidth) < PPW)
690 maskpartialbits(ppt->x, *pwidth, startmask);
691 *addrl = DoMaskMergeRop (src, *addrl, startmask);
695 maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
698 *addrl = DoMaskMergeRop (src, *addrl, startmask);
703 *addrl = DoMergeRop (src, *addrl);
707 *addrl = DoMaskMergeRop (src, *addrl, endmask);
716 DEALLOCATE_LOCAL(pptFree);
717 DEALLOCATE_LOCAL(pwidthFree);
721 /* Fill spans with tiles that aren't PPW bits wide */
723 mfbUnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
724 DrawablePtr pDrawable;
726 int nInit; /* number of spans to fill */
727 DDXPointPtr pptInit; /* pointer to list of start points */
728 int *pwidthInit; /* pointer to list of n widths */
731 int iline; /* first line of tile to use */
732 /* next three parameters are post-clip */
733 int n; /* number of spans to fill */
734 register DDXPointPtr ppt; /* pointer to list of start points */
735 register int *pwidth; /* pointer to list of n widths */
736 PixelType *addrlBase; /* pointer to start of bitmap */
737 int nlwidth; /* width in longwords of bitmap */
738 register PixelType *pdst;/* pointer to current word in bitmap */
739 register PixelType *psrc;/* pointer to current word in tile */
740 register int nlMiddle;
741 register int rop, nstart;
743 PixmapPtr pTile; /* pointer to tile we want to fill with */
744 int w, width, x, xSrc, ySrc, srcStartOver, nend;
745 int tlwidth, rem, tileWidth, tileHeight, endinc;
746 PixelType endmask, *psrcT;
747 int *pwidthFree; /* copies of the pointers to free */
750 if (!(pGC->planemask & 1))
753 n = nInit * miFindMaxBand(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip);
754 pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
755 pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
756 if(!pptFree || !pwidthFree)
758 if (pptFree) DEALLOCATE_LOCAL(pptFree);
759 if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
764 n = miClipSpans(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip,
765 pptInit, pwidthInit, nInit,
766 ppt, pwidth, fSorted);
768 if (pGC->fillStyle == FillTiled)
770 pTile = pGC->tile.pixmap;
771 tlwidth = pTile->devKind / PGSZB;
776 pTile = pGC->stipple;
777 tlwidth = pTile->devKind / PGSZB;
778 rop = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->ropOpStip;
784 mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrlBase);
786 tileWidth = pTile->drawable.width;
787 tileHeight = pTile->drawable.height;
789 /* this replaces rotating the tile. Instead we just adjust the offset
790 * at which we start grabbing bits from the tile.
791 * Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,
792 * so that iline and rem always stay within the tile bounds.
794 xSrc += (pGC->patOrg.x % tileWidth) - tileWidth;
795 ySrc += (pGC->patOrg.y % tileHeight) - tileHeight;
799 iline = (ppt->y - ySrc) % tileHeight;
800 pdst = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth);
801 psrcT = (PixelType *) pTile->devPrivate.ptr + (iline * tlwidth);
810 w = min(tileWidth, width);
811 if((rem = (x - xSrc) % tileWidth) != 0)
813 /* if we're in the middle of the tile, get
814 as many bits as will finish the span, or
815 as many as will get to the left edge of the tile,
816 or a longword worth, starting at the appropriate
819 w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
820 endinc = rem / BITMAP_SCANLINE_PAD;
821 getandputrop((psrc+endinc), (rem&PIM), (x & PIM), w, pdst, rop);
822 if((x & PIM) + w >= PPW)
825 else if(((x & PIM) + w) < PPW)
827 /* doing < PPW bits is easy, and worth special-casing */
828 putbitsrop(*psrc, x & PIM, w, pdst, rop);
832 /* start at the left edge of the tile,
833 and put down as much as we can
835 maskbits(x, w, startmask, endmask, nlMiddle);
838 nstart = PPW - (x & PIM);
842 nend = (x + w) & PIM;
846 srcStartOver = nstart > PLST;
850 putbitsrop(*psrc, (x & PIM), nstart, pdst, rop);
858 getandputrop0(psrc, nstart, PPW, pdst, rop);
864 getandputrop0(psrc, nstart, nend, pdst, rop);
874 DEALLOCATE_LOCAL(pptFree);
875 DEALLOCATE_LOCAL(pwidthFree);
879 /* Fill spans with stipples that aren't PPW bits wide */
881 mfbUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
882 DrawablePtr pDrawable;
884 int nInit; /* number of spans to fill */
885 DDXPointPtr pptInit; /* pointer to list of start points */
886 int *pwidthInit; /* pointer to list of n widths */
889 /* next three parameters are post-clip */
890 int n; /* number of spans to fill */
891 register DDXPointPtr ppt; /* pointer to list of start points */
892 register int *pwidth; /* pointer to list of n widths */
893 int iline; /* first line of tile to use */
894 PixelType *addrlBase; /* pointer to start of bitmap */
895 int nlwidth; /* width in longwords of bitmap */
896 register PixelType *pdst; /* pointer to current word in bitmap */
897 register PixelType *psrc; /* pointer to current word in tile */
898 register int nlMiddle;
899 register int rop, nstart;
901 PixmapPtr pTile; /* pointer to tile we want to fill with */
902 int w, width, x, xSrc, ySrc, srcStartOver, nend;
903 PixelType endmask, *psrcT;
904 int tlwidth, rem, tileWidth, endinc;
906 int *pwidthFree; /* copies of the pointers to free */
909 if (!(pGC->planemask & 1))
912 n = nInit * miFindMaxBand(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip);
913 pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
914 pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
915 if(!pptFree || !pwidthFree)
917 if (pptFree) DEALLOCATE_LOCAL(pptFree);
918 if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
923 n = miClipSpans(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip,
924 pptInit, pwidthInit, nInit,
925 ppt, pwidth, fSorted);
927 pTile = pGC->stipple;
928 rop = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->rop;
929 tlwidth = pTile->devKind / PGSZB;
932 mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrlBase);
934 tileWidth = pTile->drawable.width;
935 tileHeight = pTile->drawable.height;
937 /* this replaces rotating the stipple. Instead, we just adjust the offset
938 * at which we start grabbing bits from the stipple.
939 * Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,
940 * so that iline and rem always stay within the tile bounds.
942 xSrc += (pGC->patOrg.x % tileWidth) - tileWidth;
943 ySrc += (pGC->patOrg.y % tileHeight) - tileHeight;
946 iline = (ppt->y - ySrc) % tileHeight;
947 pdst = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth);
948 psrcT = (PixelType *) pTile->devPrivate.ptr + (iline * tlwidth);
957 w = min(tileWidth, width);
958 if((rem = (x - xSrc) % tileWidth) != 0)
960 /* if we're in the middle of the tile, get
961 as many bits as will finish the span, or
962 as many as will get to the left edge of the tile,
963 or a longword worth, starting at the appropriate
966 w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
967 endinc = rem / BITMAP_SCANLINE_PAD;
968 getandputrrop((psrc + endinc), (rem & PIM), (x & PIM),
970 if((x & PIM) + w >= PPW)
974 else if(((x & PIM) + w) < PPW)
976 /* doing < PPW bits is easy, and worth special-casing */
977 putbitsrrop(*psrc, x & PIM, w, pdst, rop);
981 /* start at the left edge of the tile,
982 and put down as much as we can
984 maskbits(x, w, startmask, endmask, nlMiddle);
987 nstart = PPW - (x & PIM);
991 nend = (x + w) & PIM;
995 srcStartOver = nstart > PLST;
999 putbitsrrop(*psrc, (x & PIM), nstart, pdst, rop);
1007 getandputrrop0(psrc, nstart, PPW, pdst, rop);
1013 getandputrrop0(psrc, nstart, nend, pdst, rop);
1023 DEALLOCATE_LOCAL(pptFree);
1024 DEALLOCATE_LOCAL(pwidthFree);