Simplify the RLE hack and avoid code duplication.
Bail out of UserEnumDisplaySettings early in case invalid ModeNum was requested.
Use default BPP value in UserChangeDisplaySettings if DM_BITSPERPEL is not set. Partially fixes "fullscreen issue" as described on the yarotows wiki page.
Remove some unused variables + misc cleanup.

svn path=/branches/reactos-yarotows/; revision=49267
This commit is contained in:
Kamil Hornicek 2010-10-24 23:40:23 +00:00
parent c5880b6a1c
commit a5a3c1563c
5 changed files with 67 additions and 117 deletions

View file

@ -243,9 +243,9 @@ EngpFindGraphicsDevice(
if (pustrDevice)
{
/* Loop through the list of devices */
for (pGraphicsDevice = gpGraphicsDeviceFirst, i = 0;
for (pGraphicsDevice = gpGraphicsDeviceFirst;
pGraphicsDevice;
pGraphicsDevice = pGraphicsDevice->pNextGraphicsDevice, i++)
pGraphicsDevice = pGraphicsDevice->pNextGraphicsDevice)
{
/* Compare the device name */
RtlInitUnicodeString(&ustrCurrent, pGraphicsDevice->szWinDeviceName);

View file

@ -18,108 +18,59 @@ enum Rle_EscapeCodes
RLE_DELTA = 2 /* Delta */
};
VOID Decompress4bpp(SIZEL Size, BYTE *CompressedBits, BYTE *UncompressedBits, LONG Delta)
VOID DecompressBitmap(SIZEL Size, BYTE *CompressedBits, BYTE *UncompressedBits, LONG Delta, ULONG Format)
{
int x = 0;
int y = Size.cy - 1;
int c;
int length;
int width = ((Size.cx+1)/2);
int height = Size.cy - 1;
INT x = 0;
INT y = Size.cy - 1;
INT c;
INT length;
INT width;
INT height = Size.cy - 1;
BYTE *begin = CompressedBits;
BYTE *bits = CompressedBits;
BYTE *temp;
while (y >= 0)
{
length = *bits++ / 2;
if (length)
{
c = *bits++;
while (length--)
{
if (x >= width) break;
temp = UncompressedBits + (((height - y) * Delta) + x);
x++;
*temp = c;
}
}
else
{
length = *bits++;
switch (length)
{
case RLE_EOL:
x = 0;
y--;
break;
case RLE_END:
return;
case RLE_DELTA:
x += (*bits++)/2;
y -= (*bits++)/2;
break;
default:
length /= 2;
while (length--)
{
c = *bits++;
if (x < width)
{
temp = UncompressedBits + (((height - y) * Delta) + x);
x++;
*temp = c;
}
}
if ((bits - begin) & 1)
{
bits++;
}
}
}
}
}
INT shift = 0;
VOID Decompress8bpp(SIZEL Size, BYTE *CompressedBits, BYTE *UncompressedBits, LONG Delta)
{
int x = 0;
int y = Size.cy - 1;
int c;
int length;
int width = Size.cx;
int height = Size.cy - 1;
BYTE *begin = CompressedBits;
BYTE *bits = CompressedBits;
BYTE *temp;
while (y >= 0)
if (Format == BMF_4RLE)
shift = 1;
else if(Format != BMF_8RLE)
return;
width = ((Size.cx + shift) >> shift);
_SEH2_TRY
{
length = *bits++;
if (length)
while (y >= 0)
{
c = *bits++;
while (length--)
length = (*bits++) >> shift;
if (length)
{
if (x >= width) break;
temp = UncompressedBits + (((height - y) * Delta) + x);
x++;
*temp = c;
c = *bits++;
while (length--)
{
if (x >= width) break;
temp = UncompressedBits + (((height - y) * Delta) + x);
x++;
*temp = c;
}
}
}
else
{
length = *bits++;
switch (length)
else
{
length = *bits++;
switch (length)
{
case RLE_EOL:
x = 0;
y--;
break;
case RLE_END:
return;
_SEH2_YIELD(return);
case RLE_DELTA:
x += *bits++;
y -= *bits++;
x += (*bits++) >> shift;
y -= (*bits++) >> shift;
break;
default:
length = length >> shift;
while (length--)
{
c = *bits++;
@ -134,7 +85,15 @@ VOID Decompress8bpp(SIZEL Size, BYTE *CompressedBits, BYTE *UncompressedBits, LO
{
bits++;
}
}
}
}
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
DPRINT1("Decoding error\n");
}
_SEH2_END;
return;
}

View file

@ -36,6 +36,4 @@ EngAllocSectionMem(
IN SIZE_T cjSize,
IN ULONG ulTag);
VOID Decompress4bpp(SIZEL Size, BYTE *CompressedBits, BYTE *UncompressedBits, LONG Delta);
VOID Decompress8bpp(SIZEL Size, BYTE *CompressedBits, BYTE *UncompressedBits, LONG Delta);
VOID DecompressBitmap(SIZEL Size, BYTE *CompressedBits, BYTE *UncompressedBits, LONG Delta, ULONG iFormat);

View file

@ -430,11 +430,12 @@ UserEnumDisplaySettings(
PDEVMODEENTRY pdmentry;
ULONG i, iFoundMode;
DPRINT1("Enter UserEnumDisplaySettings('%ls', %ld)\n",
DPRINT("Enter UserEnumDisplaySettings('%ls', %ld)\n",
pustrDevice ? pustrDevice->Buffer : NULL, iModeNum);
/* Ask gdi for the GRAPHICS_DEVICE */
pGraphicsDevice = EngpFindGraphicsDevice(pustrDevice, 0, 0);
if (!pGraphicsDevice)
{
/* No device found */
@ -442,19 +443,19 @@ UserEnumDisplaySettings(
return STATUS_UNSUCCESSFUL;
}
if (iModeNum == 0)
{
DPRINT1("Should initialize modes somehow\n");
// Update DISPLAY_DEVICEs?
}
if (iModeNum >= pGraphicsDevice->cDevModes)
return STATUS_NO_MORE_ENTRIES;
iFoundMode = 0;
for (i = 0; i < pGraphicsDevice->cDevModes; i++)
{
pdmentry = &pGraphicsDevice->pDevModeList[i];
// if ((!(dwFlags & EDS_RAWMODE) && (pdmentry->dwFlags & 1)) || // FIXME!
// (dwFlags & EDS_RAWMODE))
/* FIXME: consider EDS_RAWMODE */
#if 0
if ((!(dwFlags & EDS_RAWMODE) && (pdmentry->dwFlags & 1)) ||!
(dwFlags & EDS_RAWMODE))
#endif
{
/* Is this the one we want? */
if (iFoundMode == iModeNum)
@ -536,7 +537,7 @@ NtUserEnumDisplaySettings(
DEVMODEW dmReg, *pdm;
DPRINT1("Enter NtUserEnumDisplaySettings(%ls, %ld)\n",
pustrDevice ? pustrDevice->Buffer:0, iModeNum);
pustrDevice ? pustrDevice->Buffer : 0, iModeNum);
if (pustrDevice)
{
@ -668,8 +669,12 @@ UserChangeDisplaySettings(
}
/* Fixup values */
if((dm.dmFields & DM_BITSPERPEL) && (dm.dmBitsPerPel == 0))
if(dm.dmBitsPerPel == 0 || !(dm.dmFields & DM_BITSPERPEL))
{
dm.dmBitsPerPel = ppdev->pdmwDev->dmBitsPerPel;
dm.dmFields |= DM_BITSPERPEL;
}
if((dm.dmFields & DM_DISPLAYFREQUENCY) && (dm.dmDisplayFrequency == 0))
dm.dmDisplayFrequency = ppdev->pdmwDev->dmDisplayFrequency;

View file

@ -101,20 +101,13 @@ GreCreateBitmapEx(
pso = &psurf->SurfObj;
/* The infamous RLE hack */
if (iFormat == BMF_4RLE)
if (iFormat == BMF_4RLE || iFormat == BMF_8RLE)
{
sizl.cx = nWidth; sizl.cy = nHeight;
sizl.cx = nWidth;
sizl.cy = nHeight;
pvCompressedBits = pvBits;
pvBits = EngAllocMem(FL_ZERO_MEMORY, pso->cjBits, TAG_DIB);
Decompress4bpp(sizl, pvCompressedBits, pvBits, pso->lDelta);
fjBitmap |= BMF_RLE_HACK;
}
else if (iFormat == BMF_8RLE)
{
sizl.cx = nWidth; sizl.cy = nHeight;
pvCompressedBits = pvBits;
pvBits = EngAllocMem(FL_ZERO_MEMORY, pso->cjBits, TAG_DIB);
Decompress8bpp(sizl, pvCompressedBits, pvBits, pso->lDelta);
DecompressBitmap(sizl, pvCompressedBits, pvBits, pso->lDelta, iFormat);
fjBitmap |= BMF_RLE_HACK;
}
@ -239,10 +232,7 @@ IntCreateCompatibleBitmap(
if (Dc->dctype != DC_TYPE_MEMORY)
{
PSURFACE psurf;
SIZEL size;
size.cx = abs(Width);
size.cy = abs(Height);
Bmp = GreCreateBitmap(abs(Width),
abs(Height),
1,
@ -268,11 +258,9 @@ IntCreateCompatibleBitmap(
{
if (Count == sizeof(BITMAP))
{
SIZEL size;
PSURFACE psurfBmp;
size.cx = abs(Width);
size.cy = abs(Height);
Bmp = GreCreateBitmap(abs(Width),
Bmp = GreCreateBitmap(abs(Width),
abs(Height),
1,
dibs.dsBm.bmBitsPixel,