1
/* $XFree86: xc/programs/Xserver/ilbm/ilbmfillsp.c,v 3.1 1998/03/20 21:08:01 hohndel Exp $ */
2
/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
3
/***********************************************************
5
Copyright (c) 1987 X Consortium
7
Permission is hereby granted, free of charge, to any person obtaining a copy
8
of this software and associated documentation files (the "Software"), to deal
9
in the Software without restriction, including without limitation the rights
10
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
copies of the Software, and to permit persons to whom the Software is
12
furnished to do so, subject to the following conditions:
14
The above copyright notice and this permission notice shall be included in
15
all copies or substantial portions of the Software.
17
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
Except as contained in this notice, the name of the X Consortium shall not be
25
used in advertising or otherwise to promote the sale, use or other dealings
26
in this Software without prior written authorization from the X Consortium.
29
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
33
Permission to use, copy, modify, and distribute this software and its
34
documentation for any purpose and without fee is hereby granted,
35
provided that the above copyright notice appear in all copies and that
36
both that copyright notice and this permission notice appear in
37
supporting documentation, and that the name of Digital not be
38
used in advertising or publicity pertaining to distribution of the
39
software without specific, written prior permission.
41
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
42
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
43
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
44
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
45
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
46
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
49
******************************************************************/
50
/* $XConsortium: ilbmfillsp.c,v 5.13 94/04/17 20:28:21 dpw Exp $ */
52
/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
53
to use interleaved bitplanes instead of normal bitplanes */
59
#include "pixmapstr.h"
60
#include "scrnintstr.h"
61
#include "windowstr.h"
71
/* scanline filling for monochrome frame buffer
72
written by drewry, oct 1986
74
these routines all clip. they assume that anything that has called
75
them has already translated the points (i.e. pGC->miTranslate is
76
non-zero, which is howit gets set in ilbmCreateGC().)
78
the number of new scnalines created by clipping ==
79
MaxRectsPerBand * nSpans.
85
ilbmSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
86
DrawablePtr pDrawable;
88
int nInit; /* number of spans to fill */
89
DDXPointPtr pptInit; /* pointer to list of start points */
90
int *pwidthInit; /* pointer to list of n widths */
93
/* next three parameters are post-clip */
94
int n; /* number of spans to fill */
95
register DDXPointPtr ppt; /* pointer to list of start points */
96
register int *pwidth; /* pointer to list of n widths */
97
PixelType *addrlBase; /* pointer to start of bitmap */
99
int nlwidth; /* width in longwords of bitmap */
100
register PixelType *addrl;/* pointer to current longword in bitmap */
101
register int nlmiddle;
102
register PixelType startmask;
103
register PixelType endmask;
104
int *pwidthFree; /* copies of the pointers to free */
109
unsigned char *rrops;
111
n = nInit * miFindMaxBand(pGC->pCompositeClip);
112
pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
113
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
114
if (!pptFree || !pwidthFree) {
116
DEALLOCATE_LOCAL(pptFree);
118
DEALLOCATE_LOCAL(pwidthFree);
123
n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
124
ppt, pwidth, fSorted);
126
ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, nlwidth, auxDst, depthDst,
128
rrops = ((ilbmPrivGC *)(pGC->devPrivates[ilbmGCPrivateIndex].ptr))->rrops;
130
addrlBase = ilbmScanline(pBase, ppt->x, ppt->y, auxDst);
132
for (d = 0; d < depthDst; d++, addrlBase += nlwidth) { /* @@@ NEXT PLANE @@@ */
138
if ( ((ppt->x & PIM) + *pwidth) < PPW) {
139
/* all bits inside same longword */
140
maskpartialbits(ppt->x, *pwidth, startmask);
141
*addrl &= ~startmask;
143
maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
145
*addrl++ &= ~startmask;
146
Duff (nlmiddle, *addrl++ = 0x0);
153
if ( ((ppt->x & PIM) + *pwidth) < PPW) {
154
/* all bits inside same longword */
155
maskpartialbits(ppt->x, *pwidth, startmask);
158
maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
160
*addrl++ |= startmask;
161
Duff (nlmiddle, *addrl++ = ~0);
167
if ( ((ppt->x & PIM) + *pwidth) < PPW) {
168
/* all bits inside same longword */
169
maskpartialbits(ppt->x, *pwidth, startmask);
172
maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
174
*addrl++ ^= startmask;
175
Duff (nlmiddle, *addrl++ ^= ~0);
188
DEALLOCATE_LOCAL(pptFree);
189
DEALLOCATE_LOCAL(pwidthFree);
193
ilbmStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
194
DrawablePtr pDrawable;
196
int nInit; /* number of spans to fill */
197
DDXPointPtr pptInit; /* pointer to list of start points */
198
int *pwidthInit; /* pointer to list of n widths */
201
/* next three parameters are post-clip */
202
int n; /* number of spans to fill */
203
register DDXPointPtr ppt; /* pointer to list of start points */
204
register int *pwidth; /* pointer to list of n widths */
205
PixelType *addrlBase; /* pointer to start of bitmap */
207
int nlwidth; /* width in longwords of bitmap */
208
register PixelType *addrl;/* pointer to current longword in bitmap */
209
register PixelType src;
210
register int nlmiddle;
211
register PixelType startmask;
212
register PixelType endmask;
216
int *pwidthFree; /* copies of the pointers to free */
221
unsigned char *rrops;
223
n = nInit * miFindMaxBand(pGC->pCompositeClip);
224
pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
225
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
226
if (!pptFree || !pwidthFree) {
228
DEALLOCATE_LOCAL(pptFree);
230
DEALLOCATE_LOCAL(pwidthFree);
235
n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
236
ppt, pwidth, fSorted);
238
ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, nlwidth, auxDst, depthDst,
241
pStipple = pGC->pRotatedPixmap;
242
tileHeight = pStipple->drawable.height;
243
psrc = (PixelType *)(pStipple->devPrivate.ptr);
245
rrops = ((ilbmPrivGC *)(pGC->devPrivates[ilbmGCPrivateIndex].ptr))->rrops;
248
src = psrc[ppt->y % tileHeight];
249
addrlBase = ilbmScanline(pBase, ppt->x, ppt->y, auxDst);
250
for (d = 0; d < depthDst; d++, addrlBase += nlwidth) { /* @@@ NEXT PLANE @@@ */
255
/* all bits inside same longword */
256
if ( ((ppt->x & PIM) + *pwidth) < PPW) {
257
maskpartialbits(ppt->x, *pwidth, startmask);
258
*addrl &= ~(src & startmask);
260
maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
262
*addrl++ &= ~(src & startmask);
263
Duff (nlmiddle, *addrl++ &= ~src);
265
*addrl &= ~(src & endmask);
269
/* all bits inside same longword */
270
if ( ((ppt->x & PIM) + *pwidth) < PPW) {
271
maskpartialbits(ppt->x, *pwidth, startmask);
272
*addrl |= (src & startmask);
274
maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
276
*addrl++ |= (src & startmask);
277
Duff (nlmiddle, *addrl++ |= src);
279
*addrl |= (src & endmask);
283
/* all bits inside same longword */
284
if ( ((ppt->x & PIM) + *pwidth) < PPW) {
285
maskpartialbits(ppt->x, *pwidth, startmask);
286
*addrl ^= (src & startmask);
288
maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
290
*addrl++ ^= (src & startmask);
291
Duff (nlmiddle, *addrl++ ^= src);
293
*addrl ^= (src & endmask);
304
DEALLOCATE_LOCAL(pptFree);
305
DEALLOCATE_LOCAL(pwidthFree);
309
ilbmTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
310
DrawablePtr pDrawable;
312
int nInit; /* number of spans to fill */
313
DDXPointPtr pptInit; /* pointer to list of start points */
314
int *pwidthInit; /* pointer to list of n widths */
317
/* next three parameters are post-clip */
318
int n; /* number of spans to fill */
319
register DDXPointPtr ppt; /* pointer to list of start points */
320
register int *pwidth; /* pointer to list of n widths */
321
PixelType *addrlBase; /* pointer to start of bitmap */
323
int nlwidth; /* width in longwords of bitmap */
324
register PixelType *addrl; /* pointer to current longword in bitmap */
325
register PixelType src;
326
register int nlmiddle;
327
register PixelType startmask;
328
register PixelType endmask;
333
int *pwidthFree; /* copies of the pointers to free */
339
n = nInit * miFindMaxBand(pGC->pCompositeClip);
340
pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
341
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
342
if (!pptFree || !pwidthFree) {
344
DEALLOCATE_LOCAL(pptFree);
346
DEALLOCATE_LOCAL(pwidthFree);
351
n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
352
ppt, pwidth, fSorted);
354
ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, nlwidth, auxDst, depthDst,
357
pTile = pGC->pRotatedPixmap;
358
tileHeight = pTile->drawable.height;
359
psrc = (PixelType *)(pTile->devPrivate.ptr);
364
#define DoMaskCopyRop(src,dst,mask) ((dst) & ~(mask) | (src) & (mask))
367
addrlBase = ilbmScanline(pBase, ppt->x, ppt->y, auxDst);
369
for (d = 0; d < depthDst; d++, addrlBase += nlwidth) { /* @@@ NEXT PLANE @@@ */
370
if (!(pGC->planemask & (1 << d)))
374
src = psrc[ppt->y % tileHeight + tileHeight * d];
375
if ( ((ppt->x & PIM) + *pwidth) < PPW) {
376
maskpartialbits(ppt->x, *pwidth, startmask);
377
*addrl = DoMaskCopyRop (src, *addrl, startmask);
379
maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
381
*addrl = DoMaskCopyRop (src, *addrl, startmask);
389
*addrl = DoMaskCopyRop (src, *addrl, endmask);
400
register DeclareMergeRop ();
402
InitializeMergeRop(rop,~0);
405
addrlBase = ilbmScanline(pBase, ppt->x, ppt->y, auxDst);
406
for (d = 0; d < depthDst; d++, addrlBase += nlwidth) { /* @@@ NEXT PLANE @@@ */
407
if (!(pGC->planemask & (1 << d)))
412
src = psrc[ppt->y % tileHeight + tileHeight * d];
413
if ( ((ppt->x & PIM) + *pwidth) < PPW) {
414
maskpartialbits(ppt->x, *pwidth, startmask);
415
*addrl = DoMaskMergeRop (src, *addrl, startmask);
417
maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
419
*addrl = DoMaskMergeRop (src, *addrl, startmask);
423
*addrl = DoMergeRop (src, *addrl);
427
*addrl = DoMaskMergeRop (src, *addrl, endmask);
437
DEALLOCATE_LOCAL(pptFree);
438
DEALLOCATE_LOCAL(pwidthFree);
442
ilbmOpaqueStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
443
DrawablePtr pDrawable;
445
int nInit; /* number of spans to fill */
446
DDXPointPtr pptInit; /* pointer to list of start points */
447
int *pwidthInit; /* pointer to list of n widths */
450
/* next three parameters are post-clip */
451
int n; /* number of spans to fill */
452
register DDXPointPtr ppt; /* pointer to list of start points */
453
register int *pwidth; /* pointer to list of n widths */
454
PixelType *addrlBase; /* pointer to start of bitmap */
456
int nlwidth; /* width in longwords of bitmap */
457
register PixelType *addrl; /* pointer to current longword in bitmap */
458
register PixelType src;
459
register int nlmiddle;
460
register PixelType startmask;
461
register PixelType endmask;
466
unsigned char *rropsOS;
467
int *pwidthFree; /* copies of the pointers to free */
473
n = nInit * miFindMaxBand(pGC->pCompositeClip);
474
pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
475
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
476
if (!pptFree || !pwidthFree) {
478
DEALLOCATE_LOCAL(pptFree);
480
DEALLOCATE_LOCAL(pwidthFree);
485
n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
486
ppt, pwidth, fSorted);
488
ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, nlwidth, auxDst, depthDst,
491
pTile = pGC->pRotatedPixmap;
492
tileHeight = pTile->drawable.height;
493
psrc = (PixelType *)(pTile->devPrivate.ptr);
495
rropsOS = ((ilbmPrivGC *)(pGC->devPrivates[ilbmGCPrivateIndex].ptr))->rropOS;
499
#define DoMaskCopyRop(src,dst,mask) ((dst) & ~(mask) | (src) & (mask))
501
addrlBase = ilbmScanline(pBase, ppt->x, ppt->y, auxDst);
503
for (d = 0; d < depthDst; d++, addrlBase += nlwidth) { /* @@@ NEXT PLANE @@@ */
504
switch (rropsOS[d]) {
512
src = ~psrc[ppt->y % tileHeight];
515
src = psrc[ppt->y % tileHeight];
523
if ( ((ppt->x & PIM) + *pwidth) < PPW) {
524
maskpartialbits(ppt->x, *pwidth, startmask);
525
*addrl = DoMaskCopyRop (src, *addrl, startmask);
527
maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
529
*addrl = DoMaskCopyRop (src, *addrl, startmask);
537
*addrl = DoMaskCopyRop (src, *addrl, endmask);
539
} /* for (d = ...) */
549
register DeclareMergeRop ();
551
InitializeMergeRop(rop,~0);
553
addrlBase = ilbmScanline(pBase, ppt->x, ppt->y, auxDst);
555
for (d = 0; d < depthDst; d++, addrlBase += nlwidth) { /* @@@ NEXT PLANE @@@ */
556
switch (rropsOS[d]) {
564
src = ~psrc[ppt->y % tileHeight];
567
src = psrc[ppt->y % tileHeight];
575
if ( ((ppt->x & PIM) + *pwidth) < PPW) {
576
maskpartialbits(ppt->x, *pwidth, startmask);
577
*addrl = DoMaskMergeRop (src, *addrl, startmask);
579
maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
581
*addrl = DoMaskMergeRop (src, *addrl, startmask);
585
*addrl = DoMergeRop (src, *addrl);
589
*addrl = DoMaskMergeRop (src, *addrl, endmask);
591
} /* for (d = ...) */
599
DEALLOCATE_LOCAL(pptFree);
600
DEALLOCATE_LOCAL(pwidthFree);
603
/* Fill spans with tiles that aren't PPW bits wide */
605
ilbmUnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
606
DrawablePtr pDrawable;
608
int nInit; /* number of spans to fill */
609
DDXPointPtr pptInit; /* pointer to list of start points */
610
int *pwidthInit; /* pointer to list of n widths */
613
int iline; /* first line of tile to use */
614
/* next three parameters are post-clip */
615
int n; /* number of spans to fill */
616
register DDXPointPtr ppt; /* pointer to list of start points */
617
register int *pwidth; /* pointer to list of n widths */
618
PixelType *addrlBase; /* pointer to start of bitmap */
620
int nlwidth; /* width in longwords of bitmap */
621
register PixelType *pdst;/* pointer to current word in bitmap */
622
register PixelType *psrc;/* pointer to current word in tile */
623
register int nlMiddle;
624
register int rop, nstart;
626
PixmapPtr pTile; /* pointer to tile we want to fill with */
627
int w, width, x, xSrc, ySrc, srcStartOver, nend;
628
int tlwidth, rem, tileWidth, tileHeight, endinc;
629
PixelType endmask, *psrcT;
630
int *pwidthFree; /* copies of the pointers to free */
637
n = nInit * miFindMaxBand(pGC->pCompositeClip);
638
pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
639
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
640
if (!pptFree || !pwidthFree) {
642
DEALLOCATE_LOCAL(pptFree);
644
DEALLOCATE_LOCAL(pwidthFree);
649
n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
650
ppt, pwidth, fSorted);
652
pTile = pGC->tile.pixmap;
653
tlwidth = pTile->devKind/PGSZB;
659
ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, nlwidth, auxDst, depthDst,
662
tileWidth = pTile->drawable.width;
663
tileHeight = pTile->drawable.height;
664
sizeTile = tlwidth * tileHeight;
666
/* this replaces rotating the tile. Instead we just adjust the offset
667
* at which we start grabbing bits from the tile.
668
* Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,
669
* so that iline and rem always stay within the tile bounds.
671
xSrc += (pGC->patOrg.x % tileWidth) - tileWidth;
672
ySrc += (pGC->patOrg.y % tileHeight) - tileHeight;
675
iline = (ppt->y - ySrc) % tileHeight;
676
psrcT = (PixelType *) pTile->devPrivate.ptr + (iline * tlwidth);
677
addrlBase = ilbmScanline(pBase, ppt->x, ppt->y, auxDst);
679
for (d = 0; d < depthDst; d++, psrcT += sizeTile, addrlBase += nlwidth) { /* @@@ NEXT PLANE @@@ */
680
if (!(pGC->planemask & (1 << d)))
689
w = min(tileWidth, width);
690
if ((rem = (x - xSrc) % tileWidth) != 0) {
691
/* if we're in the middle of the tile, get
692
as many bits as will finish the span, or
693
as many as will get to the left edge of the tile,
694
or a longword worth, starting at the appropriate
697
w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
698
endinc = rem / BITMAP_SCANLINE_PAD;
699
getandputrop((psrc+endinc), (rem&PIM), (x & PIM), w, pdst, rop);
700
if ((x & PIM) + w >= PPW)
702
} else if (((x & PIM) + w) < PPW) {
703
/* doing < PPW bits is easy, and worth special-casing */
704
putbitsrop(*psrc, x & PIM, w, pdst, rop);
706
/* start at the left edge of the tile,
707
and put down as much as we can
709
maskbits(x, w, startmask, endmask, nlMiddle);
712
nstart = PPW - (x & PIM);
716
nend = (x + w) & PIM;
720
srcStartOver = nstart > PLST;
723
putbitsrop(*psrc, (x & PIM), nstart, pdst, rop);
730
getandputrop0(psrc, nstart, PPW, pdst, rop);
735
getandputrop0(psrc, nstart, nend, pdst, rop);
746
DEALLOCATE_LOCAL(pptFree);
747
DEALLOCATE_LOCAL(pwidthFree);
750
/* Fill spans with stipples that aren't PPW bits wide */
752
ilbmUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
753
DrawablePtr pDrawable;
755
int nInit; /* number of spans to fill */
756
DDXPointPtr pptInit; /* pointer to list of start points */
757
int *pwidthInit; /* pointer to list of n widths */
760
/* next three parameters are post-clip */
761
int n; /* number of spans to fill */
762
register DDXPointPtr ppt; /* pointer to list of start points */
763
register int *pwidth; /* pointer to list of n widths */
764
int iline; /* first line of tile to use */
765
PixelType *addrlBase; /* pointer to start of bitmap */
767
int nlwidth; /* width in longwords of bitmap */
768
register PixelType *pdst; /* pointer to current word in bitmap */
769
register PixelType *psrc; /* pointer to current word in tile */
770
register int nlMiddle;
771
register int rop, nstart;
773
PixmapPtr pTile; /* pointer to tile we want to fill with */
774
int w, width, x, xSrc, ySrc, srcStartOver, nend;
775
PixelType endmask, *psrcT;
776
int tlwidth, rem, tileWidth, endinc;
778
int *pwidthFree; /* copies of the pointers to free */
780
unsigned char *rrops;
785
n = nInit * miFindMaxBand(pGC->pCompositeClip);
786
pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
787
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
788
if (!pptFree || !pwidthFree) {
790
DEALLOCATE_LOCAL(pptFree);
792
DEALLOCATE_LOCAL(pwidthFree);
797
n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
798
ppt, pwidth, fSorted);
800
pTile = pGC->stipple;
801
tlwidth = pTile->devKind/PGSZB;
804
ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, nlwidth, auxDst, depthDst,
807
tileWidth = pTile->drawable.width;
808
tileHeight = pTile->drawable.height;
809
rrops = ((ilbmPrivGC *)(pGC->devPrivates[ilbmGCPrivateIndex].ptr))->rrops;
811
/* this replaces rotating the stipple. Instead, we just adjust the offset
812
* at which we start grabbing bits from the stipple.
813
* Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,
814
* so that iline and rem always stay within the tile bounds.
816
xSrc += (pGC->patOrg.x % tileWidth) - tileWidth;
817
ySrc += (pGC->patOrg.y % tileHeight) - tileHeight;
819
iline = (ppt->y - ySrc) % tileHeight;
820
psrcT = (PixelType *) pTile->devPrivate.ptr + (iline * tlwidth);
821
addrlBase = ilbmScanline(pBase, ppt->x, ppt->y, auxDst);
823
for (d = 0; d < depthDst; d++, addrlBase += nlwidth) { /* @@@ NEXT PLANE @@@ */
835
w = min(tileWidth, width);
836
if ((rem = (x - xSrc) % tileWidth) != 0) {
837
/* if we're in the middle of the tile, get
838
as many bits as will finish the span, or
839
as many as will get to the left edge of the tile,
840
or a longword worth, starting at the appropriate
843
w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
844
endinc = rem / BITMAP_SCANLINE_PAD;
845
getandputrrop((psrc + endinc), (rem & PIM), (x & PIM),
847
if ((x & PIM) + w >= PPW)
849
} else if (((x & PIM) + w) < PPW) {
850
/* doing < PPW bits is easy, and worth special-casing */
851
putbitsrrop(*psrc, x & PIM, w, pdst, rop);
853
/* start at the left edge of the tile,
854
and put down as much as we can
856
maskbits(x, w, startmask, endmask, nlMiddle);
859
nstart = PPW - (x & PIM);
863
nend = (x + w) & PIM;
867
srcStartOver = nstart > PLST;
870
putbitsrrop(*psrc, (x & PIM), nstart, pdst, rop);
877
getandputrrop0(psrc, nstart, PPW, pdst, rop);
882
getandputrrop0(psrc, nstart, nend, pdst, rop);
893
DEALLOCATE_LOCAL(pptFree);
894
DEALLOCATE_LOCAL(pwidthFree);
897
/* Fill spans with OpaqueStipples that aren't PPW bits wide */
899
ilbmUnnaturalOpaqueStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
900
DrawablePtr pDrawable;
902
int nInit; /* number of spans to fill */
903
DDXPointPtr pptInit; /* pointer to list of start points */
904
int *pwidthInit; /* pointer to list of n widths */
907
int iline; /* first line of tile to use */
908
/* next three parameters are post-clip */
909
int n; /* number of spans to fill */
910
register DDXPointPtr ppt; /* pointer to list of start points */
911
register int *pwidth; /* pointer to list of n widths */
912
PixelType *addrlBase; /* pointer to start of bitmap */
914
int nlwidth; /* width in longwords of bitmap */
915
register PixelType *pdst;/* pointer to current word in bitmap */
916
register PixelType *psrc;/* pointer to current word in tile */
917
register int nlMiddle;
919
register PixelType tmpsrc;
920
register PixelType tmpdst;
921
register int alu, nstart;
922
register unsigned char *rropsOS;
924
PixmapPtr pTile; /* pointer to tile we want to fill with */
925
int w, width, x, xSrc, ySrc, srcStartOver, nend;
926
int tlwidth, rem, tileWidth, tileHeight, endinc;
927
PixelType endmask, *psrcT;
928
int *pwidthFree; /* copies of the pointers to free */
934
n = nInit * miFindMaxBand(pGC->pCompositeClip);
935
pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
936
pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
937
if (!pptFree || !pwidthFree) {
939
DEALLOCATE_LOCAL(pptFree);
941
DEALLOCATE_LOCAL(pwidthFree);
946
n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
947
ppt, pwidth, fSorted);
949
pTile = pGC->stipple;
950
tlwidth = pTile->devKind/PGSZB;
956
ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, nlwidth, auxDst, depthDst,
959
tileWidth = pTile->drawable.width;
960
tileHeight = pTile->drawable.height;
961
rropsOS = ilbmGetGCPrivate(pGC)->rropOS;
963
/* this replaces rotating the tile. Instead we just adjust the offset
964
* at which we start grabbing bits from the tile.
965
* Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,
966
* so that iline and rem always stay within the tile bounds.
968
xSrc += (pGC->patOrg.x % tileWidth) - tileWidth;
969
ySrc += (pGC->patOrg.y % tileHeight) - tileHeight;
972
iline = (ppt->y - ySrc) % tileHeight;
973
psrcT = (PixelType *) pTile->devPrivate.ptr + (iline * tlwidth);
974
addrlBase = ilbmScanline(pBase, ppt->x, ppt->y, auxDst);
976
for (d = 0; d < depthDst; d++, addrlBase += nlwidth) { /* @@@ NEXT PLANE @@@ */
977
if (!(pGC->planemask & (1 << d)))
986
w = min(tileWidth, width);
987
if ((rem = (x - xSrc) % tileWidth) != 0) {
988
/* if we're in the middle of the tile, get
989
as many bits as will finish the span, or
990
as many as will get to the left edge of the tile,
991
or a longword worth, starting at the appropriate
994
w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
995
endinc = rem / BITMAP_SCANLINE_PAD;
996
switch (rropsOS[d]) {
1005
getbits ((psrc+endinc), (rem&PIM), w, tmpsrc);
1009
getbits ((psrc+endinc), (rem&PIM), w, tmpsrc);
1014
if (alu != GXcopy) {
1015
getbits (pdst, (x & PIM), w, tmpdst);
1016
DoRop (tmpsrc, alu, tmpsrc, tmpdst);
1019
putbits (tmpsrc, (x & PIM), w, pdst);
1020
if ((x & PIM) + w >= PPW)
1022
} else if (((x & PIM) + w) < PPW) {
1023
/* doing < PPW bits is easy, and worth special-casing */
1024
switch (rropsOS[d]) {
1038
if (alu != GXcopy) {
1039
getbits (pdst, (x & PIM), w, tmpdst);
1040
DoRop (tmpsrc, alu, tmpsrc, tmpdst);
1042
putbits (tmpsrc, (x & PIM), w, pdst);
1044
/* start at the left edge of the tile,
1045
and put down as much as we can
1047
maskbits(x, w, startmask, endmask, nlMiddle);
1050
nstart = PPW - (x & PIM);
1054
nend = (x + w) & PIM;
1058
srcStartOver = nstart > PLST;
1061
switch (rropsOS[d]) {
1075
if (alu != GXcopy) {
1076
getbits (pdst, (x & PIM), nstart, tmpdst);
1077
DoRop (tmpsrc, alu, tmpsrc, tmpdst);
1079
putbits (tmpsrc, (x & PIM), nstart, pdst);
1085
while (nlMiddle--) {
1086
switch (rropsOS[d]) {
1094
getbits (psrc, nstart, PPW, tmpsrc);
1097
getbits (psrc, nstart, PPW, tmpsrc);
1101
if (alu != GXcopy) {
1103
DoRop (tmpsrc, alu, tmpsrc, tmpdst);
1106
/*putbits (tmpsrc, 0, PPW, pdst);
1111
switch (rropsOS[d]) {
1120
getbits (psrc, nstart, nend, tmpsrc);
1124
getbits (psrc, nstart, nend, tmpsrc);
1128
if (alu != GXcopy) {
1130
DoRop (tmpsrc, alu, tmpsrc, tmpdst);
1132
putbits (tmpsrc, 0, nend, pdst);
1143
DEALLOCATE_LOCAL(pptFree);
1144
DEALLOCATE_LOCAL(pwidthFree);