Commit bd554e63 authored by Alex Pasadyn's avatar Alex Pasadyn Committed by Alexandre Julliard

- Add more logging to resolution changes and queries.

- Always enumerate and allow 8, 16, and 32-bit modes. - Add more default choices to Wine desktop sizes. - Renamed some variables to make things easier to follow.
parent 86794d25
......@@ -93,28 +93,6 @@ BOOL DDRAW_User_Init(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
return TRUE;
}
/* If you change this function, you probably want to change the enumeration
* code in EnumDisplayModes. */
static BOOL
IsValidDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP,
DWORD dwRefreshRate, DWORD dwFlags)
{
switch (dwBPP)
{
case 8:
case 15:
case 16:
case 24:
case 32:
break;
default:
return FALSE;
}
return TRUE;
}
static const DDPIXELFORMAT* pixelformat_for_depth(DWORD depth)
{
switch (depth)
......@@ -310,13 +288,11 @@ User_DirectDraw_EnumDisplayModes(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPDDSURFACEDESC2 pDDSD, LPVOID context,
LPDDENUMMODESCALLBACK2 callback)
{
static const int num_pixelformats
= sizeof(pixelformats)/sizeof(pixelformats[0]);
DDSURFACEDESC2 callback_sd;
DEVMODEW DevModeW;
const DDPIXELFORMAT* pixelformat;
int i, j;
int i;
TRACE("(%p)->(0x%08lx,%p,%p,%p)\n",iface,dwFlags,pDDSD,context,callback);
......@@ -336,33 +312,31 @@ User_DirectDraw_EnumDisplayModes(LPDIRECTDRAW7 iface, DWORD dwFlags,
{
callback_sd.dwHeight = DevModeW.dmPelsHeight;
callback_sd.dwWidth = DevModeW.dmPelsWidth;
if (DevModeW.dmFields&DM_DISPLAYFREQUENCY)
{
callback_sd.u2.dwRefreshRate = DevModeW.dmDisplayFrequency;
}
TRACE("- mode: %ldx%ld\n", callback_sd.dwWidth, callback_sd.dwHeight);
for (j = 0; j < num_pixelformats; j++)
{
callback_sd.u1.lPitch
= DDRAW_width_bpp_to_pitch(DevModeW.dmPelsWidth,
pixelformats[j].u1.dwRGBBitCount);
callback_sd.u4.ddpfPixelFormat = pixelformats[j];
callback_sd.ddsCaps.dwCaps = 0;
if (pixelformats[j].dwFlags & DDPF_PALETTEINDEXED8) /* ick */
callback_sd.ddsCaps.dwCaps |= DDSCAPS_PALETTE;
assert(IsValidDisplayMode(callback_sd.dwWidth,
callback_sd.dwHeight,
callback_sd.u4.ddpfPixelFormat.u1.dwRGBBitCount,
0, 0));
TRACE(" - %2ld bpp, R=%08lx G=%08lx B=%08lx\n",
callback_sd.u4.ddpfPixelFormat.u1.dwRGBBitCount,
callback_sd.u4.ddpfPixelFormat.u2.dwRBitMask,
callback_sd.u4.ddpfPixelFormat.u3.dwGBitMask,
callback_sd.u4.ddpfPixelFormat.u4.dwBBitMask);
if (callback(&callback_sd, context) == DDENUMRET_CANCEL)
return DD_OK;
}
pixelformat = pixelformat_for_depth(DevModeW.dmBitsPerPel);
callback_sd.u1.lPitch
= DDRAW_width_bpp_to_pitch(DevModeW.dmPelsWidth,
pixelformat->u1.dwRGBBitCount);
callback_sd.u4.ddpfPixelFormat = *pixelformat;
callback_sd.ddsCaps.dwCaps = 0;
if (pixelformat->dwFlags & DDPF_PALETTEINDEXED8) /* ick */
callback_sd.ddsCaps.dwCaps |= DDSCAPS_PALETTE;
TRACE(" - %2ld bpp, R=%08lx G=%08lx B=%08lx\n",
callback_sd.u4.ddpfPixelFormat.u1.dwRGBBitCount,
callback_sd.u4.ddpfPixelFormat.u2.dwRBitMask,
callback_sd.u4.ddpfPixelFormat.u3.dwGBitMask,
callback_sd.u4.ddpfPixelFormat.u4.dwBBitMask);
if (callback(&callback_sd, context) == DDENUMRET_CANCEL)
return DD_OK;
i++;
}
......@@ -528,8 +502,7 @@ User_DirectDraw_SetDisplayMode(LPDIRECTDRAW7 iface, DWORD dwWidth,
LONG pitch;
TRACE("(%p)->(%ldx%ldx%ld,%ld Hz,%08lx)\n",This,dwWidth,dwHeight,dwBPP,dwRefreshRate,dwFlags);
devmode.dmFields = /* DM_BITSPERPEL | */ DM_PELSWIDTH | DM_PELSHEIGHT;
FIXME("Ignoring requested BPP (%ld)\n", dwBPP);
devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
devmode.dmBitsPerPel = dwBPP;
devmode.dmPelsWidth = dwWidth;
devmode.dmPelsHeight = dwHeight;
......
......@@ -120,43 +120,64 @@ static int nmodes;
static unsigned int max_width;
static unsigned int max_height;
static const unsigned int widths[] = {320, 640, 800, 1024, 1280, 1600};
static const unsigned int heights[] = {200, 480, 600, 768, 1024, 1200};
static const unsigned int widths[] = {320, 512, 640, 800, 1024, 1152, 1280, 1600};
static const unsigned int heights[] = {200, 384, 480, 600, 768, 864, 1024, 1200};
static const unsigned int depths[] = {8, 16, 32};
/* fill in DD mode info for one mode*/
static void make_one_mode (LPDDHALMODEINFO info, unsigned int width, unsigned int height)
static void make_one_mode (LPDDHALMODEINFO info, unsigned int width, unsigned int height, unsigned int bpp)
{
info->dwWidth = width;
info->dwHeight = height;
info->wRefreshRate = 0;
info->lPitch = 0;
info->dwBPP = 0;
info->dwBPP = bpp;
info->wFlags = 0;
info->dwRBitMask = 0;
info->dwGBitMask = 0;
info->dwBBitMask = 0;
info->dwAlphaBitMask = 0;
TRACE("initialized mode %dx%d\n", width, height);
TRACE("initialized mode %d: %dx%dx%d\n", nmodes, width, height, bpp);
}
/* create the mode structures */
static void make_modes(void)
{
int i;
nmodes = 2;
for (i=0; i<6; i++)
int i,j;
int max_modes = (3+1)*(8+2);
DWORD dwBpp = screen_depth;
if (dwBpp == 24) dwBpp = 32;
nmodes = 0;
dd_modes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DDHALMODEINFO) * max_modes);
/* original specified desktop size */
make_one_mode(&dd_modes[nmodes++], screen_width, screen_height, dwBpp);
for (i=0; i<8; i++)
{
if ( (widths[i] <= max_width) && (heights[i] <= max_height) ) nmodes++;
if ( (widths[i] <= max_width) && (heights[i] <= max_height) )
{
if ( ( (widths[i] != max_width) || (heights[i] != max_height) ) &&
( (widths[i] != screen_width) || (heights[i] != screen_height) ) )
{
/* only add them if they are smaller than the root window and unique */
make_one_mode(&dd_modes[nmodes++], widths[i], heights[i], dwBpp);
}
}
}
dd_modes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DDHALMODEINFO) * nmodes);
/* mode 0 is the original specified desktop size */
make_one_mode(&dd_modes[0], screen_width, screen_height);
/* mode 1 is the root window size */
make_one_mode(&dd_modes[1], max_width, max_height);
/* these modes are all the standard modes smaller than the root window */
for (i=2; i<nmodes; i++)
if ((max_width != screen_width) && (max_height != screen_height))
{
make_one_mode(&dd_modes[i], widths[i-2], heights[i-2]);
/* root window size (if different from desktop window) */
make_one_mode(&dd_modes[nmodes++], max_width, max_height, dwBpp);
}
max_modes = nmodes;
for (j=0; j<3; j++)
{
if (depths[j] != dwBpp)
{
for (i=0; i < max_modes; i++)
{
make_one_mode(&dd_modes[nmodes++], dd_modes[i].dwWidth, dd_modes[i].dwHeight, depths[j]);
}
}
}
}
......@@ -191,6 +212,9 @@ int X11DRV_resize_desktop( unsigned int width, unsigned int height )
#if 0 /* FIXME */
SYSMETRICS_Set( SM_CXSCREEN, width );
SYSMETRICS_Set( SM_CYSCREEN, height );
#else
FIXME("Need to update SYSMETRICS after resizing display (now %dx%d)\n",
width, height);
#endif
/* clean up */
......@@ -279,19 +303,29 @@ Window X11DRV_create_desktop( XVisualInfo *desktop_vi, const char *geometry )
void X11DRV_desktop_SetCurrentMode(int mode)
{
DWORD dwBpp = screen_depth;
if (dwBpp == 24) dwBpp = 32;
if (mode < nmodes)
{
TRACE("Resizing Wine desktop window to %ldx%ld\n", dd_modes[mode].dwWidth, dd_modes[mode].dwHeight);
X11DRV_resize_desktop(dd_modes[mode].dwWidth, dd_modes[mode].dwHeight);
if (dwBpp != dd_modes[mode].dwBPP)
{
FIXME("Cannot change screen BPP from %ld to %ld\n", dwBpp, dd_modes[mode].dwBPP);
}
}
}
int X11DRV_desktop_GetCurrentMode(void)
{
int i;
DWORD dwBpp = screen_depth;
if (dwBpp == 24) dwBpp = 32;
for (i=0; i<nmodes; i++)
{
if ( (screen_width == dd_modes[i].dwWidth) &&
(screen_height == dd_modes[i].dwHeight) )
(screen_height == dd_modes[i].dwHeight) &&
(dwBpp == dd_modes[i].dwBPP))
return i;
}
ERR("In unknown mode, returning default\n");
......@@ -308,21 +342,31 @@ BOOL X11DRV_desktop_EnumDisplaySettingsExW( LPCWSTR name, DWORD n, LPDEVMODEW de
devmode->dmDisplayFlags = 0;
devmode->dmDisplayFrequency = 85;
devmode->dmSize = sizeof(DEVMODEW);
if (n==0 || n == (DWORD)-1 || n == (DWORD)-2)
if (n==(DWORD)-1)
{
devmode->dmBitsPerPel = dwBpp;
devmode->dmPelsHeight = screen_height;
devmode->dmPelsWidth = screen_width;
devmode->dmFields = (DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL);
TRACE("mode %ld (current) -- returning current %ldx%ldx%ldbpp\n", n,
devmode->dmPelsWidth, devmode->dmPelsHeight, devmode->dmBitsPerPel);
return TRUE;
}
else if (n==(DWORD)-2)
{
devmode->dmBitsPerPel = dwBpp;
devmode->dmPelsHeight = dd_modes[0].dwHeight;
devmode->dmPelsWidth = dd_modes[0].dwWidth;
devmode->dmFields = (DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL);
TRACE("mode %ld -- returning default %ldx%ldx%ldbpp\n", n,
TRACE("mode %ld (registry) -- returning default %ldx%ldx%ldbpp\n", n,
devmode->dmPelsWidth, devmode->dmPelsHeight, devmode->dmBitsPerPel);
return TRUE;
}
if (n <= nmodes)
}
else if (n < nmodes)
{
devmode->dmPelsWidth = dd_modes[n].dwWidth;
devmode->dmPelsHeight = dd_modes[n].dwHeight;
devmode->dmBitsPerPel = dwBpp;
devmode->dmBitsPerPel = dd_modes[n].dwBPP;
devmode->dmFields = (DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL);
TRACE("mode %ld -- %ldx%ldx%ldbpp\n", n,
devmode->dmPelsWidth, devmode->dmPelsHeight, devmode->dmBitsPerPel);
......@@ -349,7 +393,7 @@ LONG X11DRV_desktop_ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmod
{
if (devmode->dmFields & DM_BITSPERPEL)
{
if (devmode->dmBitsPerPel != dwBpp)
if (devmode->dmBitsPerPel != dd_modes[i].dwBPP)
continue;
}
if (devmode->dmFields & DM_PELSWIDTH)
......@@ -363,12 +407,8 @@ LONG X11DRV_desktop_ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmod
continue;
}
/* we have a valid mode */
TRACE("Matches mode %ld\n", i);
TRACE("Requested display settings match mode %ld\n", i);
X11DRV_desktop_SetCurrentMode(i);
#if 0 /* FIXME */
SYSMETRICS_Set( SM_CXSCREEN, devmode->dmPelsWidth );
SYSMETRICS_Set( SM_CYSCREEN, devmode->dmPelsHeight );
#endif
return DISP_CHANGE_SUCCESSFUL;
}
......@@ -381,6 +421,7 @@ LONG X11DRV_desktop_ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmod
static DWORD PASCAL X11DRV_desktop_SetMode(LPDDHAL_SETMODEDATA data)
{
TRACE("Mode %ld requested by DDHAL\n", data->dwModeIndex);
X11DRV_desktop_SetCurrentMode(data->dwModeIndex);
X11DRV_DDHAL_SwitchMode(data->dwModeIndex, NULL, NULL);
data->ddRVal = DD_OK;
......@@ -391,6 +432,7 @@ int X11DRV_desktop_CreateDriver(LPDDHALINFO info)
{
if (!nmodes) return 0; /* no desktop */
TRACE("Setting up Desktop mode for DDRAW\n");
info->dwNumModes = nmodes;
info->lpModeInfo = dd_modes;
X11DRV_DDHAL_SwitchMode(X11DRV_desktop_GetCurrentMode(), NULL, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment