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

« back to all changes in this revision

Viewing changes to hw/xfree86/xf4bpp/ppcPixFS.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/hw/xfree86/xf4bpp/ppcPixFS.c,v 1.4tsi Exp $ */
 
2
/*
 
3
 * Copyright IBM Corporation 1987,1988,1989
 
4
 *
 
5
 * All Rights Reserved
 
6
 *
 
7
 * Permission to use, copy, modify, and distribute this software and its
 
8
 * documentation for any purpose and without fee is hereby granted,
 
9
 * provided that the above copyright notice appear in all copies and that 
 
10
 * both that copyright notice and this permission notice appear in
 
11
 * supporting documentation, and that the name of IBM not be
 
12
 * used in advertising or publicity pertaining to distribution of the
 
13
 * software without specific, written prior permission.
 
14
 *
 
15
 * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 
16
 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 
17
 * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 
18
 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 
19
 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 
20
 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 
21
 * SOFTWARE.
 
22
 *
 
23
*/
 
24
 
 
25
/******************************************************************
 
26
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
27
 
 
28
                        All Rights Reserved
 
29
 
 
30
Permission to use, copy, modify, and distribute this software and its
 
31
documentation for any purpose and without fee is hereby granted,
 
32
provided that the above copyright notice appear in all copies and that
 
33
both that copyright notice and this permission notice appear in
 
34
supporting documentation, and that the name of Digital not be
 
35
used in advertising or publicity pertaining to distribution of the
 
36
software without specific, written prior permission.
 
37
 
 
38
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 
39
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 
40
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 
41
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 
42
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 
43
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 
44
SOFTWARE.
 
45
 
 
46
******************************************************************/
 
47
/* $XConsortium: ppcPixFS.c /main/3 1996/02/21 17:57:57 kaleb $ */
 
48
 
 
49
#ifdef HAVE_XORG_CONFIG_H
 
50
#include <xorg-config.h>
 
51
#endif
 
52
 
 
53
#include "xf4bpp.h"
 
54
#include "mfbmap.h"
 
55
#include "mfb.h"
 
56
#include "maskbits.h"
 
57
#include "mi.h"
 
58
#include "mispans.h"
 
59
#include "ppcGCstr.h"
 
60
#include "ppcSpMcro.h"
 
61
#include "vgaVideo.h"
 
62
#include "ibmTrace.h"
 
63
 
 
64
#define LeftMostBitInScreenLongWord SCRLEFT( 0xFFFFFFFF, 31 )
 
65
 
 
66
/* GJA -- copied this from VGA */
 
67
#define SCRLEFT8(lw, n) ( (unsigned char) (((unsigned char) lw) << (n)) )
 
68
#define SCRRIGHT8(lw, n)        ( (unsigned char) (((unsigned char)lw) >> (n)) )
 
69
/*
 
70
********** ********** ********** ********** ********** ********** **********
 
71
   these routines all clip.  they assume that anything that has called
 
72
them has already translated the points (i.e. pGC->miTranslate is
 
73
non-zero, which is howit gets set in mfbCreateGC().)
 
74
 
 
75
   the number of new scnalines created by clipping ==
 
76
MaxRectsPerBand * nSpans.
 
77
********** ********** ********** ********** ********** ********** **********
 
78
*/
 
79
/* A mod definition that goes smoothly into the negative.
 
80
 */
 
81
static int
 
82
modulo
 
83
(
 
84
      int n1,
 
85
      int n2
 
86
)
 
87
{
 
88
      int tmp;
 
89
      if ( n1 < 0 ) {
 
90
              tmp = (-n1) % n2;
 
91
              if ( tmp == 0 ) {
 
92
                      return 0;
 
93
              } else {
 
94
                      return n2 - tmp;
 
95
              }
 
96
      } else {
 
97
              return n1 % n2;
 
98
      }
 
99
}
 
100
 
 
101
void
 
102
xf4bppSolidPixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
 
103
    DrawablePtr pDrawable ;
 
104
    GCPtr       pGC ;
 
105
    int         nInit ;                 /* number of spans to fill */
 
