2 * IDirect3DVolume8 implementation
4 * Copyright 2005 Oliver Stieber
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "d3d8_private.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
26 /* IDirect3DVolume8 IUnknown parts follow: */
27 static HRESULT WINAPI IDirect3DVolume8Impl_QueryInterface(LPDIRECT3DVOLUME8 iface, REFIID riid, LPVOID *ppobj) {
28 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
30 if (IsEqualGUID(riid, &IID_IUnknown)
31 || IsEqualGUID(riid, &IID_IDirect3DVolume8)) {
32 IUnknown_AddRef(iface);
37 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
42 static ULONG WINAPI IDirect3DVolume8Impl_AddRef(LPDIRECT3DVOLUME8 iface) {
43 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
45 TRACE("(%p)\n", This);
47 if (This->forwardReference) {
48 /* Forward to the containerParent */
49 TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
50 return IUnknown_AddRef(This->forwardReference);
52 /* No container, handle our own refcounting */
53 ULONG ref = InterlockedIncrement(&This->ref);
54 TRACE("(%p) : AddRef from %d\n", This, ref - 1);
59 IWineD3DVolume_AddRef(This->wineD3DVolume);
60 wined3d_mutex_unlock();
67 static ULONG WINAPI IDirect3DVolume8Impl_Release(LPDIRECT3DVOLUME8 iface) {
68 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
70 TRACE("(%p)\n", This);
72 if (This->forwardReference) {
73 /* Forward to the containerParent */
74 TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
75 return IUnknown_Release(This->forwardReference);
78 /* No container, handle our own refcounting */
79 ULONG ref = InterlockedDecrement(&This->ref);
80 TRACE("(%p) : ReleaseRef to %d\n", This, ref);
84 IWineD3DVolume_Release(This->wineD3DVolume);
85 wined3d_mutex_unlock();
92 /* IDirect3DVolume8 Interface follow: */
93 static HRESULT WINAPI IDirect3DVolume8Impl_GetDevice(LPDIRECT3DVOLUME8 iface, IDirect3DDevice8 **ppDevice) {
94 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
95 IWineD3DDevice *myDevice = NULL;
98 IWineD3DVolume_GetDevice(This->wineD3DVolume, &myDevice);
99 IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
100 IWineD3DDevice_Release(myDevice);
101 wined3d_mutex_unlock();
106 static HRESULT WINAPI IDirect3DVolume8Impl_SetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
107 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
109 TRACE("(%p) Relay\n", This);
111 wined3d_mutex_lock();
112 hr = IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
113 wined3d_mutex_unlock();
118 static HRESULT WINAPI IDirect3DVolume8Impl_GetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, void *pData, DWORD* pSizeOfData) {
119 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
121 TRACE("(%p) Relay\n", This);
123 wined3d_mutex_lock();
124 hr = IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
125 wined3d_mutex_unlock();
130 static HRESULT WINAPI IDirect3DVolume8Impl_FreePrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid) {
131 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
133 TRACE("(%p) Relay\n", This);
135 wined3d_mutex_lock();
136 hr = IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
137 wined3d_mutex_unlock();
142 static HRESULT WINAPI IDirect3DVolume8Impl_GetContainer(LPDIRECT3DVOLUME8 iface, REFIID riid, void **ppContainer) {
143 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
146 TRACE("(This %p, riid %s, ppContainer %p)\n", This, debugstr_guid(riid), ppContainer);
148 if (!This->container) return E_NOINTERFACE;
151 ERR("Called without a valid ppContainer.\n");
154 res = IUnknown_QueryInterface(This->container, riid, ppContainer);
156 TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer);
161 static HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface, D3DVOLUME_DESC *pDesc) {
162 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
164 WINED3DVOLUME_DESC wined3ddesc;
166 TRACE("(%p) Relay\n", This);
168 wined3d_mutex_lock();
169 hr = IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
170 wined3d_mutex_unlock();
174 pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.Format);
175 pDesc->Type = wined3ddesc.Type;
176 pDesc->Usage = wined3ddesc.Usage;
177 pDesc->Pool = wined3ddesc.Pool;
178 pDesc->Size = wined3ddesc.Size;
179 pDesc->Width = wined3ddesc.Width;
180 pDesc->Height = wined3ddesc.Height;
181 pDesc->Depth = wined3ddesc.Depth;
187 static HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags) {
188 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
190 TRACE("(%p) relay %p %p %p %d\n", This, This->wineD3DVolume, pLockedVolume, pBox, Flags);
192 wined3d_mutex_lock();
193 hr = IWineD3DVolume_LockBox(This->wineD3DVolume, (WINED3DLOCKED_BOX *) pLockedVolume, (CONST WINED3DBOX *) pBox, Flags);
194 wined3d_mutex_unlock();
199 static HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface) {
200 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
202 TRACE("(%p) relay %p\n", This, This->wineD3DVolume);
204 wined3d_mutex_lock();
205 hr = IWineD3DVolume_UnlockBox(This->wineD3DVolume);
206 wined3d_mutex_unlock();
211 static const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl =
214 IDirect3DVolume8Impl_QueryInterface,
215 IDirect3DVolume8Impl_AddRef,
216 IDirect3DVolume8Impl_Release,
217 /* IDirect3DVolume8 */
218 IDirect3DVolume8Impl_GetDevice,
219 IDirect3DVolume8Impl_SetPrivateData,
220 IDirect3DVolume8Impl_GetPrivateData,
221 IDirect3DVolume8Impl_FreePrivateData,
222 IDirect3DVolume8Impl_GetContainer,
223 IDirect3DVolume8Impl_GetDesc,
224 IDirect3DVolume8Impl_LockBox,
225 IDirect3DVolume8Impl_UnlockBox
228 static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void *parent)
230 HeapFree(GetProcessHeap(), 0, parent);
233 static const struct wined3d_parent_ops d3d8_volume_wined3d_parent_ops =
235 volume_wined3d_object_destroyed,
238 HRESULT volume_init(IDirect3DVolume8Impl *volume, IDirect3DDevice8Impl *device, UINT width, UINT height,
239 UINT depth, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool)
243 volume->lpVtbl = &Direct3DVolume8_Vtbl;
246 hr = IWineD3DDevice_CreateVolume(device->WineD3DDevice, width, height, depth, usage,
247 format, pool, &volume->wineD3DVolume, (IUnknown *)volume, &d3d8_volume_wined3d_parent_ops);
250 WARN("Failed to create wined3d volume, hr %#x.\n", hr);