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

« back to all changes in this revision

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