mirror of
https://github.com/reactos/reactos.git
synced 2025-05-25 20:18:22 +00:00
[WIN32SS] Improve selection of 'closest graphic mode'
If color depth is not provided (in registry), try to find a 32 bit one. If not found, fall back to first available graphic mode. CORE-18027
This commit is contained in:
parent
d8b3402fe6
commit
14d50cc6c0
1 changed files with 63 additions and 37 deletions
|
@ -669,6 +669,31 @@ LDEVOBJ_bBuildDevmodeList(
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
BOOL
|
||||||
|
LDEVOBJ_bGetClosestMode(
|
||||||
|
_Inout_ PGRAPHICS_DEVICE pGraphicsDevice,
|
||||||
|
_In_ PDEVMODEW RequestedMode,
|
||||||
|
_Out_ PDEVMODEW *pSelectedMode)
|
||||||
|
{
|
||||||
|
if (pGraphicsDevice->cDevModes == 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/* Search a 32bit mode (if not already specified) */
|
||||||
|
if (!(RequestedMode->dmFields & DM_BITSPERPEL))
|
||||||
|
{
|
||||||
|
RequestedMode->dmBitsPerPel = 32;
|
||||||
|
RequestedMode->dmFields |= DM_BITSPERPEL;
|
||||||
|
}
|
||||||
|
if (LDEVOBJ_bProbeAndCaptureDevmode(pGraphicsDevice, RequestedMode, pSelectedMode, FALSE))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
/* Fall back to first mode */
|
||||||
|
WARN("Fall back to first available mode\n");
|
||||||
|
*pSelectedMode = pGraphicsDevice->pDevModeList[0].pdm;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
LDEVOBJ_bProbeAndCaptureDevmode(
|
LDEVOBJ_bProbeAndCaptureDevmode(
|
||||||
_Inout_ PGRAPHICS_DEVICE pGraphicsDevice,
|
_Inout_ PGRAPHICS_DEVICE pGraphicsDevice,
|
||||||
|
@ -683,6 +708,15 @@ LDEVOBJ_bProbeAndCaptureDevmode(
|
||||||
if (!LDEVOBJ_bBuildDevmodeList(pGraphicsDevice))
|
if (!LDEVOBJ_bBuildDevmodeList(pGraphicsDevice))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
if (bSearchClosestMode)
|
||||||
|
{
|
||||||
|
/* Search the closest mode */
|
||||||
|
if (!LDEVOBJ_bGetClosestMode(pGraphicsDevice, RequestedMode, &pdmSelected))
|
||||||
|
return FALSE;
|
||||||
|
ASSERT(pdmSelected);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/* Search if requested mode exists */
|
/* Search if requested mode exists */
|
||||||
for (i = 0; i < pGraphicsDevice->cDevModes; i++)
|
for (i = 0; i < pGraphicsDevice->cDevModes; i++)
|
||||||
{
|
{
|
||||||
|
@ -713,16 +747,8 @@ LDEVOBJ_bProbeAndCaptureDevmode(
|
||||||
RequestedMode->dmFields & DM_PELSHEIGHT ? RequestedMode->dmPelsHeight : 0,
|
RequestedMode->dmFields & DM_PELSHEIGHT ? RequestedMode->dmPelsHeight : 0,
|
||||||
RequestedMode->dmFields & DM_BITSPERPEL ? RequestedMode->dmBitsPerPel : 0,
|
RequestedMode->dmFields & DM_BITSPERPEL ? RequestedMode->dmBitsPerPel : 0,
|
||||||
RequestedMode->dmFields & DM_DISPLAYFREQUENCY ? RequestedMode->dmDisplayFrequency : 0);
|
RequestedMode->dmFields & DM_DISPLAYFREQUENCY ? RequestedMode->dmDisplayFrequency : 0);
|
||||||
if (!bSearchClosestMode || pGraphicsDevice->cDevModes == 0)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
/* FIXME: need to search the closest mode instead of taking the first one */
|
|
||||||
pdmSelected = pGraphicsDevice->pDevModeList[0].pdm;
|
|
||||||
WARN("Replacing it by %dx%dx%d %d Hz\n",
|
|
||||||
pdmSelected->dmFields & DM_PELSWIDTH ? pdmSelected->dmPelsWidth : 0,
|
|
||||||
pdmSelected->dmFields & DM_PELSHEIGHT ? pdmSelected->dmPelsHeight : 0,
|
|
||||||
pdmSelected->dmFields & DM_BITSPERPEL ? pdmSelected->dmBitsPerPel : 0,
|
|
||||||
pdmSelected->dmFields & DM_DISPLAYFREQUENCY ? pdmSelected->dmDisplayFrequency : 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate memory for output */
|
/* Allocate memory for output */
|
||||||
|
|
Loading…
Reference in a new issue