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) if (pustrDevice)
{ {
/* Loop through the list of devices */ /* Loop through the list of devices */
for (pGraphicsDevice = gpGraphicsDeviceFirst, i = 0; for (pGraphicsDevice = gpGraphicsDeviceFirst;
pGraphicsDevice; pGraphicsDevice;
pGraphicsDevice = pGraphicsDevice->pNextGraphicsDevice, i++) pGraphicsDevice = pGraphicsDevice->pNextGraphicsDevice)
{ {
/* Compare the device name */ /* Compare the device name */
RtlInitUnicodeString(&ustrCurrent, pGraphicsDevice->szWinDeviceName); RtlInitUnicodeString(&ustrCurrent, pGraphicsDevice->szWinDeviceName);

View file

@ -18,108 +18,59 @@ enum Rle_EscapeCodes
RLE_DELTA = 2 /* Delta */ 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 x = 0;
int y = Size.cy - 1; INT y = Size.cy - 1;
int c; INT c;
int length; INT length;
int width = ((Size.cx+1)/2); INT width;
int height = Size.cy - 1; INT height = Size.cy - 1;
BYTE *begin = CompressedBits; BYTE *begin = CompressedBits;
BYTE *bits = CompressedBits; BYTE *bits = CompressedBits;
BYTE *temp; BYTE *temp;
while (y >= 0) INT shift = 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++;
}
}
}
}
}
VOID Decompress8bpp(SIZEL Size, BYTE *CompressedBits, BYTE *UncompressedBits, LONG Delta) if (Format == BMF_4RLE)
{ shift = 1;
int x = 0; else if(Format != BMF_8RLE)
int y = Size.cy - 1; return;
int c;
int length; width = ((Size.cx + shift) >> shift);
int width = Size.cx;
int height = Size.cy - 1; _SEH2_TRY
BYTE *begin = CompressedBits;
BYTE *bits = CompressedBits;
BYTE *temp;
while (y >= 0)
{ {
length = *bits++; while (y >= 0)
if (length)
{ {
c = *bits++; length = (*bits++) >> shift;
while (length--) if (length)
{ {
if (x >= width) break; c = *bits++;
temp = UncompressedBits + (((height - y) * Delta) + x); while (length--)
x++; {
*temp = c; if (x >= width) break;
temp = UncompressedBits + (((height - y) * Delta) + x);
x++;
*temp = c;
}
} }
} else
else
{
length = *bits++;
switch (length)
{ {
length = *bits++;
switch (length)
{
case RLE_EOL: case RLE_EOL:
x = 0; x = 0;
y--; y--;
break; break;
case RLE_END: case RLE_END:
return; _SEH2_YIELD(return);
case RLE_DELTA: case RLE_DELTA:
x += *bits++; x += (*bits++) >> shift;
y -= *bits++; y -= (*bits++) >> shift;
break; break;
default: default:
length = length >> shift;
while (length--) while (length--)
{ {
c = *bits++; c = *bits++;
@ -134,7 +85,15 @@ VOID Decompress8bpp(SIZEL Size, BYTE *CompressedBits, BYTE *UncompressedBits, LO
{ {
bits++; 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 SIZE_T cjSize,
IN ULONG ulTag); IN ULONG ulTag);
VOID Decompress4bpp(SIZEL Size, BYTE *CompressedBits, BYTE *UncompressedBits, LONG Delta); VOID DecompressBitmap(SIZEL Size, BYTE *CompressedBits, BYTE *UncompressedBits, LONG Delta, ULONG iFormat);
VOID Decompress8bpp(SIZEL Size, BYTE *CompressedBits, BYTE *UncompressedBits, LONG Delta);

View file

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

View file

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