~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to ilbm/ilbmtile.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
ImportĀ upstreamĀ versionĀ 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $XFree86$ */
 
2
/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
 
3
/***********************************************************
 
4
 
 
5
Copyright (c) 1987  X Consortium
 
6
 
 
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:
 
13
 
 
14
The above copyright notice and this permission notice shall be included in
 
15
all copies or substantial portions of the Software.
 
16
 
 
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.
 
23
 
 
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.
 
27
 
 
28
 
 
29
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
30
 
 
31
                        All Rights Reserved
 
32
 
 
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.
 
40
 
 
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
 
47
SOFTWARE.
 
48
 
 
49
******************************************************************/
 
50
/* $XConsortium: ilbmtile.c,v 5.8 94/04/17 20:28:36 dpw Exp $ */
 
51
 
 
52
/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
 
53
   to use interleaved bitplanes instead of normal bitplanes */
 
54
 
 
55
#ifdef HAVE_DIX_CONFIG_H
 
56
#include <dix-config.h>
 
57
#endif
 
58
 
 
59
#include <X11/X.h>
 
60
 
 
61
#include "windowstr.h"
 
62
#include "regionstr.h"
 
63
#include "pixmapstr.h"
 
64
#include "scrnintstr.h"
 
65
 
 
66
#include "ilbm.h"
 
67
#include "maskbits.h"
 
68
 
 
69
#include "mergerop.h"
 
70
/*
 
71
 
 
72
   the boxes are already translated.
 
73
 
 
74
   NOTE:
 
75
   iy = ++iy < tileHeight ? iy : 0
 
76
is equivalent to iy%= tileheight, and saves a division.
 
77
*/
 
78
 
 
79
/*
 
80
        tile area with a PPW bit wide pixmap
 
81
*/
 
82
void
 
83
MROP_NAME(ilbmTileAreaPPW)(pDraw, nbox, pbox, alu, ptile, planemask)
 
84
        DrawablePtr pDraw;
 
85
        int nbox;
 
86
        BoxPtr pbox;
 
87
        int alu;
 
88
        PixmapPtr ptile;
 
89
        unsigned long planemask;
 
