d3d10core: Implement d3d10_rendertarget_view_GetDevice().

This commit is contained in:
Henri Verbeet 2014-02-13 10:14:23 +01:00 committed by Alexandre Julliard
parent 01d435288f
commit 40686f48cb
4 changed files with 26 additions and 8 deletions

View File

@ -138,9 +138,10 @@ struct d3d10_rendertarget_view
struct wined3d_rendertarget_view *wined3d_view;
D3D10_RENDER_TARGET_VIEW_DESC desc;
ID3D10Resource *resource;
ID3D10Device1 *device;
};
HRESULT d3d10_rendertarget_view_init(struct d3d10_rendertarget_view *view,
HRESULT d3d10_rendertarget_view_init(struct d3d10_rendertarget_view *view, struct d3d10_device *device,
ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc) DECLSPEC_HIDDEN;
struct d3d10_rendertarget_view *unsafe_impl_from_ID3D10RenderTargetView(ID3D10RenderTargetView *iface) DECLSPEC_HIDDEN;

View File

@ -1188,17 +1188,16 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Dev
static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Device1 *iface,
ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc, ID3D10RenderTargetView **view)
{
struct d3d10_device *device = impl_from_ID3D10Device(iface);
struct d3d10_rendertarget_view *object;
HRESULT hr;
TRACE("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view);
TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
return E_OUTOFMEMORY;
hr = d3d10_rendertarget_view_init(object, resource, desc);
if (FAILED(hr))
if (FAILED(hr = d3d10_rendertarget_view_init(object, device, resource, desc)))
{
WARN("Failed to initialize rendertarget view, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);

View File

@ -308,8 +308,18 @@ static void test_create_rendertarget_view(void)
U(rtv_desc).Buffer.ElementOffset = 0;
U(rtv_desc).Buffer.ElementWidth = 64;
expected_refcount = get_refcount((IUnknown *)device) + 1;
hr = ID3D10Device_CreateRenderTargetView(device, (ID3D10Resource *)buffer, &rtv_desc, &rtview);
ok(SUCCEEDED(hr), "Failed to create a rendertarget view, hr %#x\n", hr);
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;
ID3D10RenderTargetView_GetDevice(rtview, &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);
ID3D10RenderTargetView_Release(rtview);
ID3D10Buffer_Release(buffer);

View File

@ -587,6 +587,7 @@ static ULONG STDMETHODCALLTYPE d3d10_rendertarget_view_Release(ID3D10RenderTarge
{
wined3d_rendertarget_view_decref(This->wined3d_view);
ID3D10Resource_Release(This->resource);
ID3D10Device1_Release(This->device);
HeapFree(GetProcessHeap(), 0, This);
}
@ -597,7 +598,12 @@ static ULONG STDMETHODCALLTYPE d3d10_rendertarget_view_Release(ID3D10RenderTarge
static void STDMETHODCALLTYPE d3d10_rendertarget_view_GetDevice(ID3D10RenderTargetView *iface, ID3D10Device **device)
{
FIXME("iface %p, device %p stub!\n", iface, device);
struct d3d10_rendertarget_view *view = impl_from_ID3D10RenderTargetView(iface);
TRACE("iface %p, device %p.\n", iface, device);
*device = (ID3D10Device *)view->device;
ID3D10Device_AddRef(*device);
}
static HRESULT STDMETHODCALLTYPE d3d10_rendertarget_view_GetPrivateData(ID3D10RenderTargetView *iface,
@ -668,7 +674,7 @@ static const struct ID3D10RenderTargetViewVtbl d3d10_rendertarget_view_vtbl =
d3d10_rendertarget_view_GetDesc,
};
HRESULT d3d10_rendertarget_view_init(struct d3d10_rendertarget_view *view,
HRESULT d3d10_rendertarget_view_init(struct d3d10_rendertarget_view *view, struct d3d10_device *device,
ID3D10Resource *resource, const D3D10_RENDER_TARGET_VIEW_DESC *desc)
{
struct wined3d_resource *wined3d_resource;
@ -703,6 +709,8 @@ HRESULT d3d10_rendertarget_view_init(struct d3d10_rendertarget_view *view,
view->resource = resource;
ID3D10Resource_AddRef(resource);
view->device = &device->ID3D10Device1_iface;
ID3D10Device1_AddRef(view->device);
return S_OK;
}