From 6e8b7c4cef5f0b03cf1e35a76d7919513e54b087 Mon Sep 17 00:00:00 2001 From: Peter Dons Tychsen Date: Tue, 1 Jan 2008 21:33:32 +0100 Subject: [PATCH] ddraw: Add missing pitch in callback from EnumDisplayModes(). --- dlls/ddraw/ddraw.c | 7 ++++++- dlls/ddraw/tests/ddrawmodes.c | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index 15e8edcb2c8..e87043ad0d6 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -1289,7 +1289,12 @@ IDirectDrawImpl_EnumDisplayModes(IDirectDraw7 *iface, PixelFormat_WineD3DtoDD(&callback_sd.u4.ddpfPixelFormat, mode.Format); - TRACE("Enumerating %dx%d@%d\n", callback_sd.dwWidth, callback_sd.dwHeight, callback_sd.u4.ddpfPixelFormat.u1.dwRGBBitCount); + /* Calc pitch and DWORD align like MSDN says */ + callback_sd.u1.lPitch = (callback_sd.u4.ddpfPixelFormat.u1.dwRGBBitCount / 8) * mode.Width; + callback_sd.u1.lPitch = (callback_sd.u1.lPitch + 3) & ~3; + + TRACE("Enumerating %dx%dx%d @%d\n", callback_sd.dwWidth, callback_sd.dwHeight, callback_sd.u4.ddpfPixelFormat.u1.dwRGBBitCount, + callback_sd.u2.dwRefreshRate); if(cb(&callback_sd, Context) == DDENUMRET_CANCEL) { diff --git a/dlls/ddraw/tests/ddrawmodes.c b/dlls/ddraw/tests/ddrawmodes.c index 4db0856acbe..5af8ba457a1 100644 --- a/dlls/ddraw/tests/ddrawmodes.c +++ b/dlls/ddraw/tests/ddrawmodes.c @@ -108,9 +108,22 @@ static void flushdisplaymodes(void) static HRESULT WINAPI enummodescallback(LPDDSURFACEDESC lpddsd, LPVOID lpContext) { - trace("Width = %i, Height = %i, Refresh Rate = %i\r\n", + trace("Width = %i, Height = %i, Refresh Rate = %i, Pitch = %i, flags =%02X\r\n", lpddsd->dwWidth, lpddsd->dwHeight, - U2(*lpddsd).dwRefreshRate); + U2(*lpddsd).dwRefreshRate, lpddsd->lPitch, lpddsd->dwFlags); + + /* Check that the pitch is valid if applicable */ + if(lpddsd->dwFlags & DDSD_PITCH) + { + ok(lpddsd->lPitch != 0, "EnumDisplayModes callback with bad pitch\n"); + } + + /* Check that frequency is valid if applicable */ + if(lpddsd->dwFlags & DDSD_REFRESHRATE) + { + ok(lpddsd->dwRefreshRate != 0, "EnumDisplayModes callback with bad refresh rate\n"); + } + adddisplaymode(lpddsd); return DDENUMRET_OK;