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: ilbmtile.c,v 5.8 94/04/17 20:28:36 dpw Exp $ */
52
/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
53
to use interleaved bitplanes instead of normal bitplanes */
55
#ifdef HAVE_DIX_CONFIG_H
56
#include <dix-config.h>
61
#include "windowstr.h"
62
#include "regionstr.h"
63
#include "pixmapstr.h"
64
#include "scrnintstr.h"
72
the boxes are already translated.
75
iy = ++iy < tileHeight ? iy : 0
76
is equivalent to iy%= tileheight, and saves a division.
80
tile area with a PPW bit wide pixmap
83
MROP_NAME(ilbmTileAreaPPW)(pDraw, nbox, pbox, alu, ptile, planemask)
89
unsigned long planemask;
91
register PixelType *psrc;
92
/* pointer to bits in tile, if needed */
93
int tileHeight; /* height of the tile */
94
register PixelType srcpix;
95
int nlwidth; /* width in longwords of the drawable */
96
int w; /* width of current box */
98
register int h; /* height of current box */
99
register int nlw; /* loop version of nlwMiddle */
100
register PixelType *p; /* pointer to bits we're writing */
106
PixelType endmask; /* masks for reggedy bits at either end of line */
107
int nlwMiddle; /* number of longwords between sides of boxes */
108
int nlwExtra; /* to get from right of box to left of next span */
109
register int iy; /* index of current scanline in tile */
110
PixelType *pbits; /* pointer to start of drawable */
116
ilbmGetPixelWidthAuxDepthAndPointer(pDraw, nlwidth, auxDst, depthDst,
119
MROP_INITIALIZE(alu,~0)
121
tileHeight = ptile->drawable.height;
122
tlwidth = ptile->devKind/sizeof(PixelType);
123
pSaveSrc = (PixelType *)(ptile->devPrivate.ptr);
126
w = pbox->x2 - pbox->x1;
127
saveH = pbox->y2 - pbox->y1;
128
saveIY = pbox->y1 % tileHeight;
129
saveP = ilbmScanline(pbits, pbox->x1, pbox->y1, auxDst);
132
if (((pbox->x1 & PIM) + w) < PPW) {
133
maskpartialbits(pbox->x1, w, startmask);
135
for (d = 0; d < depthDst; d++, saveP += nlwidth, psrc += tileHeight) { /* @@@ NEXT PLANE @@@ */
136
if (!(planemask & (1 << d)))
146
if (iy == tileHeight)
148
*p = MROP_MASK(srcpix,*p,startmask);
149
ilbmScanlineInc(p, nlwExtra);
153
maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
155
for (d = 0; d < depthDst; d++, saveP += nlwidth, psrc += tileHeight) { /* @@@ NEXT PLANE @@@ */
156
if (!(planemask & (1 << d)))
162
nlwExtra = auxDst - nlwMiddle;
164
if (startmask && endmask) {
169
if (iy == tileHeight)
172
*p = MROP_MASK (srcpix,*p,startmask);
175
*p = MROP_SOLID(srcpix,*p);
179
*p = MROP_MASK(srcpix,*p,endmask);
180
ilbmScanlineInc(p, nlwExtra);
182
} else if (startmask && !endmask) {
187
if (iy == tileHeight)
190
*p = MROP_MASK(srcpix,*p,startmask);
193
*p = MROP_SOLID(srcpix,*p);
196
ilbmScanlineInc(p, nlwExtra);
198
} else if (!startmask && endmask) {
202
if (iy == tileHeight)
206
*p = MROP_SOLID(srcpix,*p);
210
*p = MROP_MASK(srcpix,*p,endmask);
211
ilbmScanlineInc(p, nlwExtra);
213
} else { /* no ragged bits at either end */
217
if (iy == tileHeight)
221
*p = MROP_SOLID (srcpix,*p);
224
ilbmScanlineInc(p, nlwExtra);
227
} /* for (d = ...) */
234
MROP_NAME(ilbmTileArea)(pDraw, nbox, pbox, alu, pTile, xOff, yOff, planemask)
242
unsigned long planemask;
244
register PixelType *psrc;
245
/* pointer to bits in tile, if needed */
246
int nlwidth; /* width in longwords of the drawable */
248
register int h; /* height of current box */
249
register PixelType *pdst; /* pointer to bits we're writing */
250
register PixelType tmpsrc, tmpdst;
256
int w, width, x, xSrc, ySrc, srcStartOver, nend;
257
int tlwidth, rem, tileWidth, tileHeight, endinc;
263
PixelType endmask; /* masks for reggedy bits at either end of line */
264
int nlMiddle; /* number of longwords between sides of boxes */
266
PixelType *pBase; /* pointer to start of drawable */
268
PixelType *pStartDst;
269
PixelType *pStartTile;
272
ilbmGetPixelWidthAuxDepthAndPointer(pDraw, nlwidth, auxDst, depthDst,
275
MROP_INITIALIZE(alu,~0)
277
tileHeight = pTile->drawable.height;
278
tileWidth = pTile->drawable.width;
279
tlwidth = pTile->devKind/sizeof(PixelType);
280
sizeTile = tlwidth * tileHeight;
282
xSrc = pDraw->x + ((xOff % tileWidth) - tileWidth);
283
ySrc = pDraw->y + ((yOff % tileHeight) - tileHeight);
286
saveW = pbox->x2 - pbox->x1;
287
iline = (pbox->y1 - ySrc) % tileHeight;
288
psrcT = (PixelType *) pTile->devPrivate.ptr;
289
tileLine = iline * tlwidth;
290
saveH = pbox->y2 - pbox->y1;
291
saveP = ilbmScanline(pBase, pbox->x1, pbox->y1, auxDst);
293
for (d = 0; d < depthDst; d++, psrcT += sizeTile, saveP += nlwidth) { /* @@@ NEXT PLANE @@@ */
294
if (!(planemask & (1 << d)))
299
pStartTile = psrcT + tileLine;
308
w = min(tileWidth, width);
309
if ((rem = (x - xSrc) % tileWidth) != 0) {
310
/* if we're in the middle of the tile, get
311
as many bits as will finish the span, or
312
as many as will get to the left edge of the tile,
313
or a longword worth, starting at the appropriate
316
w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
317
endinc = rem / BITMAP_SCANLINE_PAD;
319
getbits ((psrc+endinc), (rem&PIM), w, tmpsrc);
321
getbits (pdst, (x & PIM), w, tmpdst);
322
tmpsrc = DoMergeRop (tmpsrc, tmpdst);
324
putbits (tmpsrc, (x & PIM), w, pdst);
326
if ((x & PIM) + w >= PPW)
328
} else if (((x & PIM) + w) < PPW) {
329
/* doing < PPW bits is easy, and worth special-casing */
332
getbits (pdst, (x & PIM), w, tmpdst);
333
tmpsrc = DoMergeRop (tmpsrc, tmpdst);
335
putbits (tmpsrc, (x & PIM), w, pdst);
337
/* start at the left edge of the tile,
338
and put down as much as we can
340
maskbits(x, w, startmask, endmask, nlMiddle);
343
nstart = PPW - (x & PIM);
347
nend = (x + w) & PIM;
351
srcStartOver = nstart > PLST;
356
getbits (pdst, (x & PIM), nstart, tmpdst);
357
tmpsrc = DoMergeRop (tmpsrc, tmpdst);
359
putbits (tmpsrc, (x & PIM), nstart, pdst);
366
getbits (psrc, nstart, PPW, tmpsrc);
369
tmpsrc = DoMergeRop (tmpsrc, tmpdst);
372
/*putbits (tmpsrc, 0, PPW, pdst);
378
getbits (psrc, nstart, nend, tmpsrc);
381
tmpsrc = DoMergeRop (tmpsrc, tmpdst);
383
putbits (tmpsrc, 0, nend, pdst);
388
} /* while (width > 0) */
391
if (++iy >= tileHeight) {
395
pStartTile += tlwidth;
398
} /* for (d = ... ) */
404
MROP_NAME(ilbmOpaqueStippleAreaPPW)(pDraw, nbox, pbox, alu, ptile,
411
register unsigned char *rropsOS;
412
unsigned long planemask;
414
register PixelType *psrc;
415
/* pointer to bits in tile, if needed */
416
int tileHeight; /* height of the tile */
417
register PixelType srcpix;
418
int nlwidth; /* width in longwords of the drawable */
419
int w; /* width of current box */
421
register int h; /* height of current box */
422
register int nlw; /* loop version of nlwMiddle */
423
register PixelType *p; /* pointer to bits we're writing */
428
PixelType endmask; /* masks for reggedy bits at either end of line */
429
int nlwMiddle; /* number of longwords between sides of boxes */
430
int nlwExtra; /* to get from right of box to left of next span */
431
register int iy; /* index of current scanline in tile */
432
PixelType *pbits; /* pointer to start of drawable */
437
ilbmGetPixelWidthAuxDepthAndPointer(pDraw, nlwidth, auxDst, depthDst,
440
MROP_INITIALIZE(alu,~0)
442
tileHeight = ptile->drawable.height;
443
psrc = (PixelType *)(ptile->devPrivate.ptr);
446
w = pbox->x2 - pbox->x1;
447
saveH = pbox->y2 - pbox->y1;
448
saveIY = pbox->y1 % tileHeight;
449
saveP = ilbmScanline(pbits, pbox->x1, pbox->y1, auxDst);
451
if ( ((pbox->x1 & PIM) + w) < PPW) {
452
maskpartialbits(pbox->x1, w, startmask);
454
for (d = 0; d < depthDst; d++, saveP += nlwidth) { /* @@@ NEXT PLANE @@@ */
455
if (!(planemask & (1 << d)))
463
switch (rropsOS[d]) {
478
if (iy == tileHeight)
480
*p = MROP_MASK(srcpix,*p,startmask);
481
ilbmScanlineInc(p, nlwExtra);
485
maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
487
for (d = 0; d < depthDst; d++, saveP += nlwidth) { /* @@@ NEXT PLANE @@@ */
488
if (!(planemask & (1 << d)))
494
nlwExtra = auxDst - nlwMiddle;
496
if (startmask && endmask) {
499
switch (rropsOS[d]) {
514
if (iy == tileHeight)
517
*p = MROP_MASK (srcpix,*p,startmask);
520
*p = MROP_SOLID(srcpix,*p);
524
*p = MROP_MASK(srcpix,*p,endmask);
525
ilbmScanlineInc(p, nlwExtra);
527
} else if (startmask && !endmask) {
530
switch (rropsOS[d]) {
545
if (iy == tileHeight)
548
*p = MROP_MASK(srcpix,*p,startmask);
551
*p = MROP_SOLID(srcpix,*p);
554
ilbmScanlineInc(p, nlwExtra);
556
} else if (!startmask && endmask) {
558
switch (rropsOS[d]) {
573
if (iy == tileHeight)
577
*p = MROP_SOLID(srcpix,*p);
581
*p = MROP_MASK(srcpix,*p,endmask);
582
ilbmScanlineInc(p, nlwExtra);
584
} else { /* no ragged bits at either end */
586
switch (rropsOS[d]) {
601
if (iy == tileHeight)
605
*p = MROP_SOLID (srcpix,*p);
608
ilbmScanlineInc(p, nlwExtra);
611
} /* for (d = ...) */
618
MROP_NAME(ilbmOpaqueStippleArea)(pDraw, nbox, pbox, alu, pTile, xOff, yOff,
627
register unsigned char *rropsOS;
628
unsigned long planemask;
630
register PixelType *psrc;
631
/* pointer to bits in tile, if needed */
632
int nlwidth; /* width in longwords of the drawable */
634
register int h; /* height of current box */
635
register PixelType *pdst; /* pointer to bits we're writing */
636
register PixelType tmpsrc, tmpdst;
641
int w, width, x, xSrc, ySrc, srcStartOver, nend;
642
int tlwidth, rem, tileWidth, tileHeight, endinc;
648
PixelType endmask; /* masks for reggedy bits at either end of line */
649
int nlMiddle; /* number of longwords between sides of boxes */
651
PixelType *pBase; /* pointer to start of drawable */
653
PixelType *pStartDst;
654
PixelType *pStartTile;
657
ilbmGetPixelWidthAuxDepthAndPointer(pDraw, nlwidth, auxDst, depthDst,
660
MROP_INITIALIZE(alu,~0)
662
tileHeight = pTile->drawable.height;
663
tileWidth = pTile->drawable.width;
664
tlwidth = pTile->devKind/sizeof(PixelType);
666
xSrc = pDraw->x + ((xOff % tileWidth) - tileWidth);
667
ySrc = pDraw->y + ((yOff % tileHeight) - tileHeight);
670
saveW = pbox->x2 - pbox->x1;
671
iline = (pbox->y1 - ySrc) % tileHeight;
672
psrcT = (PixelType *) pTile->devPrivate.ptr;
673
tileLine = iline * tlwidth;
674
saveH = pbox->y2 - pbox->y1;
675
saveP = ilbmScanline(pBase, pbox->x1, pbox->y1, auxDst);
677
for (d = 0; d < depthDst; d++, saveP += nlwidth) { /* @@@ NEXT PLANE @@@ */
678
if (!(planemask & (1 << d)))
683
pStartTile = psrcT + tileLine;
692
w = min(tileWidth, width);
693
if ((rem = (x - xSrc) % tileWidth) != 0) {
694
/* if we're in the middle of the tile, get
695
as many bits as will finish the span, or
696
as many as will get to the left edge of the tile,
697
or a longword worth, starting at the appropriate
700
w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
701
endinc = rem / BITMAP_SCANLINE_PAD;
703
switch (rropsOS[d]) {
712
getbits ((psrc+endinc), (rem&PIM), w, tmpsrc);
716
getbits ((psrc+endinc), (rem&PIM), w, tmpsrc);
721
getbits (pdst, (x & PIM), w, tmpdst);
722
tmpsrc = DoMergeRop (tmpsrc, tmpdst);
724
putbits (tmpsrc, (x & PIM), w, pdst);
726
if ((x & PIM) + w >= PPW)
728
} else if (((x & PIM) + w) < PPW) {
729
/* doing < PPW bits is easy, and worth special-casing */
730
switch (rropsOS[d]) {
745
getbits (pdst, (x & PIM), w, tmpdst);
746
tmpsrc = DoMergeRop (tmpsrc, tmpdst);
748
putbits (tmpsrc, (x & PIM), w, pdst);
750
/* start at the left edge of the tile,
751
and put down as much as we can
753
maskbits(x, w, startmask, endmask, nlMiddle);
756
nstart = PPW - (x & PIM);
760
nend = (x + w) & PIM;
764
srcStartOver = nstart > PLST;
767
switch (rropsOS[d]) {
782
getbits (pdst, (x & PIM), nstart, tmpdst);
783
tmpsrc = DoMergeRop (tmpsrc, tmpdst);
785
putbits (tmpsrc, (x & PIM), nstart, pdst);
792
switch (rropsOS[d]) {
800
getbits (psrc, nstart, PPW, tmpsrc);
803
getbits (psrc, nstart, PPW, tmpsrc);
809
tmpsrc = DoMergeRop (tmpsrc, tmpdst);
812
/*putbits (tmpsrc, 0, PPW, pdst);
818
switch (rropsOS[d]) {
827
getbits (psrc, nstart, nend, tmpsrc);
831
getbits (psrc, nstart, nend, tmpsrc);
837
tmpsrc = DoMergeRop (tmpsrc, tmpdst);
839
putbits (tmpsrc, 0, nend, pdst);
844
} /* while (width > 0) */
847
if (++iy >= tileHeight) {
851
pStartTile += tlwidth;
854
} /* for (d = ... ) */