d3d10core: Implement d3d10_rasterizer_state_GetDevice().

This commit is contained in:
Henri Verbeet 2014-02-17 11:24:32 +01:00 committed by Alexandre Julliard
parent c7fb7ba539
commit 569a2e758a
3 changed files with 25 additions and 6 deletions

View File

@ -257,9 +257,9 @@ struct d3d10_rasterizer_state
ID3D10RasterizerState ID3D10RasterizerState_iface;
LONG refcount;
struct d3d10_device *device;
D3D10_RASTERIZER_DESC desc;
struct wine_rb_entry entry;
ID3D10Device1 *device;
};
HRESULT d3d10_rasterizer_state_init(struct d3d10_rasterizer_state *state, struct d3d10_device *device,

View File

@ -366,7 +366,9 @@ static ULONG STDMETHODCALLTYPE d3d10_rasterizer_state_Release(ID3D10RasterizerSt
if (!refcount)
{
wine_rb_remove(&state->device->rasterizer_states, &state->desc);
struct d3d10_device *device = impl_from_ID3D10Device(state->device);
wine_rb_remove(&device->rasterizer_states, &state->desc);
ID3D10Device1_Release(state->device);
HeapFree(GetProcessHeap(), 0, state);
}
@ -377,7 +379,12 @@ static ULONG STDMETHODCALLTYPE d3d10_rasterizer_state_Release(ID3D10RasterizerSt
static void STDMETHODCALLTYPE d3d10_rasterizer_state_GetDevice(ID3D10RasterizerState *iface, ID3D10Device **device)
{
FIXME("iface %p, device %p stub!\n", iface, device);
struct d3d10_rasterizer_state *state = impl_from_ID3D10RasterizerState(iface);
TRACE("iface %p, device %p.\n", iface, device);
*device = (ID3D10Device *)state->device;
ID3D10Device_AddRef(*device);
}
static HRESULT STDMETHODCALLTYPE d3d10_rasterizer_state_GetPrivateData(ID3D10RasterizerState *iface,
@ -438,7 +445,6 @@ HRESULT d3d10_rasterizer_state_init(struct d3d10_rasterizer_state *state, struct
{
state->ID3D10RasterizerState_iface.lpVtbl = &d3d10_rasterizer_state_vtbl;
state->refcount = 1;
state->device = device;
state->desc = *desc;
if (wine_rb_put(&device->rasterizer_states, desc, &state->entry) == -1)
@ -447,6 +453,9 @@ HRESULT d3d10_rasterizer_state_init(struct d3d10_rasterizer_state *state, struct
return E_FAIL;
}
state->device = &device->ID3D10Device1_iface;
ID3D10Device1_AddRef(state->device);
return S_OK;
}

View File

@ -784,9 +784,9 @@ static void test_create_depthstencil_state(void)
static void test_create_rasterizer_state(void)
{
ID3D10RasterizerState *rast_state1, *rast_state2;
ULONG refcount, expected_refcount;
D3D10_RASTERIZER_DESC rast_desc;
ID3D10Device *device;
ULONG refcount;
ID3D10Device *device, *tmp;
HRESULT hr;
if (!(device = create_device()))
@ -809,11 +809,21 @@ static void test_create_rasterizer_state(void)
rast_desc.MultisampleEnable = FALSE;
rast_desc.AntialiasedLineEnable = FALSE;
expected_refcount = get_refcount((IUnknown *)device) + 1;
hr = ID3D10Device_CreateRasterizerState(device, &rast_desc, &rast_state1);
ok(SUCCEEDED(hr), "Failed to create rasterizer state, hr %#x.\n", hr);
hr = ID3D10Device_CreateRasterizerState(device, &rast_desc, &rast_state2);
ok(SUCCEEDED(hr), "Failed to create rasterizer state, hr %#x.\n", hr);
ok(rast_state1 == rast_state2, "Got different rasterizer state objects.\n");
refcount = get_refcount((IUnknown *)device);
ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount);
tmp = NULL;
expected_refcount = refcount + 1;
ID3D10RasterizerState_GetDevice(rast_state1, &tmp);
ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
refcount = get_refcount((IUnknown *)device);
ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
ID3D10Device_Release(tmp);
refcount = ID3D10RasterizerState_Release(rast_state2);
ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);