Author: greatlrd
Date: Wed Dec 13 01:03:49 2006
New Revision: 25137
URL:
http://svn.reactos.org/svn/reactos?rev=25137&view=rev
Log:
do not crash if we call lock and unlock but something are wrong.
we manger getting a lock but ms sdk font sample does not showing the font why ??
Modified:
trunk/reactos/dll/directx/ddraw/main/surface_main.c
Modified: trunk/reactos/dll/directx/ddraw/main/surface_main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/main/sur…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/main/surface_main.c (original)
+++ trunk/reactos/dll/directx/ddraw/main/surface_main.c Wed Dec 13 01:03:49 2006
@@ -215,43 +215,73 @@
LPDDSURFACEDESC2 pDDSD, DWORD flags, HANDLE events)
{
LPDDRAWI_DDRAWSURFACE_INT This = (LPDDRAWI_DDRAWSURFACE_INT)iface;
- DDHAL_LOCKDATA LockData;
-
- DX_WINDBG_trace();
-
- if (events != NULL)
- {
- return DDERR_INVALIDPARAMS;
- }
-
- RtlZeroMemory(&LockData,sizeof(DDHAL_LOCKDATA));
- LockData.ddRVal = DDERR_GENERIC;
-
-
-
- if (This->lpLcl->lpGbl->lpDD->lpDDCBtmp->cbDDSurfaceCallbacks.dwFlags
& DDHAL_SURFCB32_LOCK)
- {
- LockData.lpDD = This->lpLcl->lpGbl->lpDD;
- LockData.Lock =
This->lpLcl->lpGbl->lpDD->lpDDCBtmp->cbDDSurfaceCallbacks.Lock;
-
-
-
- //LockData.lpDDSurface;
- //LockData.bHasRect;
- //LockData.rArea;
- //LockData.lpSurfData;
-
- LockData.dwFlags = flags;
-
- if (LockData.Lock(&LockData) == DDHAL_DRIVER_HANDLED)
- {
- return LockData.ddRVal;
- }
- }
-
-
- return DDERR_GENERIC;
-}
+ DDHAL_LOCKDATA mdLock;
+
+ DX_WINDBG_trace();
+
+ /* FIXME add a check see if lock suport or not */
+
+ if (prect!=NULL)
+ {
+ mdLock.bHasRect = TRUE;
+ memcpy(&mdLock.rArea,prect,sizeof(RECTL));
+ }
+ else
+ {
+ mdLock.bHasRect = FALSE;
+ }
+
+ mdLock.ddRVal = DDERR_NOTPALETTIZED;
+ mdLock.Lock =
This->lpLcl->lpSurfMore->lpDD_lcl->lpDDCB->cbDDSurfaceCallbacks.Lock;
+ mdLock.dwFlags = flags;
+ mdLock.lpDDSurface = This->lpLcl->lpSurfMore->slist[0];
+ mdLock.lpDD = This->lpLcl->lpSurfMore->lpDD_lcl->lpGbl;
+ mdLock.lpSurfData = NULL;
+
+ if (!DdResetVisrgn(This->lpLcl->lpSurfMore->slist[0], NULL))
+ {
+ DX_STUB_str("Here DdResetVisrgn lock");
+ return DDERR_UNSUPPORTED;
+ }
+
+ if (mdLock.Lock(&mdLock)!= DDHAL_DRIVER_HANDLED)
+ {
+ DX_STUB_str("Here DDHAL_DRIVER_HANDLED lock");
+ return DDERR_UNSUPPORTED;
+ }
+
+ if (mdLock.ddRVal!= DD_OK)
+ {
+ DX_STUB_str("Here ddRVal lock");
+ return mdLock.ddRVal;
+ }
+
+ // FIXME ??? is this right ??
+ if (pDDSD != NULL)
+ {
+ ZeroMemory(pDDSD,sizeof(DDSURFACEDESC2));
+ pDDSD->dwSize = sizeof(DDSURFACEDESC2);
+
+ //if (pDDSD->dwSize == sizeof(DDSURFACEDESC2))
+ //{
+ // ZeroMemory(pDDSD,sizeof(DDSURFACEDESC2));
+ // // FIXME the interanl mddsdPrimary shall be DDSURFACEDESC2
+ // memcpy(pDDSD,&This->Surf->mddsdPrimary,sizeof(DDSURFACEDESC));
+ // pDDSD->dwSize = sizeof(DDSURFACEDESC2);
+ //}
+ //if (pDDSD->dwSize == sizeof(DDSURFACEDESC))
+ //{
+ // RtlZeroMemory(pDDSD,sizeof(DDSURFACEDESC));
+ // memcpy(pDDSD,&This->Surf->mddsdPrimary,sizeof(DDSURFACEDESC));
+ // pDDSD->dwSize = sizeof(DDSURFACEDESC);
+ //}
+
+ pDDSD->lpSurface = (LPVOID) mdLock.lpSurfData;
+ }
+
+ return DD_OK;
+}
+
HRESULT WINAPI Main_DDrawSurface_Unlock (LPDIRECTDRAWSURFACE7 iface, LPRECT pRect)
{
@@ -260,30 +290,34 @@
DX_WINDBG_trace();
- if (!This->lpLcl->lpGbl->lpDD->lpDDCBtmp->cbDDSurfaceCallbacks.dwFlags
& DDHAL_SURFCB32_UNLOCK)
+ if
(!This->lpLcl->lpSurfMore->lpDD_lcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags
& DDHAL_SURFCB32_UNLOCK)
{
+ DX_STUB_str("DDERR_UNSUPPORTED");
return DDERR_UNSUPPORTED;
}
unLock.ddRVal = DDERR_NOTPALETTIZED;
- unLock.lpDD = This->lpLcl->lpGbl->lpDD;
- unLock.lpDDSurface = This->lpLcl;
- unLock.Unlock =
This->lpLcl->lpGbl->lpDD->lpDDCBtmp->cbDDSurfaceCallbacks.Unlock;
+ unLock.lpDD = This->lpLcl->lpSurfMore->lpDD_lcl->lpGbl;
+ unLock.lpDDSurface = This->lpLcl->lpSurfMore->slist[0];
+ unLock.Unlock =
This->lpLcl->lpSurfMore->lpDD_lcl->lpDDCB->cbDDSurfaceCallbacks.Unlock;
if (!DdResetVisrgn( unLock.lpDDSurface, NULL))
{
- return DDERR_UNSUPPORTED;
+ DX_STUB_str("DDERR_UNSUPPORTED");
+ return DDERR_UNSUPPORTED;
}
if (unLock.Unlock(&unLock)!= DDHAL_DRIVER_HANDLED)
{
+ DX_STUB_str("unLock fail");
return DDERR_UNSUPPORTED;
}
if (unLock.ddRVal!= DD_OK)
{
+ DX_STUB_str("ddRVal errror");
return unLock.ddRVal;
}