1
/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcPixFS.c,v 1.4tsi Exp $ */
3
* Copyright IBM Corporation 1987,1988,1989
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.
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
25
/******************************************************************
26
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
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.
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
46
******************************************************************/
47
/* $XConsortium: ppcPixFS.c /main/3 1996/02/21 17:57:57 kaleb $ */
49
#ifdef HAVE_XORG_CONFIG_H
50
#include <xorg-config.h>
60
#include "ppcSpMcro.h"
64
#define LeftMostBitInScreenLongWord SCRLEFT( 0xFFFFFFFF, 31 )
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)) )
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().)
75
the number of new scnalines created by clipping ==
76
MaxRectsPerBand * nSpans.
77
********** ********** ********** ********** ********** ********** **********
79
/* A mod definition that goes smoothly into the negative.
102
xf4bppSolidPixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
103
DrawablePtr pDrawable ;
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 */
110
register unsigned long int pm, npm ;
111
register unsigned long int fg ;
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 */
119
int *pwidthFree ; /* copies of the pointers to free */
120
DDXPointPtr pptFree ;
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)) ;
124
if ( pDrawable->type != DRAWABLE_PIXMAP ) {
125
ErrorF("xf4bppSolidPixmapFS: drawable is not a pixmap\n") ;
129
if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
132
n = nInit * miFindMaxBand(pGC->pCompositeClip) ;
133
if ( !( pwidthFree = (int *) ALLOCATE_LOCAL( n * sizeof( int ) ) ) )
135
pwidth = pwidthFree ;
137
if ( !( pptFree = (DDXPointRec *)
138
ALLOCATE_LOCAL( n * sizeof( DDXPointRec ) ) ) ) {
139
DEALLOCATE_LOCAL( pwidth ) ;
144
n = miClipSpans( pGC->pCompositeClip, pptInit, pwidthInit, nInit,
145
ppt, pwidth, fSorted ) ;
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 ) ;
151
for ( ; n-- ; ppt++, pwidth++ ) {
152
addrl = ( (unsigned char *) ( ( (PixmapPtr) pDrawable )->devPrivate.ptr ) )
153
+ ( ppt->y * ( (int) ( ( (PixmapPtr) pDrawable )->devKind ) ) )
155
for ( i = *pwidth ; i-- ; addrl++ )
158
DoRop( _p, alu, fg, *addrl );
159
*addrl = ( *addrl & npm ) | ( pm & _p ) ;
161
#ifdef notdef /* PURDUE */
162
*addrl = ( *addrl & npm ) | ( pm & DoRop( alu, fg, *addrl ) ) ;
165
DEALLOCATE_LOCAL( pptFree ) ;
166
DEALLOCATE_LOCAL( pwidthFree ) ;
170
/* GJA -- copied from vgaStipple.c */
174
register const int x,
175
register const unsigned int patternWidth,
176
register const unsigned char * const lineptr
179
register unsigned char bits ;
180
register const unsigned char *cptr ;
184
cptr = lineptr + ( x >> 3 ) ;
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 ) ) ;
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.
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);
204
bits &= ~SCRRIGHT8(0xFF,2);
205
bits |= SCRRIGHT8(bits,2); bits |= SCRRIGHT8(bits,4); break;
207
bits &= ~SCRRIGHT8(0xFF,3);
208
bits |= (SCRRIGHT8(bits,3) | SCRRIGHT8(bits,6)); break;
210
bits = (bits & ~SCRRIGHT8(0xFF,4)) | SCRRIGHT8(bits,4); break;
212
bits = (bits & ~SCRRIGHT8(0xFF,5)) | SCRRIGHT8(bits,5); break;
214
bits = (bits & ~SCRRIGHT8(0xFF,6)) | SCRRIGHT8(bits,6); break;
216
bits = (bits & ~SCRRIGHT8(0xFF,7)) | SCRRIGHT8(bits,7); break;
219
/* Do nothing, of course */
226
xf4bppStipplePixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
227
register DrawablePtr pDrawable ;
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 */
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 ;
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 ;
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)) ;
254
if ( pDrawable->type != DRAWABLE_PIXMAP ) {
255
ErrorF( "xf4bppStippleWindowFS: drawable is not a pixmap\n") ;
258
if ( pGC->stipple->drawable.depth != 1 ) {
259
ErrorF( "ppcStippleFS: bad depth\ntype = %d, depth = %d\n",
260
pDrawable->type, pGC->stipple->drawable.depth ) ;
264
if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
267
SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit,
268
pptFree, pwidth, ppt, fSorted ) ;
270
pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ;
271
fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ;
273
pTile = pGC->stipple ;
274
tlwidth = pTile->devKind ;
276
tileWidth = pTile->drawable.width ;
278
npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ;
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;
286
pdst = ( (unsigned char *) ( (PixmapPtr) pDrawable )->devPrivate.ptr )
287
+ ( ppt->y * ( (int) ( ( (PixmapPtr) pDrawable )->devKind ) ) )
289
psrcT = (unsigned char *)pTile->devPrivate.ptr
290
+ ( modulo( ppt->y - ySrc, pTile->drawable.height ) * tlwidth ) ;
293
xoff = modulo( x - xSrc, tileWidth) ;
294
for ( width = *pwidth ; width ; psrc++, width -= count, xoff+=count ) {
296
if ( xoff >= tileWidth ) xoff -= tileWidth;
303
stip = vgagetbits( xoff, tileWidth, psrcT ) ;
305
for ( i = count ; i-- ; ) {
309
DoRop( _p, alu, fg, *pdst ) ;
310
*pdst = ( *pdst & npm ) | ( pm & _p ) ;
312
#ifdef notdef /* PURDUE */
313
*pdst = ( *pdst & npm ) | ( pm & DoRop( alu, fg, *pdst ) ) ;
316
stip = SCRLEFT( stip, 1 ) ;
322
DEALLOCATE_LOCAL( pptFree ) ;
323
DEALLOCATE_LOCAL( pwidthFree ) ;
328
xf4bppOpStipplePixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
329
DrawablePtr pDrawable ;
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 */
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 ;
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 */
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 ;
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 ) ) ;
357
if ( pGC->stipple->drawable.depth != 1 ) {
358
ErrorF( "xf4bppOpStipplePixmapFS: bad depth\ntype = %d, depth = %d\n",
359
pDrawable->type, pGC->stipple->drawable.depth ) ;
363
if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
366
SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit,
367
pptFree, pwidth, ppt, fSorted ) ;
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 ) ;
374
pTile = pGC->stipple ;
375
tlwidth = pTile->devKind ;
376
tileWidth = pTile->drawable.width ;
378
xSrc = pGC->patOrg.x + pDrawable->x;
379
ySrc = pGC->patOrg.y + pDrawable->y;
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 ) )
387
psrcT = (unsigned char *)pTile->devPrivate.ptr
388
+ ( modulo( ppt->y - ySrc, pTile->drawable.height ) * tlwidth ) ;
390
xoff = modulo( ppt->x - xSrc, tileWidth) ;
392
for ( width = *pwidth ; width ; psrc++, width -= count, xoff+=count ) {
394
if ( xoff >= tileWidth ) xoff -= tileWidth;
401
stip = vgagetbits( xoff, tileWidth, psrcT ) ;
402
for ( i = count ; i-- ; pdst++, stip = SCRLEFT( stip, 1 ) )
406
DoRop( _p, alu, fg, *pdst ) ;
407
*pdst = ( *pdst & npm ) | ( pm & _p ) ;
409
#ifdef notdef /* PURDUE */
410
*pdst = ( *pdst & npm ) | ( pm & DoRop( alu, fg, *pdst ) ) ;
415
DoRop( _p, alu, bg, *pdst ) ;
416
*pdst = ( *pdst & npm ) | ( pm & _p ) ;
418
#ifdef notdef /* PURDUE */
419
*pdst = ( *pdst & npm ) | ( pm & DoRop( alu, bg, *pdst ) ) ;
423
DEALLOCATE_LOCAL( pptFree ) ;
424
DEALLOCATE_LOCAL( pwidthFree ) ;
429
xf4bppTilePixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
430
register DrawablePtr pDrawable ;
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 */
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 */
444
unsigned char pm, npm ;
445
/* next three parameters are post-clip */
446
int n ; /* number of spans to fill */
449
unsigned char *psrcT ;
450
int *pwidthFree ; /* copies of the pointers to free */
451
DDXPointPtr pptFree ;
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 ) ) ;
456
if ( ( pDrawable->depth == 1 ) && ( pDrawable->type == DRAWABLE_PIXMAP ) ) {
457
mfbTileFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ;
460
if ( !xf4bppDepthOK( pDrawable, pGC->tile.pixmap->drawable.depth ) ) {
461
ErrorF( "ppcTileFS: bad depth\ntype = %d, depth = %d\n",
462
pDrawable->type, pDrawable->depth) ;
466
if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
469
SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit,
470
pptFree, pwidth, ppt, fSorted ) ;
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 ;
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 ) )
486
psrcT = (unsigned char *) pTile->devPrivate.ptr
487
+ ( modulo( ppt->y - ySrc, pTile->drawable.height) * pTile->devKind ) ;
489
psrc = psrcT + modulo( ppt->x - xSrc, tileWidth ) ;
490
for ( i = *pwidth ; i-- ; pdst++, psrc++ ) {
491
if ( psrc >= ( psrcT + tileWidth ) )
495
DoRop( _p, alu, *psrc, *pdst ) ;
496
*pdst = ( *pdst & npm ) | ( pm & _p ) ;
498
#ifdef notdef /* PURDUE */
499
*pdst = ( *pdst & npm ) | ( pm & DoRop( alu, *psrc, *pdst ) ) ;
503
DEALLOCATE_LOCAL( pptFree ) ;
504
DEALLOCATE_LOCAL( pwidthFree ) ;