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

« back to all changes in this revision

Viewing changes to cfb/cfbfillsp.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/cfb/cfbfillsp.c,v 3.7tsi Exp $ */
 
2
/************************************************************
 
3
Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
 
4
 
 
5
                    All Rights Reserved
 
6
 
 
7
Permission  to  use,  copy,  modify,  and  distribute   this
 
8
software  and  its documentation for any purpose and without
 
9
fee is hereby granted, provided that the above copyright no-
 
10
tice  appear  in all copies and that both that copyright no-
 
11
tice and this permission notice appear in  supporting  docu-
 
12
mentation,  and  that the names of Sun or The Open Group
 
13
not be used in advertising or publicity pertaining to 
 
14
distribution  of  the software  without specific prior 
 
15
written permission. Sun and The Open Group make no 
 
16
representations about the suitability of this software for 
 
17
any purpose. It is provided "as is" without any express or 
 
18
implied warranty.
 
19
 
 
20
SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
 
21
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
 
22
NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
 
23
ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 
24
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
 
25
PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
 
26
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 
27
THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
28
 
 
29
********************************************************/
 
30
 
 
31
/***********************************************************
 
32
 
 
33
Copyright 1987, 1998  The Open Group
 
34
 
 
35
Permission to use, copy, modify, distribute, and sell this software and its
 
36
documentation for any purpose is hereby granted without fee, provided that
 
37
the above copyright notice appear in all copies and that both that
 
38
copyright notice and this permission notice appear in supporting
 
39
documentation.
 
40
 
 
41
The above copyright notice and this permission notice shall be included in
 
42
all copies or substantial portions of the Software.
 
43
 
 
44
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
45
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
46
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
47
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
48
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
49
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
50
 
 
51
Except as contained in this notice, the name of The Open Group shall not be
 
52
used in advertising or otherwise to promote the sale, use or other dealings
 
53
in this Software without prior written authorization from The Open Group.
 
54
 
 
55
 
 
56
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
57
 
 
58
                        All Rights Reserved
 
59
 
 
60
Permission to use, copy, modify, and distribute this software and its 
 
61
documentation for any purpose and without fee is hereby granted, 
 
62
provided that the above copyright notice appear in all copies and that
 
63
both that copyright notice and this permission notice appear in 
 
64
supporting documentation, and that the name of Digital not be
 
65
used in advertising or publicity pertaining to distribution of the
 
66
software without specific, written prior permission.  
 
67
 
 
68
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 
69
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 
70
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 
71
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 
72
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 
73
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 
74
SOFTWARE.
 
75
 
 
76
******************************************************************/
 
77
 
 
78
/* $Xorg: cfbfillsp.c,v 1.4 2001/02/09 02:04:37 xorgcvs Exp $ */
 
79
 
 
80
#ifdef HAVE_DIX_CONFIG_H
 
81
#include <dix-config.h>
 
82
#endif
 
83
 
 
84
#include <X11/X.h>
 
85
#include <X11/Xmd.h>
 
86
#include "servermd.h"
 
87
#include "gcstruct.h"
 
88
#include "window.h"
 
89
#include "pixmapstr.h"
 
90
#include "scrnintstr.h"
 
91
#include "windowstr.h"
 
92
 
 
93
#include "cfb.h"
 
94
#include "cfbmskbits.h"
 
95
 
 
96
#include "mergerop.h"
 
97
 
 
98
#if PSZ == 8
 
99
#include "cfb8bit.h"
 
100
#endif
 
101
 
 
102
#define MFB_CONSTS_ONLY
 
103
#include "maskbits.h"
 
104
 
 
105
#include "mi.h"
 
106
#include "mispans.h"
 
107
 
 
108
/* scanline filling for color frame buffer
 
109
   written by drewry, oct 1986 modified by smarks
 
110
   changes for compatibility with Little-endian systems Jul 1987; MIT:yba.
 
111
 
 
112
   these routines all clip.  they assume that anything that has called
 
113
them has already translated the points (i.e. pGC->miTranslate is
 
114
non-zero, which is howit gets set in cfbCreateGC().)
 
115
 
 
116
   the number of new scnalines created by clipping ==
 
117
MaxRectsPerBand * nSpans.
 
118
 
 
119
    FillSolid is overloaded to be used for OpaqueStipple as well,
 
120
if fgPixel == bgPixel.  
 
121
Note that for solids, PrivGC.rop == PrivGC.ropOpStip
 
122
 
 
123
 
 
124
    FillTiled is overloaded to be used for OpaqueStipple, if
 
125
fgPixel != bgPixel.  based on the fill style, it uses
 
126
{RotatedTile, gc.alu} or {RotatedStipple, PrivGC.ropOpStip}
 
127
*/
 
128
 
 
129
#ifdef  notdef
 
130
#include        <stdio.h>
 
131
static
 
132
dumpspans(n, ppt, pwidth)
 
133
    int n;
 
134
    DDXPointPtr ppt;
 
135
    int *pwidth;
 
136
{
 
137
    fprintf(stderr,"%d spans\n", n);
 
138
    while (n--) {
 
139
        fprintf(stderr, "[%d,%d] %d\n", ppt->x, ppt->y, *pwidth);
 
140
        ppt++;
 
141
        pwidth++;
 
142
    }
 
143
    fprintf(stderr, "\n");
 
144
}
 
