mirror of
https://github.com/reactos/reactos.git
synced 2024-08-07 19:58:21 +00:00
Improved HLine algorithm; improvement carried over to FillSolid
svn path=/trunk/; revision=3370
This commit is contained in:
parent
6b30cb44dd
commit
51f0384fc0
|
@ -1,9 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* entry.c
|
* entry.c
|
||||||
*
|
*
|
||||||
* $Revision: 1.18 $
|
* $Revision: 1.19 $
|
||||||
* $Author: ekohl $
|
* $Author: jfilby $
|
||||||
* $Date: 2002/06/15 14:57:26 $
|
* $Date: 2002/08/19 22:01:11 $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -202,13 +202,14 @@ DrvAssertMode(IN DHPDEV DPev,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID STDCALL
|
VOID STDCALL
|
||||||
DrvDisablePDEV(IN DHPDEV PDev)
|
DrvDisablePDEV(IN DHPDEV PDev)
|
||||||
{
|
{
|
||||||
PPDEV ppdev = (PPDEV)PDev;
|
PPDEV ppdev = (PPDEV)PDev;
|
||||||
|
|
||||||
// EngDeletePalette(devinfoVGA.hpalDefault);
|
// EngDeletePalette(devinfoVGA.hpalDefault);
|
||||||
if (ppdev->pjPreallocSSBBuffer != NULL)
|
if (ppdev->pjPreallocSSBBuffer != NULL)
|
||||||
|
|
|
@ -10,9 +10,11 @@ BOOL VGADDIFillSolid(SURFOBJ *Surface, RECTL Dimensions, ULONG iColor)
|
||||||
int x, y, x2, y2, w, h;
|
int x, y, x2, y2, w, h;
|
||||||
ULONG offset, i, j, pre1;
|
ULONG offset, i, j, pre1;
|
||||||
ULONG orgpre1, orgx, midpre1, tmppre1;
|
ULONG orgpre1, orgx, midpre1, tmppre1;
|
||||||
ULONG long leftpixs, midpixs, rightpixs, temp;
|
ULONG ileftpix, imidpix, irightpix;
|
||||||
|
double leftpix, midpix, rightpix, temp;
|
||||||
UCHAR a;
|
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
|
// Swap dimensions so that x, y are at topmost left
|
||||||
if(Dimensions.right < Dimensions.left) {
|
if(Dimensions.right < Dimensions.left) {
|
||||||
|
@ -33,7 +35,6 @@ BOOL VGADDIFillSolid(SURFOBJ *Surface, RECTL Dimensions, ULONG iColor)
|
||||||
// Calculate the width and height
|
// Calculate the width and height
|
||||||
w = x2 - x;
|
w = x2 - x;
|
||||||
h = y2 - y;
|
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
|
// Calculate the starting offset
|
||||||
offset = xconv[x]+y80[y];
|
offset = xconv[x]+y80[y];
|
||||||
|
@ -50,33 +51,23 @@ BOOL VGADDIFillSolid(SURFOBJ *Surface, RECTL Dimensions, ULONG iColor)
|
||||||
// Otherwise, use the optimized code
|
// Otherwise, use the optimized code
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
leftpixs=x;
|
// Calculate the left mask pixels, middle bytes and right mask pixel
|
||||||
while(leftpixs>8) leftpixs-=8;
|
leftpix = 8-mod(x, 8);
|
||||||
temp = w;
|
rightpix = mod(x+w, 8);
|
||||||
midpixs = 0;
|
midpix = (w-leftpix-rightpix) / 8;
|
||||||
|
|
||||||
// Determine the number of bytes we can write (all 8 bits of the byte mask)
|
ileftpix = leftpix;
|
||||||
while(temp>7)
|
irightpix = rightpix;
|
||||||
{
|
imidpix = midpix;
|
||||||
temp-=8;
|
|
||||||
midpixs++;
|
|
||||||
}
|
|
||||||
if((temp>=0) && (midpixs>0)) midpixs--;
|
|
||||||
|
|
||||||
pre1=xconv[x]+y80[y];
|
pre1=xconv[x-(8-ileftpix)]+y80[y];
|
||||||
orgpre1=pre1;
|
orgpre1=pre1;
|
||||||
|
|
||||||
// Left
|
if(ileftpix>0)
|
||||||
if(leftpixs==8) {
|
|
||||||
// Left edge should be an entire middle bar
|
|
||||||
x=orgx;
|
|
||||||
leftpixs=0;
|
|
||||||
}
|
|
||||||
else if(leftpixs>0)
|
|
||||||
{
|
{
|
||||||
// Write left pixels
|
// Write left pixels
|
||||||
WRITE_PORT_UCHAR((PUCHAR)0x3ce,0x08); // set the mask
|
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;
|
tmppre1 = pre1;
|
||||||
for (j=y; j<y+h; j++)
|
for (j=y; j<y+h; j++)
|
||||||
|
@ -86,63 +77,38 @@ BOOL VGADDIFillSolid(SURFOBJ *Surface, RECTL Dimensions, ULONG iColor)
|
||||||
tmppre1+=80;
|
tmppre1+=80;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Middle
|
// Prepare new x for the middle
|
||||||
|
x=orgx+8;
|
||||||
x=orgx+(8-leftpixs)+leftpixs;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// leftpixs == 0
|
|
||||||
midpixs+=1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(midpixs>0)
|
if(imidpix>0)
|
||||||
{
|
{
|
||||||
midpre1=xconv[x]+y80[y];
|
midpre1=xconv[x]+y80[y];
|
||||||
|
|
||||||
// Set mask to all pixels in byte
|
// Set mask to all pixels in byte
|
||||||
WRITE_PORT_UCHAR((PUCHAR)0x3ce, 0x08);
|
WRITE_PORT_UCHAR((PUCHAR)0x3ce, 0x08);
|
||||||
|
|
||||||
WRITE_PORT_UCHAR((PUCHAR)0x3cf, 0xff);
|
WRITE_PORT_UCHAR((PUCHAR)0x3cf, 0xff);
|
||||||
|
|
||||||
for (j=y; j<y+h; j++)
|
for (j=y; j<y+h; j++)
|
||||||
{
|
{
|
||||||
memset(vidmem+midpre1, iColor, midpixs); // write middle pixels, no need to read in latch because of the width
|
memset(vidmem+midpre1, iColor, imidpix); // write middle pixels, no need to read in latch because of the width
|
||||||
midpre1+=80;
|
midpre1+=80;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rightpixs = w - ((midpixs*8) + leftpixs);
|
x=orgx+w-irightpix;
|
||||||
|
pre1=xconv[x]+y80[y];
|
||||||
|
|
||||||
if((rightpixs>0))
|
// Write right pixels
|
||||||
|
WRITE_PORT_UCHAR((PUCHAR)0x3ce,0x08); // set the mask bits
|
||||||
|
WRITE_PORT_UCHAR((PUCHAR)0x3cf,endmasks[irightpix]);
|
||||||
|
|
||||||
|
for (j=y; j<y+h; j++)
|
||||||
{
|
{
|
||||||
x=(orgx+w)-rightpixs;
|
a = READ_REGISTER_UCHAR(vidmem + pre1);
|
||||||
|
WRITE_REGISTER_UCHAR(vidmem + pre1, iColor);
|
||||||
// Go backwards till we reach the 8-byte boundary
|
pre1+=80;
|
||||||
while(mod(x, 8)!=0) { x--; rightpixs++; }
|
|
||||||
|
|
||||||
while(rightpixs>7)
|
|
||||||
{
|
|
||||||
// This is a BAD case as this should have been a midpixs
|
|
||||||
|
|
||||||
for (j=y; j<y+h; j++)
|
|
||||||
{
|
|
||||||
vgaPutByte(x, j, iColor);
|
|
||||||
}
|
|
||||||
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]);
|
|
||||||
|
|
||||||
for (j=y; j<y+h; j++)
|
|
||||||
{
|
|
||||||
a = READ_REGISTER_UCHAR(vidmem + pre1);
|
|
||||||
WRITE_REGISTER_UCHAR(vidmem + pre1, iColor);
|
|
||||||
pre1+=80;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,13 +80,14 @@ VOID vgaPreCalc()
|
||||||
{
|
{
|
||||||
ULONG j;
|
ULONG j;
|
||||||
|
|
||||||
startmasks[1] = 127;
|
startmasks[0] = 255;
|
||||||
startmasks[2] = 63;
|
startmasks[1] = 1;
|
||||||
startmasks[3] = 31;
|
startmasks[2] = 3;
|
||||||
|
startmasks[3] = 7;
|
||||||
startmasks[4] = 15;
|
startmasks[4] = 15;
|
||||||
startmasks[5] = 7;
|
startmasks[5] = 31;
|
||||||
startmasks[6] = 3;
|
startmasks[6] = 63;
|
||||||
startmasks[7] = 1;
|
startmasks[7] = 127;
|
||||||
startmasks[8] = 255;
|
startmasks[8] = 255;
|
||||||
|
|
||||||
endmasks[0] = 128;
|
endmasks[0] = 128;
|
||||||
|
@ -226,7 +227,8 @@ BOOL vgaHLine(INT x, INT y, INT len, UCHAR c)
|
||||||
UCHAR a;
|
UCHAR a;
|
||||||
ULONG pre1, i;
|
ULONG pre1, i;
|
||||||
ULONG orgpre1, orgx, midpre1;
|
ULONG orgpre1, orgx, midpre1;
|
||||||
ULONG long leftpixs, midpixs, rightpixs, temp;
|
ULONG ileftpix, imidpix, irightpix;
|
||||||
|
double leftpix, midpix, rightpix, temp;
|
||||||
|
|
||||||
orgx=x;
|
orgx=x;
|
||||||
|
|
||||||
|
@ -236,81 +238,51 @@ BOOL vgaHLine(INT x, INT y, INT len, UCHAR c)
|
||||||
vgaPutPixel(i, y, c);
|
vgaPutPixel(i, y, c);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
leftpixs=x;
|
// Calculate the left mask pixels, middle bytes and right mask pixel
|
||||||
while(leftpixs>8) leftpixs-=8;
|
leftpix = 8-mod(x, 8);
|
||||||
temp = len;
|
rightpix = mod(x+len, 8);
|
||||||
midpixs = 0;
|
midpix = (len-leftpix-rightpix) / 8;
|
||||||
|
|
||||||
while(temp>7)
|
ileftpix = leftpix;
|
||||||
{
|
irightpix = rightpix;
|
||||||
temp-=8;
|
imidpix = midpix;
|
||||||
midpixs++;
|
|
||||||
}
|
|
||||||
if((temp>=0) && (midpixs>0)) midpixs--;
|
|
||||||
|
|
||||||
pre1=xconv[x]+y80[y];
|
pre1=xconv[x-(8-ileftpix)]+y80[y];
|
||||||
orgpre1=pre1;
|
orgpre1=pre1;
|
||||||
|
|
||||||
// Left
|
// Left
|
||||||
if(leftpixs==8) {
|
if(ileftpix>0)
|
||||||
// Left edge should be an entire middle bar
|
|
||||||
x=orgx;
|
|
||||||
leftpixs=0;
|
|
||||||
}
|
|
||||||
else if(leftpixs>0)
|
|
||||||
{
|
{
|
||||||
// Write left pixels
|
// Write left pixels
|
||||||
WRITE_PORT_UCHAR((PUCHAR)0x3ce,0x08); // set the mask
|
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);
|
a = READ_REGISTER_UCHAR(vidmem + pre1);
|
||||||
WRITE_REGISTER_UCHAR(vidmem + pre1, c);
|
WRITE_REGISTER_UCHAR(vidmem + pre1, c);
|
||||||
|
|
||||||
// Middle
|
// Prepare new x for the middle
|
||||||
x=orgx+(8-leftpixs)+leftpixs;
|
x=orgx+8;
|
||||||
|
|
||||||
} else {
|
|
||||||
// leftpixs == 0
|
|
||||||
midpixs+=1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(midpixs>0)
|
if(imidpix>0)
|
||||||
{
|
{
|
||||||
midpre1=xconv[x]+y80[y];
|
midpre1=xconv[x]+y80[y];
|
||||||
|
|
||||||
// Set mask to all pixels in byte
|
// Set mask to all pixels in byte
|
||||||
WRITE_PORT_UCHAR((PUCHAR)0x3ce, 0x08);
|
WRITE_PORT_UCHAR((PUCHAR)0x3ce, 0x08);
|
||||||
WRITE_PORT_UCHAR((PUCHAR)0x3cf, 0xff);
|
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))
|
// Write right pixels
|
||||||
{
|
WRITE_PORT_UCHAR((PUCHAR)0x3ce,0x08); // set the mask bits
|
||||||
x=(orgx+len)-rightpixs;
|
WRITE_PORT_UCHAR((PUCHAR)0x3cf, endmasks[irightpix]);
|
||||||
|
|
||||||
// Go backwards till we reach the 8-byte boundary
|
a = READ_REGISTER_UCHAR(vidmem + pre1);
|
||||||
while(mod(x, 8)!=0) { x--; rightpixs++; }
|
WRITE_REGISTER_UCHAR(vidmem + pre1, c);
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
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;
|
opb += Source_lDelta;
|
||||||
|
|
||||||
pb = opb;
|
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)
|
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
|
// This algorithm converts a DIB into a DFB
|
||||||
|
|
Loading…
Reference in a new issue