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 static ULONG WINAPI
IDirect3DVolume8Impl_Release(LPDIRECT3DVOLUME8 iface
) {
60 IDirect3DVolume8Impl
*This
= (IDirect3DVolume8Impl
*)iface
;
62 TRACE("(%p)\n", This
);
64 if (This
->forwardReference
) {
65 /* Forward to the containerParent */
66 TRACE("(%p) : Forwarding to %p\n", This
, This
->forwardReference
);
67 return IUnknown_Release(This
->forwardReference
);
70 /* No container, handle our own refcounting */
71 ULONG ref
= InterlockedDecrement(&This
->ref
);
72 TRACE("(%p) : ReleaseRef to %d\n", This
, ref
);
76 IWineD3DVolume_Release(This
->wineD3DVolume
);
77 wined3d_mutex_unlock();
79 HeapFree(GetProcessHeap(), 0, This
);
86 /* IDirect3DVolume8 Interface follow: */
87 static HRESULT WINAPI
IDirect3DVolume8Impl_GetDevice(LPDIRECT3DVOLUME8 iface
, IDirect3DDevice8
**ppDevice
) {
88 IDirect3DVolume8Impl
*This
= (IDirect3DVolume8Impl
*)iface
;
89 IWineD3DDevice
*myDevice
= NULL
;
92 IWineD3DVolume_GetDevice(This
->wineD3DVolume
, &myDevice
);
93 IWineD3DDevice_GetParent(myDevice
, (IUnknown
**)ppDevice
);
94 IWineD3DDevice_Release(myDevice
);
95 wined3d_mutex_unlock();
100 static HRESULT WINAPI
IDirect3DVolume8Impl_SetPrivateData(LPDIRECT3DVOLUME8 iface
, REFGUID refguid
, CONST
void *pData
, DWORD SizeOfData
, DWORD Flags
) {
101 IDirect3DVolume8Impl
*This
= (IDirect3DVolume8Impl
*)iface
;
103 TRACE("(%p) Relay\n", This
);
105 wined3d_mutex_lock();
106 hr
= IWineD3DVolume_SetPrivateData(This
->wineD3DVolume
, refguid
, pData
, SizeOfData
, Flags
);
107 wined3d_mutex_unlock();
112 static HRESULT WINAPI
IDirect3DVolume8Impl_GetPrivateData(LPDIRECT3DVOLUME8 iface
, REFGUID refguid
, void *pData
, DWORD
* pSizeOfData
) {
113 IDirect3DVolume8Impl
*This
= (IDirect3DVolume8Impl
*)iface
;
115 TRACE("(%p) Relay\n", This
);
117 wined3d_mutex_lock();
118 hr
= IWineD3DVolume_GetPrivateData(This
->wineD3DVolume
, refguid
, pData
, pSizeOfData
);
119 wined3d_mutex_unlock();
124 static HRESULT WINAPI
IDirect3DVolume8Impl_FreePrivateData(LPDIRECT3DVOLUME8 iface
, REFGUID refguid
) {
125 IDirect3DVolume8Impl
*This
= (IDirect3DVolume8Impl
*)iface
;
127 TRACE("(%p) Relay\n", This
);
129 wined3d_mutex_lock();
130 hr
= IWineD3DVolume_FreePrivateData(This
->wineD3DVolume
, refguid
);
131 wined3d_mutex_unlock();
136 static HRESULT WINAPI
IDirect3DVolume8Impl_GetContainer(LPDIRECT3DVOLUME8 iface
, REFIID riid
, void **ppContainer
) {
137 IDirect3DVolume8Impl
*This
= (IDirect3DVolume8Impl
*)iface
;
140 TRACE("(This %p, riid %s, ppContainer %p)\n", This
, debugstr_guid(riid
), ppContainer
);
142 if (!This
->container
) return E_NOINTERFACE
;
145 ERR("Called without a valid ppContainer.\n");
148 res
= IUnknown_QueryInterface(This
->container
, riid
, ppContainer
);
150 TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer
, *ppContainer
);
155 static HRESULT WINAPI
IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface
, D3DVOLUME_DESC
*pDesc
) {
156 IDirect3DVolume8Impl
*This
= (IDirect3DVolume8Impl
*)iface
;
158 WINED3DVOLUME_DESC wined3ddesc
;
160 TRACE("(%p) Relay\n", This
);
162 wined3d_mutex_lock();
163 hr
= IWineD3DVolume_GetDesc(This
->wineD3DVolume
, &wined3ddesc
);
164 wined3d_mutex_unlock();
168 pDesc
->Format
= d3dformat_from_wined3dformat(wined3ddesc
.Format
);
169 pDesc
->Type
= wined3ddesc
.Type
;
170 pDesc
->Usage
= wined3ddesc
.Usage
;
171 pDesc
->Pool
= wined3ddesc
.Pool
;
172 pDesc
->Size
= wined3ddesc
.Size
;
173 pDesc
->Width
= wined3ddesc
.Width
;
174 pDesc
->Height
= wined3ddesc
.Height
;
175 pDesc
->Depth
= wined3ddesc
.Depth
;
181 static HRESULT WINAPI
IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface
, D3DLOCKED_BOX
*pLockedVolume
, CONST D3DBOX
*pBox
, DWORD Flags
) {
182 IDirect3DVolume8Impl
*This
= (IDirect3DVolume8Impl
*)iface
;
184 TRACE("(%p) relay %p %p %p %d\n", This
, This
->wineD3DVolume
, pLockedVolume
, pBox
, Flags
);
186 wined3d_mutex_lock();
187 hr
= IWineD3DVolume_LockBox(This
->wineD3DVolume
, (WINED3DLOCKED_BOX
*) pLockedVolume
, (CONST WINED3DBOX
*) pBox
, Flags
);
188 wined3d_mutex_unlock();
193 static HRESULT WINAPI
IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface
) {
194 IDirect3DVolume8Impl
*This
= (IDirect3DVolume8Impl
*)iface
;
196 TRACE("(%p) relay %p\n", This
, This
->wineD3DVolume
);
198 wined3d_mutex_lock();
199 hr
= IWineD3DVolume_UnlockBox(This
->wineD3DVolume
);
200 wined3d_mutex_unlock();
205 const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl
=
208 IDirect3DVolume8Impl_QueryInterface
,
209 IDirect3DVolume8Impl_AddRef
,
210 IDirect3DVolume8Impl_Release
,
211 /* IDirect3DVolume8 */
212 IDirect3DVolume8Impl_GetDevice
,
213 IDirect3DVolume8Impl_SetPrivateData
,
214 IDirect3DVolume8Impl_GetPrivateData
,
215 IDirect3DVolume8Impl_FreePrivateData
,
216 IDirect3DVolume8Impl_GetContainer
,
217 IDirect3DVolume8Impl_GetDesc
,
218 IDirect3DVolume8Impl_LockBox
,
219 IDirect3DVolume8Impl_UnlockBox
222 ULONG WINAPI
D3D8CB_DestroyVolume(IWineD3DVolume
*pVolume
) {
223 IDirect3DVolume8Impl
* volumeParent
;
225 IWineD3DVolume_GetParent(pVolume
, (IUnknown
**) &volumeParent
);
226 /* GetParent's AddRef was forwarded to an object in destruction.
227 * Releasing it here again would cause an endless recursion. */
228 volumeParent
->forwardReference
= NULL
;
229 return IDirect3DVolume8_Release((IDirect3DVolume8
*) volumeParent
);