90
{
 
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 */
 
97
        MROP_DECLARE_REG ()
 
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 */
 
101
        int auxDst;
 
102
        int depthDst;
 
103
        int tlwidth;
 
104
        register int d;
 
105
        PixelType startmask;
 
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 */
 
111
        PixelType *saveP;
 
112
        PixelType *pSaveSrc;
 
113
        int saveH;
 
114
        int saveIY;
 
115
 
 
116
        ilbmGetPixelWidthAuxDepthAndPointer(pDraw, nlwidth, auxDst, depthDst,
 
117
                                                                                                        pbits);
 
118
 
 
119
        MROP_INITIALIZE(alu,~0)
 
120
 
 
121
        tileHeight = ptile->drawable.height;
 
122
        tlwidth = ptile->devKind/sizeof(PixelType);
 
123
        pSaveSrc = (PixelType *)(ptile->devPrivate.ptr);
 
124
 
 
125
        while (nbox--) {
 
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);
 
130
                psrc = pSaveSrc;
 
131
 
 
132
                if (((pbox->x1 & PIM) + w) < PPW) {
 
133
                        maskpartialbits(pbox->x1, w, startmask);
 
134
                        nlwExtra = auxDst;
 
135
                        for (d = 0; d < depthDst; d++, saveP += nlwidth, psrc += tileHeight) {  /* @@@ NEXT PLANE @@@ */
 
136
                                if (!(planemask & (1 << d)))
 
137
                                        continue;
 
138
 
 
139
                                p = saveP;
 
140
                                h = saveH;
 
141
                                iy = saveIY;
 
142
 
 
143
                                while (h--) {
 
144
                                        srcpix = psrc[iy];
 
145
                                        iy++;
 
146
                                        if (iy == tileHeight)
 
147
                                                iy = 0;
 
148
                                        *p = MROP_MASK(srcpix,*p,startmask);
 
149
                                        ilbmScanlineInc(p, nlwExtra);
 
150
                                }
 
151
                        }
 
152
                } else {
 
153
                        maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
 
154
 
 
155
                        for (d = 0; d < depthDst; d++, saveP += nlwidth, psrc += tileHeight) {  /* @@@ NEXT PLANE @@@ */
 
156
                                if (!(planemask & (1 << d)))
 
157
                                        continue;
 
158
 
 
159
                                p = saveP;
 
160
                                h = saveH;
 
161
                                iy = saveIY;
 
162
                                nlwExtra = auxDst - nlwMiddle;
 
163
 
 
164
                                if (startmask && endmask) {
 
165
                                        nlwExtra -= 1;
 
166
                                        while (h--) {
 
167
                                                srcpix = psrc[iy];
 
168
                                                iy++;
 
169
                                                if (iy == tileHeight)
 
170
                                                        iy = 0;
 
171
                                                nlw = nlwMiddle;
 
172
                                                *p = MROP_MASK (srcpix,*p,startmask);
 
173
                                                p++;
 
174
                                                while (nlw--) {
 
175
                                                        *p = MROP_SOLID(srcpix,*p);
 
176
                                                        p++;
 
177
                                                }
 
178
 
 
179
                                                *p = MROP_MASK(srcpix,*p,endmask);
 
180
                                                ilbmScanlineInc(p, nlwExtra);
 
181
                                        }
 
182
                                } else if (startmask && !endmask) {
 
183
                                        nlwExtra -= 1;
 
184
                                        while (h--) {
 
185
                                                srcpix = psrc[iy];
 
186
                                                iy++;
 
187
                                                if (iy == tileHeight)
 
188
                                                        iy = 0;
 
189
                                                nlw = nlwMiddle;
 
190
                                                *p = MROP_MASK(srcpix,*p,startmask);
 
191
                                                p++;
 
192
                                                while (nlw--) {
 
193
                                                        *p = MROP_SOLID(srcpix,*p);
 
194
                                                        p++;
 
195
                                                }
 
196
                                                ilbmScanlineInc(p, nlwExtra);
 
197
                                        }
 
198
                                } else if (!startmask && endmask) {
 
199
                                        while (h--) {
 
200
                                                srcpix = psrc[iy];
 
201
                                                iy++;
 
202
                                                if (iy == tileHeight)
 
203
                                                        iy = 0;
 
204
                                                nlw = nlwMiddle;
 
205
                                                while (nlw--) {
 
206
                                                        *p = MROP_SOLID(srcpix,*p);
 
207
                                                        p++;
 
208
                                                }
 
209
 
 
210
                                                *p = MROP_MASK(srcpix,*p,endmask);
 
211
                                                ilbmScanlineInc(p, nlwExtra);
 
212
                                        }
 
213
                                } else { /* no ragged bits at either end */
 
214
                                        while (h--) {
 
215
                                                srcpix = psrc[iy];
 
216
                                                iy++;
 
217
                                                if (iy == tileHeight)
 
218
                                                        iy = 0;
 
219
                                                nlw = nlwMiddle;
 
220
                                                while (nlw--) {
 
221
                                                        *p = MROP_SOLID (srcpix,*p);
 
222
                                                        p++;
 
223
                                                }
 
224
                                                ilbmScanlineInc(p, nlwExtra);
 
225
                                        }
 
226
                                }
 
227
                        } /* for (d = ...) */
 
228
                }
 
229
                pbox++;
 
230
        }
 
231
}
 
232
 
 
233
void
 
234
MROP_NAME(ilbmTileArea)(pDraw, nbox, pbox, alu, pTile, xOff, yOff, planemask)
 
235
        DrawablePtr pDraw;
 
236
        int nbox;
 
237
        BoxPtr pbox;
 
238
        int alu;
 
239
        PixmapPtr pTile;
 
240
        int xOff;
 
241
        int yOff;
 
242
        unsigned long planemask;
 
