Fill some more structs, that ms ddraw fill as well.

svn path=/trunk/; revision=17539
This commit is contained in:
Maarten Bosma 2005-08-25 15:31:28 +00:00
parent 25d3bf68ab
commit bebf0b4a61
5 changed files with 105 additions and 87 deletions

View file

@ -15,59 +15,87 @@ HRESULT Hal_DirectDraw_Initialize (LPDIRECTDRAW7 iface)
{ {
IDirectDrawImpl* This = (IDirectDrawImpl*)iface; IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
/* get the object */
if(!DdCreateDirectDrawObject (&This->DirectDrawGlobal, This->hdc)) if(!DdCreateDirectDrawObject (&This->DirectDrawGlobal, This->hdc))
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
This->HalInfo.dwSize = sizeof(DDHALINFO); /* alloc some space */
This->D3dDriverData.dwSize = sizeof(D3DHAL_GLOBALDRIVERDATA); This->DirectDrawGlobal.lpDDCBtmp = (LPDDHAL_CALLBACKS)HeapAlloc(GetProcessHeap(), 0, sizeof(DDHAL_CALLBACKS));
This->DriverCallbacks.DdMain.dwSize = sizeof(DDHAL_DDCALLBACKS); memset(This->DirectDrawGlobal.lpDDCBtmp, 0, sizeof(DDHAL_CALLBACKS));
This->DriverCallbacks.DdSurface.dwSize = sizeof(DDHAL_DDSURFACECALLBACKS); This->HalInfo.lpDDCallbacks = &This->DirectDrawGlobal.lpDDCBtmp->cbDDCallbacks;
This->DriverCallbacks.DdPalette.dwSize = sizeof(DDHAL_DDPALETTECALLBACKS); This->HalInfo.lpDDSurfaceCallbacks = &This->DirectDrawGlobal.lpDDCBtmp->cbDDSurfaceCallbacks;
This->DriverCallbacks.D3dMain.dwSize = sizeof(D3DHAL_CALLBACKS); This->HalInfo.lpDDExeBufCallbacks = &This->DirectDrawGlobal.lpDDCBtmp->cbDDExeBufCallbacks;
This->DriverCallbacks.D3dBufferCallbacks.dwSize = sizeof(DDHAL_DDEXEBUFCALLBACKS); This->HalInfo.lpDDPaletteCallbacks = &This->DirectDrawGlobal.lpDDCBtmp->cbDDPaletteCallbacks;
This->DirectDrawGlobal.lpD3DHALCallbacks = (ULONG_PTR)HeapAlloc(GetProcessHeap(), 0, sizeof(D3DHAL_CALLBACKS));
This->DirectDrawGlobal.lpD3DGlobalDriverData = (ULONG_PTR)HeapAlloc(GetProcessHeap(), 0, sizeof(D3DHAL_GLOBALDRIVERDATA));
/* fill the sizeofs */
This->HalInfo.dwSize = sizeof(DDHALINFO);
This->HalInfo.lpDDCallbacks->dwSize = sizeof(DDHAL_DDCALLBACKS);
This->HalInfo.lpDDSurfaceCallbacks->dwSize = sizeof(DDHAL_DDSURFACECALLBACKS);
This->HalInfo.lpDDPaletteCallbacks->dwSize = sizeof(DDHAL_DDPALETTECALLBACKS);
This->HalInfo.lpDDExeBufCallbacks->dwSize = sizeof(DDHAL_DDEXEBUFCALLBACKS);
((LPD3DHAL_CALLBACKS)This->DirectDrawGlobal.lpD3DHALCallbacks)->dwSize = sizeof(D3DHAL_CALLBACKS);
((LPD3DHAL_GLOBALDRIVERDATA)This->DirectDrawGlobal.lpD3DGlobalDriverData)->dwSize = sizeof(D3DHAL_GLOBALDRIVERDATA);
/* query all kinds of infos from the driver */
if(!DdQueryDirectDrawObject ( if(!DdQueryDirectDrawObject (
&This->DirectDrawGlobal, &This->DirectDrawGlobal,
&This->HalInfo, &This->HalInfo,
&This->DriverCallbacks.DdMain, This->HalInfo.lpDDCallbacks,
&This->DriverCallbacks.DdSurface, This->HalInfo.lpDDSurfaceCallbacks,
&This->DriverCallbacks.DdPalette, This->HalInfo.lpDDPaletteCallbacks,
&This->DriverCallbacks.D3dMain, (LPD3DHAL_CALLBACKS)This->DirectDrawGlobal.lpD3DHALCallbacks,
&This->D3dDriverData, (LPD3DHAL_GLOBALDRIVERDATA)This->DirectDrawGlobal.lpD3DGlobalDriverData,
&This->DriverCallbacks.D3dBufferCallbacks, This->HalInfo.lpDDExeBufCallbacks,
NULL, NULL,
NULL, NULL,
NULL )) NULL ))
return DDERR_INVALIDPARAMS; {
OutputDebugString(L"First DdQueryDirectDrawObject failed");
return 1;
}
This->pD3dTextureFormats = HeapAlloc(GetProcessHeap(), 0, sizeof(DDSURFACEDESC) * This->D3dDriverData.dwNumTextureFormats); /* ms wants us to call that function twice */
This->HalInfo.vmiData.pvmList = HeapAlloc(GetProcessHeap(), 0, sizeof(VIDMEM) * This->HalInfo.vmiData.dwNumHeaps); This->HalInfo.vmiData.pvmList = HeapAlloc(GetProcessHeap(), 0, sizeof(VIDMEM) * This->HalInfo.vmiData.dwNumHeaps);
This->DirectDrawGlobal.lpdwFourCC = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) * This->HalInfo.ddCaps.dwNumFourCCCodes); This->DirectDrawGlobal.lpdwFourCC = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) * This->HalInfo.ddCaps.dwNumFourCCCodes);
This->DirectDrawGlobal.lpZPixelFormats = HeapAlloc(GetProcessHeap(), 0, sizeof(DDPIXELFORMAT) * This->DirectDrawGlobal.dwNumZPixelFormats); This->DirectDrawGlobal.lpZPixelFormats = HeapAlloc(GetProcessHeap(), 0, sizeof(DDPIXELFORMAT) * This->DirectDrawGlobal.dwNumZPixelFormats);
((LPD3DHAL_GLOBALDRIVERDATA)This->DirectDrawGlobal.lpD3DGlobalDriverData)->lpTextureFormats = HeapAlloc(GetProcessHeap(), 0, sizeof(DDSURFACEDESC) * ((LPD3DHAL_GLOBALDRIVERDATA)This->DirectDrawGlobal.lpD3DGlobalDriverData)->dwNumTextureFormats);
if(!DdQueryDirectDrawObject ( if(!DdQueryDirectDrawObject (
&This->DirectDrawGlobal, &This->DirectDrawGlobal,
&This->HalInfo, &This->HalInfo,
&This->DriverCallbacks.DdMain, This->HalInfo.lpDDCallbacks,
&This->DriverCallbacks.DdSurface, This->HalInfo.lpDDSurfaceCallbacks,
&This->DriverCallbacks.DdPalette, This->HalInfo.lpDDPaletteCallbacks,
&This->DriverCallbacks.D3dMain, (LPD3DHAL_CALLBACKS)This->DirectDrawGlobal.lpD3DHALCallbacks,
&This->D3dDriverData, (LPD3DHAL_GLOBALDRIVERDATA)This->DirectDrawGlobal.lpD3DGlobalDriverData,
&This->DriverCallbacks.D3dBufferCallbacks, This->HalInfo.lpDDExeBufCallbacks,
This->pD3dTextureFormats, ((LPD3DHAL_GLOBALDRIVERDATA)This->DirectDrawGlobal.lpD3DGlobalDriverData)->lpTextureFormats,
This->DirectDrawGlobal.lpdwFourCC, This->DirectDrawGlobal.lpdwFourCC,
This->HalInfo.vmiData.pvmList )) This->HalInfo.vmiData.pvmList
return DDERR_INVALIDPARAMS; ))
{
OutputDebugString(L"Second DdQueryDirectDrawObject failed");
return 1;
}
/* fill some extra data */
This->DirectDrawGlobal.vmiData.dwDisplayWidth = This->Width; This->DirectDrawGlobal.vmiData.dwDisplayWidth = This->Width;
This->DirectDrawGlobal.vmiData.dwDisplayHeight = This->Height; This->DirectDrawGlobal.vmiData.dwDisplayHeight = This->Height;
This->DirectDrawGlobal.vmiData.lDisplayPitch = This->Width * This->Bpp/8; This->DirectDrawGlobal.vmiData.lDisplayPitch = This->Width * This->Bpp/8;
//This->DirectDrawGlobal.vmiData.ddpfDisplay; // This has to be filled
This->DirectDrawGlobal.vmiData.dwOffscreenAlign = 64; This->DirectDrawGlobal.vmiData.dwOffscreenAlign = 64;
This->DirectDrawGlobal.vmiData.dwOverlayAlign = 64; This->DirectDrawGlobal.vmiData.dwOverlayAlign = 64;
This->DirectDrawGlobal.vmiData.dwTextureAlign = 64; This->DirectDrawGlobal.vmiData.dwTextureAlign = 64;
This->DirectDrawGlobal.vmiData.dwZBufferAlign = 64; This->DirectDrawGlobal.vmiData.dwZBufferAlign = 64;
This->DirectDrawGlobal.vmiData.dwAlphaAlign = 64; This->DirectDrawGlobal.vmiData.dwAlphaAlign = 64;
//This->DirectDrawGlobal.vmiData.ddpfDisplay; // This has to be filled
This->DirectDrawGlobal.ddCaps = This->HalInfo.ddCaps;
This->DirectDrawGlobal.lpDDCBtmp->HALDD = This->DirectDrawGlobal.lpDDCBtmp->cbDDCallbacks;
This->DirectDrawGlobal.lpDDCBtmp->HALDDSurface = This->DirectDrawGlobal.lpDDCBtmp->cbDDSurfaceCallbacks;
This->DirectDrawGlobal.lpDDCBtmp->HALDDExeBuf = This->DirectDrawGlobal.lpDDCBtmp->cbDDExeBufCallbacks;
This->DirectDrawGlobal.lpDDCBtmp->HALDDPalette = This->DirectDrawGlobal.lpDDCBtmp->cbDDPaletteCallbacks;
return DD_OK; return DD_OK;
} }
@ -83,10 +111,19 @@ VOID Hal_DirectDraw_Release (LPDIRECTDRAW7 iface)
DdDeleteDirectDrawObject (&This->DirectDrawGlobal); DdDeleteDirectDrawObject (&This->DirectDrawGlobal);
if(This->pD3dTextureFormats)
HeapFree(GetProcessHeap(), 0, This->pD3dTextureFormats);
if(This->DirectDrawGlobal.lpdwFourCC)
HeapFree(GetProcessHeap(), 0, This->DirectDrawGlobal.lpdwFourCC);
if(This->HalInfo.vmiData.pvmList) if(This->HalInfo.vmiData.pvmList)
HeapFree(GetProcessHeap(), 0, This->HalInfo.vmiData.pvmList); HeapFree(GetProcessHeap(), 0, This->HalInfo.vmiData.pvmList);
if(This->DirectDrawGlobal.lpdwFourCC)
HeapFree(GetProcessHeap(), 0, This->DirectDrawGlobal.lpdwFourCC);
if(This->DirectDrawGlobal.lpZPixelFormats)
HeapFree(GetProcessHeap(), 0, This->DirectDrawGlobal.lpZPixelFormats);
if(((LPD3DHAL_GLOBALDRIVERDATA)This->DirectDrawGlobal.lpD3DGlobalDriverData)->lpTextureFormats)
HeapFree(GetProcessHeap(), 0, ((LPD3DHAL_GLOBALDRIVERDATA)This->DirectDrawGlobal.lpD3DGlobalDriverData)->lpTextureFormats);
if(This->DirectDrawGlobal.lpDDCBtmp)
HeapFree(GetProcessHeap(), 0, This->DirectDrawGlobal.lpDDCBtmp);
if(This->DirectDrawGlobal.lpD3DHALCallbacks)
HeapFree(GetProcessHeap(), 0, (PVOID)This->DirectDrawGlobal.lpD3DHALCallbacks);
if(This->DirectDrawGlobal.lpD3DGlobalDriverData)
HeapFree(GetProcessHeap(), 0, (PVOID)This->DirectDrawGlobal.lpD3DGlobalDriverData);
} }