145
#endif
 
146
 
 
147
/* Fill spans with tiles that aren't 32 bits wide */
 
148
void
 
149
cfbUnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
 
150
DrawablePtr pDrawable;
 
151
GC              *pGC;
 
152
int             nInit;          /* number of spans to fill */
 
153
DDXPointPtr pptInit;            /* pointer to list of start points */
 
154
int *pwidthInit;                /* pointer to list of n widths */
 
155
int fSorted;
 
156
{
 
157
    int n;                      /* number of spans to fill */
 
158
    register DDXPointPtr ppt;   /* pointer to list of start points */
 
159
    register int *pwidth;       /* pointer to list of n widths */
 
160
    void    (*fill)(DrawablePtr, int, DDXPointPtr, int *, PixmapPtr, int, int, int, unsigned long);
 
161
    int xrot, yrot;
 
162
 
 
163
    if (!(pGC->planemask))
 
164
        return;
 
165
 
 
166
#if PSZ == 24
 
167
    if (pGC->tile.pixmap->drawable.width & 3)
 
168
#else
 
169
    if (pGC->tile.pixmap->drawable.width & PIM)
 
170
#endif
 
171
    {
 
172
        fill = cfbFillSpanTileOddGeneral;
 
173
        if ((pGC->planemask & PMSK) == PMSK)
 
174
        {
 
175
            if (pGC->alu == GXcopy)
 
176
                fill = cfbFillSpanTileOddCopy;
 
177
        }
 
178
    }
 
179
    else
 
180
    {
 
181
        fill = cfbFillSpanTile32sGeneral;
 
182
        if ((pGC->planemask & PMSK) == PMSK)
 
183
        {
 
184
            if (pGC->alu == GXcopy)
 
185
                fill = cfbFillSpanTile32sCopy;
 
186
        }
 
187
    }
 
188
    n = nInit * miFindMaxBand( cfbGetCompositeClip(pGC) );
 
189
    if ( n == 0 )
 
190
        return;
 
191
    pwidth = (int *)ALLOCATE_LOCAL(n * sizeof(int));
 
192
    ppt = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
 
193
    if(!ppt || !pwidth)
 
194
    {
 
195
        if (ppt) DEALLOCATE_LOCAL(ppt);
 
196
        if (pwidth) DEALLOCATE_LOCAL(pwidth);
 
197
        return;
 
198
    }
 
199
    n = miClipSpans( cfbGetCompositeClip(pGC),
 
200
                     pptInit, pwidthInit, nInit, 
 
201
                     ppt, pwidth, fSorted);
 
202
 
 
203
    xrot = pDrawable->x + pGC->patOrg.x;
 
204
    yrot = pDrawable->y + pGC->patOrg.y;
 
205
 
 
206
    (*fill) (pDrawable, n, ppt, pwidth, pGC->tile.pixmap, xrot, yrot, pGC->alu, pGC->planemask);
 
207
 
 
208
    DEALLOCATE_LOCAL(ppt);
 
209
    DEALLOCATE_LOCAL(pwidth);
 
210
}
 
211
 
 
212
#if PSZ == 8
 
213
 
 
214
void
 
215
cfbUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
 
216
DrawablePtr pDrawable;
 
217
GC              *pGC;
 
218
int             nInit;          /* number of spans to fill */
 
219
DDXPointPtr pptInit;            /* pointer to list of start points */
 
220
int *pwidthInit;                /* pointer to list of n widths */
 
221
int fSorted;
 
