d3dx9: Implement ID3DXRenderToSurface::GetDesc.
[wine/multimedia.git] / dlls / d3dx9_36 / render.c
blob99cee8d131a927f894e37a9b548d27add74c042f
1 /*
2 * Copyright (C) 2012 Józef Kucia
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "wine/debug.h"
21 #include "d3dx9_36_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
25 struct render_to_surface
27 ID3DXRenderToSurface ID3DXRenderToSurface_iface;
28 LONG ref;
30 IDirect3DDevice9 *device;
31 D3DXRTS_DESC desc;
34 static inline struct render_to_surface *impl_from_ID3DXRenderToSurface(ID3DXRenderToSurface *iface)
36 return CONTAINING_RECORD(iface, struct render_to_surface, ID3DXRenderToSurface_iface);
39 static HRESULT WINAPI D3DXRenderToSurface_QueryInterface(ID3DXRenderToSurface *iface,
40 REFIID riid,
41 void **out)
43 TRACE("iface %p, riid %s, out %p\n", iface, debugstr_guid(riid), out);
45 if (IsEqualGUID(riid, &IID_ID3DXRenderToSurface)
46 || IsEqualGUID(riid, &IID_IUnknown))
48 IUnknown_AddRef(iface);
49 *out = iface;
50 return S_OK;
53 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
55 *out = NULL;
56 return E_NOINTERFACE;
59 static ULONG WINAPI D3DXRenderToSurface_AddRef(ID3DXRenderToSurface *iface)
61 struct render_to_surface *render = impl_from_ID3DXRenderToSurface(iface);
62 ULONG ref = InterlockedIncrement(&render->ref);
64 TRACE("%p increasing refcount to %u\n", iface, ref);
66 return ref;
69 static ULONG WINAPI D3DXRenderToSurface_Release(ID3DXRenderToSurface *iface)
71 struct render_to_surface *render = impl_from_ID3DXRenderToSurface(iface);
72 ULONG ref = InterlockedDecrement(&render->ref);
74 TRACE("%p decreasing refcount to %u\n", iface, ref);
76 if (!ref)
78 IDirect3DDevice9_Release(render->device);
79 HeapFree(GetProcessHeap(), 0, render);
82 return ref;
85 static HRESULT WINAPI D3DXRenderToSurface_GetDevice(ID3DXRenderToSurface *iface,
86 IDirect3DDevice9 **device)
88 FIXME("(%p)->(%p): stub\n", iface, device);
89 return E_NOTIMPL;
92 static HRESULT WINAPI D3DXRenderToSurface_GetDesc(ID3DXRenderToSurface *iface,
93 D3DXRTS_DESC *desc)
95 struct render_to_surface *render = impl_from_ID3DXRenderToSurface(iface);
97 TRACE("(%p)->(%p)\n", iface, desc);
99 if (!desc) return D3DERR_INVALIDCALL;
101 *desc = render->desc;
102 return D3D_OK;
105 static HRESULT WINAPI D3DXRenderToSurface_BeginScene(ID3DXRenderToSurface *iface,
106 IDirect3DSurface9 *surface,
107 const D3DVIEWPORT9 *viewport)
109 FIXME("(%p)->(%p, %p): stub\n", iface, surface, viewport);
110 return E_NOTIMPL;
113 static HRESULT WINAPI D3DXRenderToSurface_EndScene(ID3DXRenderToSurface *iface,
114 DWORD mip_filter)
116 FIXME("(%p)->(%#x): stub\n", iface, mip_filter);
117 return E_NOTIMPL;
120 static HRESULT WINAPI D3DXRenderToSurface_OnLostDevice(ID3DXRenderToSurface *iface)
122 FIXME("(%p)->(): stub\n", iface);
123 return D3D_OK;
126 static HRESULT WINAPI D3DXRenderToSurface_OnResetDevice(ID3DXRenderToSurface *iface)
128 FIXME("(%p)->(): stub\n", iface);
129 return D3D_OK;
132 static const ID3DXRenderToSurfaceVtbl d3dx_render_to_surface_vtbl =
134 /* IUnknown methods */
135 D3DXRenderToSurface_QueryInterface,
136 D3DXRenderToSurface_AddRef,
137 D3DXRenderToSurface_Release,
138 /* ID3DXRenderToSurface methods */
139 D3DXRenderToSurface_GetDevice,
140 D3DXRenderToSurface_GetDesc,
141 D3DXRenderToSurface_BeginScene,
142 D3DXRenderToSurface_EndScene,
143 D3DXRenderToSurface_OnLostDevice,
144 D3DXRenderToSurface_OnResetDevice
147 HRESULT WINAPI D3DXCreateRenderToSurface(IDirect3DDevice9 *device,
148 UINT width,
149 UINT height,
150 D3DFORMAT format,
151 BOOL depth_stencil,
152 D3DFORMAT depth_stencil_format,
153 ID3DXRenderToSurface **out)
155 struct render_to_surface *render;
157 TRACE("(%p, %u, %u, %#x, %d, %#x, %p)\n", device, width, height, format,
158 depth_stencil, depth_stencil_format, out);
160 if (!device || !out) return D3DERR_INVALIDCALL;
162 render = HeapAlloc(GetProcessHeap(), 0, sizeof(struct render_to_surface));
163 if (!render) return E_OUTOFMEMORY;
165 render->ID3DXRenderToSurface_iface.lpVtbl = &d3dx_render_to_surface_vtbl;
166 render->ref = 1;
168 IDirect3DDevice9_AddRef(device);
169 render->device = device;
171 render->desc.Width = width;
172 render->desc.Height = height;
173 render->desc.Format = format;
174 render->desc.DepthStencil = depth_stencil;
175 render->desc.DepthStencilFormat = depth_stencil_format;
177 *out = &render->ID3DXRenderToSurface_iface;
178 return D3D_OK;