106
    DDXPointPtr pptInit ;               /* pointer to list of start points */
 
107
    int         *pwidthInit ;           /* pointer to list of n widths */
 
108
    int         fSorted ;
 
109
{
 
110
    register unsigned long int pm, npm ;
 
111
    register unsigned long int fg ;
 
112
    register int alu ;
 
113
                                /* next three parameters are post-clip */
 
114
    int n ;                     /* number of spans to fill */
 
115
    register DDXPointPtr ppt ;  /* pointer to list of start points */
 
116
    register int *pwidth ;      /* pointer to list of n widths */
 
117
    register unsigned char *addrl ;     /* pointer to current longword in bitmap */
 
118
    int i ;
 
119
    int *pwidthFree ;           /* copies of the pointers to free */
 
120
    DDXPointPtr pptFree ;
 
121
 
 
122
    TRACE(("xf4bppSolidPixmapFS(pDrawable=0x%x, pGC=0x%x, nInit=%d, pptInit=0x%x, pwidthInit=0x%x, fSorted=%d)\n", pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)) ;
 
123
 
 
124
    if ( pDrawable->type != DRAWABLE_PIXMAP ) {
 
125
        ErrorF("xf4bppSolidPixmapFS: drawable is not a pixmap\n") ;
 
126
        return ;
 
127
    }
 
128
 
 
129
    if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
 
130
        return ;
 
131
 
 
132
    n = nInit * miFindMaxBand(pGC->pCompositeClip) ;
 
133
    if ( !( pwidthFree = (int *) ALLOCATE_LOCAL( n * sizeof( int ) ) ) )
 
134
        return ;
 
135
    pwidth = pwidthFree ;
 
136
 
 
137
    if ( !( pptFree = (DDXPointRec *)
 
138
            ALLOCATE_LOCAL( n * sizeof( DDXPointRec ) ) ) ) {
 
139
        DEALLOCATE_LOCAL( pwidth ) ;
 
140
        return ;
 
141
    }
 
142
    ppt = pptFree ;
 
143
 
 
144
    n = miClipSpans( pGC->pCompositeClip, pptInit, pwidthInit, nInit,
 
145
        ppt, pwidth, fSorted ) ;
 
146
 
 
147
    pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ;
 
148
    fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ;
 
149
    npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ;
 
150
 
 
151
    for ( ; n-- ; ppt++, pwidth++ ) {
 
152
        addrl = ( (unsigned char *) ( ( (PixmapPtr) pDrawable )->devPrivate.ptr ) )
 
153
              + ( ppt->y * ( (int) ( ( (PixmapPtr) pDrawable )->devKind ) ) )
 
154
              + ppt->x ;
 
155
        for ( i = *pwidth ; i-- ; addrl++ )
 
156
            {
 
157
            unsigned _p;
 
158
            DoRop( _p, alu, fg, *addrl );
 
159
            *addrl = ( *addrl & npm ) | ( pm & _p ) ;
 
160
            }
 
161
#ifdef notdef /* PURDUE */
 
162
            *addrl = ( *addrl & npm ) | ( pm & DoRop( alu, fg, *addrl ) ) ;
 
163
#endif /* PURDUE */
 
164
    }
 
165
    DEALLOCATE_LOCAL( pptFree ) ;
 
166
    DEALLOCATE_LOCAL( pwidthFree ) ;
 
167
    return ;
 
168
}
 
169
 
 
170
/* GJA -- copied from vgaStipple.c */
 
171
static unsigned char
 
172
vgagetbits
 
173
(
 
174
        register const int x,
 
175
        register const unsigned int patternWidth,
 
176
        register const unsigned char * const lineptr
 
177
)
 
