From 23153cc3cf1649020f150f3880fc106909cae9ef Mon Sep 17 00:00:00 2001 From: Magnus Olsen Date: Thu, 14 Dec 2006 19:33:05 +0000 Subject: [PATCH] 1. fixed fullscreen crash when we exit 2. more prepations for backbuffer support svn path=/trunk/; revision=25163 --- reactos/dll/directx/ddraw/cleanup.c | 2 +- reactos/dll/directx/ddraw/createsurface.c | 175 ++++++++++++-------- reactos/dll/directx/ddraw/main/ddraw_main.c | 17 +- 3 files changed, 108 insertions(+), 86 deletions(-) diff --git a/reactos/dll/directx/ddraw/cleanup.c b/reactos/dll/directx/ddraw/cleanup.c index 1bc1052e08a..0175c288811 100644 --- a/reactos/dll/directx/ddraw/cleanup.c +++ b/reactos/dll/directx/ddraw/cleanup.c @@ -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) diff --git a/reactos/dll/directx/ddraw/createsurface.c b/reactos/dll/directx/ddraw/createsurface.c index 06dad7d3b4d..6f72452e972 100644 --- a/reactos/dll/directx/ddraw/createsurface.c +++ b/reactos/dll/directx/ddraw/createsurface.c @@ -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;tdwBackBufferCount;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; - } - - } diff --git a/reactos/dll/directx/ddraw/main/ddraw_main.c b/reactos/dll/directx/ddraw/main/ddraw_main.c index 15be001b4d2..b6ae6b96719 100644 --- a/reactos/dll/directx/ddraw/main/ddraw_main.c +++ b/reactos/dll/directx/ddraw/main/ddraw_main.c @@ -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;