222
{
 
223
                                /* next three parameters are post-clip */
 
224
    int             n;          /* number of spans to fill */
 
225
    DDXPointPtr     ppt;        /* pointer to list of start points */
 
226
    int             *pwidth;    /* pointer to list of n widths */
 
227
    int             *pwidthFree;/* copies of the pointers to free */
 
228
    DDXPointPtr     pptFree;
 
229
    CfbBits   *pdstBase;        /* pointer to start of bitmap */
 
230
    int             nlwDst;     /* width in longwords of bitmap */
 
231
    register CfbBits    *pdst;  /* pointer to current word in bitmap */
 
232
    PixmapPtr       pStipple;   /* pointer to stipple we want to fill with */
 
233
    int             nlw;
 
234
    int             x, y, w, xrem, xSrc, ySrc;
 
235
    int             stwidth, stippleWidth;
 
236
    int             stippleHeight;
 
237
    register CfbBits  bits, inputBits;
 
238
    register int    partBitsLeft;
 
239
    int             nextPartBits;
 
240
    int             bitsLeft, bitsWhole;
 
241
    CfbBits   *srcTemp, *srcStart;
 
242
    CfbBits   *psrcBase;
 
243
    CfbBits   startmask, endmask;
 
244
 
 
245
    if (pGC->fillStyle == FillStippled)
 
246
        cfb8CheckStipple (pGC->alu, pGC->fgPixel, pGC->planemask);
 
247
    else
 
248
        cfb8CheckOpaqueStipple (pGC->alu, pGC->fgPixel, pGC->bgPixel, pGC->planemask);
 
249
 
 
250
    if (cfb8StippleRRop == GXnoop)
 
251
        return;
 
252
 
 
253
    n = nInit * miFindMaxBand( cfbGetCompositeClip(pGC) );
 
254
    if ( n == 0 )
 
255
        return;
 
256
    pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
 
257
    pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
 
258
    if(!pptFree || !pwidthFree)
 
259
    {
 
260
        if (pptFree) DEALLOCATE_LOCAL(pptFree);
 
261
        if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
 
262
        return;
 
263
    }
 
264
 
 
265
    pwidth = pwidthFree;
 
266
    ppt = pptFree;
 
267
    n = miClipSpans( cfbGetCompositeClip(pGC),
 
268
                     pptInit, pwidthInit, nInit, 
 
269
                     ppt, pwidth, fSorted);
 
270
 
 
271
    /*
 
272
     *  OK,  so what's going on here?  We have two Drawables:
 
273
     *
 
274
     *  The Stipple:
 
275
     *          Depth = 1
 
276
     *          Width = stippleWidth
 
277
     *          Words per scanline = stwidth
 
278
     *          Pointer to pixels = pStipple->devPrivate.ptr
 
279
     */
 
280
 
 
281
    pStipple = pGC->stipple;
 
282
 
 
283
    stwidth = pStipple->devKind >> PWSH;
 
284
    stippleWidth = pStipple->drawable.width;
 
285
    stippleHeight = pStipple->drawable.height;
 
286
    psrcBase = (CfbBits *) pStipple->devPrivate.ptr;
 
287
 
 
288
    /*
 
289
     *  The Target:
 
290
     *          Depth = PSZ
 
291
     *          Width = determined from *pwidth
 
292
     *          Words per scanline = nlwDst
 
293
     *          Pointer to pixels = addrlBase
 
294
     */
 
295
 
 
296
    cfbGetLongWidthAndPointer (pDrawable, nlwDst, pdstBase)
 
297
 
 
298
    /* this replaces rotating the stipple. Instead we just adjust the offset
 
299
     * at which we start grabbing bits from the stipple.
 
300
     * Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,
 
301
     * so that iline and xrem always stay within the stipple bounds.
 
302
     */
 
303
 
 
304
    modulus (pGC->patOrg.x, stippleWidth, xSrc);
 
305
    xSrc += pDrawable->x - stippleWidth;
 
306
    modulus (pGC->patOrg.y, stippleHeight, ySrc);
 
307
    ySrc += pDrawable->y - stippleHeight;
 
308
 
 
309
    bitsWhole = stippleWidth;
 
310
 
 
311
    while (n--)
 
312
    {
 
313
        x = ppt->x;
 
314
        y = ppt->y;
 
315
        ppt++;
 
316
        w = *pwidth++;
 
317
        pdst = pdstBase + y * nlwDst + (x >> PWSH);
 
318
        y = (y - ySrc) % stippleHeight;
 
319
        srcStart = psrcBase + y * stwidth;
 
320
        xrem = ((x & ~(PGSZB-1)) - xSrc) % stippleWidth;
 
321
        srcTemp = srcStart + (xrem >> MFB_PWSH);
 
322
        bitsLeft = stippleWidth - (xrem & ~MFB_PIM);
 
323
        xrem &= MFB_PIM;
 
324
        NextUnnaturalStippleWord
 
325
        if (partBitsLeft < xrem)
 
326
            FatalError ("cfbUnnaturalStippleFS bad partBitsLeft %d xrem %d",
 
327
                        partBitsLeft, xrem);
 
328
        NextSomeBits (inputBits, xrem);
 
329
        partBitsLeft -= xrem;
 
330
        if (((x & PIM) + w) <= PPW)
 
331
        {
 
332
            maskpartialbits (x, w, startmask)
 
333
            NextUnnaturalStippleBits
 
334
            *pdst = MaskRRopPixels(*pdst,bits,startmask);
 
335
        }
 
336
        else
 
337
        {
 
338
            maskbits (x, w, startmask, endmask, nlw);
 
339
            nextPartBits = (x & (PGSZB-1)) + w;
 
340
            if (nextPartBits < partBitsLeft)
 
341
            {
 
342
                if (startmask)
 
343
                {
 
344
                    MaskRRopBitGroup(pdst,GetBitGroup(inputBits),startmask)
 
345
                    pdst++;
 
346
                    NextBitGroup (inputBits);
 
347
                }
 
348
                while (nlw--)
 
349
                {
 
350
                    RRopBitGroup (pdst, GetBitGroup (inputBits));
 
351
                    pdst++;
 
352
                    NextBitGroup (inputBits);
 
353
                }
 
354
                if (endmask)
 
355
                {
 
356
                    MaskRRopBitGroup(pdst,GetBitGroup(inputBits),endmask)
 
357
                }
 
358
            }
 
359
            else if (bitsLeft != bitsWhole && nextPartBits < partBitsLeft + bitsLeft)
 
360
            {
 
361
                NextUnnaturalStippleBitsFast
 
362
                if (startmask)
 
363
                {
 
364
                    *pdst = MaskRRopPixels(*pdst,bits,startmask);
 
365
                    pdst++;
 
366
                    NextUnnaturalStippleBitsFast
 
367
                }
 
368
                while (nlw--)
 
369
                {
 
370
                    *pdst = RRopPixels(*pdst,bits);
 
371
                    pdst++;
 
372
                    NextUnnaturalStippleBitsFast
 
373
                }
 
374
                if (endmask)
 
375
                    *pdst = MaskRRopPixels (*pdst,bits,endmask);
 
376
            }
 
377
            else
 
378
            {
 
379
                NextUnnaturalStippleBits
 
380
                if (startmask)
 
381
                {
 
382
                    *pdst = MaskRRopPixels(*pdst,bits,startmask);
 
383
                    pdst++;
 
384
                    NextUnnaturalStippleBits
 
385
                }
 
386
                while (nlw--)
 
387
                {
 
388
                    *pdst = RRopPixels(*pdst,bits);
 
389
                    pdst++;
 
390
                    NextUnnaturalStippleBits
 
391
                }
 
392
                if (endmask)
 
393
                    *pdst = MaskRRopPixels(*pdst,bits,endmask);
 
394
            }
 
395
        }
 
396
    }
 
397
    DEALLOCATE_LOCAL(pptFree);
 
398
    DEALLOCATE_LOCAL(pwidthFree);
 
399
}
 