View file

@ -24,7 +24,7 @@ HRESULT WINAPI Create_DirectDraw (LPGUID pGUID, LPDIRECTDRAW* pIface,
ZeroMemory(This,sizeof(IDirectDrawImpl)); ZeroMemory(This,sizeof(IDirectDrawImpl));
This->lpVtbl = &DirectDraw_VTable; This->lpVtbl = &DirectDraw_VTable;
This->ref = 1; This->DirectDrawGlobal.dwRefCnt = 1;
*pIface = (LPDIRECTDRAW)This; *pIface = (LPDIRECTDRAW)This;
return This->lpVtbl->Initialize ((LPDIRECTDRAW7)This, pGUID); return This->lpVtbl->Initialize ((LPDIRECTDRAW7)This, pGUID);
@ -39,7 +39,6 @@ HRESULT WINAPI DirectDrawCreate (LPGUID lpGUID, LPDIRECTDRAW* lplpDD, LPUNKNOWN
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
} }
return Create_DirectDraw (lpGUID, lplpDD, pUnkOuter, FALSE); return Create_DirectDraw (lpGUID, lplpDD, pUnkOuter, FALSE);
} }

View file

@ -25,8 +25,8 @@ HRESULT WINAPI Main_DirectDraw_Initialize (LPDIRECTDRAW7 iface, LPGUID lpGUID)
// get the HDC // get the HDC
This->hdc = GetWindowDC(GetDesktopWindow()); This->hdc = GetWindowDC(GetDesktopWindow());
This->Height = GetDeviceCaps(This->hdc, HORZRES); This->Height = GetDeviceCaps(This->hdc, VERTRES);
This->Width = GetDeviceCaps(This->hdc, VERTRES); This->Width = GetDeviceCaps(This->hdc, HORZRES);
This->Bpp = GetDeviceCaps(This->hdc, BITSPIXEL); This->Bpp = GetDeviceCaps(This->hdc, BITSPIXEL);
// call software first // call software first
@ -151,7 +151,7 @@ HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDE
ULONG WINAPI Main_DirectDraw_AddRef (LPDIRECTDRAW7 iface) ULONG WINAPI Main_DirectDraw_AddRef (LPDIRECTDRAW7 iface)
{ {
IDirectDrawImpl* This = (IDirectDrawImpl*)iface; IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
ULONG ref = InterlockedIncrement(&This->ref); ULONG ref = InterlockedIncrement(&This->DirectDrawGlobal.dwRefCnt);
return ref; return ref;
} }
@ -159,7 +159,7 @@ ULONG WINAPI Main_DirectDraw_AddRef (LPDIRECTDRAW7 iface)
ULONG WINAPI Main_DirectDraw_Release (LPDIRECTDRAW7 iface) ULONG WINAPI Main_DirectDraw_Release (LPDIRECTDRAW7 iface)
{ {
IDirectDrawImpl* This = (IDirectDrawImpl*)iface; IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
ULONG ref = InterlockedDecrement(&This->ref); ULONG ref = InterlockedDecrement(&This->DirectDrawGlobal.dwRefCnt);
if (ref == 0) if (ref == 0)
{ {

View file

@ -26,72 +26,69 @@ HRESULT WINAPI Main_DDrawSurface_Initialize (LPDIRECTDRAWSURFACE7 iface, LPDIREC
This->owner = (IDirectDrawImpl*)pDD; This->owner = (IDirectDrawImpl*)pDD;
// Surface Global Struct /* can the driver create the surface */
DDHAL_CANCREATESURFACEDATA CanCreateData;
memset(&CanCreateData, 0, sizeof(DD_CANCREATESURFACEDATA));
CanCreateData.lpDD = &This->owner->DirectDrawGlobal;
CanCreateData.lpDDSurfaceDesc = (DDSURFACEDESC*)pDDSD;
CanCreateData.CanCreateSurface = This->owner->HalInfo.lpDDCallbacks->CanCreateSurface;
if (CanCreateData.CanCreateSurface(&CanCreateData) == DDHAL_DRIVER_NOTHANDLED)
return DDERR_INVALIDPARAMS;
if(CanCreateData.ddRVal != DD_OK)
return CanCreateData.ddRVal;
/* surface global struct */
DDRAWI_DDRAWSURFACE_GBL Global; DDRAWI_DDRAWSURFACE_GBL Global;
memset(&Global, 0, sizeof(DDRAWI_DDRAWSURFACE_GBL)); memset(&Global, 0, sizeof(DDRAWI_DDRAWSURFACE_GBL));
if(pDDSD->ddsCaps.dwCaps == DDSCAPS_PRIMARYSURFACE)
Global.dwGlobalFlags |= DDRAWISURFGBL_ISGDISURFACE;
Global.lpDD = &This->owner->DirectDrawGlobal; Global.lpDD = &This->owner->DirectDrawGlobal;
Global.wHeight = This->owner->Height; Global.wHeight = This->owner->Height;
Global.wWidth = This->owner->Width; Global.wWidth = This->owner->Width;
Global.dwLinearSize = Global.wWidth * This->owner->Bpp/8; Global.dwLinearSize = Global.wWidth * This->owner->Bpp/8;
// Surface More Struct /* surface more struct */
DDRAWI_DDRAWSURFACE_MORE More; DDRAWI_DDRAWSURFACE_MORE More;
memset(&More, 0, sizeof(DDRAWI_DDRAWSURFACE_MORE)); memset(&More, 0, sizeof(DDRAWI_DDRAWSURFACE_MORE));
More.dwSize = sizeof(DDRAWI_DDRAWSURFACE_MORE); More.dwSize = sizeof(DDRAWI_DDRAWSURFACE_MORE);
// Surface Local Struct /* surface local struct */
DDRAWI_DDRAWSURFACE_LCL Local; DDRAWI_DDRAWSURFACE_LCL Local;
memset(&Local, 0, sizeof(DDRAWI_DDRAWSURFACE_LCL)); memset(&Local, 0, sizeof(DDRAWI_DDRAWSURFACE_LCL));
Local.lpGbl = &Global; Local.lpGbl = &Global;
Local.lpSurfMore = &More; Local.lpSurfMore = &More;
Local.ddsCaps = *(DDSCAPS*)&pDDSD->ddsCaps; Local.ddsCaps = *(DDSCAPS*)&pDDSD->ddsCaps;
// BitDepth = DDSurf_BitDepth(psurf); ? /* we need to set some flags if we create the primary surface */
if(pDDSD->ddsCaps.dwCaps == DDSCAPS_PRIMARYSURFACE) if(pDDSD->ddsCaps.dwCaps == DDSCAPS_PRIMARYSURFACE)
{
Local.dwFlags |= DDRAWISURF_FRONTBUFFER; Local.dwFlags |= DDRAWISURF_FRONTBUFFER;
Global.dwGlobalFlags |= DDRAWISURFGBL_ISGDISURFACE;
}
DDRAWI_DDRAWSURFACE_LCL *pLocal[2]; // for stupid double pointer below /* for the double pointer below */
DDRAWI_DDRAWSURFACE_LCL *pLocal[2];
pLocal[0] = &Local; pLocal[0] = &Local;
pLocal[1] = NULL; pLocal[1] = NULL; // we need this one for bad written drivers
// The Parameter Struct /* the parameter struct */
DDHAL_CREATESURFACEDATA CreateData; DDHAL_CREATESURFACEDATA CreateData;
memset(&CreateData, 0, sizeof(DDHAL_CREATESURFACEDATA)); memset(&CreateData, 0, sizeof(DDHAL_CREATESURFACEDATA));
CreateData.lpDD = &This->owner->DirectDrawGlobal; CreateData.lpDD = &This->owner->DirectDrawGlobal;
CreateData.lpDDSurfaceDesc = (DDSURFACEDESC*)pDDSD; CreateData.lpDDSurfaceDesc = (DDSURFACEDESC*)pDDSD;
CreateData.dwSCnt = 1; CreateData.dwSCnt = 1;
CreateData.lplpSList = pLocal; CreateData.lplpSList = pLocal;
CreateData.CreateSurface = This->owner->HalInfo.lpDDCallbacks->CreateSurface;
/* this is the call we were waiting for */
if(CreateData.CreateSurface(&CreateData) == DDHAL_DRIVER_NOTHANDLED)
DDHAL_CANCREATESURFACEDATA CanCreateData;
memset(&CanCreateData, 0, sizeof(DD_CANCREATESURFACEDATA));
CanCreateData.lpDD = &This->owner->DirectDrawGlobal;
CanCreateData.lpDDSurfaceDesc = (DDSURFACEDESC*)pDDSD;
if (This->owner->DriverCallbacks.DdMain.CanCreateSurface (&CanCreateData) == DDHAL_DRIVER_NOTHANDLED)
return DDERR_INVALIDPARAMS;
if(CanCreateData.ddRVal != DD_OK)
return CanCreateData.ddRVal;
if(This->owner->DriverCallbacks.DdMain.CreateSurface (&CreateData) == DDHAL_DRIVER_NOTHANDLED)
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
if(CreateData.ddRVal != DD_OK) if(CreateData.ddRVal != DD_OK)
return CreateData.ddRVal; return CreateData.ddRVal;
OutputDebugString(L"This does not get hit :( ");
OutputDebugString(L"This does not get hit."); OutputDebugString(L"Yet ;)");
return DD_OK; return DD_OK;
} }
@ -122,7 +119,7 @@ ULONG WINAPI Main_DDrawSurface_AddRef(LPDIRECTDRAWSURFACE7 iface)
ULONG WINAPI Main_DDrawSurface_Release(LPDIRECTDRAWSURFACE7 iface) ULONG WINAPI Main_DDrawSurface_Release(LPDIRECTDRAWSURFACE7 iface)
{ {
IDirectDrawImpl* This = (IDirectDrawImpl*)iface; IDirectDrawSurfaceImpl* This = (IDirectDrawSurfaceImpl*)iface;
ULONG ref = InterlockedDecrement(&This->ref); ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0) if (ref == 0)

View file

@ -16,25 +16,11 @@
/******** Main Object ********/ /******** Main Object ********/
typedef struct
{
DDHAL_DDCALLBACKS DdMain;
DDHAL_DDSURFACECALLBACKS DdSurface;
DDHAL_DDPALETTECALLBACKS DdPalette;
D3DHAL_CALLBACKS D3dMain;
DDHAL_DDEXEBUFCALLBACKS D3dBufferCallbacks;
} DRIVERCALLBACKS;
typedef struct typedef struct
{ {
IDirectDraw7Vtbl* lpVtbl; IDirectDraw7Vtbl* lpVtbl;
DRIVERCALLBACKS DriverCallbacks; DDRAWI_DIRECTDRAW_GBL DirectDrawGlobal;
DWORD ref;
DDHALINFO HalInfo; DDHALINFO HalInfo;
D3DHAL_GLOBALDRIVERDATA D3dDriverData;
LPDDSURFACEDESC pD3dTextureFormats;
HWND window; HWND window;
DWORD cooperative_level; DWORD cooperative_level;
@ -42,7 +28,6 @@ typedef struct
int Height, Width, Bpp; int Height, Width, Bpp;
GUID* lpGUID; GUID* lpGUID;
DDRAWI_DIRECTDRAW_GBL DirectDrawGlobal;
} IDirectDrawImpl; } IDirectDrawImpl;