/***************************************************************************** * IDirect3DVertexBuffer7::Release * * Release for Vertex Buffers * * Returns: * The new refcount * *****************************************************************************/ static ULONG WINAPI IDirect3DVertexBufferImpl_Release(IDirect3DVertexBuffer7 *iface) { ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p)->() decrementing from %u.\n", This, ref + 1); if (ref == 0) { IWineD3DVertexBuffer *curVB = NULL; UINT offset, stride; EnterCriticalSection(&ddraw_cs); /* D3D7 Vertex buffers don't stay bound in the device, they are passed as a parameter * to drawPrimitiveVB. DrawPrimitiveVB sets them as the stream source in wined3d, * and they should get unset there before they are destroyed */ IWineD3DDevice_GetStreamSource(This->ddraw->wineD3DDevice, 0 /* Stream number */, &curVB, &offset, &stride); if(curVB == This->wineD3DVertexBuffer) { IWineD3DDevice_SetStreamSource(This->ddraw->wineD3DDevice, 0 /* Steam number */, NULL /* stream data */, 0 /* Offset */, 0 /* stride */); } if(curVB) { IWineD3DVertexBuffer_Release(curVB); /* For the GetStreamSource */ } IWineD3DVertexDeclaration_Release(This->wineD3DVertexDeclaration); IWineD3DVertexBuffer_Release(This->wineD3DVertexBuffer); LeaveCriticalSection(&ddraw_cs); HeapFree(GetProcessHeap(), 0, This); return 0; } return ref; }
static ULONG WINAPI IDirect3DVertexBuffer9Impl_Release(LPDIRECT3DVERTEXBUFFER9 iface) { IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface; ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p) : ReleaseRef to %ld\n", This, ref); if (ref == 0) { IWineD3DVertexBuffer_Release(This->wineD3DVertexBuffer); IUnknown_Release(This->parentDevice); HeapFree(GetProcessHeap(), 0, This); } return ref; }