Alexander Dorofeyev : ddraw: Fix some code unprotected by ddraw lock.
Module: wine Branch: master Commit: 17dacf90b23a0bcecd18e8ab30f2929e550ad4eb URL: http://source.winehq.org/git/wine.git/?a=commit;h=17dacf90b23a0bcecd18e8ab30... Author: Alexander Dorofeyev <alexd4(a)inbox.lv> Date: Sun May 11 00:19:43 2008 +0300 ddraw: Fix some code unprotected by ddraw lock. --- dlls/ddraw/device.c | 24 ++++++++++++++---------- 1 files changed, 14 insertions(+), 10 deletions(-) diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index 57bb83c..88d5453 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -2343,8 +2343,6 @@ IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3 *iface, HRESULT hr; TRACE("(%p)->(%08x,%p)\n", This, dwRenderStateType, lpdwRenderState); - /* D3DRENDERSTATE_TEXTUREMAPBLEND is mapped to texture state stages in SetRenderState; reverse - the mapping to get the value. */ switch(dwRenderStateType) { case D3DRENDERSTATE_TEXTUREHANDLE: @@ -2355,6 +2353,8 @@ IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3 *iface, IWineD3DBaseTexture *tex = NULL; *lpdwRenderState = 0; + EnterCriticalSection(&ddraw_cs); + hr = IWineD3DDevice_GetTexture(This->wineD3DDevice, 0, &tex); @@ -2378,11 +2378,15 @@ IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3 *iface, IWineD3DBaseTexture_Release(tex); } + LeaveCriticalSection(&ddraw_cs); + return hr; } case D3DRENDERSTATE_TEXTUREMAPBLEND: { + /* D3DRENDERSTATE_TEXTUREMAPBLEND is mapped to texture state stages in SetRenderState; reverse + the mapping to get the value. */ DWORD colorop, colorarg1, colorarg2; DWORD alphaop, alphaarg1, alphaarg2; @@ -2627,6 +2631,8 @@ IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3 *iface, ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface); TRACE("(%p)->(%08x,%d)\n", This, RenderStateType, Value); + EnterCriticalSection(&ddraw_cs); + switch(RenderStateType) { case D3DRENDERSTATE_TEXTUREHANDLE: @@ -2661,8 +2667,6 @@ IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3 *iface, case D3DRENDERSTATE_TEXTUREMAPBLEND: { - EnterCriticalSection(&ddraw_cs); - This->legacyTextureBlending = TRUE; switch ( (D3DTEXTUREBLEND) Value) @@ -2748,8 +2752,6 @@ IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3 *iface, ERR("Unhandled texture environment %d !\n",Value); } - LeaveCriticalSection(&ddraw_cs); - hr = D3D_OK; break; } @@ -2761,6 +2763,8 @@ IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3 *iface, break; } + LeaveCriticalSection(&ddraw_cs); + return hr; } @@ -4429,6 +4433,8 @@ IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3 *iface, HRESULT hr; TRACE("(%p)->(%d,%p)\n", This, Stage, tex); + EnterCriticalSection(&ddraw_cs); + if (This->legacyTextureBlending) IDirect3DDevice3_GetRenderState(iface, D3DRENDERSTATE_TEXTUREMAPBLEND, &texmapblend); @@ -4447,8 +4453,6 @@ IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3 *iface, DDPIXELFORMAT ddfmt; HRESULT result; - EnterCriticalSection(&ddraw_cs); - result = IWineD3DDevice_GetTexture(This->wineD3DDevice, 0, &tex); @@ -4477,10 +4481,10 @@ IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3 *iface, { IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, WINED3DTA_CURRENT); } - - LeaveCriticalSection(&ddraw_cs); } + LeaveCriticalSection(&ddraw_cs); + return hr; }
participants (1)
-
Alexandre Julliard