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;
44 IUnknown *containerParent = NULL;
46 TRACE("(%p)\n", This);
48 IWineD3DVolume_GetContainerParent(This->wineD3DVolume, &containerParent);
49 if (containerParent) {
50 /* Forward to the containerParent */
51 TRACE("(%p) : Forwarding to %p\n", This, containerParent);
52 return IUnknown_AddRef(containerParent);
54 /* No container, handle our own refcounting */
55 ULONG ref = InterlockedIncrement(&This->ref);
56 TRACE("(%p) : AddRef from %d\n", This, ref - 1);
61 static ULONG WINAPI IDirect3DVolume8Impl_Release(LPDIRECT3DVOLUME8 iface) {
62 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
63 IUnknown *containerParent = NULL;
65 TRACE("(%p)\n", This);
67 IWineD3DVolume_GetContainerParent(This->wineD3DVolume, &containerParent);
68 if (containerParent) {
69 /* Forward to the containerParent */
70 TRACE("(%p) : Forwarding to %p\n", This, containerParent);
71 return IUnknown_Release(containerParent);
74 /* No container, handle our own refcounting */
75 ULONG ref = InterlockedDecrement(&This->ref);
76 TRACE("(%p) : ReleaseRef to %d\n", This, ref);
79 IWineD3DVolume_Release(This->wineD3DVolume);
80 HeapFree(GetProcessHeap(), 0, This);
87 /* IDirect3DVolume8 Interface follow: */
88 static HRESULT WINAPI IDirect3DVolume8Impl_GetDevice(LPDIRECT3DVOLUME8 iface, IDirect3DDevice8 **ppDevice) {
89 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
90 IWineD3DDevice *myDevice = NULL;
92 IWineD3DVolume_GetDevice(This->wineD3DVolume, &myDevice);
93 IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
94 IWineD3DDevice_Release(myDevice);
98 static HRESULT WINAPI IDirect3DVolume8Impl_SetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
99 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
100 TRACE("(%p) Relay\n", This);
101 return IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
104 static HRESULT WINAPI IDirect3DVolume8Impl_GetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, void *pData, DWORD* pSizeOfData) {
105 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
106 TRACE("(%p) Relay\n", This);
107 return IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
110 static HRESULT WINAPI IDirect3DVolume8Impl_FreePrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid) {
111 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
112 TRACE("(%p) Relay\n", This);
113 return IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
116 static HRESULT WINAPI IDirect3DVolume8Impl_GetContainer(LPDIRECT3DVOLUME8 iface, REFIID riid, void **ppContainer) {
117 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
118 IWineD3DBase *wineD3DContainer = NULL;
119 IUnknown *wineD3DContainerParent = NULL;
122 TRACE("(This %p, riid %s, ppContainer %p)\n", This, debugstr_guid(riid), ppContainer);
125 ERR("Called without a valid ppContainer.\n");
128 /* Get the WineD3D container. */
129 res = IWineD3DVolume_GetContainer(This->wineD3DVolume, &IID_IWineD3DBase, (void **)&wineD3DContainer);
130 if (res != D3D_OK) return res;
132 if (!wineD3DContainer) {
133 ERR("IWineD3DSurface_GetContainer should never return NULL\n");
137 IWineD3DBase_GetParent(wineD3DContainer, &wineD3DContainerParent);
138 IUnknown_Release(wineD3DContainer);
140 if (!wineD3DContainerParent) {
141 ERR("IWineD3DBase_GetParent should never return NULL\n");
144 /* Now, query the interface of the parent for the riid */
145 res = IUnknown_QueryInterface(wineD3DContainerParent, riid, ppContainer);
146 IUnknown_Release(wineD3DContainerParent);
148 TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer);
153 static HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface, D3DVOLUME_DESC *pDesc) {
154 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
155 WINED3DVOLUME_DESC wined3ddesc;
157 TRACE("(%p) Relay\n", This);
159 /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
160 wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
161 wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
162 wined3ddesc.Usage = &pDesc->Usage;
163 wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
164 wined3ddesc.Size = &pDesc->Size;
165 wined3ddesc.Width = &pDesc->Width;
166 wined3ddesc.Height = &pDesc->Height;
167 wined3ddesc.Depth = &pDesc->Depth;
169 return IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
172 static HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags) {
173 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
174 TRACE("(%p) relay %p %p %p %d\n", This, This->wineD3DVolume, pLockedVolume, pBox, Flags);
175 return IWineD3DVolume_LockBox(This->wineD3DVolume, (WINED3DLOCKED_BOX *) pLockedVolume, (CONST WINED3DBOX *) pBox, Flags);
178 static HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface) {
179 IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
180 TRACE("(%p) relay %p\n", This, This->wineD3DVolume);
181 return IWineD3DVolume_UnlockBox(This->wineD3DVolume);
184 static const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl =
187 IDirect3DVolume8Impl_QueryInterface,
188 IDirect3DVolume8Impl_AddRef,
189 IDirect3DVolume8Impl_Release,
190 /* IDirect3DVolume8 */
191 IDirect3DVolume8Impl_GetDevice,
192 IDirect3DVolume8Impl_SetPrivateData,
193 IDirect3DVolume8Impl_GetPrivateData,
194 IDirect3DVolume8Impl_FreePrivateData,
195 IDirect3DVolume8Impl_GetContainer,
196 IDirect3DVolume8Impl_GetDesc,
197 IDirect3DVolume8Impl_LockBox,
198 IDirect3DVolume8Impl_UnlockBox
202 /* Internal function called back during the CreateVolumeTexture */
203 HRESULT WINAPI D3D8CB_CreateVolume(IUnknown *pDevice, UINT Width, UINT Height, UINT Depth,
204 WINED3DFORMAT Format, WINED3DPOOL Pool, DWORD Usage,
205 IWineD3DVolume **ppVolume,
206 HANDLE * pSharedHandle) {
207 IDirect3DVolume8Impl *object;
208 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)pDevice;
209 HRESULT hrc = D3D_OK;
211 /* Allocate the storage for the device */
212 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolume8Impl));
213 if (NULL == object) {
214 FIXME("Allocation of memory failed\n");
216 return D3DERR_OUTOFVIDEOMEMORY;
219 object->lpVtbl = &Direct3DVolume8_Vtbl;
221 hrc = IWineD3DDevice_CreateVolume(This->WineD3DDevice, Width, Height, Depth, Usage, Format,
222 Pool, &object->wineD3DVolume, pSharedHandle, (IUnknown *)object);
225 FIXME("(%p) call to IWineD3DDevice_CreateVolume failed\n", This);
226 HeapFree(GetProcessHeap(), 0, object);
229 *ppVolume = (IWineD3DVolume *)object->wineD3DVolume;
231 TRACE("(%p) Created volume %p\n", This, *ppVolume);