Commit 9eda5c04 authored by Sven Baars's avatar Sven Baars Committed by Alexandre Julliard

d3dx9: Don't release textures when D3DXSPRITE_DO_NOT_ADDREF_TEXTURE is specified.

parent 15346b36
......@@ -112,10 +112,13 @@ static ULONG WINAPI d3dx9_sprite_Release(ID3DXSprite *iface)
{
int i;
for (i = 0; i < sprite->sprite_count; ++i)
if (!(sprite->flags & D3DXSPRITE_DO_NOT_ADDREF_TEXTURE))
{
if (sprite->sprites[i].texture)
IDirect3DTexture9_Release(sprite->sprites[i].texture);
for (i = 0; i < sprite->sprite_count; ++i)
{
if (sprite->sprites[i].texture)
IDirect3DTexture9_Release(sprite->sprites[i].texture);
}
}
HeapFree(GetProcessHeap(), 0, sprite->sprites);
......@@ -518,10 +521,13 @@ static HRESULT WINAPI d3dx9_sprite_OnResetDevice(ID3DXSprite *iface)
TRACE("iface %p.\n", iface);
for (i = 0; i < sprite->sprite_count; ++i)
if (!(sprite->flags & D3DXSPRITE_DO_NOT_ADDREF_TEXTURE))
{
if (sprite->sprites[i].texture)
IDirect3DTexture9_Release(sprite->sprites[i].texture);
for (i = 0; i < sprite->sprite_count; ++i)
{
if (sprite->sprites[i].texture)
IDirect3DTexture9_Release(sprite->sprites[i].texture);
}
}
sprite->sprite_count = 0;
......
......@@ -306,6 +306,20 @@ static void test_ID3DXSprite(IDirect3DDevice9 *device)
hr = ID3DXSprite_End(sprite);
ok (hr == D3DERR_INVALIDCALL, "End returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
/* Test D3DXSPRITE_DO_NOT_ADDREF_TEXTURE */
hr = ID3DXSprite_Begin(sprite, D3DXSPRITE_DO_NOT_ADDREF_TEXTURE);
ok (hr == D3D_OK, "Begin returned %#x, expected %#x\n", hr, D3D_OK);
hr = ID3DXSprite_Draw(sprite, tex2, &rect, &center, &pos, D3DCOLOR_XRGB(255, 255, 255));
ok (hr == D3D_OK, "Draw returned %#x, expected %#x\n", hr, D3D_OK);
hr = ID3DXSprite_OnResetDevice(sprite);
ok (hr == D3D_OK, "OnResetDevice returned %#x, expected %#x\n", hr, D3D_OK);
check_ref((IUnknown*)tex2, 1);
hr = ID3DXSprite_Begin(sprite, D3DXSPRITE_DO_NOT_ADDREF_TEXTURE);
ok (hr == D3D_OK, "Begin returned %#x, expected %#x\n", hr, D3D_OK);
hr = ID3DXSprite_Draw(sprite, tex2, &rect, &center, &pos, D3DCOLOR_XRGB(255, 255, 255));
ok (hr == D3D_OK, "Draw returned %#x, expected %#x\n", hr, D3D_OK);
IDirect3DDevice9_EndScene(device);
check_release((IUnknown*)sprite, 0);
check_release((IUnknown*)tex2, 0);
......
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