From 51f0384fc082b467fb12b9aeaac6f7be785ff54d Mon Sep 17 00:00:00 2001 From: Jason Filby Date: Mon, 19 Aug 2002 22:01:12 +0000 Subject: [PATCH] Improved HLine algorithm; improvement carried over to FillSolid svn path=/trunk/; revision=3370 --- reactos/drivers/dd/vga/display/main/enable.c | 9 +- .../drivers/dd/vga/display/objects/paint.c | 90 ++++++------------- .../dd/vga/display/vgavideo/vgavideo.c | 90 +++++++------------ 3 files changed, 65 insertions(+), 124 deletions(-) diff --git a/reactos/drivers/dd/vga/display/main/enable.c b/reactos/drivers/dd/vga/display/main/enable.c index 57deba4c7c3..3bd357fc2c4 100644 --- a/reactos/drivers/dd/vga/display/main/enable.c +++ b/reactos/drivers/dd/vga/display/main/enable.c @@ -1,9 +1,9 @@ /* * entry.c * - * $Revision: 1.18 $ - * $Author: ekohl $ - * $Date: 2002/06/15 14:57:26 $ + * $Revision: 1.19 $ + * $Author: jfilby $ + * $Date: 2002/08/19 22:01:11 $ * */ @@ -202,13 +202,14 @@ DrvAssertMode(IN DHPDEV DPev, } } + } VOID STDCALL DrvDisablePDEV(IN DHPDEV PDev) { - PPDEV ppdev = (PPDEV)PDev; + PPDEV ppdev = (PPDEV)PDev; // EngDeletePalette(devinfoVGA.hpalDefault); if (ppdev->pjPreallocSSBBuffer != NULL) diff --git a/reactos/drivers/dd/vga/display/objects/paint.c b/reactos/drivers/dd/vga/display/objects/paint.c index 8193b49549a..f50ab17402e 100644 --- a/reactos/drivers/dd/vga/display/objects/paint.c +++ b/reactos/drivers/dd/vga/display/objects/paint.c @@ -10,9 +10,11 @@ BOOL VGADDIFillSolid(SURFOBJ *Surface, RECTL Dimensions, ULONG iColor) int x, y, x2, y2, w, h; ULONG offset, i, j, pre1; ULONG orgpre1, orgx, midpre1, tmppre1; - ULONG long leftpixs, midpixs, rightpixs, temp; + ULONG ileftpix, imidpix, irightpix; + double leftpix, midpix, rightpix, temp; UCHAR a; + DPRINT("VGADDIFillSolid: x:%d, y:%d, w:%d, h:%d\n", x, y, w, h); // Swap dimensions so that x, y are at topmost left if(Dimensions.right < Dimensions.left) { @@ -33,7 +35,6 @@ BOOL VGADDIFillSolid(SURFOBJ *Surface, RECTL Dimensions, ULONG iColor) // Calculate the width and height w = x2 - x; h = y2 - y; - DPRINT("VGADDIFillSolid: x:%d, y:%d, w:%d, h:%d, color: %d\n", x, y, w, h, iColor); // Calculate the starting offset offset = xconv[x]+y80[y]; @@ -50,33 +51,23 @@ BOOL VGADDIFillSolid(SURFOBJ *Surface, RECTL Dimensions, ULONG iColor) // Otherwise, use the optimized code } else { - leftpixs=x; - while(leftpixs>8) leftpixs-=8; - temp = w; - midpixs = 0; + // Calculate the left mask pixels, middle bytes and right mask pixel + leftpix = 8-mod(x, 8); + rightpix = mod(x+w, 8); + midpix = (w-leftpix-rightpix) / 8; - // Determine the number of bytes we can write (all 8 bits of the byte mask) - while(temp>7) - { - temp-=8; - midpixs++; - } - if((temp>=0) && (midpixs>0)) midpixs--; + ileftpix = leftpix; + irightpix = rightpix; + imidpix = midpix; - pre1=xconv[x]+y80[y]; + pre1=xconv[x-(8-ileftpix)]+y80[y]; orgpre1=pre1; - // Left - if(leftpixs==8) { - // Left edge should be an entire middle bar - x=orgx; - leftpixs=0; - } - else if(leftpixs>0) + if(ileftpix>0) { // Write left pixels WRITE_PORT_UCHAR((PUCHAR)0x3ce,0x08); // set the mask - WRITE_PORT_UCHAR((PUCHAR)0x3cf,startmasks[leftpixs]); + WRITE_PORT_UCHAR((PUCHAR)0x3cf,startmasks[ileftpix]); tmppre1 = pre1; for (j=y; j0) + if(imidpix>0) { midpre1=xconv[x]+y80[y]; // Set mask to all pixels in byte WRITE_PORT_UCHAR((PUCHAR)0x3ce, 0x08); + WRITE_PORT_UCHAR((PUCHAR)0x3cf, 0xff); for (j=y; j0)) + // Write right pixels + WRITE_PORT_UCHAR((PUCHAR)0x3ce,0x08); // set the mask bits + WRITE_PORT_UCHAR((PUCHAR)0x3cf,endmasks[irightpix]); + + for (j=y; j7) - { - // This is a BAD case as this should have been a midpixs - - for (j=y; j8) leftpixs-=8; - temp = len; - midpixs = 0; + // Calculate the left mask pixels, middle bytes and right mask pixel + leftpix = 8-mod(x, 8); + rightpix = mod(x+len, 8); + midpix = (len-leftpix-rightpix) / 8; - while(temp>7) - { - temp-=8; - midpixs++; - } - if((temp>=0) && (midpixs>0)) midpixs--; + ileftpix = leftpix; + irightpix = rightpix; + imidpix = midpix; - pre1=xconv[x]+y80[y]; + pre1=xconv[x-(8-ileftpix)]+y80[y]; orgpre1=pre1; // Left - if(leftpixs==8) { - // Left edge should be an entire middle bar - x=orgx; - leftpixs=0; - } - else if(leftpixs>0) + if(ileftpix>0) { // Write left pixels WRITE_PORT_UCHAR((PUCHAR)0x3ce,0x08); // set the mask - WRITE_PORT_UCHAR((PUCHAR)0x3cf,startmasks[leftpixs]); + WRITE_PORT_UCHAR((PUCHAR)0x3cf,startmasks[ileftpix]); a = READ_REGISTER_UCHAR(vidmem + pre1); WRITE_REGISTER_UCHAR(vidmem + pre1, c); - // Middle - x=orgx+(8-leftpixs)+leftpixs; - - } else { - // leftpixs == 0 - midpixs+=1; + // Prepare new x for the middle + x=orgx+8; } - if(midpixs>0) + if(imidpix>0) { midpre1=xconv[x]+y80[y]; // Set mask to all pixels in byte WRITE_PORT_UCHAR((PUCHAR)0x3ce, 0x08); WRITE_PORT_UCHAR((PUCHAR)0x3cf, 0xff); - memset(vidmem+midpre1, c, midpixs); // write middle pixels, no need to read in latch because of the width + memset(vidmem+midpre1, c, imidpix); // write middle pixels, no need to read in latch because of the width } - rightpixs = len - ((midpixs*8) + leftpixs); + x=orgx+len-irightpix; + pre1=xconv[x]+y80[y]; - if((rightpixs>0)) - { - x=(orgx+len)-rightpixs; + // Write right pixels + WRITE_PORT_UCHAR((PUCHAR)0x3ce,0x08); // set the mask bits + WRITE_PORT_UCHAR((PUCHAR)0x3cf, endmasks[irightpix]); - // Go backwards till we reach the 8-byte boundary - while(mod(x, 8)!=0) { x--; rightpixs++; } - - while(rightpixs>7) - { - // This is a BAD case as this should have been a midpixs - - vgaPutByte(x, y, c); - rightpixs-=8; - x+=8; - } - - pre1=xconv[x]+y80[y]; - - // Write right pixels - WRITE_PORT_UCHAR((PUCHAR)0x3ce,0x08); // set the mask bits - WRITE_PORT_UCHAR((PUCHAR)0x3cf,endmasks[rightpixs]); - - a = READ_REGISTER_UCHAR(vidmem + pre1); - WRITE_REGISTER_UCHAR(vidmem + pre1, c); - } + a = READ_REGISTER_UCHAR(vidmem + pre1); + WRITE_REGISTER_UCHAR(vidmem + pre1, c); } return TRUE; @@ -439,6 +411,7 @@ void DIB_BltToVGA(int x, int y, int w, int h, void *b, int Source_lDelta) } opb += Source_lDelta; + pb = opb; } @@ -686,6 +659,7 @@ void DFB_BltToDIB(int x, int y, int w, int h, void *b, int bw, void *bdib, int d } } + void DIB_BltToDFB(int x, int y, int w, int h, void *b, int bw, void *bdib, int dibw) // This algorithm converts a DIB into a DFB