Module: wine Branch: master Commit: 5dbd834ca07a38a5aad8a117ca893107284167d5 URL: http://source.winehq.org/git/wine.git/?a=commit;h=5dbd834ca07a38a5aad8a117ca...
Author: Markus Amsler markus.amsler@oribi.org Date: Thu Dec 14 01:55:48 2006 +0100
d3d8: Release non implicit surfaces only if refcount is 0, with test.
---
dlls/d3d8/surface.c | 12 +++++++----- dlls/d3d8/tests/device.c | 3 +++ 2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/dlls/d3d8/surface.c b/dlls/d3d8/surface.c index 848b314..d834460 100644 --- a/dlls/d3d8/surface.c +++ b/dlls/d3d8/surface.c @@ -72,11 +72,13 @@ static ULONG WINAPI IDirect3DSurface8Imp ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p) : ReleaseRef to %d\n", This, ref);
- if (ref == 0 && This->parentDevice) IUnknown_Release(This->parentDevice); - /* Implicit surfaces are destroyed with the device, not if refcount reaches 0. */ - if (ref >= 0 && !This->isImplicit) { - IWineD3DSurface_Release(This->wineD3DSurface); - HeapFree(GetProcessHeap(), 0, This); + if (ref == 0) { + if (This->parentDevice) IUnknown_Release(This->parentDevice); + /* Implicit surfaces are destroyed with the device, not if refcount reaches 0. */ + if (!This->isImplicit) { + IWineD3DSurface_Release(This->wineD3DSurface); + HeapFree(GetProcessHeap(), 0, This); + } }
return ref; diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index b22759d..3ec0dbd 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -476,10 +476,13 @@ static void test_refcount(void) /* Surfaces */ hr = IDirect3DDevice8_CreateDepthStencilSurface( pDevice, 32, 32, D3DFMT_D24S8, D3DMULTISAMPLE_NONE, &pStencilSurface ); CHECK_CALL( hr, "CreateDepthStencilSurface", pDevice, ++refcount ); + CHECK_REFCOUNT( pStencilSurface, 1); hr = IDirect3DDevice8_CreateImageSurface( pDevice, 32, 32, D3DFMT_X8R8G8B8, &pImageSurface ); CHECK_CALL( hr, "CreateImageSurface", pDevice, ++refcount ); + CHECK_REFCOUNT( pImageSurface, 1); hr = IDirect3DDevice8_CreateRenderTarget( pDevice, 32, 32, D3DFMT_X8R8G8B8, D3DMULTISAMPLE_NONE, TRUE, &pRenderTarget3 ); CHECK_CALL( hr, "CreateRenderTarget", pDevice, ++refcount ); + CHECK_REFCOUNT( pRenderTarget3, 1); /* Misc */ hr = IDirect3DDevice8_CreateStateBlock( pDevice, D3DSBT_ALL, &dStateBlock ); CHECK_CALL( hr, "CreateStateBlock", pDevice, refcount );