1. fixed fullscreen crash when we exit

2. more prepations for backbuffer support

svn path=/trunk/; revision=25163
This commit is contained in:
Magnus Olsen 2006-12-14 19:33:05 +00:00
parent 4eca115ed8
commit 23153cc3cf
3 changed files with 108 additions and 86 deletions

View file

@ -36,7 +36,7 @@ Cleanup(LPDIRECTDRAW7 iface)
*/
/* release the linked interface */
while (!IsBadWritePtr( This->lpVtbl, sizeof( LPDDRAWI_DIRECTDRAW_INT )) )
while (IsBadWritePtr( This->lpVtbl, sizeof( LPDDRAWI_DIRECTDRAW_INT )) )
{
LPDDRAWI_DIRECTDRAW_INT newThis = This->lpVtbl;
if (This->lpLcl != NULL)

View file

@ -6,78 +6,113 @@ CreateBackBufferSurface(LPDDRAWI_DIRECTDRAW_INT This,
LPDDRAWI_DDRAWSURFACE_INT That,
LPDDSURFACEDESC2 pDDSD)
{
DWORD t;
That = (LPDDRAWI_DDRAWSURFACE_INT)DxHeapMemAlloc(sizeof(DDRAWI_DDRAWSURFACE_INT));
if (That == NULL)
/* we are building the backbuffersurface pointer list
* and create the backbuffer surface and set it up
*/
for (t=0;t<pDDSD->dwBackBufferCount;t++)
{
return E_OUTOFMEMORY;
That = (LPDDRAWI_DDRAWSURFACE_INT)DxHeapMemAlloc(sizeof(DDRAWI_DDRAWSURFACE_INT));
if (That == NULL)
{
return DDERR_OUTOFMEMORY;
}
That->lpLcl = (LPDDRAWI_DDRAWSURFACE_LCL)DxHeapMemAlloc(sizeof(DDRAWI_DDRAWSURFACE_LCL));
if (That->lpLcl == NULL)
{
return DDERR_OUTOFMEMORY;
}
That->lpLcl->lpSurfMore = DxHeapMemAlloc(sizeof(DDRAWI_DDRAWSURFACE_MORE));
if (That->lpLcl->lpSurfMore == NULL)
{
return DDERR_OUTOFMEMORY;
}
That->lpLcl->lpSurfMore->slist = DxHeapMemAlloc(sizeof(LPDDRAWI_DDRAWSURFACE_LCL)<<1);
if (That->lpLcl->lpSurfMore->slist == NULL)
{
return DDERR_OUTOFMEMORY;
}
That->lpLcl->lpGbl = DxHeapMemAlloc(sizeof(DDRAWI_DDRAWSURFACE_GBL));
if (That->lpLcl->lpGbl == NULL)
{
return DDERR_OUTOFMEMORY;
}
memcpy(That->lpLcl->lpGbl, &ddSurfGbl,sizeof(DDRAWI_DDRAWSURFACE_GBL);
That->lpVtbl = &DirectDrawSurface7_Vtable;
That->lpLcl->lpSurfMore->dwSize = sizeof(DDRAWI_DDRAWSURFACE_MORE);
That->lpLcl->lpSurfMore->lpDD_int = This;
That->lpLcl->lpSurfMore->lpDD_lcl = This->lpLcl;
That->lpLcl->lpSurfMore->slist[0] = That->lpLcl;
That->lpLcl->dwProcessId = GetCurrentProcessId();
That->lpVtbl = &DirectDrawSurface7_Vtable;
That->lpLcl->lpSurfMore->dwSize = sizeof(DDRAWI_DDRAWSURFACE_MORE);
That->lpLcl->lpSurfMore->lpDD_int = This;
That->lpLcl->lpSurfMore->lpDD_lcl = This->lpLcl;
That->lpLcl->lpSurfMore->slist[0] = That->lpLcl;
That->lpLcl->dwProcessId = GetCurrentProcessId();
if (pDDSD->dwFlags & DDSD_PIXELFORMAT)
{
That->lpLcl->dwFlags |= DDRAWISURF_HASPIXELFORMAT;
}
mDdCanCreateSurface.lpDD = This->lpLcl->lpGbl;
if (pDDSD->dwFlags & DDSD_PIXELFORMAT)
{
That->lpLcl->dwFlags |= DDRAWISURF_HASPIXELFORMAT;
mDdCanCreateSurface.bIsDifferentPixelFormat = TRUE; //isDifferentPixelFormat;
}
else
{
mDdCanCreateSurface.bIsDifferentPixelFormat = FALSE; //isDifferentPixelFormat;
}
That->lpLcl->ddsCaps.dwCaps = pDDSD->ddsCaps.dwCaps;
mDdCanCreateSurface.lpDDSurfaceDesc = (LPDDSURFACEDESC) pDDSD;
mDdCanCreateSurface.CanCreateSurface = This->lpLcl->lpDDCB->cbDDCallbacks.CanCreateSurface;
mDdCanCreateSurface.ddRVal = DDERR_GENERIC;
mDdCreateSurface.lpDD = This->lpLcl->lpGbl;
mDdCreateSurface.CreateSurface = This->lpLcl->lpDDCB->cbDDCallbacks.CreateSurface;
mDdCreateSurface.ddRVal = DDERR_GENERIC;
mDdCreateSurface.dwSCnt = That->dwIntRefCnt + 1; // is this correct
mDdCreateSurface.lpDDSurfaceDesc = (LPDDSURFACEDESC) pDDSD;
mDdCreateSurface.lplpSList = That->lpLcl->lpSurfMore->slist;
if (mDdCanCreateSurface.CanCreateSurface(&mDdCanCreateSurface)== DDHAL_DRIVER_NOTHANDLED)
{
return DDERR_NOTINITIALIZED;
}
if (mDdCanCreateSurface.ddRVal != DD_OK)
{
return DDERR_NOTINITIALIZED;
}
mDdCreateSurface.lplpSList = That->lpLcl->lpSurfMore->slist;
if (mDdCreateSurface.CreateSurface(&mDdCreateSurface) == DDHAL_DRIVER_NOTHANDLED)
{
return DDERR_NOTINITIALIZED;
}
if (mDdCreateSurface.ddRVal != DD_OK)
{
return mDdCreateSurface.ddRVal;
}
This->lpLcl->lpGbl->dsList[t] = That;
}
That->lpLcl = (LPDDRAWI_DDRAWSURFACE_LCL)DxHeapMemAlloc(sizeof(DDRAWI_DDRAWSURFACE_LCL));
if (That->lpLcl == NULL)
{
/* shall we free it if it fail ?? */
DxHeapMemFree(That);
return E_OUTOFMEMORY;
}
That->lpLcl->lpSurfMore = DxHeapMemAlloc(sizeof(DDRAWI_DDRAWSURFACE_MORE));
if (That->lpLcl->lpSurfMore == NULL)
{
/* shall we free it if it fail ?? */
DxHeapMemFree(That->lpLcl);
DxHeapMemFree(That);
return DDERR_OUTOFMEMORY;
}
That->lpLcl->lpSurfMore->slist = DxHeapMemAlloc(sizeof(LPDDRAWI_DDRAWSURFACE_LCL)<<1);
if (That->lpLcl->lpSurfMore->slist == NULL)
{
/* shall we free it if it fail ?? */
DxHeapMemFree(That->lpLcl->lpSurfMore);
DxHeapMemFree(That->lpLcl);
DxHeapMemFree(That);
return DDERR_OUTOFMEMORY;
}
That->lpLcl->lpGbl = DxHeapMemAlloc(sizeof(DDRAWI_DDRAWSURFACE_GBL));
if (That->lpLcl->lpGbl == NULL)
{
/* shall we free it if it fail ?? */
DxHeapMemFree(That->lpLcl->lpSurfMore->slist);
DxHeapMemFree(That->lpLcl->lpSurfMore);
DxHeapMemFree(That->lpLcl);
DxHeapMemFree(That);
return DDERR_OUTOFMEMORY;
}
memcpy(That->lpLcl->lpGbl, &ddSurfGbl,sizeof(DDRAWI_DDRAWSURFACE_GBL);
That->lpVtbl = &DirectDrawSurface7_Vtable;
That->lpLcl->lpGbl->lpDD = &ddgbl;
That->lpLcl->lpSurfMore->dwSize = sizeof(DDRAWI_DDRAWSURFACE_MORE);
That->lpLcl->lpSurfMore->lpDD_int = This;
That->lpLcl->lpSurfMore->lpDD_lcl = This->lpLcl;
That->lpLcl->lpSurfMore->slist[0] = That->lpLcl;
That->lpLcl->dwProcessId = GetCurrentProcessId();
mDdCreateSurface.lplpSList = That->lpLcl->lpSurfMore->slist;
That->lpVtbl = &DirectDrawSurface7_Vtable;
That->lpLcl->lpGbl = &ddSurfGbl;
That->lpLcl->lpGbl->lpDD = &ddgbl;
That->lpLcl->lpSurfMore->dwSize = sizeof(DDRAWI_DDRAWSURFACE_MORE);
That->lpLcl->lpSurfMore->lpDD_int = This;
That->lpLcl->lpSurfMore->lpDD_lcl = This->lpLcl;
That->lpLcl->lpSurfMore->slist[0] = That->lpLcl;
That->lpLcl->dwProcessId = GetCurrentProcessId();
if (pDDSD->dwFlags & DDSD_PIXELFORMAT)
{
That->lpLcl->dwFlags |= DDRAWISURF_HASPIXELFORMAT;
}
}

View file

@ -288,16 +288,12 @@ HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDE
That->lpVtbl = &DirectDrawSurface7_Vtable;
That->lpLcl->lpGbl = &ddSurfGbl;
That->lpLcl->lpGbl->lpDD = &ddgbl;
That->lpLcl->lpSurfMore->dwSize = sizeof(DDRAWI_DDRAWSURFACE_MORE);
That->lpLcl->lpSurfMore->lpDD_int = This;
That->lpLcl->lpSurfMore->lpDD_lcl = This->lpLcl;
That->lpLcl->lpSurfMore->slist[0] = That->lpLcl;
That->lpLcl->dwProcessId = GetCurrentProcessId();
/* setup the callback struct right
* maybe we should fill in
* xx.lpDD, xx.function, xx.ddRVal
@ -332,7 +328,8 @@ HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDE
/* Create the surface */
if (pDDSD->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
That->lpLcl->ddsCaps.dwCaps = pDDSD->ddsCaps.dwCaps;
This->lpLcl->lpPrimary = That;
if (mDdCanCreateSurface.CanCreateSurface(&mDdCanCreateSurface)== DDHAL_DRIVER_NOTHANDLED)
{
@ -343,16 +340,6 @@ HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDE
{
return DDERR_NOTINITIALIZED;
}
/* FIXME
* check the value from pDDSD and use it as size
*/
// That->lpLcl->dwFlags = DDRAWISURF_PARTOFPRIMARYCHAIN|DDRAWISURF_HASOVERLAYDATA;
That->lpLcl->ddsCaps.dwCaps = pDDSD->ddsCaps.dwCaps;
mDdCreateSurface.lplpSList = That->lpLcl->lpSurfMore->slist;