1
/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaBitmap.c,v 1.10 2000/09/01 05:49:45 mvojkovi Exp $ */
8
#include "xf86_ansic.h"
12
/********** byte swapping ***************/
16
# define DEST(i) *dest
17
# define RETURN(i) return(dest)
19
# define DEST(i) dest[i]
20
# define RETURN(i) return(dest + i)
24
# define SOURCE(i) SWAP_BITS_IN_BYTES(src[i])
26
# define SOURCE(i) src[i]
30
typedef CARD32 *(* BitmapScanlineProcPtr)(CARD32 *, CARD32 *, int, int);
35
CARD32 *src, CARD32 *base,
36
int count, int skipleft )
49
} else if (count == 1) {
58
BitmapScanline_Inverted(
59
CARD32 *src, CARD32 *base,
60
int count, int skipleft )
73
} else if (count == 1) {
83
BitmapScanline_Shifted(
84
CARD32 *src, CARD32 *base,
85
int count, int skipleft )
90
bits = SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft));
96
bits = SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft));
98
} else if (count == 1) {
99
bits = SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft));
107
BitmapScanline_Shifted_Inverted(
108
CARD32 *src, CARD32 *base,
109
int count, int skipleft )
114
bits = ~(SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft)));
120
bits = ~(SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft)));
122
} else if (count == 1) {
123
bits = ~(SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft)));
130
#define BitmapScanline_Shifted_Careful BitmapScanline_Shifted
131
#define BitmapScanline_Shifted_Inverted_Careful BitmapScanline_Shifted_Inverted
136
CARD32 *src, CARD32 *dest,
137
int count, int skipleft )
151
if(!count) return dest;
153
if(count == 1) RETURN(1);
155
if(count == 2) RETURN(2);
161
BitmapScanline_Inverted(
162
CARD32 *src, CARD32 *dest,
163
int count, int skipleft )
166
DEST(0) = ~SOURCE(0);
167
DEST(1) = ~SOURCE(1);
168
DEST(2) = ~SOURCE(2);
169
DEST(3) = ~SOURCE(3);
177
if(!count) return dest;
178
DEST(0) = ~SOURCE(0);
179
if(count == 1) RETURN(1);
180
DEST(1) = ~SOURCE(1);
181
if(count == 2) RETURN(2);
182
DEST(2) = ~SOURCE(2);
188
BitmapScanline_Shifted(
189
CARD32 *bits, CARD32 *base,
190
int count, int skipleft )
193
register CARD32 tmp = SHIFT_R(*bits,skipleft) |
194
SHIFT_L(*(bits + 1),(32 - skipleft));
202
BitmapScanline_Shifted_Inverted(
203
CARD32 *bits, CARD32 *base,
204
int count, int skipleft )
207
register CARD32 tmp = ~(SHIFT_R(*bits,skipleft) |
208
SHIFT_L(*(bits + 1),(32 - skipleft)));
216
BitmapScanline_Shifted_Careful(
217
CARD32 *bits, CARD32 *base,
218
int count, int skipleft )
222
tmp = SHIFT_R(*bits,skipleft) | SHIFT_L(*(bits + 1),(32 - skipleft));
226
tmp = SHIFT_R(*bits,skipleft);
233
BitmapScanline_Shifted_Inverted_Careful(
234
CARD32 *bits, CARD32 *base,
235
int count, int skipleft )
239
tmp = ~(SHIFT_R(*bits,skipleft) | SHIFT_L(*(bits + 1),(32 - skipleft)));
243
tmp = ~(SHIFT_R(*bits,skipleft));
251
When the accelerator is TRANSPARENCY_ONLY, WriteBitmap can do
252
the fill in two passes, inverting the source on the second pass.
253
For GXcopy we can fill the backing rectangle as a solid rect and
259
EXPNAME(XAAWriteBitmapColorExpand3)(
261
EXPNAME(XAAWriteBitmapColorExpand)(
264
int x, int y, int w, int H,
270
unsigned int planemask
273
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
275
unsigned char *srcp = src;
276
int SecondPassColor = -1;
277
int shift = 0, dwords;
278
BitmapScanlineProcPtr firstFunc;
279
BitmapScanlineProcPtr secondFunc;
285
((infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY) ||
286
((infoRec->CPUToScreenColorExpandFillFlags & RGB_EQUAL) &&
287
(!CHECK_RGB_EQUAL(bg))))) {
290
(infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)) {
292
if((rop == GXcopy) && infoRec->SetupForSolidFill) {
293
(*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask);
294
(*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h);
295
} else SecondPassColor = bg;
303
(!(infoRec->CPUToScreenColorExpandFillFlags & LEFT_EDGE_CLIPPING) ||
304
(!(infoRec->CPUToScreenColorExpandFillFlags & LEFT_EDGE_CLIPPING_NEGATIVE_X) &&
307
if((skipleft + ((w + 31) & ~31)) > ((skipleft + w + 31) & ~31)) {
308
/* don't read past the end */
309
firstFunc = BitmapScanline_Shifted_Careful;
310
secondFunc = BitmapScanline_Shifted_Inverted_Careful;
312
firstFunc = BitmapScanline_Shifted;
313
secondFunc = BitmapScanline_Shifted_Inverted;
318
firstFunc = BitmapScanline;
319
secondFunc = BitmapScanline_Inverted;
325
dwords = (3 * w + 31) >> 5;
327
dwords = (w + 31) >> 5;
332
flag = (infoRec->CPUToScreenColorExpandFillFlags
333
& CPU_TRANSFER_PAD_QWORD) && ((dwords * h) & 0x01);
334
(*infoRec->SetupForCPUToScreenColorExpandFill)(
335
pScrn, fg, bg, rop, planemask);
336
(*infoRec->SubsequentCPUToScreenColorExpandFill)(
337
pScrn, x, y, w, h, skipleft);
339
base = (CARD32*)infoRec->ColorExpandBase;
342
if((dwords * h) <= infoRec->ColorExpandRange)
344
base = (*firstFunc)((CARD32*)srcp, base, dwords, shift);
350
(*firstFunc)((CARD32*)srcp, base, dwords, shift);
355
base = (CARD32*)infoRec->ColorExpandBase;
356
base[0] = 0x00000000;
359
if(SecondPassColor != -1) {
360
h = H; /* Reset height */
361
fg = SecondPassColor;
362
SecondPassColor = -1;
363
firstFunc = secondFunc;
368
if(infoRec->CPUToScreenColorExpandFillFlags & SYNC_AFTER_COLOR_EXPAND)
369
(*infoRec->Sync)(pScrn);
370
else SET_SYNC_FLAG(infoRec);
377
EXPNAME(XAAWriteBitmapScanlineColorExpand3)(
379
EXPNAME(XAAWriteBitmapScanlineColorExpand)(
382
int x, int y, int w, int h,
388
unsigned int planemask
391
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
393
unsigned char *srcp = src;
394
int SecondPassColor = -1;
395
int shift = 0, dwords, bufferNo;
396
BitmapScanlineProcPtr firstFunc;
397
BitmapScanlineProcPtr secondFunc;
401
((infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)
402
|| ((infoRec->ScanlineCPUToScreenColorExpandFillFlags & RGB_EQUAL) &&
403
(!CHECK_RGB_EQUAL(bg))))) {
406
(infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)){
408
if((rop == GXcopy) && infoRec->SetupForSolidFill) {
409
(*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask);
410
(*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h);
411
} else SecondPassColor = bg;
419
(!(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
420
LEFT_EDGE_CLIPPING) ||
421
(!(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
422
LEFT_EDGE_CLIPPING_NEGATIVE_X) && (skipleft > x)))) {
424
if((skipleft + ((w + 31) & ~31)) > ((skipleft + w + 31) & ~31)) {
425
/* don't read past the end */
426
firstFunc = BitmapScanline_Shifted_Careful;
427
secondFunc = BitmapScanline_Shifted_Inverted_Careful;
429
firstFunc = BitmapScanline_Shifted;
430
secondFunc = BitmapScanline_Shifted_Inverted;
435
firstFunc = BitmapScanline;
436
secondFunc = BitmapScanline_Inverted;
442
dwords = (3 * w + 31) >> 5;
444
dwords = (w + 31) >> 5;
449
(*infoRec->SetupForScanlineCPUToScreenColorExpandFill)(pScrn, fg, bg, rop, planemask);
450
(*infoRec->SubsequentScanlineCPUToScreenColorExpandFill)(
451
pScrn, x, y, w, h, skipleft);
456
base = (CARD32*)infoRec->ScanlineColorExpandBuffers[bufferNo];
457
(*firstFunc)((CARD32*)srcp, base, dwords, shift);
458
(*infoRec->SubsequentColorExpandScanline)(pScrn, bufferNo++);
460
if(bufferNo >= infoRec->NumScanlineColorExpandBuffers)
464
if(SecondPassColor != -1) {
465
fg = SecondPassColor;
466
SecondPassColor = -1;
467
firstFunc = secondFunc;
472
SET_SYNC_FLAG(infoRec);