243
{
 
244
        register PixelType *psrc;
 
245
                                                /* pointer to bits in tile, if needed */
 
246
        int nlwidth;            /* width in longwords of the drawable */
 
247
        MROP_DECLARE_REG ()
 
248
        register int h;         /* height of current box */
 
249
        register PixelType *pdst;               /* pointer to bits we're writing */
 
250
        register PixelType tmpsrc, tmpdst;
 
251
        int auxDst;
 
252
        int depthDst;
 
253
        int sizeTile;
 
254
        int tileLine;
 
255
        int                             iline;
 
256
        int                             w, width, x, xSrc, ySrc, srcStartOver, nend;
 
257
        int             tlwidth, rem, tileWidth, tileHeight, endinc;
 
258
        int                             saveW;
 
259
        PixelType   *psrcT;
 
260
        int d;
 
261
        int nstart;
 
262
        PixelType startmask;
 
263
        PixelType endmask;              /* masks for reggedy bits at either end of line */
 
264
        int nlMiddle;           /* number of longwords between sides of boxes */
 
265
        int iy;
 
266
        PixelType *pBase;               /* pointer to start of drawable */
 
267
        PixelType *saveP;
 
268
        PixelType *pStartDst;
 
269
        PixelType *pStartTile;
 
270
        int saveH;
 
271
 
 
272
        ilbmGetPixelWidthAuxDepthAndPointer(pDraw, nlwidth, auxDst, depthDst,
 
273
                                                                                                        pBase);
 
274
 
 
275
        MROP_INITIALIZE(alu,~0)
 
276
 
 
277
        tileHeight = pTile->drawable.height;
 
278
        tileWidth = pTile->drawable.width;
 
279
        tlwidth = pTile->devKind/sizeof(PixelType);
 
280
        sizeTile = tlwidth * tileHeight;
 
281
 
 
282
        xSrc = pDraw->x + ((xOff % tileWidth) - tileWidth);
 
283
        ySrc = pDraw->y + ((yOff % tileHeight) - tileHeight);
 
284
 
 
285
        while (nbox--) {
 
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);
 
292
 
 
293
                for (d = 0; d < depthDst; d++, psrcT += sizeTile, saveP += nlwidth) {   /* @@@ NEXT PLANE @@@ */
 
294
                        if (!(planemask & (1 << d)))
 
295
                                continue;
 
296
 
 
297
                        h = saveH;
 
298
                        pStartDst = saveP;
 
299
                        pStartTile = psrcT + tileLine;
 
300
                        iy = iline;
 
301
 
 
302
                        while (h--) {
 
303
                                x = pbox->x1;
 
304
                                width = saveW;
 
305
                                pdst = pStartDst;
 
306
                                while (width > 0) {
 
307
                                        psrc = pStartTile;
 
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
 
314
                                                   offset in the tile.
 
315
                                                */
 
316
                                                w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
 
317
                                                endinc = rem / BITMAP_SCANLINE_PAD;
 
318
 
 
319
                                                getbits ((psrc+endinc), (rem&PIM), w, tmpsrc);
 
320
#if (MROP) != Mcopy
 
321
                                                getbits (pdst, (x & PIM), w, tmpdst);
 
322
                                                tmpsrc = DoMergeRop (tmpsrc, tmpdst);
 
323
#endif
 
324
                                                putbits (tmpsrc, (x & PIM), w, pdst);
 
325
 
 
326
                                                if ((x & PIM) + w >= PPW)
 
327
                                                        pdst++;
 
328
                                        } else if (((x & PIM) + w) < PPW) {
 
329
                                                /* doing < PPW bits is easy, and worth special-casing */
 
330
                                                tmpsrc = *psrc;
 
331
#if (MROP) != Mcopy
 
332
                                                getbits (pdst, (x & PIM), w, tmpdst);
 
333
                                                tmpsrc = DoMergeRop (tmpsrc, tmpdst);
 
334
#endif
 
335
                                                putbits (tmpsrc, (x & PIM), w, pdst);
 
336
                                        } else {
 
337
                                                /* start at the left edge of the tile,
 
338
                                                   and put down as much as we can
 
339
                                                */
 
340
                                                maskbits(x, w, startmask, endmask, nlMiddle);
 
341
 
 
342
                                                if (startmask)
 
343
                                                        nstart = PPW - (x & PIM);
 
344
                                                else
 
345
                                                        nstart = 0;
 
346
                                                if (endmask)
 
347
                                                        nend = (x + w)  & PIM;
 
348
                                                else
 
349
                                                        nend = 0;
 
350
 
 
351
                                                srcStartOver = nstart > PLST;
 
352
 
 
353
                                                if (startmask) {
 
354
                                                        tmpsrc = *psrc;
 
355
#if (MROP) != Mcopy
 
356
                                                        getbits (pdst, (x & PIM), nstart, tmpdst);
 
357
                                                        tmpsrc = DoMergeRop (tmpsrc, tmpdst);
 
358
#endif
 
359
                                                        putbits (tmpsrc, (x & PIM), nstart, pdst);
 
360
                                                        pdst++;
 
361
                                                        if (srcStartOver)
 
362
                                                                psrc++;
 
363
                                                }
 
364
 
 
365
                                                while (nlMiddle--) {
 
366
                                                        getbits (psrc, nstart, PPW, tmpsrc);
 
367
#if (MROP) != Mcopy
 
368
                                                        tmpdst = *pdst;
 
369
                                                        tmpsrc = DoMergeRop (tmpsrc, tmpdst);
 
370
#endif
 
371
                                                        *pdst++ = tmpsrc;
 
372
                                                        /*putbits (tmpsrc, 0, PPW, pdst);
 
373
                                                        pdst++;*/
 
374
                                                        psrc++;
 
375
                                                }
 
376
 
 
377
                                                if (endmask) {
 
378
                                                        getbits (psrc, nstart, nend, tmpsrc);
 
379
#if (MROP) != Mcopy
 
380
                                                        tmpdst = *pdst;
 
381
                                                        tmpsrc = DoMergeRop (tmpsrc, tmpdst);
 
382
#endif
 
383
                                                        putbits (tmpsrc, 0, nend, pdst);
 
384
                                                }
 
385
                                         }
 
386
                                         x += w;
 
387
                                         width -= w;
 
388
                                } /* while (width > 0) */
 
389
 
 
390
                                pStartDst += auxDst;
 
391
                                if (++iy >= tileHeight) {
 
392
                                        iy = 0;
 
393
                                        pStartTile = psrcT;
 
394
                                } else
 
395
                                        pStartTile += tlwidth;
 
396
 
 
397
                        } /* while (h) */
 
398
                } /* for (d = ... ) */
 
