Author: khornicek Date: Sun Oct 24 23:40:23 2010 New Revision: 49267
URL: http://svn.reactos.org/svn/reactos?rev=49267&view=rev Log: [WIN32K] 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.
Modified: branches/reactos-yarotows/subsystems/win32/win32k/eng/device.c branches/reactos-yarotows/subsystems/win32/win32k/eng/rlecomp.c branches/reactos-yarotows/subsystems/win32/win32k/include/eng.h branches/reactos-yarotows/subsystems/win32/win32k/ntuser/display.c branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c
Modified: branches/reactos-yarotows/subsystems/win32/win32k/eng/device.c URL: http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win3... ============================================================================== --- branches/reactos-yarotows/subsystems/win32/win32k/eng/device.c [iso-8859-1] (original) +++ branches/reactos-yarotows/subsystems/win32/win32k/eng/device.c [iso-8859-1] Sun Oct 24 23:40:23 2010 @@ -243,9 +243,9 @@ 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);
Modified: branches/reactos-yarotows/subsystems/win32/win32k/eng/rlecomp.c URL: http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win3... ============================================================================== --- branches/reactos-yarotows/subsystems/win32/win32k/eng/rlecomp.c [iso-8859-1] (original) +++ branches/reactos-yarotows/subsystems/win32/win32k/eng/rlecomp.c [iso-8859-1] Sun Oct 24 23:40:23 2010 @@ -18,48 +18,59 @@ 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) + INT shift = 0; + + if (Format == BMF_4RLE) + shift = 1; + else if(Format != BMF_8RLE) + return; + + width = ((Size.cx + shift) >> shift); + + _SEH2_TRY { - length = *bits++ / 2; - 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++)/2; - y -= (*bits++)/2; + x += (*bits++) >> shift; + y -= (*bits++) >> shift; break; default: - length /= 2; + length = length >> shift; while (length--) { c = *bits++; @@ -74,67 +85,15 @@ { bits++; } + } } } } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + DPRINT1("Decoding error\n"); + } + _SEH2_END; + + return; } - -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) - { - length = *bits++; - 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++; - y -= *bits++; - break; - default: - while (length--) - { - c = *bits++; - if (x < width) - { - temp = UncompressedBits + (((height - y) * Delta) + x); - x++; - *temp = c; - } - } - if ((bits - begin) & 1) - { - bits++; - } - } - } - } -}
Modified: branches/reactos-yarotows/subsystems/win32/win32k/include/eng.h URL: http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win3... ============================================================================== --- branches/reactos-yarotows/subsystems/win32/win32k/include/eng.h [iso-8859-1] (original) +++ branches/reactos-yarotows/subsystems/win32/win32k/include/eng.h [iso-8859-1] Sun Oct 24 23:40:23 2010 @@ -36,6 +36,4 @@ 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);
Modified: branches/reactos-yarotows/subsystems/win32/win32k/ntuser/display.c URL: http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win3... ============================================================================== --- branches/reactos-yarotows/subsystems/win32/win32k/ntuser/display.c [iso-8859-1] (original) +++ branches/reactos-yarotows/subsystems/win32/win32k/ntuser/display.c [iso-8859-1] Sun Oct 24 23:40:23 2010 @@ -430,11 +430,12 @@ 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 @@ 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 @@ 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 @@ }
/* 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;
Modified: branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c URL: http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win3... ============================================================================== --- branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] (original) +++ branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] Sun Oct 24 23:40:23 2010 @@ -101,20 +101,13 @@ pso = &psurf->SurfObj;
/* The infamous RLE hack */ - if (iFormat == BMF_4RLE) - { - sizl.cx = nWidth; sizl.cy = nHeight; + if (iFormat == BMF_4RLE || iFormat == BMF_8RLE) + { + 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 @@ 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 @@ { 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,