400
 
 
401
#else /* PSZ != 8 */
 
402
 
 
403
/* Fill spans with stipples that aren't 32 bits wide */
 
404
void
 
405
cfbUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
 
406
DrawablePtr pDrawable;
 
407
GC              *pGC;
 
408
int             nInit;          /* number of spans to fill */
 
409
DDXPointPtr pptInit;            /* pointer to list of start points */
 
410
int *pwidthInit;                /* pointer to list of n widths */
 
411
int fSorted;
 
412
{
 
413
                                /* next three parameters are post-clip */
 
414
    int                     n;          /* number of spans to fill */
 
415
    register DDXPointPtr    ppt;        /* pointer to list of start points */
 
416
    register int            *pwidth;    /* pointer to list of n widths */
 
417
    int                     iline;      /* first line of tile to use */
 
418
    CfbBits         *addrlBase; /* pointer to start of bitmap */
 
419
    int                     nlwidth;    /* width in longwords of bitmap */
 
420
    register CfbBits  *pdst;    /* pointer to current word in bitmap */
 
421
    PixmapPtr               pStipple;   /* pointer to stipple we want to fill with */
 
422
    register int            w;
 
423
    int                     width,  x, xrem, xSrc, ySrc;
 
424
    CfbBits         tmpSrc, tmpDst1, tmpDst2;
 
425
    int                     stwidth, stippleWidth;
 
426
    CfbBits         *psrcS;
 
427
    int                     rop, stiprop = 0;
 
428
    int                     stippleHeight;
 
429
    int                     *pwidthFree;    /* copies of the pointers to free */
 
430
    DDXPointPtr             pptFree;
 
431
    CfbBits         fgfill, bgfill;
 
432
 
 
433
    if (!(pGC->planemask))
 
434
        return;
 
435
 
 
436
    n = nInit * miFindMaxBand( cfbGetCompositeClip(pGC) );
 
437
    if ( n == 0 )
 
438
        return;
 
439
    pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
 
440
    pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
 
441
    if(!pptFree || !pwidthFree)
 
442
    {
 
443
        if (pptFree) DEALLOCATE_LOCAL(pptFree);
 
444
        if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
 
445
        return;
 
446
    }
 
447
    pwidth = pwidthFree;
 
448
    ppt = pptFree;
 
449
    n = miClipSpans( cfbGetCompositeClip(pGC),
 
450
                     pptInit, pwidthInit, nInit, 
 
451
                     ppt, pwidth, fSorted);
 
452
    rop = pGC->alu;
 
453
    if (pGC->fillStyle == FillStippled) {
 
454
        switch (rop) {
 
455
            case GXand:
 
456
            case GXcopy:
 
457
            case GXnoop:
 
458
            case GXor:
 
459
                stiprop = rop;
 
460
                break;
 
461
            default:
 
462
                stiprop = rop;
 
463
                rop = GXcopy;
 
464
        }
 
465
    }
 
466
    fgfill = PFILL(pGC->fgPixel);
 
467
    bgfill = PFILL(pGC->bgPixel);
 
468
 
 
469
    /*
 
470
     *  OK,  so what's going on here?  We have two Drawables:
 
471
     *
 
472
     *  The Stipple:
 
473
     *          Depth = 1
 
474
     *          Width = stippleWidth
 
475
     *          Words per scanline = stwidth
 
476
     *          Pointer to pixels = pStipple->devPrivate.ptr
 
477
     */
 
478
    pStipple = pGC->stipple;
 
479
 
 
480
    stwidth = pStipple->devKind / PGSZB;
 
481
    stippleWidth = pStipple->drawable.width;
 
482
    stippleHeight = pStipple->drawable.height;
 
483
 
 
484
    /*
 
485
     *  The Target:
 
486
     *          Depth = PSZ
 
487
     *          Width = determined from *pwidth
 
488
     *          Words per scanline = nlwidth
 
489
     *          Pointer to pixels = addrlBase
 
490
     */
 
491
 
 
492
    cfbGetLongWidthAndPointer (pDrawable, nlwidth, addrlBase)
 
493
 
 
494
    /* this replaces rotating the stipple. Instead we just adjust the offset
 
495
     * at which we start grabbing bits from the stipple.
 
496
     * Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,
 
497
     * so that iline and xrem always stay within the stipple bounds.
 
498
     */
 
499
    modulus (pGC->patOrg.x, stippleWidth, xSrc);
 
500
    xSrc += pDrawable->x - stippleWidth;
 
501
    modulus (pGC->patOrg.y, stippleHeight, ySrc);
 
502
    ySrc += pDrawable->y - stippleHeight;
 
503
 
 
504
    while (n--)
 
505
    {
 
506
        iline = (ppt->y - ySrc) % stippleHeight;
 
507
        x = ppt->x;
 
508
        pdst = addrlBase + (ppt->y * nlwidth);
 
509
        psrcS = (CfbBits *) pStipple->devPrivate.ptr + (iline * stwidth);
 
510
 
 
511
        if (*pwidth)
 
512
        {
 
513
            width = *pwidth;
 
514
            while(width > 0)
 
515
            {
 
516
                int xtemp;
 
517
#if PSZ != 32 || PPW != 1
 
518
                int tmpx;
 
519
#endif
 
520
                register CfbBits *ptemp;
 
521
                register CfbBits *pdsttmp;
 
522
                /*
 
523
                 *  Do a stripe through the stipple & destination w pixels
 
524
                 *  wide.  w is not more than:
 
525
                 *      -       the width of the destination
 
526
                 *      -       the width of the stipple
 
527
                 *      -       the distance between x and the next word 
 
528
                 *              boundary in the destination
 
529
                 *      -       the distance between x and the next word
 
530
                 *              boundary in the stipple
 
531
                 */
 
532
 
 
533
                /* width of dest/stipple */
 
534
                xrem = (x - xSrc) % stippleWidth;
 
535
#if PSZ == 24
 
536
                w = 1;
 
537
#else
 
538
                w = min((stippleWidth - xrem), width);
 
539
                /* dist to word bound in dest */
 
540
                w = min(w, PPW - (x & PIM));
 
541
                /* dist to word bound in stip */
 
542
                w = min(w, MFB_PPW - (x & MFB_PIM));
 
543
#endif
 
544
 
 
545
                xtemp = (xrem & MFB_PIM);
 
546
                ptemp = (CfbBits *)(psrcS + (xrem >> MFB_PWSH));
 
547
#if PSZ == 24
 
548
                tmpx = x & 3;
 
549
                pdsttmp = pdst + ((x * 3)>>2);
 
550
#else
 
551
#if PSZ != 32 || PPW != 1
 
552
                tmpx = x & PIM;
 
553
#endif
 
554
                pdsttmp = pdst + (x>>PWSH);
 
555
#endif
 
556
                switch ( pGC->fillStyle ) {
 
557
                    case FillOpaqueStippled:
 
558
#if PSZ == 24
 
559
                        getstipplepixels24(ptemp, xtemp, 0, &bgfill, &tmpDst1, xrem);
 
560
                        getstipplepixels24(ptemp, xtemp, 1, &fgfill, &tmpDst2, xrem);
 
561
#else
 
562
                        getstipplepixels(ptemp, xtemp, w, 0, &bgfill, &tmpDst1);
 
563
                        getstipplepixels(ptemp, xtemp, w, 1, &fgfill, &tmpDst2);
 
564
#endif
 
565
                        break;
 
566
                    case FillStippled:
 
567
                        /* Fill tmpSrc with the source pixels */
 
568
#if PSZ == 24
 
569
                        getbits24(pdsttmp, tmpSrc, x);
 
570
                        getstipplepixels24(ptemp, xtemp, 0, &tmpSrc, &tmpDst1, xrem);
 
571
#else
 
572
                        getbits(pdsttmp, tmpx, w, tmpSrc);
 
573
                        getstipplepixels(ptemp, xtemp, w, 0, &tmpSrc, &tmpDst1);
 
574
#endif
 
575
                        if (rop != stiprop) {
 
576
#if PSZ == 24
 
577
                            putbitsrop24(fgfill, 0, &tmpSrc, pGC->planemask, stiprop);
 
578
#else
 
579
                            putbitsrop(fgfill, 0, w, &tmpSrc, pGC->planemask, stiprop);
 
580
#endif
 
581
                        } else {
 
582
                            tmpSrc = fgfill;
 
583
                        }
 
584
#if PSZ == 24
 
585
                        getstipplepixels24(ptemp, xtemp, 1, &tmpSrc, &tmpDst2, xrem);
 
586
#else
 
587
                        getstipplepixels(ptemp, xtemp, w, 1, &tmpSrc, &tmpDst2);
 
588
#endif
 
589
                        break;
 
590
                }
 
591
                tmpDst2 |= tmpDst1;
 
592
#if PSZ == 24
 
593
                putbitsrop24(tmpDst2, tmpx, pdsttmp, pGC->planemask, rop);
 
594
#else
 
595
                putbitsrop(tmpDst2, tmpx, w, pdsttmp, pGC->planemask, rop);
 
596
#endif
 
597
                x += w;
 
598
                width -= w;
 
599
            }
 
600
        }
 
601
        ppt++;
 
602
        pwidth++;
 
603
    }
 
604
    DEALLOCATE_LOCAL(pptFree);
 
605
    DEALLOCATE_LOCAL(pwidthFree);
 
606
}
 
