d3d: Enumerate palettized formats for ddraw.

This commit is contained in:
Stefan Dösinger 2007-04-13 16:38:10 +02:00 committed by Alexandre Julliard
parent 3d92b2931c
commit 8a5b6df483
3 changed files with 76 additions and 28 deletions

View file

@ -98,14 +98,20 @@ static HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9 iface, UIN
static UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
/* Others than that not supported by d3d9, but reported by wined3d for ddraw. Filter them out */
if(Format != D3DFMT_X8R8G8B8 && Format != D3DFMT_R5G6B5 && Format != D3DFMT_UNKNOWN) {
return 0;
}
return IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, Format);
}
static HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
/* We can't pass this to WineD3D, otherwise it'll think it came from D3D8.
/* We can't pass this to WineD3D, otherwise it'll think it came from D3D8 or DDraw.
It's supposed to fail anyway, so no harm returning failure. */
if(Format == D3DFMT_UNKNOWN)
if(Format != WINED3DFMT_X8R8G8B8 && Format != WINED3DFMT_R5G6B5)
return D3DERR_INVALIDCALL;
return IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, Format, Mode, (WINED3DDISPLAYMODE *) pMode);
}

View file

@ -1166,11 +1166,31 @@ IDirectDrawImpl_EnumDisplayModes(IDirectDraw7 *iface,
LPDDENUMMODESCALLBACK2 cb)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirectDraw7, iface);
unsigned int modenum = 0;
unsigned int modenum, fmt;
WINED3DFORMAT pixelformat = WINED3DFMT_UNKNOWN;
WINED3DDISPLAYMODE mode;
DDSURFACEDESC2 callback_sd;
WINED3DFORMAT checkFormatList[] =
{
WINED3DFMT_R8G8B8,
WINED3DFMT_A8R8G8B8,
WINED3DFMT_X8R8G8B8,
WINED3DFMT_R5G6B5,
WINED3DFMT_X1R5G5B5,
WINED3DFMT_A1R5G5B5,
WINED3DFMT_A4R4G4B4,
WINED3DFMT_R3G3B2,
WINED3DFMT_A8R3G3B2,
WINED3DFMT_X4R4G4B4,
WINED3DFMT_A2B10G10R10,
WINED3DFMT_A8B8G8R8,
WINED3DFMT_X8B8G8R8,
WINED3DFMT_A2R10G10B10,
WINED3DFMT_A8P8,
WINED3DFMT_P8
};
TRACE("(%p)->(%p,%p,%p): Relay\n", This, DDSD, Context, cb);
/* This looks sane */
@ -1182,41 +1202,52 @@ IDirectDrawImpl_EnumDisplayModes(IDirectDraw7 *iface,
pixelformat = PixelFormat_DD2WineD3D(&DDSD->u4.ddpfPixelFormat);
}
while(IWineD3D_EnumAdapterModes(This->wineD3D,
WINED3DADAPTER_DEFAULT,
pixelformat,
modenum++,
&mode) == WINED3D_OK) {
if(DDSD)
for(fmt = 0; fmt < (sizeof(checkFormatList) / sizeof(checkFormatList[0])); fmt++)
{
if(pixelformat != WINED3DFMT_UNKNOWN && checkFormatList[fmt] != pixelformat)
{
if(DDSD->dwFlags & DDSD_WIDTH && mode.Width != DDSD->dwWidth) continue;
if(DDSD->dwFlags & DDSD_HEIGHT && mode.Height != DDSD->dwHeight) continue;
continue;
}
memset(&callback_sd, 0, sizeof(callback_sd));
callback_sd.dwSize = sizeof(callback_sd);
callback_sd.u4.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
callback_sd.dwFlags = DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT|DDSD_PITCH;
if(Flags & DDEDM_REFRESHRATES)
modenum = 0;
while(IWineD3D_EnumAdapterModes(This->wineD3D,
WINED3DADAPTER_DEFAULT,
checkFormatList[fmt],
modenum++,
&mode) == WINED3D_OK)
{
callback_sd.dwFlags |= DDSD_REFRESHRATE;
callback_sd.u2.dwRefreshRate = mode.RefreshRate;
}
if(DDSD)
{
if(DDSD->dwFlags & DDSD_WIDTH && mode.Width != DDSD->dwWidth) continue;
if(DDSD->dwFlags & DDSD_HEIGHT && mode.Height != DDSD->dwHeight) continue;
}
callback_sd.dwWidth = mode.Width;
callback_sd.dwHeight = mode.Height;
memset(&callback_sd, 0, sizeof(callback_sd));
callback_sd.dwSize = sizeof(callback_sd);
callback_sd.u4.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
PixelFormat_WineD3DtoDD(&callback_sd.u4.ddpfPixelFormat, mode.Format);
callback_sd.dwFlags = DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT|DDSD_PITCH;
if(Flags & DDEDM_REFRESHRATES)
{
callback_sd.dwFlags |= DDSD_REFRESHRATE;
callback_sd.u2.dwRefreshRate = mode.RefreshRate;
}
TRACE("Enumerating %dx%d@%d\n", callback_sd.dwWidth, callback_sd.dwHeight, callback_sd.u4.ddpfPixelFormat.u1.dwRGBBitCount);
callback_sd.dwWidth = mode.Width;
callback_sd.dwHeight = mode.Height;
if(cb(&callback_sd, Context) == DDENUMRET_CANCEL)
{
TRACE("Application asked to terminate the enumeration\n");
return DD_OK;
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);
if(cb(&callback_sd, Context) == DDENUMRET_CANCEL)
{
TRACE("Application asked to terminate the enumeration\n");
return DD_OK;
}
}
}
TRACE("End of enumeration\n");
return DD_OK;
}

View file

@ -1117,6 +1117,7 @@ static UINT WINAPI IWineD3DImpl_GetAdapterModeCount(IWineD3D *iface, UINT Ad
switch (Format)
{
case WINED3DFMT_UNKNOWN:
/* This is for D3D8, do not enumerate P8 here */
if (DevModeW.dmBitsPerPel == 32 ||
DevModeW.dmBitsPerPel == 16) i++;
break;
@ -1126,6 +1127,9 @@ static UINT WINAPI IWineD3DImpl_GetAdapterModeCount(IWineD3D *iface, UINT Ad
case WINED3DFMT_R5G6B5:
if (DevModeW.dmBitsPerPel == 16) i++;
break;
case WINED3DFMT_P8:
if (DevModeW.dmBitsPerPel == 8) i++;
break;
default:
/* Skip other modes as they do not match the requested format */
break;
@ -1169,6 +1173,7 @@ static HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapte
switch (Format)
{
case WINED3DFMT_UNKNOWN:
/* This is D3D8. Do not enumerate P8 here */
if (DevModeW.dmBitsPerPel == 32 ||
DevModeW.dmBitsPerPel == 16) i++;
break;
@ -1178,6 +1183,9 @@ static HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapte
case WINED3DFMT_R5G6B5:
if (DevModeW.dmBitsPerPel == 16) i++;
break;
case WINED3DFMT_P8:
if (DevModeW.dmBitsPerPel == 8) i++;
break;
default:
/* Modes that don't match what we support can get an early-out */
TRACE_(d3d_caps)("Searching for %s, returning D3DERR_INVALIDCALL\n", debug_d3dformat(Format));
@ -1203,6 +1211,9 @@ static HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapte
{
switch (DevModeW.dmBitsPerPel)
{
case 8:
pMode->Format = WINED3DFMT_P8;
break;
case 16:
pMode->Format = WINED3DFMT_R5G6B5;
break;