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