399
                pbox++;
 
400
        } /* for each box */
 
401
}
 
402
 
 
403
void
 
404
MROP_NAME(ilbmOpaqueStippleAreaPPW)(pDraw, nbox, pbox, alu, ptile,
 
405
                                                                   rropsOS, planemask)
 
406
        DrawablePtr pDraw;
 
407
        int nbox;
 
408
        BoxPtr pbox;
 
409
        int alu;
 
410
        PixmapPtr ptile;
 
411
        register unsigned char *rropsOS;
 
412
        unsigned long planemask;
 
413
{
 
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 */
 
420
        MROP_DECLARE_REG ()
 
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 */
 
424
        int auxDst;
 
425
        int depthDst;
 
426
        register int d;
 
427
        PixelType startmask;
 
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 */
 
433
        PixelType *saveP;
 
434
        int saveH;
 
435
        int saveIY;
 
436
 
 
437
        ilbmGetPixelWidthAuxDepthAndPointer(pDraw, nlwidth, auxDst, depthDst,
 
438
                                                                                                        pbits);
 
439
 
 
440
        MROP_INITIALIZE(alu,~0)
 
441
 
 
442
        tileHeight = ptile->drawable.height;
 
443
        psrc = (PixelType *)(ptile->devPrivate.ptr);
 
444
 
 
445
        while (nbox--) {
 
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);
 
450
 
 
451
                if ( ((pbox->x1 & PIM) + w) < PPW) {
 
452
                        maskpartialbits(pbox->x1, w, startmask);
 
453
                        nlwExtra = auxDst;
 
454
                        for (d = 0; d < depthDst; d++, saveP += nlwidth) {      /* @@@ NEXT PLANE @@@ */
 
455
                                if (!(planemask & (1 << d)))
 
456
                                        continue;
 
457
 
 
458
                                p = saveP;
 
459
                                h = saveH;
 
460
                                iy = saveIY;
 
461
 
 
462
                                while (h--) {
 
463
                                        switch (rropsOS[d]) {
 
464
                                                case RROP_BLACK:
 
465
                                                        srcpix = 0;
 
466
                                                        break;
 
467
                                                case RROP_WHITE:
 
468
                                                        srcpix = ~0;
 
469
                                                        break;
 
470
                                                case RROP_COPY:
 
471
                                                        srcpix = psrc[iy];
 
472
                                                        break;
 
473
                                                case RROP_INVERT:
 
474
                                                        srcpix = ~psrc[iy];
 
475
                                                        break;
 
476
                                        }
 
477
                                        iy++;
 
478
                                        if (iy == tileHeight)
 
479
                                                iy = 0;
 
480
                                        *p = MROP_MASK(srcpix,*p,startmask);
 
481
                                        ilbmScanlineInc(p, nlwExtra);
 
482
                                }
 
483
                        }
 
484
                } else {
 
485
                        maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
 
486
 
 
487
                        for (d = 0; d < depthDst; d++, saveP += nlwidth) {      /* @@@ NEXT PLANE @@@ */
 
488
                                if (!(planemask & (1 << d)))
 
489
                                        continue;
 
490
 
 
491
                                p = saveP;
 
492
                                h = saveH;
 
493
                                iy = saveIY;
 
494
                                nlwExtra = auxDst - nlwMiddle;
 
495
 
 
496
                                if (startmask && endmask) {
 
497
                                        nlwExtra -= 1;
 
498
                                        while (h--) {
 
499
                                                switch (rropsOS[d]) {
 
500
                                                        case RROP_BLACK:
 
501
                                                                srcpix = 0;
 
502
                                                                break;
 
503
                                                        case RROP_WHITE:
 
504
                                                                srcpix = ~0;
 
505
                                                                break;
 
506
                                                        case RROP_COPY:
 
507
                                                                srcpix = psrc[iy];
 
508
                                                                break;
 
509
                                                        case RROP_INVERT:
 
510
                                                                srcpix = ~psrc[iy];
 
511
                                                                break;
 
512
                                                }
 
513
                                                iy++;
 
514
                                                if (iy == tileHeight)
 
515
                                                        iy = 0;
 
516
                                                nlw = nlwMiddle;
 
517
                                                *p = MROP_MASK (srcpix,*p,startmask);
 
518
                                                p++;
 
519
                                                while (nlw--) {
 
520
                                                        *p = MROP_SOLID(srcpix,*p);
 
521
                                                        p++;
 
522
                                                }
 
523
 
 
524
                                                *p = MROP_MASK(srcpix,*p,endmask);
 
525
                                                ilbmScanlineInc(p, nlwExtra);
 
526
                                        }
 
527
                                } else if (startmask && !endmask) {
 
528
                                        nlwExtra -= 1;
 
529
                                        while (h--) {
 
530
                                                switch (rropsOS[d]) {
 
531
                                                        case RROP_BLACK:
 
532
                                                                srcpix = 0;
 
533
                                                                break;
 
534
                                                        case RROP_WHITE:
 
535
                                                                srcpix = ~0;
 
536
                                                                break;
 
537
                                                        case RROP_COPY:
 
538
                                                                srcpix = psrc[iy];
 
539
                                                                break;
 
540
                                                        case RROP_INVERT:
 
541
                                                                srcpix = ~psrc[iy];
 
542
                                                                break;
 
543
                                                }
 
544
                                                iy++;
 
545
                                                if (iy == tileHeight)
 
546
                                                        iy = 0;
 
547
                                                nlw = nlwMiddle;
 
548
                                                *p = MROP_MASK(srcpix,*p,startmask);
 
549
                                                p++;
 
550
                                                while (nlw--) {
 
551
                                                        *p = MROP_SOLID(srcpix,*p);
 
552
                                                        p++;
 
553
                                                }
 
554
                                                ilbmScanlineInc(p, nlwExtra);
 
555
                                        }
 
556
                                } else if (!startmask && endmask) {
 
557
                                        while (h--) {
 
558
                                                switch (rropsOS[d]) {
 
559
                                                        case RROP_BLACK:
 
560
                                                                srcpix = 0;
 
561
                                                                break;
 
562
                                                        case RROP_WHITE:
 
563
                                                                srcpix = ~0;
 
564
                                                                break;
 
565
                                                        case RROP_COPY:
 
566
                                                                srcpix = psrc[iy];
 
567
                                                                break;
 
568
                                                        case RROP_INVERT:
 
569
                                                                srcpix = ~psrc[iy];
 
570
                                                                break;
 
571
                                                }
 
572
                                                iy++;
 
573
                                                if (iy == tileHeight)
 
574
                                                        iy = 0;
 
575
                                                nlw = nlwMiddle;
 
576
                                                while (nlw--) {
 
577
                                                        *p = MROP_SOLID(srcpix,*p);
 
578
                                                        p++;
 
579
                                                }
 
580
 
 
581
                                                *p = MROP_MASK(srcpix,*p,endmask);
 
582
                                                ilbmScanlineInc(p, nlwExtra);
 
583
                                        }
 
584
                                } else { /* no ragged bits at either end */
 
585
                                        while (h--) {
 
586
                                                switch (rropsOS[d]) {
 
587
                                                        case RROP_BLACK:
 
588
                                                                srcpix = 0;
 
589
                                                                break;
 
590
                                                        case RROP_WHITE:
 
591
                                                                srcpix = ~0;
 
592
                                                                break;
 
593
                                                        case RROP_COPY:
 
594
                                                                srcpix = psrc[iy];
 
595
                                                                break;
 
596
                                                        case RROP_INVERT:
 
597
                                                                srcpix = ~psrc[iy];
 
598
                                                                break;
 
599
                                                }
 
600
                                                iy++;
 
601
                                                if (iy == tileHeight)
 
602
                                                        iy = 0;
 
603
                                                nlw = nlwMiddle;
 
604
                                                while (nlw--) {
 
605
                                                        *p = MROP_SOLID (srcpix,*p);
 
606
                                                        p++;
 
607
                                                }
 
608
                                                ilbmScanlineInc(p, nlwExtra);
 
609
                                        }
 
610
                                }
 
611
                        } /* for (d = ...) */
 
612
                }
 
613
                pbox++;
 
614
        }
 