178
{
 
179
register unsigned char bits ;
 
180
register const unsigned char *cptr ;
 
181
register int shift ;
 
182
register int wrap ;
 
183
 
 
184
cptr = lineptr + ( x >> 3 ) ;
 
185
bits = *cptr ;
 
186
if ((shift = x & 7))
 
187
      bits = SCRLEFT8( bits, shift ) | SCRRIGHT8( cptr[1], ( 8 - shift ) ) ;
 
188
if ( ( wrap = x + 8 - patternWidth ) > 0 ) {
 
189
      bits &= SCRLEFT8( 0xFF, wrap ) ;
 
190
      bits |= SCRRIGHT8( *lineptr, ( 8 - wrap ) ) ;
 
191
}
 
192
 
 
193
/* GJA -- Handle extraction of 8 bits from < 8 bits wide stipple.
 
194
 * I duplicated case 4,5,6,7 to give the compiler a chance to optimize.
 
195
 */
 
196
switch (patternWidth) {
 
197
case 1: /* Not really useful. */
 
198
        bits &= ~SCRRIGHT8(0xFF,1);
 
199
        bits |= SCRRIGHT8(bits,1); 
 
200
        bits |= SCRRIGHT8(bits,2);
 
201
        bits |= SCRRIGHT8(bits,4);
 
202
        break;
 
203
case 2:
 
204
        bits &= ~SCRRIGHT8(0xFF,2);
 
205
        bits |= SCRRIGHT8(bits,2); bits |= SCRRIGHT8(bits,4); break;
 
206
case 3:
 
207
        bits &= ~SCRRIGHT8(0xFF,3);
 
208
        bits |= (SCRRIGHT8(bits,3) | SCRRIGHT8(bits,6)); break;
 
209
case 4:
 
210
        bits = (bits & ~SCRRIGHT8(0xFF,4)) | SCRRIGHT8(bits,4); break;
 
211
case 5:
 
212
        bits = (bits & ~SCRRIGHT8(0xFF,5)) | SCRRIGHT8(bits,5); break;
 
213
case 6:
 
214
        bits = (bits & ~SCRRIGHT8(0xFF,6)) | SCRRIGHT8(bits,6); break;
 
215
case 7:
 
216
        bits = (bits & ~SCRRIGHT8(0xFF,7)) | SCRRIGHT8(bits,7); break;
 
217
default:
 
218
        ;
 
219
        /* Do nothing, of course */
 
220
}
 
221
 
 
222
return bits ;
 
223
}
 
224
 
 
225
void
 
226
xf4bppStipplePixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
 
227
register DrawablePtr pDrawable ;
 
228
GC *pGC ;
 
229
int nInit ;                     /* number of spans to fill */
 
230
DDXPointPtr pptInit ;           /* pointer to list of start points */
 
231
int *pwidthInit ;               /* pointer to list of n widths */
 
232
int fSorted ;
 
233
{
 
234
    register unsigned char *pdst ; /* pointer to current word in bitmap */
 
235
    register int *psrc ;                /* pointer to current word in tile */
 
236
    register unsigned long int pm, npm ;
 
237
    register unsigned long int fg ;
 
238
    register int alu ;
 
239
                                /* next three parameters are post-clip */
 
240
    int n ;                     /* number of spans to fill */
 
241
    register DDXPointPtr ppt ;  /* pointer to list of start points */
 
242
    register int *pwidth ;      /* pointer to list of n widths */
 
243
    PixmapPtr   pTile ;         /* pointer to tile we want to fill with */
 
244
    int         width,  x, xSrc, ySrc ;
 
245
    int         tlwidth, tileWidth ;
 
246
    unsigned char *psrcT ;
 
247
    int *pwidthFree ;           /* copies of the pointers to free */
 
248
    DDXPointPtr pptFree ;
 
249
    int xoff, count, stip, i ;
 
250
 
 
251
    TRACE(("xf4bppStipplePixmapFS(pDrawable=0x%x, pGC=0x%x, nInit=%d, pptInit=0x%x, pwidthInit=0x%x, fSorted=%d)\n",
 
252
                 pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)) ;
 
253
 
 
254
    if ( pDrawable->type != DRAWABLE_PIXMAP ) {
 
255
        ErrorF( "xf4bppStippleWindowFS: drawable is not a pixmap\n") ;
 
256
        return ;
 
257
    }
 
258
    if ( pGC->stipple->drawable.depth != 1 ) {
 
259
        ErrorF( "ppcStippleFS: bad depth\ntype = %d, depth = %d\n",
 
260
                pDrawable->type, pGC->stipple->drawable.depth ) ;
 
261
        return ;
 
262
    }
 
263
 
 
264
    if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
 
265
        return ;
 
266
 
 
267
    SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit,
 
268
                pptFree, pwidth, ppt, fSorted ) ;
 