607
 
 
608
#endif /* PSZ == 8 */
 
609
 
 
610
#if PSZ == 8
 
611
 
 
612
void
 
613
cfb8Stipple32FS (pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
 
614
    DrawablePtr pDrawable;
 
615
    GCPtr       pGC;
 
616
    int         nInit;                  /* number of spans to fill */
 
617
    DDXPointPtr pptInit;                /* pointer to list of start points */
 
618
    int         *pwidthInit;            /* pointer to list of n widths */
 
619
    int         fSorted;
 
620
{
 
621
                                /* next three parameters are post-clip */
 
622
    int             n;                  /* number of spans to fill */
 
623
    DDXPointPtr     ppt;                /* pointer to list of start points */
 
624
    int             *pwidth;            /* pointer to list of n widths */
 
625
    CfbBits   *src;             /* pointer to bits in stipple, if needed */
 
626
    int             stippleHeight;      /* height of the stipple */
 
627
    PixmapPtr       stipple;
 
628
 
 
629
    int             nlwDst;             /* width in longwords of the dest pixmap */
 
630
    int             x,y,w;              /* current span */
 
631
    CfbBits   startmask;
 
632
    CfbBits   endmask;
 
633
    register CfbBits *dst;      /* pointer to bits we're writing */
 
634
    register int    nlw;
 
635
    CfbBits   *dstTmp;
 
636
    int             nlwTmp;
 
637
 
 
638
    CfbBits   *pbits;           /* pointer to start of pixmap */
 
639
    register CfbBits  xor;
 
640
    register CfbBits  mask;
 
641
    register CfbBits  bits;     /* bits from stipple */
 
642
    int             wEnd;
 
643
 
 
644
    int             *pwidthFree;        /* copies of the pointers to free */
 
645
    DDXPointPtr     pptFree;
 
646
    cfbPrivGCPtr    devPriv;
 
647
 
 
648
    devPriv = cfbGetGCPrivate(pGC);
 
649
    cfb8CheckStipple (pGC->alu, pGC->fgPixel, pGC->planemask);
 
650
    n = nInit * miFindMaxBand(pGC->pCompositeClip);
 
651
    if ( n == 0 )
 
652
        return;
 
653
    pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
 
654
    pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
 
655
    if(!pptFree || !pwidthFree)
 
656
    {
 
657
        if (pptFree) DEALLOCATE_LOCAL(pptFree);
 
658
        if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
 
659
        return;
 
660
    }
 
661
    pwidth = pwidthFree;
 
662
    ppt = pptFree;
 
663
    n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
 
664
                     ppt, pwidth, fSorted);
 
665
 
 
666
    stipple = pGC->pRotatedPixmap;
 
667
    src = (CfbBits *)stipple->devPrivate.ptr;
 
668
    stippleHeight = stipple->drawable.height;
 
669
 
 
670
    cfbGetLongWidthAndPointer (pDrawable, nlwDst, pbits)
 
671
 
 
672
    while (n--)
 
673
    {
 
674
        w = *pwidth++;
 
675
        x = ppt->x;
 
676
        y = ppt->y;
 
677
        ppt++;
 
678
        dst = pbits + (y * nlwDst) + (x >> PWSH);
 
679
        if (((x & PIM) + w) <= PPW)
 
680
        {
 
681
            maskpartialbits(x, w, startmask);
 
682
            endmask = 0;
 
683
            nlw = 0;
 
684
        }
 
685
        else
 
686
        {
 
687
            maskbits (x, w, startmask, endmask, nlw);
 
688
        }
 
689
        bits = src[y % stippleHeight];
 
690
        RotBitsLeft (bits, (x & ((PGSZ-1) & ~PIM)));
 
691
#if PPW == 4
 
692
        if (cfb8StippleRRop == GXcopy)
 
693
        {
 
694
            xor = devPriv->xor;
 
695
            if (w < (PGSZ*2))
 
696
            {
 
697
                if (startmask)
 
698
                {
 
699
                    mask = cfb8PixelMasks[GetBitGroup(bits)];
 
700
                    *dst = (*dst & ~(mask & startmask)) |
 
701
                           (xor & (mask & startmask));
 
702
                    dst++;
 
703
                    RotBitsLeft (bits, PGSZB);
 
704
                }
 
705
                while (nlw--)
 
706
                {
 
707
                    WriteBitGroup (dst,xor,GetBitGroup(bits))
 
708
                    dst++;
 
709
                    RotBitsLeft (bits, PGSZB);
 
710
                }
 
711
                if (endmask)
 
712
                {
 
713
                    mask = cfb8PixelMasks[GetBitGroup(bits)];
 
714
                    *dst = (*dst & ~(mask & endmask)) |
 
715
                           (xor & (mask & endmask));
 
716
                }
 
717
            }
 
718
            else
 
719
            { /* XXX constants probably not OK here */
 
720
                wEnd = 7 - (nlw & 7);
 
721
                nlw = (nlw >> 3) + 1;
 
722
                dstTmp = dst;
 
723
                nlwTmp = nlw;
 
724
                if (startmask)
 
725
                {
 
726
                    mask = cfb8PixelMasks[GetBitGroup(bits)];
 
727
                    *dstTmp = (*dstTmp & ~(mask & startmask)) |
 
728
                           (xor & (mask & startmask));
 
729
                    dstTmp++;
 
730
                    RotBitsLeft (bits, PGSZB);
 
731
                }
 
732
                w = 7 - wEnd;
 
733
                while (w--)
 
734
                {
 
735
                    dst = dstTmp;
 
736
                    dstTmp++;
 
737
                    nlw = nlwTmp;
 
738
#if defined(__GNUC__) && defined(mc68020)
 
739
                    mask = cfb8PixelMasks[GetBitGroup(bits)];
 
740
                    xor = xor & mask;
 
741
                    mask = ~mask;
 
742
                    while (nlw--)
 
743
                    {
 
744
                        *dst = (*dst & mask) | xor;
 
745
                        dst += 8;
 
746
                    }
 
747
                    xor = devPriv->xor;
 
748
#else
 
749
#define SwitchBitsLoop(body) \
 
750
    while (nlw--)       \
 
751
    {           \
 
752
        body    \
 
753
        dst += 8;       \
 
754
    }
 
755
                    SwitchBitGroup(dst, xor, GetBitGroup(bits));
 
756
#undef SwitchBitsLoop
 
757
#endif
 
758
                    NextBitGroup (bits);
 
759
                }
 
760
                nlwTmp--;
 
761
                w = wEnd + 1;
 
762
                if (endmask)
 
763
                {
 
764
                    mask = cfb8PixelMasks[GetBitGroup(bits)];
 
765
                    dst = dstTmp + (nlwTmp << 3);
 
766
                    *dst = (*dst & ~(mask & endmask)) |
 
767
                           (xor &  (mask & endmask));
 
768
                }
 
769
                while (w--)
 
770
                {
 
771
                    nlw = nlwTmp;
 
772
                    dst = dstTmp;
 
773
                    dstTmp++;
 
774
#if defined(__GNUC__) && defined(mc68020)
 
775
                    mask = cfb8PixelMasks[GetBitGroup(bits)];
 
776
                    xor = xor & mask;
 
777
                    mask = ~mask;
 
778
                    while (nlw--)
 
779
                    {
 
780
                        *dst = (*dst & mask) | xor;
 
781
                        dst += 8;
 
782
                    }
 
783
                    xor = devPriv->xor;
 
784
#else
 
785
#define SwitchBitsLoop(body) \
 
786
        while (nlw--)   \
 
787
        {               \
 
788
            body        \
 
789
            dst += 8;   \
 
790
        }
 
791
                    SwitchBitGroup(dst, xor, GetBitGroup(bits));
 
792
#undef SwitchBitsLoop
 
793
#endif
 
794
                    NextBitGroup (bits);
 
795
                }
 
796
            }
 
797
        }
 
798
        else
 
799
#endif /* PPW == 4 */
 
800
        {
 
801
            if (startmask)
 
802
            {
 
803
                xor = GetBitGroup(bits);
 
804
                *dst = MaskRRopPixels(*dst, xor, startmask);
 
805
                dst++;
 
806
                RotBitsLeft (bits, PGSZB);
 
807
            }
 
808
            while (nlw--)
 
809
            {
 
810
                RRopBitGroup(dst, GetBitGroup(bits));
 
811
                dst++;
 
812
                RotBitsLeft (bits, PGSZB);
 
813
            }
 
814
            if (endmask)
 
815
            {
 
816
                xor = GetBitGroup(bits);
 
817
                *dst = MaskRRopPixels(*dst, xor, endmask);
 
818
            }
 
819
        }
 
820
    }
 
821
    DEALLOCATE_LOCAL(pptFree);
 
822
    DEALLOCATE_LOCAL(pwidthFree);
 
823
}
 