615
}
 
616
 
 
617
void
 
618
MROP_NAME(ilbmOpaqueStippleArea)(pDraw, nbox, pbox, alu, pTile, xOff, yOff,
 
619
                                                                rropsOS, planemask)
 
620
        DrawablePtr pDraw;
 
621
        int nbox;
 
622
        BoxPtr pbox;
 
623
        int alu;
 
624
        PixmapPtr pTile;
 
625
        int xOff;
 
626
        int yOff;
 
627
        register unsigned char *rropsOS;
 
628
        unsigned long planemask;
 
629
{
 
630
        register PixelType *psrc;
 
631
                                                /* pointer to bits in tile, if needed */
 
632
        int nlwidth;            /* width in longwords of the drawable */
 
633
        MROP_DECLARE_REG ()
 
634
        register int h;         /* height of current box */
 
635
        register PixelType *pdst;               /* pointer to bits we're writing */
 
636
        register PixelType tmpsrc, tmpdst;
 
637
        int auxDst;
 
638
        int depthDst;
 
639
        int tileLine;
 
640
        int                             iline;
 
641
        int                             w, width, x, xSrc, ySrc, srcStartOver, nend;
 
642
        int             tlwidth, rem, tileWidth, tileHeight, endinc;
 
643
        int                             saveW;
 
644
        PixelType   *psrcT;
 
645
        int d;
 
646
        int nstart;
 
647
        PixelType startmask;
 
648
        PixelType endmask;              /* masks for reggedy bits at either end of line */
 
649
        int nlMiddle;           /* number of longwords between sides of boxes */
 
650
        int iy;
 
651
        PixelType *pBase;               /* pointer to start of drawable */
 
652
        PixelType *saveP;
 
653
        PixelType *pStartDst;
 
654
        PixelType *pStartTile;
 
655
        int saveH;
 
656
 
 
657
        ilbmGetPixelWidthAuxDepthAndPointer(pDraw, nlwidth, auxDst, depthDst,
 
658
                                                                                                        pBase);
 
659
 
 
660
        MROP_INITIALIZE(alu,~0)
 
661
 
 
662
        tileHeight = pTile->drawable.height;
 
663
        tileWidth = pTile->drawable.width;
 
664
        tlwidth = pTile->devKind/sizeof(PixelType);
 
665
 
 
666
        xSrc = pDraw->x + ((xOff % tileWidth) - tileWidth);
 
667
        ySrc = pDraw->y + ((yOff % tileHeight) - tileHeight);
 
668
 
 
669
        while (nbox--) {
 
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);
 
676
 
 
677
                for (d = 0; d < depthDst; d++, saveP += nlwidth) {      /* @@@ NEXT PLANE @@@ */
 
678
                        if (!(planemask & (1 << d)))
 
679
                                continue;
 
680
 
 
681
                        h = saveH;
 
682
                        pStartDst = saveP;
 
683
                        pStartTile = psrcT + tileLine;
 
684
                        iy = iline;
 
685
 
 
686
                        while (h--) {
 
687
                                x = pbox->x1;
 
688
                                width = saveW;
 
689
                                pdst = pStartDst;
 
690
                                while (width > 0) {
 
691
                                        psrc = pStartTile;
 
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
 
698
                                                   offset in the tile.
 
699
                                                */
 
700
                                                w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
 
701
                                                endinc = rem / BITMAP_SCANLINE_PAD;
 
702
 
 
703
                                                switch (rropsOS[d]) {
 
704
                                                        case RROP_BLACK:
 
705
                                                                tmpsrc = 0;
 
706
                                                                break;
 
707
                                                        case RROP_WHITE:
 
708
                                                                tmpsrc = ~0;
 
709
                                                                break;
 
710
 
 
711
                                                        case RROP_COPY:
 
712
                                                                getbits ((psrc+endinc), (rem&PIM), w, tmpsrc);
 
713
                                                                break;
 
714
 
 
715
                                                        case RROP_INVERT:
 
716
                                                                getbits ((psrc+endinc), (rem&PIM), w, tmpsrc);
 
717
                                                                tmpsrc = ~tmpsrc;
 
718
                                                                break;
 
719
                                                }
 
720
#if (MROP) != Mcopy
 
721
                                                getbits (pdst, (x & PIM), w, tmpdst);
 
722
                                                tmpsrc = DoMergeRop (tmpsrc, tmpdst);
 
723
#endif
 
724
                                                putbits (tmpsrc, (x & PIM), w, pdst);
 
725
 
 
726
                                                if ((x & PIM) + w >= PPW)
 
727
                                                        pdst++;
 
728
                                        } else if (((x & PIM) + w) < PPW) {
 
729
                                                /* doing < PPW bits is easy, and worth special-casing */
 
730
                                                switch (rropsOS[d]) {
 
731
                                                        case RROP_BLACK:
 
732
                                                                tmpsrc = 0;
 
733
                                                                break;
 
734
                                                        case RROP_WHITE:
 
735
                                                                tmpsrc = ~0;
 
736
                                                                break;
 
737
                                                        case RROP_COPY:
 
738
                                                                tmpsrc = *psrc;
 
739
                                                                break;
 
740
                                                        case RROP_INVERT:
 
741
                                                                tmpsrc = ~*psrc;
 
742
                                                                break;
 
743
                                                }
 
744
#if (MROP) != Mcopy
 
745
                                                getbits (pdst, (x & PIM), w, tmpdst);
 
746
                                                tmpsrc = DoMergeRop (tmpsrc, tmpdst);
 
747
#endif
 
748
                                                putbits (tmpsrc, (x & PIM), w, pdst);
 
749
                                        } else {
 
750
                                                /* start at the left edge of the tile,
 
751
                                                   and put down as much as we can
 
752
                                                */
 
753
                                                maskbits(x, w, startmask, endmask, nlMiddle);
 
754
 
 
755
                                                if (startmask)
 
756
                                                        nstart = PPW - (x & PIM);
 
757
                                                else
 
758
                                                        nstart = 0;
 
759
                                                if (endmask)
 
760
                                                        nend = (x + w)  & PIM;
 
761
                                                else
 
762
                                                        nend = 0;
 
763
 
 
764
                                                srcStartOver = nstart > PLST;
 
765
 
 
766
                                                if (startmask) {
 
767
                                                switch (rropsOS[d]) {
 
768
                                                        case RROP_BLACK:
 
769
                                                                tmpsrc = 0;
 
770
                                                                break;
 
771
                                                        case RROP_WHITE:
 
772
                                                                tmpsrc = ~0;
 
773
                                                                break;
 
774
                                                        case RROP_COPY:
 
775
                                                                tmpsrc = *psrc;
 
776
                                                                break;
 
777
                                                        case RROP_INVERT:
 
778
                                                                tmpsrc = ~*psrc;
 
779
                                                                break;
 
780
                                                }
 
781
#if (MROP) != Mcopy
 
782
                                                        getbits (pdst, (x & PIM), nstart, tmpdst);
 
783
                                                        tmpsrc = DoMergeRop (tmpsrc, tmpdst);
 
784
#endif
 
785
                                                        putbits (tmpsrc, (x & PIM), nstart, pdst);
 
786
                                                        pdst++;
 
787
                                                        if (srcStartOver)
 
788
                                                                psrc++;
 
789
                                                }
 
790
 
 
791
                                                while (nlMiddle--) {
 
792
                                                switch (rropsOS[d]) {
 
793
                                                        case RROP_BLACK:
 
794
                                                                tmpsrc = 0;
 
795
                                                                break;
 
796
                                                        case RROP_WHITE:
 
797
                                                                tmpsrc = ~0;
 
798
                                                                break;
 
799
                                                        case RROP_COPY:
 
800
                                                                getbits (psrc, nstart, PPW, tmpsrc);
 
801
                                                                break;
 
802
                                                        case RROP_INVERT:
 
803
                                                                getbits (psrc, nstart, PPW, tmpsrc);
 
804
                                                                tmpsrc = ~tmpsrc;
 
805
                                                                break;
 
806
                                                }
 
807
#if (MROP) != Mcopy
 
808
                                                        tmpdst = *pdst;
 
809
                                                        tmpsrc = DoMergeRop (tmpsrc, tmpdst);
 
810
#endif
 
811
                                                        *pdst++ = tmpsrc;
 
812
                                                        /*putbits (tmpsrc, 0, PPW, pdst);
 
813
                                                        pdst++; */
 
814
                                                        psrc++;
 
815
                                                }
 
816
 
 
817
                                                if (endmask) {
 
818
                                                switch (rropsOS[d]) {
 
819
                                                        case RROP_BLACK:
 
820
                                                                tmpsrc = 0;
 
821
                                                                break;
 
822
                                                        case RROP_WHITE:
 
823
                                                                tmpsrc = ~0;
 
824
                                                                break;
 
825
 
 
826
                                                        case RROP_COPY:
 
827
                                                                getbits (psrc, nstart, nend, tmpsrc);
 
828
                                                                break;
 
829
 
 
830
                                                        case RROP_INVERT:
 
831
                                                                getbits (psrc, nstart, nend, tmpsrc);
 
832
                                                                tmpsrc = ~tmpsrc;
 
833
                                                                break;
 
834
                                                }
 
835
#if (MROP) != Mcopy
 
836
                                                        tmpdst = *pdst;
 
837
                                                        tmpsrc = DoMergeRop (tmpsrc, tmpdst);
 
838
#endif
 
839
                                                        putbits (tmpsrc, 0, nend, pdst);
 
840
                                                }
 
841
                                         }
 
842
                                         x += w;
 
843
                                         width -= w;
 
844
                                } /* while (width > 0) */
 
845
 
 
846
                                pStartDst += auxDst;
 
847
                                if (++iy >= tileHeight) {
 
848
                                        iy = 0;
 
849
                                        pStartTile = psrcT;
 
850
                                } else
 
851
                                        pStartTile += tlwidth;
 
852
 
 
853
                        } /* while (h) */
 
854
                } /* for (d = ... ) */
 
855
                pbox++;
 
856
        } /* for each box */
 
857
}