269
 
 
270
    pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ;
 
271
    fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ;
 
272
 
 
273
    pTile = pGC->stipple ;
 
274
    tlwidth = pTile->devKind ;
 
275
 
 
276
    tileWidth = pTile->drawable.width ;
 
277
 
 
278
    npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ;
 
279
 
 
280
    /* this replaces rotating the stipple.  Instead, we just adjust the offset
 
281
     * at which we start grabbing bits from the stipple */
 
282
    xSrc = pGC->patOrg.x + pDrawable->x;
 
283
    ySrc = pGC->patOrg.y + pDrawable->y;
 
284
 
 
285
    while ( n-- ) {
 
286
        pdst = ( (unsigned char *) ( (PixmapPtr) pDrawable )->devPrivate.ptr )
 
287
             + ( ppt->y * ( (int) ( ( (PixmapPtr) pDrawable )->devKind ) ) )
 
288
             + ppt->x ;
 
289
        psrcT = (unsigned char *)pTile->devPrivate.ptr
 
290
              + ( modulo( ppt->y - ySrc, pTile->drawable.height ) * tlwidth ) ;
 
291
        x = ppt->x ;
 
292
 
 
293
        xoff = modulo( x - xSrc, tileWidth) ;
 
294
        for ( width = *pwidth ; width ; psrc++, width -= count, xoff+=count ) {
 
295
 
 
296
            if ( xoff >= tileWidth ) xoff -= tileWidth;
 
297
 
 
298
            if ( width < 8 )
 
299
                count = width;
 
300
            else
 
301
                count = 8;
 
302
 
 
303
            stip = vgagetbits( xoff, tileWidth, psrcT ) ;
 
304
 
 
305
            for ( i = count ; i-- ; ) {
 
306
                if ( stip & 128 )
 
307
                    {
 
308
                    unsigned _p;
 
309
                    DoRop( _p, alu, fg, *pdst ) ;
 
310
                    *pdst = ( *pdst & npm ) | ( pm & _p ) ;
 
311
                    }
 
312
#ifdef notdef /* PURDUE */
 
313
                    *pdst = ( *pdst & npm ) | ( pm & DoRop( alu, fg, *pdst ) ) ;
 
314
#endif /* PURDUE */
 
315
                pdst++ ;
 
316
                stip = SCRLEFT( stip, 1 ) ;
 
317
            }
 
318
        }
 
319
        ppt++ ;
 
320
        pwidth++ ;
 
321
    }
 
322
    DEALLOCATE_LOCAL( pptFree ) ;
 
323
    DEALLOCATE_LOCAL( pwidthFree ) ;
 
324
    return ;
 
325
}
 
326
 
 
327
void
 
328
xf4bppOpStipplePixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
 
329
DrawablePtr pDrawable ;
 
330
GC *pGC ;
 
331
int nInit ;                     /* number of spans to fill */
 
332
DDXPointPtr pptInit ;           /* pointer to list of start points */
 
333
int *pwidthInit ;               /* pointer to list of n widths */
 
334
int fSorted ;
 
