3 #ifdef HAVE_XORG_CONFIG_H
4 #include <xorg-config.h>
13 /********** byte swapping ***************/
17 # define DEST(i) *dest
18 # define RETURN(i) return(dest)
20 # define DEST(i) dest[i]
21 # define RETURN(i) return(dest + i)
25 # define SOURCE(i) SWAP_BITS_IN_BYTES(src[i])
27 # define SOURCE(i) src[i]
31 typedef CARD32 *(* BitmapScanlineProcPtr)(CARD32 *, CARD32 *, int, int);
36 CARD32 *src, CARD32 *base,
37 int count, int skipleft )
50 } else if (count == 1) {
59 BitmapScanline_Inverted(
60 CARD32 *src, CARD32 *base,
61 int count, int skipleft )
74 } else if (count == 1) {
84 BitmapScanline_Shifted(
85 CARD32 *src, CARD32 *base,
86 int count, int skipleft )
91 bits = SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft));
97 bits = SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft));
99 } else if (count == 1) {
100 bits = SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft));
108 BitmapScanline_Shifted_Inverted(
109 CARD32 *src, CARD32 *base,
110 int count, int skipleft )
115 bits = ~(SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft)));
121 bits = ~(SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft)));
123 } else if (count == 1) {
124 bits = ~(SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft)));
131 #define BitmapScanline_Shifted_Careful BitmapScanline_Shifted
132 #define BitmapScanline_Shifted_Inverted_Careful BitmapScanline_Shifted_Inverted
137 CARD32 *src, CARD32 *dest,
138 int count, int skipleft )
152 if(!count) return dest;
154 if(count == 1) RETURN(1);
156 if(count == 2) RETURN(2);
162 BitmapScanline_Inverted(
163 CARD32 *src, CARD32 *dest,
164 int count, int skipleft )
167 DEST(0) = ~SOURCE(0);
168 DEST(1) = ~SOURCE(1);
169 DEST(2) = ~SOURCE(2);
170 DEST(3) = ~SOURCE(3);
178 if(!count) return dest;
179 DEST(0) = ~SOURCE(0);
180 if(count == 1) RETURN(1);
181 DEST(1) = ~SOURCE(1);
182 if(count == 2) RETURN(2);
183 DEST(2) = ~SOURCE(2);
189 BitmapScanline_Shifted(
190 CARD32 *bits, CARD32 *base,
191 int count, int skipleft )
194 register CARD32 tmp = SHIFT_R(*bits,skipleft) |
195 SHIFT_L(*(bits + 1),(32 - skipleft));
203 BitmapScanline_Shifted_Inverted(
204 CARD32 *bits, CARD32 *base,
205 int count, int skipleft )
208 register CARD32 tmp = ~(SHIFT_R(*bits,skipleft) |
209 SHIFT_L(*(bits + 1),(32 - skipleft)));
217 BitmapScanline_Shifted_Careful(
218 CARD32 *bits, CARD32 *base,
219 int count, int skipleft )
223 tmp = SHIFT_R(*bits,skipleft) | SHIFT_L(*(bits + 1),(32 - skipleft));
227 tmp = SHIFT_R(*bits,skipleft);
234 BitmapScanline_Shifted_Inverted_Careful(
235 CARD32 *bits, CARD32 *base,
236 int count, int skipleft )
240 tmp = ~(SHIFT_R(*bits,skipleft) | SHIFT_L(*(bits + 1),(32 - skipleft)));
244 tmp = ~(SHIFT_R(*bits,skipleft));
252 When the accelerator is TRANSPARENCY_ONLY, WriteBitmap can do
253 the fill in two passes, inverting the source on the second pass.
254 For GXcopy we can fill the backing rectangle as a solid rect and
260 EXPNAME(XAAWriteBitmapColorExpand3)(
262 EXPNAME(XAAWriteBitmapColorExpand)(
265 int x, int y, int w, int H,
271 unsigned int planemask
274 XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
276 unsigned char *srcp = src;
277 int SecondPassColor = -1;
278 int shift = 0, dwords;
279 BitmapScanlineProcPtr firstFunc;
280 BitmapScanlineProcPtr secondFunc;
286 ((infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY) ||
287 ((infoRec->CPUToScreenColorExpandFillFlags & RGB_EQUAL) &&
288 (!CHECK_RGB_EQUAL(bg))))) {
291 (infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)) {
293 if((rop == GXcopy) && infoRec->SetupForSolidFill) {
294 (*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask);
295 (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h);
296 } else SecondPassColor = bg;
304 (!(infoRec->CPUToScreenColorExpandFillFlags & LEFT_EDGE_CLIPPING) ||
305 (!(infoRec->CPUToScreenColorExpandFillFlags & LEFT_EDGE_CLIPPING_NEGATIVE_X) &&
308 if((skipleft + ((w + 31) & ~31)) > ((skipleft + w + 31) & ~31)) {
309 /* don't read past the end */
310 firstFunc = BitmapScanline_Shifted_Careful;
311 secondFunc = BitmapScanline_Shifted_Inverted_Careful;
313 firstFunc = BitmapScanline_Shifted;
314 secondFunc = BitmapScanline_Shifted_Inverted;
319 firstFunc = BitmapScanline;
320 secondFunc = BitmapScanline_Inverted;
326 dwords = (3 * w + 31) >> 5;
328 dwords = (w + 31) >> 5;
333 flag = (infoRec->CPUToScreenColorExpandFillFlags
334 & CPU_TRANSFER_PAD_QWORD) && ((dwords * h) & 0x01);
335 (*infoRec->SetupForCPUToScreenColorExpandFill)(
336 pScrn, fg, bg, rop, planemask);
337 (*infoRec->SubsequentCPUToScreenColorExpandFill)(
338 pScrn, x, y, w, h, skipleft);
340 base = (CARD32*)infoRec->ColorExpandBase;
343 if((dwords * h) <= infoRec->ColorExpandRange)
345 base = (*firstFunc)((CARD32*)srcp, base, dwords, shift);
351 (*firstFunc)((CARD32*)srcp, base, dwords, shift);
356 base = (CARD32*)infoRec->ColorExpandBase;
357 base[0] = 0x00000000;
360 if(SecondPassColor != -1) {
361 h = H; /* Reset height */
362 fg = SecondPassColor;
363 SecondPassColor = -1;
364 firstFunc = secondFunc;
369 if(infoRec->CPUToScreenColorExpandFillFlags & SYNC_AFTER_COLOR_EXPAND)
370 (*infoRec->Sync)(pScrn);
371 else SET_SYNC_FLAG(infoRec);
378 EXPNAME(XAAWriteBitmapScanlineColorExpand3)(
380 EXPNAME(XAAWriteBitmapScanlineColorExpand)(
383 int x, int y, int w, int h,
389 unsigned int planemask
392 XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
394 unsigned char *srcp = src;
395 int SecondPassColor = -1;
396 int shift = 0, dwords, bufferNo;
397 BitmapScanlineProcPtr firstFunc;
398 BitmapScanlineProcPtr secondFunc;
402 ((infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)
403 || ((infoRec->ScanlineCPUToScreenColorExpandFillFlags & RGB_EQUAL) &&
404 (!CHECK_RGB_EQUAL(bg))))) {
407 (infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)){
409 if((rop == GXcopy) && infoRec->SetupForSolidFill) {
410 (*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask);
411 (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h);
412 } else SecondPassColor = bg;
420 (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
421 LEFT_EDGE_CLIPPING) ||
422 (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
423 LEFT_EDGE_CLIPPING_NEGATIVE_X) && (skipleft > x)))) {
425 if((skipleft + ((w + 31) & ~31)) > ((skipleft + w + 31) & ~31)) {
426 /* don't read past the end */
427 firstFunc = BitmapScanline_Shifted_Careful;
428 secondFunc = BitmapScanline_Shifted_Inverted_Careful;
430 firstFunc = BitmapScanline_Shifted;
431 secondFunc = BitmapScanline_Shifted_Inverted;
436 firstFunc = BitmapScanline;
437 secondFunc = BitmapScanline_Inverted;
443 dwords = (3 * w + 31) >> 5;
445 dwords = (w + 31) >> 5;
450 (*infoRec->SetupForScanlineCPUToScreenColorExpandFill)(pScrn, fg, bg, rop, planemask);
451 (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill)(
452 pScrn, x, y, w, h, skipleft);
457 base = (CARD32*)infoRec->ScanlineColorExpandBuffers[bufferNo];
458 (*firstFunc)((CARD32*)srcp, base, dwords, shift);
459 (*infoRec->SubsequentColorExpandScanline)(pScrn, bufferNo++);
461 if(bufferNo >= infoRec->NumScanlineColorExpandBuffers)
465 if(SecondPassColor != -1) {
466 fg = SecondPassColor;
467 SecondPassColor = -1;
468 firstFunc = secondFunc;
473 SET_SYNC_FLAG(infoRec);