824
 
 
825
void
 
826
cfb8OpaqueStipple32FS (pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
 
827
    DrawablePtr pDrawable;
 
828
    GCPtr       pGC;
 
829
    int         nInit;                  /* number of spans to fill */
 
830
    DDXPointPtr pptInit;                /* pointer to list of start points */
 
831
    int         *pwidthInit;            /* pointer to list of n widths */
 
832
    int         fSorted;
 
833
{
 
834
                                /* next three parameters are post-clip */
 
835
    int             n;                  /* number of spans to fill */
 
836
    DDXPointPtr     ppt;                /* pointer to list of start points */
 
837
    int             *pwidth;            /* pointer to list of n widths */
 
838
    CfbBits   *src;             /* pointer to bits in stipple, if needed */
 
839
    int             stippleHeight;      /* height of the stipple */
 
840
    PixmapPtr       stipple;
 
841
 
 
842
    int             nlwDst;             /* width in longwords of the dest pixmap */
 
843
    int             x,y,w;              /* current span */
 
844
    CfbBits   startmask;
 
845
    CfbBits   endmask;
 
846
    register CfbBits *dst;      /* pointer to bits we're writing */
 
847
    register int    nlw;
 
848
    CfbBits   *dstTmp;
 
849
    int             nlwTmp;
 
850
 
 
851
    CfbBits   *pbits;           /* pointer to start of pixmap */
 
852
    register CfbBits  xor;
 
853
    register CfbBits  bits;     /* bits from stipple */
 
854
    int             wEnd;
 
855
 
 
856
    int             *pwidthFree;        /* copies of the pointers to free */
 
857
    DDXPointPtr     pptFree;
 
858
    cfbPrivGCPtr    devPriv;
 
859
 
 
860
    devPriv = cfbGetGCPrivate(pGC);
 
861
 
 
862
    cfb8CheckOpaqueStipple(pGC->alu, pGC->fgPixel, pGC->bgPixel, pGC->planemask);
 
863
 
 
864
    n = nInit * miFindMaxBand(pGC->pCompositeClip);
 
865
    if ( n == 0 )
 
866
        return;
 
867
    pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
 
868
    pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
 
869
    if(!pptFree || !pwidthFree)
 
870
    {
 
871
        if (pptFree) DEALLOCATE_LOCAL(pptFree);
 
872
        if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
 
873
        return;
 
874
    }
 
875
    pwidth = pwidthFree;
 
876
    ppt = pptFree;
 
877
    n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
 
878
                     ppt, pwidth, fSorted);
 
879
 
 
880
    stipple = pGC->pRotatedPixmap;
 
881
    src = (CfbBits *)stipple->devPrivate.ptr;
 
882
    stippleHeight = stipple->drawable.height;
 
883
 
 
884
    cfbGetLongWidthAndPointer (pDrawable, nlwDst, pbits)
 
885
 
 
886
    while (n--)
 
887
    {
 
888
        w = *pwidth++;
 
889
        x = ppt->x;
 
890
        y = ppt->y;
 
891
        ppt++;
 
892
        dst = pbits + (y * nlwDst) + (x >> PWSH);
 
893
        if (((x & PIM) + w) <= PPW)
 
894
        {
 
895
            maskpartialbits(x, w, startmask);
 
896
            endmask = 0;
 
897
            nlw = 0;
 
898
        }
 
899
        else
 
900
        {
 
901
            maskbits (x, w, startmask, endmask, nlw);
 
902
        }
 
903
        bits = src[y % stippleHeight];
 
904
        RotBitsLeft (bits, (x & ((PGSZ-1) & ~PIM)));
 
905
#if PPW == 4
 
906
        if (cfb8StippleRRop == GXcopy)
 
907
        {
 
908
            xor = devPriv->xor;
 
909
            if (w < PGSZ*2)
 
910
            {
 
911
                if (startmask)
 
912
                {
 
913
                    *dst = (*dst & ~startmask) |
 
914
                           (GetPixelGroup (bits) & startmask);
 
915
                    dst++;
 
916
                    RotBitsLeft (bits, PGSZB);
 
917
                }
 
918
                while (nlw--)
 
919
                {
 
920
                    *dst++ = GetPixelGroup(bits);
 
921
                    RotBitsLeft (bits, PGSZB);
 
922
                }
 
923
                if (endmask)
 
924
                {
 
925
                    *dst = (*dst & ~endmask) |
 
926
                           (GetPixelGroup (bits) & endmask);
 
927
                }
 
928
            }
 
929
            else
 
930
            { /* XXX consts probably not OK here */
 
931
                wEnd = 7 - (nlw & 7);
 
932
                nlw = (nlw >> 3) + 1;
 
933
                dstTmp = dst;
 
934
                nlwTmp = nlw;
 
935
                if (startmask)
 
936
                {
 
937
                    *dstTmp = (*dstTmp & ~startmask) |
 
938
                              (GetPixelGroup (bits) & startmask);
 
939
                    dstTmp++;
 
940
                    RotBitsLeft (bits, PGSZB);
 
941
                }
 
942
                w = 7 - wEnd;
 
943
                while (w--)
 
944
                {
 
945
                    nlw = nlwTmp;
 
946
                    dst = dstTmp;
 
947
                    dstTmp++;
 
948
                    xor = GetPixelGroup (bits);
 
949
                    while (nlw--)
 
950
                    {
 
951
                        *dst = xor;
 
952
                        dst += 8;
 
953
                    }
 
954
                    NextBitGroup (bits);
 
955
                }
 
956
                nlwTmp--;
 
957
                w = wEnd + 1;
 
958
                if (endmask)
 
959
                {
 
960
                    dst = dstTmp + (nlwTmp << 3);
 
961
                    *dst = (*dst & ~endmask) |
 
962
                           (GetPixelGroup (bits) & endmask);
 
963
                }
 
964
                while (w--)
 
965
                {
 
966
                    nlw = nlwTmp;
 
967
                    dst = dstTmp;
 
968
                    dstTmp++;
 
969
                    xor = GetPixelGroup (bits);
 
970
                    while (nlw--)
 
971
                    {
 
972
                        *dst = xor;
 
973
                        dst += 8;
 
974
                    }
 
975
                    NextBitGroup (bits);
 
976
                }
 
977
            }
 
978
        }
 
979
        else
 
980
#endif /* PPW == 4 */
 
981
        {
 
982
            if (startmask)
 
983
            {
 
984
                xor = GetBitGroup(bits);
 
985
                *dst = MaskRRopPixels(*dst, xor, startmask);
 
986
                dst++;
 
987
                RotBitsLeft (bits, PGSZB);
 
988
            }
 
989
            while (nlw--)
 
990
            {
 
991
                RRopBitGroup(dst, GetBitGroup(bits));
 
992
                dst++;
 
993
                RotBitsLeft (bits, PGSZB);
 
994
            }
 
995
            if (endmask)
 
996
            {
 
997
                xor = GetBitGroup(bits);
 
998
                *dst = MaskRRopPixels(*dst, xor, endmask);
 
999
            }
 
1000
        }
 
1001
    }
 
1002
    DEALLOCATE_LOCAL(pptFree);
 
1003
    DEALLOCATE_LOCAL(pwidthFree);
 
1004
}
 
1005
 
 
1006
#endif /* PSZ == 8 */