335
{
 
336
    register unsigned char *pdst ;      /* pointer to current word in bitmap */
 
337
    register unsigned long int pm, npm ;
 
338
    register unsigned long int fg, bg ;
 
339
    register int alu ;
 
340
                                /* next three parameters are post-clip */
 
341
    int n ;                     /* number of spans to fill */
 
342
    register DDXPointPtr ppt ;  /* pointer to list of start points */
 
343
    register int *pwidth ;      /* pointer to list of n widths */
 
344
    register int *psrc ;        /* pointer to current word in tile */
 
345
    PixmapPtr pTile ;           /* pointer to tile we want to fill with */
 
346
    int width ;
 
347
    int xSrc, ySrc ;
 
348
    int tlwidth, tileWidth ;
 
349
    unsigned char *psrcT ;
 
350
    int *pwidthFree ;           /* copies of the pointers to free */
 
351
    DDXPointPtr pptFree ;
 
352
    int xoff, count, stip, i ;
 
353
 
 
354
    TRACE( ( "xf4bppOpStipplePixmapFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n",
 
355
           pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ;
 
356
 
 
357
    if ( pGC->stipple->drawable.depth != 1 ) {
 
358
        ErrorF( "xf4bppOpStipplePixmapFS: bad depth\ntype = %d, depth = %d\n",
 
359
                pDrawable->type, pGC->stipple->drawable.depth ) ;
 
360
        return ;
 
361
    }
 
362
 
 
363
    if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
 
364
        return ;
 
365
 
 
366
    SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit,
 
367
                 pptFree, pwidth, ppt, fSorted ) ;
 
368
 
 
369
    fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ;
 
370
    bg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.bgPixel ;
 
371
    pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ;
 
372
    npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ;
 
373
 
 
374
    pTile = pGC->stipple ;
 
375
    tlwidth = pTile->devKind ;
 
376
    tileWidth = pTile->drawable.width ;
 
377
 
 
378
    xSrc = pGC->patOrg.x + pDrawable->x;
 
379
    ySrc = pGC->patOrg.y + pDrawable->y;
 
380
 
 
381
    /* this replaces rotating the stipple.  Instead, we just adjust the offset
 
382
     * at which we start grabbing bits from the stipple */
 
383
    for ( ; n-- ; ppt++, pwidth++ ) {
 
384
        pdst = ( (unsigned char *) ( (PixmapPtr) pDrawable )->devPrivate.ptr )
 
385
             + ( ppt->y * ( (int) ( (PixmapPtr) pDrawable )->devKind ) )
 
386
             + ppt->x ;
 
387
        psrcT = (unsigned char *)pTile->devPrivate.ptr
 
388
            + ( modulo( ppt->y - ySrc, pTile->drawable.height ) * tlwidth ) ;
 
389
 
 
390
        xoff = modulo( ppt->x - xSrc, tileWidth) ;
 
391
 
 
392
        for ( width = *pwidth ; width ; psrc++, width -= count, xoff+=count ) {
 
393
 
 
394
            if ( xoff >= tileWidth ) xoff -= tileWidth;
 
395
 
 
396
            if ( width < 8 )
 
397
                count = width;
 
398
            else
 
399
                count = 8;
 
400
 
 
401
            stip = vgagetbits( xoff, tileWidth, psrcT ) ;
 
402
            for ( i = count ; i-- ; pdst++, stip = SCRLEFT( stip, 1 ) )
 
403
                if ( stip & 128 )
 
404
                    {
 
405
                    unsigned _p;
 
406
                    DoRop( _p, alu, fg, *pdst ) ;
 
407
                    *pdst = ( *pdst & npm ) | ( pm & _p ) ;
 
408
                    }
 
409
#ifdef notdef /* PURDUE */
 
410
                    *pdst = ( *pdst & npm ) | ( pm & DoRop( alu, fg, *pdst ) ) ;
 
411
#endif /* PURDUE */
 
412
                else
 
413
                    {
 
414
                    unsigned _p;
 
415
                    DoRop( _p, alu, bg, *pdst ) ;
 
416
                    *pdst = ( *pdst & npm ) | ( pm & _p ) ;
 
417
                    }
 
418
#ifdef notdef /* PURDUE */
 
419
                    *pdst = ( *pdst & npm ) | ( pm & DoRop( alu, bg, *pdst ) ) ;
 
420
#endif /* PURDUE */
 
421
        }
 
422
    }
 
423
    DEALLOCATE_LOCAL( pptFree ) ;
 
424
    DEALLOCATE_LOCAL( pwidthFree ) ;
 
425
    return ;
 
426
}
 
427
 
 
428
void
 
429
xf4bppTilePixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
 
430
register DrawablePtr pDrawable ;
 
431
GC *pGC ;
 
432
int nInit ;                     /* number of spans to fill */
 
433
DDXPointPtr pptInit ;           /* pointer to list of start points */
 
434
int *pwidthInit ;               /* pointer to list of n widths */
 
435
int fSorted ;
 
436
{
 
437
    register DDXPointPtr ppt ;  /* pointer to list of start points */
 
438
    register int *pwidth ;      /* pointer to list of n widths */
 
439
    register unsigned char *pdst ;      /* pointer to current word in bitmap */
 
440
    register unsigned char *psrc ;      /* pointer to current word in tile */
 
441
    register PixmapPtr pTile ;  /* pointer to tile we want to fill with */
 
442
    int i ;
 
443
    int alu ;
 
444
    unsigned char pm, npm ;
 
445
                                /* next three parameters are post-clip */
 
446
    int n ;                     /* number of spans to fill */
 
447
    int tileWidth ;
 
448
    int xSrc, ySrc;
 
449
    unsigned char *psrcT ;
 
450
    int *pwidthFree ;           /* copies of the pointers to free */
 
451
    DDXPointPtr pptFree ;
 
452
 
 
453
    TRACE( ( "ppcTileFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n",
 
454
            pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ;
 
455
 
 
456
    if ( ( pDrawable->depth == 1 ) && ( pDrawable->type == DRAWABLE_PIXMAP ) ) {
 
457
        mfbTileFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ;
 
458
        return ;
 
459
    }
 
460
    if ( !xf4bppDepthOK( pDrawable, pGC->tile.pixmap->drawable.depth ) ) {
 
461
        ErrorF( "ppcTileFS: bad depth\ntype = %d, depth = %d\n",
 
462
                pDrawable->type, pDrawable->depth) ;
 
463
        return ;
 
464
    }
 
465
 
 
466
    if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
 
467
        return ;
 
468
 
 
469
    SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit,
 
470
                 pptFree, pwidth, ppt, fSorted ) ;
 
471
 
 
472
    /* the following code is for 8 bits per pixel addressable memory only */
 
473
    pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ;
 
474
    npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ;
 
475
    pTile = pGC->tile.pixmap ;
 
476
    tileWidth = pTile->drawable.width ;
 
477
 
 
478
     xSrc = pGC->patOrg.x + pDrawable->x;
 
479
     ySrc = pGC->patOrg.y + pDrawable->y;
 
480
    /* this replaces rotating the tile. Instead we just adjust the offset
 
481
     * at which we start grabbing bits from the tile */
 
482
    for ( ; n-- ; ppt++, pwidth++ ) {
 
483
        pdst = ( (unsigned char *) ( (PixmapPtr) pDrawable )->devPrivate.ptr )
 
484
             + ( ppt->y * ( (int) ( (PixmapPtr) pDrawable )->devKind ) )
 
485
             + ppt->x ;
 
486
        psrcT = (unsigned char *) pTile->devPrivate.ptr
 
487
        + ( modulo( ppt->y - ySrc, pTile->drawable.height) * pTile->devKind ) ;
 
488
 
 
489
        psrc = psrcT + modulo( ppt->x - xSrc, tileWidth ) ;
 
490
        for ( i = *pwidth ; i-- ; pdst++, psrc++ ) {
 
491
            if ( psrc >= ( psrcT + tileWidth ) )
 
492
                psrc = psrcT ;
 
493
            {
 
494
            unsigned _p;
 
495
            DoRop( _p, alu, *psrc, *pdst ) ;
 
496
            *pdst = ( *pdst & npm ) | ( pm & _p ) ;
 
497
            }
 
498
#ifdef notdef /* PURDUE */
 
499
            *pdst = ( *pdst & npm ) | ( pm & DoRop( alu, *psrc, *pdst ) ) ;
 
500
#endif /* PURDUE */
 
501
        }
 
502
    }
 
503
    DEALLOCATE_LOCAL( pptFree ) ;
 
504
    DEALLOCATE_LOCAL( pwidthFree ) ;
 
505
    return ;
 
506
}