Commit 35c5c452 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

d3d9: Hold the lock in suface methods.

parent fb269f92
......@@ -78,7 +78,9 @@ static ULONG WINAPI IDirect3DSurface9Impl_Release(LPDIRECT3DSURFACE9 iface) {
if (ref == 0) {
if (This->parentDevice) IUnknown_Release(This->parentDevice);
if (!This->isImplicit) {
EnterCriticalSection(&d3d9_cs);
IWineD3DSurface_Release(This->wineD3DSurface);
LeaveCriticalSection(&d3d9_cs);
HeapFree(GetProcessHeap(), 0, This);
}
}
......@@ -90,50 +92,89 @@ static ULONG WINAPI IDirect3DSurface9Impl_Release(LPDIRECT3DSURFACE9 iface) {
/* IDirect3DSurface9 IDirect3DResource9 Interface follow: */
static HRESULT WINAPI IDirect3DSurface9Impl_GetDevice(LPDIRECT3DSURFACE9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
HRESULT hr;
TRACE("(%p)->(%p)\n", This, ppDevice);
EnterCriticalSection(&d3d9_cs);
hr = IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
LeaveCriticalSection(&d3d9_cs);
return hr;
}
static HRESULT WINAPI IDirect3DSurface9Impl_SetPrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n", This);
return IWineD3DSurface_SetPrivateData(This->wineD3DSurface, refguid, pData, SizeOfData, Flags);
EnterCriticalSection(&d3d9_cs);
hr = IWineD3DSurface_SetPrivateData(This->wineD3DSurface, refguid, pData, SizeOfData, Flags);
LeaveCriticalSection(&d3d9_cs);
return hr;
}
static HRESULT WINAPI IDirect3DSurface9Impl_GetPrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n", This);
return IWineD3DSurface_GetPrivateData(This->wineD3DSurface, refguid, pData, pSizeOfData);
EnterCriticalSection(&d3d9_cs);
hr = IWineD3DSurface_GetPrivateData(This->wineD3DSurface, refguid, pData, pSizeOfData);
LeaveCriticalSection(&d3d9_cs);
return hr;
}
static HRESULT WINAPI IDirect3DSurface9Impl_FreePrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n", This);
return IWineD3DSurface_FreePrivateData(This->wineD3DSurface, refguid);
EnterCriticalSection(&d3d9_cs);
hr = IWineD3DSurface_FreePrivateData(This->wineD3DSurface, refguid);
LeaveCriticalSection(&d3d9_cs);
return hr;
}
static DWORD WINAPI IDirect3DSurface9Impl_SetPriority(LPDIRECT3DSURFACE9 iface, DWORD PriorityNew) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n", This);
return IWineD3DSurface_SetPriority(This->wineD3DSurface, PriorityNew);
EnterCriticalSection(&d3d9_cs);
hr = IWineD3DSurface_SetPriority(This->wineD3DSurface, PriorityNew);
LeaveCriticalSection(&d3d9_cs);
return hr;
}
static DWORD WINAPI IDirect3DSurface9Impl_GetPriority(LPDIRECT3DSURFACE9 iface) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n", This);
return IWineD3DSurface_GetPriority(This->wineD3DSurface);
EnterCriticalSection(&d3d9_cs);
hr = IWineD3DSurface_GetPriority(This->wineD3DSurface);
LeaveCriticalSection(&d3d9_cs);
return hr;
}
static void WINAPI IDirect3DSurface9Impl_PreLoad(LPDIRECT3DSURFACE9 iface) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
IWineD3DSurface_PreLoad(This->wineD3DSurface);
LeaveCriticalSection(&d3d9_cs);
return ;
}
static D3DRESOURCETYPE WINAPI IDirect3DSurface9Impl_GetType(LPDIRECT3DSURFACE9 iface) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
D3DRESOURCETYPE ret;
TRACE("(%p) Relay\n", This);
return IWineD3DSurface_GetType(This->wineD3DSurface);
EnterCriticalSection(&d3d9_cs);
ret = IWineD3DSurface_GetType(This->wineD3DSurface);
LeaveCriticalSection(&d3d9_cs);
return ret;
}
/* IDirect3DSurface9 Interface follow: */
......@@ -160,6 +201,7 @@ static HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(LPDIRECT3DSURFACE9 iface, D3
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
WINED3DSURFACE_DESC wined3ddesc;
UINT tmpInt = -1;
HRESULT hr;
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
......@@ -173,32 +215,55 @@ static HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(LPDIRECT3DSURFACE9 iface, D3
wined3ddesc.Width = &pDesc->Width;
wined3ddesc.Height = &pDesc->Height;
return IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc);
EnterCriticalSection(&d3d9_cs);
hr = IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc);
LeaveCriticalSection(&d3d9_cs);
return hr;
}
static HRESULT WINAPI IDirect3DSurface9Impl_LockRect(LPDIRECT3DSURFACE9 iface, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
TRACE("(%p) calling IWineD3DSurface_LockRect %p %p %p %d\n", This, This->wineD3DSurface, pLockedRect, pRect, Flags);
return IWineD3DSurface_LockRect(This->wineD3DSurface, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
hr = IWineD3DSurface_LockRect(This->wineD3DSurface, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
LeaveCriticalSection(&d3d9_cs);
return hr;
}
static HRESULT WINAPI IDirect3DSurface9Impl_UnlockRect(LPDIRECT3DSURFACE9 iface) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n", This);
return IWineD3DSurface_UnlockRect(This->wineD3DSurface);
EnterCriticalSection(&d3d9_cs);
hr = IWineD3DSurface_UnlockRect(This->wineD3DSurface);
LeaveCriticalSection(&d3d9_cs);
return hr;
}
static HRESULT WINAPI IDirect3DSurface9Impl_GetDC(LPDIRECT3DSURFACE9 iface, HDC* phdc) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n", This);
return IWineD3DSurface_GetDC(This->wineD3DSurface, phdc);
EnterCriticalSection(&d3d9_cs);
hr = IWineD3DSurface_GetDC(This->wineD3DSurface, phdc);
LeaveCriticalSection(&d3d9_cs);
return hr;
}
static HRESULT WINAPI IDirect3DSurface9Impl_ReleaseDC(LPDIRECT3DSURFACE9 iface, HDC hdc) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n", This);
return IWineD3DSurface_ReleaseDC(This->wineD3DSurface, hdc);
EnterCriticalSection(&d3d9_cs);
hr = IWineD3DSurface_ReleaseDC(This->wineD3DSurface, hdc);
LeaveCriticalSection(&d3d9_cs);
return hr;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment