From 88ece3c37c4ed529686b6cdea1bf9b6eed8fceea Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Mon, 20 Mar 2006 19:12:50 +0000 Subject: Bug #5587: Refactor mga_storm.c to only build once for all color depths. (Ian Romanick) --- src/mga_dga.c | 90 +++++++++++++++-------------------------------------------- 1 file changed, 23 insertions(+), 67 deletions(-) (limited to 'src/mga_dga.c') diff --git a/src/mga_dga.c b/src/mga_dga.c index 28ff766..e728484 100644 --- a/src/mga_dga.c +++ b/src/mga_dga.c @@ -366,21 +366,8 @@ MGA_FillRect ( if(!pMga->AccelInfoRec) return; - switch(pMga->CurrentLayout.bitsPerPixel) { - case 8: - Mga8SetupForSolidFill(pScrn, color, GXcopy, ~0); - break; - case 16: - Mga16SetupForSolidFill(pScrn, color, GXcopy, ~0); - break; - case 24: - Mga24SetupForSolidFill(pScrn, color, GXcopy, ~0); - break; - case 32: - Mga32SetupForSolidFill(pScrn, color, GXcopy, ~0); - break; - } - + mgaDoSetupForSolidFill(pScrn, color, GXcopy, ~0, + pMga->CurrentLayout.bitsPerPixel); (*pMga->AccelInfoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h); SET_SYNC_FLAG(pMga->AccelInfoRec); @@ -399,24 +386,8 @@ MGA_BlitRect( if(!pMga->AccelInfoRec) return; - switch(pMga->CurrentLayout.bitsPerPixel) { - case 8: - Mga8SetupForScreenToScreenCopy( - pScrn, xdir, ydir, GXcopy, ~0, -1); - break; - case 16: - Mga16SetupForScreenToScreenCopy( - pScrn, xdir, ydir, GXcopy, ~0, -1); - break; - case 24: - Mga24SetupForScreenToScreenCopy( - pScrn, xdir, ydir, GXcopy, ~0, -1); - break; - case 32: - Mga32SetupForScreenToScreenCopy( - pScrn, xdir, ydir, GXcopy, ~0, -1); - break; - } + mgaDoSetupForScreenToScreenCopy( pScrn, xdir, ydir, GXcopy, ~0, -1, + pMga->CurrentLayout.bitsPerPixel ); (*pMga->AccelInfoRec->SubsequentScreenToScreenCopy)( pScrn, srcx, srcy, dstx, dsty, w, h); @@ -425,45 +396,30 @@ MGA_BlitRect( } -static void -MGA_BlitTransRect( - ScrnInfoPtr pScrn, - int srcx, int srcy, - int w, int h, - int dstx, int dsty, - unsigned long color -){ +static void MGA_BlitTransRect( ScrnInfoPtr pScrn, int srcx, int srcy, + int w, int h, int dstx, int dsty, + unsigned long color ) +{ MGAPtr pMga = MGAPTR(pScrn); - int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1; - int ydir = (srcy < dsty) ? -1 : 1; - if(!pMga->AccelInfoRec) return; - if(pMga->CurrentLayout.bitsPerPixel == 24) return; - if(pMga->Chipset == PCI_CHIP_MGA2064) return; - - pMga->DrawTransparent = TRUE; - - switch(pMga->CurrentLayout.bitsPerPixel) { - case 8: - Mga8SetupForScreenToScreenCopy( - pScrn, xdir, ydir, GXcopy, ~0, color); - break; - case 16: - Mga16SetupForScreenToScreenCopy( - pScrn, xdir, ydir, GXcopy, ~0, color); - break; - case 32: - Mga32SetupForScreenToScreenCopy( - pScrn, xdir, ydir, GXcopy, ~0, color); - break; - } + if( (pMga->AccelInfoRec != NULL) + && (pMga->CurrentLayout.bitsPerPixel != 24) + && (pMga->Chipset != PCI_CHIP_MGA2064) ) { + const int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1; + const int ydir = (srcy < dsty) ? -1 : 1; - pMga->DrawTransparent = FALSE; + pMga->DrawTransparent = TRUE; - (*pMga->AccelInfoRec->SubsequentScreenToScreenCopy)( - pScrn, srcx, srcy, dstx, dsty, w, h); + mgaDoSetupForScreenToScreenCopy( pScrn, xdir, ydir, GXcopy, ~0, color, + pMga->CurrentLayout.bitsPerPixel ); - SET_SYNC_FLAG(pMga->AccelInfoRec); + pMga->DrawTransparent = FALSE; + + (*pMga->AccelInfoRec->SubsequentScreenToScreenCopy)( + pScrn, srcx, srcy, dstx, dsty, w, h); + + SET_SYNC_FLAG(pMga->AccelInfoRec); + } } -- cgit v1.2.3