Module: wine Branch: master Commit: 5c6438e834c90001d41e1b71ca6aea5415ee17d1 URL: http://source.winehq.org/git/wine.git/?a=commit;h=5c6438e834c90001d41e1b71ca...
Author: Józef Kucia joseph.kucia@gmail.com Date: Tue Jun 5 12:05:43 2012 +0200
d3dx9: Add ID3DXRenderToSurface interface stub.
---
dlls/d3dx9_36/render.c | 131 +++++++++++++++++++++++++++++++++++++++++++- dlls/d3dx9_36/tests/core.c | 2 - 2 files changed, 129 insertions(+), 4 deletions(-)
diff --git a/dlls/d3dx9_36/render.c b/dlls/d3dx9_36/render.c index 0e8ed7a..4e4adfb 100644 --- a/dlls/d3dx9_36/render.c +++ b/dlls/d3dx9_36/render.c @@ -22,6 +22,121 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
+struct render_to_surface +{ + ID3DXRenderToSurface ID3DXRenderToSurface_iface; + LONG ref; + + IDirect3DDevice9 *device; +}; + +static inline struct render_to_surface *impl_from_ID3DXRenderToSurface(ID3DXRenderToSurface *iface) +{ + return CONTAINING_RECORD(iface, struct render_to_surface, ID3DXRenderToSurface_iface); +} + +static HRESULT WINAPI D3DXRenderToSurface_QueryInterface(ID3DXRenderToSurface *iface, + REFIID riid, + void **out) +{ + TRACE("iface %p, riid %s, out %p\n", iface, debugstr_guid(riid), out); + + if (IsEqualGUID(riid, &IID_ID3DXRenderToSurface) + || IsEqualGUID(riid, &IID_IUnknown)) + { + IUnknown_AddRef(iface); + *out = iface; + return S_OK; + } + + WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid)); + + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI D3DXRenderToSurface_AddRef(ID3DXRenderToSurface *iface) +{ + struct render_to_surface *render = impl_from_ID3DXRenderToSurface(iface); + ULONG ref = InterlockedIncrement(&render->ref); + + TRACE("%p increasing refcount to %u\n", iface, ref); + + return ref; +} + +static ULONG WINAPI D3DXRenderToSurface_Release(ID3DXRenderToSurface *iface) +{ + struct render_to_surface *render = impl_from_ID3DXRenderToSurface(iface); + ULONG ref = InterlockedDecrement(&render->ref); + + TRACE("%p decreasing refcount to %u\n", iface, ref); + + if (!ref) + { + IDirect3DDevice9_Release(render->device); + HeapFree(GetProcessHeap(), 0, render); + } + + return ref; +} + +static HRESULT WINAPI D3DXRenderToSurface_GetDevice(ID3DXRenderToSurface *iface, + IDirect3DDevice9 **device) +{ + FIXME("(%p)->(%p): stub\n", iface, device); + return E_NOTIMPL; +} + +static HRESULT WINAPI D3DXRenderToSurface_GetDesc(ID3DXRenderToSurface *iface, + D3DXRTS_DESC *desc) +{ + FIXME("(%p)->(%p): stub\n", iface, desc); + return E_NOTIMPL; +} + +static HRESULT WINAPI D3DXRenderToSurface_BeginScene(ID3DXRenderToSurface *iface, + IDirect3DSurface9 *surface, + const D3DVIEWPORT9 *viewport) +{ + FIXME("(%p)->(%p, %p): stub\n", iface, surface, viewport); + return E_NOTIMPL; +} + +static HRESULT WINAPI D3DXRenderToSurface_EndScene(ID3DXRenderToSurface *iface, + DWORD mip_filter) +{ + FIXME("(%p)->(%#x): stub\n", iface, mip_filter); + return E_NOTIMPL; +} + +static HRESULT WINAPI D3DXRenderToSurface_OnLostDevice(ID3DXRenderToSurface *iface) +{ + FIXME("(%p)->(): stub\n", iface); + return D3D_OK; +} + +static HRESULT WINAPI D3DXRenderToSurface_OnResetDevice(ID3DXRenderToSurface *iface) +{ + FIXME("(%p)->(): stub\n", iface); + return D3D_OK; +} + +static const ID3DXRenderToSurfaceVtbl d3dx_render_to_surface_vtbl = +{ + /* IUnknown methods */ + D3DXRenderToSurface_QueryInterface, + D3DXRenderToSurface_AddRef, + D3DXRenderToSurface_Release, + /* ID3DXRenderToSurface methods */ + D3DXRenderToSurface_GetDevice, + D3DXRenderToSurface_GetDesc, + D3DXRenderToSurface_BeginScene, + D3DXRenderToSurface_EndScene, + D3DXRenderToSurface_OnLostDevice, + D3DXRenderToSurface_OnResetDevice +}; + HRESULT WINAPI D3DXCreateRenderToSurface(IDirect3DDevice9 *device, UINT width, UINT height, @@ -30,10 +145,22 @@ HRESULT WINAPI D3DXCreateRenderToSurface(IDirect3DDevice9 *device, D3DFORMAT depth_stencil_format, ID3DXRenderToSurface **out) { - FIXME("(%p, %u, %u, %#x, %d, %#x, %p): stub\n", device, width, height, format, + struct render_to_surface *render; + + FIXME("(%p, %u, %u, %#x, %d, %#x, %p): semi-stub\n", device, width, height, format, depth_stencil, depth_stencil_format, out);
if (!device || !out) return D3DERR_INVALIDCALL;
- return E_NOTIMPL; + render = HeapAlloc(GetProcessHeap(), 0, sizeof(struct render_to_surface)); + if (!render) return E_OUTOFMEMORY; + + render->ID3DXRenderToSurface_iface.lpVtbl = &d3dx_render_to_surface_vtbl; + render->ref = 1; + + IDirect3DDevice9_AddRef(device); + render->device = device; + + *out = &render->ID3DXRenderToSurface_iface; + return D3D_OK; } diff --git a/dlls/d3dx9_36/tests/core.c b/dlls/d3dx9_36/tests/core.c index 2ba56b5..ae60080 100644 --- a/dlls/d3dx9_36/tests/core.c +++ b/dlls/d3dx9_36/tests/core.c @@ -459,7 +459,6 @@ void test_D3DXCreateRenderToSurface(IDirect3DDevice9 *device) hr = D3DXCreateRenderToSurface(device, 256, 256, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN, NULL /* out */); ok(hr == D3DERR_INVALIDCALL, "D3DXCreateRenderToSurface returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
- todo_wine { hr = D3DXCreateRenderToSurface(device, 0 /* width */, 256, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN, &render); ok(hr == D3D_OK, "D3DXCreateRenderToSurface returned %#x, expected %#x\n", hr, D3D_OK); if (SUCCEEDED(hr)) ID3DXRenderToSurface_Release(render); @@ -481,7 +480,6 @@ void test_D3DXCreateRenderToSurface(IDirect3DDevice9 *device) hr = D3DXCreateRenderToSurface(device, 0, 0, D3DFMT_UNKNOWN, FALSE, D3DFMT_UNKNOWN, &render); check_ref((IUnknown *)device, ref_count + 1); if (SUCCEEDED(hr)) ID3DXRenderToSurface_Release(render); - } }
START_TEST(core)