urlmon: Fix a LARGE_INTEGER truncation.
[wine/multimedia.git] / dlls / d3d9 / volume.c
blobd16b2ee4275bd48c1e92dff839b62fed09b1886c
1 /*
2 * IDirect3DVolume9 implementation
4 * Copyright 2002-2005 Jason Edmeades
5 * Raphael Junqueira
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "config.h"
23 #include "d3d9_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
27 /* IDirect3DVolume9 IUnknown parts follow: */
28 HRESULT WINAPI IDirect3DVolume9Impl_QueryInterface(LPDIRECT3DVOLUME9 iface, REFIID riid, LPVOID* ppobj) {
29 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
31 if (IsEqualGUID(riid, &IID_IUnknown)
32 || IsEqualGUID(riid, &IID_IDirect3DVolume9)) {
33 IUnknown_AddRef(iface);
34 *ppobj = This;
35 return D3D_OK;
38 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
39 return E_NOINTERFACE;
42 ULONG WINAPI IDirect3DVolume9Impl_AddRef(LPDIRECT3DVOLUME9 iface) {
43 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
44 ULONG ref = InterlockedIncrement(&This->ref);
46 TRACE("(%p) : AddRef from %ld\n", This, ref - 1);
48 return ref;
51 ULONG WINAPI IDirect3DVolume9Impl_Release(LPDIRECT3DVOLUME9 iface) {
52 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
53 ULONG ref = InterlockedDecrement(&This->ref);
55 TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
57 if (ref == 0) {
58 IWineD3DVolume_Release(This->wineD3DVolume);
59 HeapFree(GetProcessHeap(), 0, This);
61 return ref;
64 /* IDirect3DVolume9 Interface follow: */
65 HRESULT WINAPI IDirect3DVolume9Impl_GetDevice(LPDIRECT3DVOLUME9 iface, IDirect3DDevice9** ppDevice) {
66 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
67 IWineD3DDevice *myDevice = NULL;
69 IWineD3DVolume_GetDevice(This->wineD3DVolume, &myDevice);
70 IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
71 IWineD3DDevice_Release(myDevice);
72 return D3D_OK;
75 HRESULT WINAPI IDirect3DVolume9Impl_SetPrivateData(LPDIRECT3DVOLUME9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
76 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
77 TRACE("(%p) Relay\n", This);
78 return IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
81 HRESULT WINAPI IDirect3DVolume9Impl_GetPrivateData(LPDIRECT3DVOLUME9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
82 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
83 TRACE("(%p) Relay\n", This);
84 return IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
87 HRESULT WINAPI IDirect3DVolume9Impl_FreePrivateData(LPDIRECT3DVOLUME9 iface, REFGUID refguid) {
88 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
89 TRACE("(%p) Relay\n", This);
90 return IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
93 HRESULT WINAPI IDirect3DVolume9Impl_GetContainer(LPDIRECT3DVOLUME9 iface, REFIID riid, void** ppContainer) {
94 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
95 HRESULT res;
96 IUnknown *IWineContainer = NULL;
98 TRACE("(%p) Relay\n", This);
99 res = IWineD3DVolume_GetContainer(This->wineD3DVolume, riid, (void **)&IWineContainer);
101 /* If this works, the only valid container is a child of resource (volumetexture) */
102 if (res == D3D_OK && NULL != ppContainer) {
103 IWineD3DResource_GetParent((IWineD3DResource *)IWineContainer, (IUnknown **)ppContainer);
104 IWineD3DResource_Release((IWineD3DResource *)IWineContainer);
107 return res;
110 HRESULT WINAPI IDirect3DVolume9Impl_GetDesc(LPDIRECT3DVOLUME9 iface, D3DVOLUME_DESC* pDesc) {
111 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
112 WINED3DVOLUME_DESC wined3ddesc;
113 UINT tmpInt = -1;
115 TRACE("(%p) Relay\n", This);
117 /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
118 wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
119 wined3ddesc.Type = &pDesc->Type;
120 wined3ddesc.Usage = &pDesc->Usage;
121 wined3ddesc.Pool = &pDesc->Pool;
122 wined3ddesc.Size = &tmpInt;
123 wined3ddesc.Width = &pDesc->Width;
124 wined3ddesc.Height = &pDesc->Height;
125 wined3ddesc.Depth = &pDesc->Depth;
127 return IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
130 HRESULT WINAPI IDirect3DVolume9Impl_LockBox(LPDIRECT3DVOLUME9 iface, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
131 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
132 TRACE("(%p) relay %p %p %p %ld\n", This, This->wineD3DVolume, pLockedVolume, pBox, Flags);
133 return IWineD3DVolume_LockBox(This->wineD3DVolume, pLockedVolume, pBox, Flags);
136 HRESULT WINAPI IDirect3DVolume9Impl_UnlockBox(LPDIRECT3DVOLUME9 iface) {
137 IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
138 TRACE("(%p) relay %p\n", This, This->wineD3DVolume);
139 return IWineD3DVolume_UnlockBox(This->wineD3DVolume);
142 const IDirect3DVolume9Vtbl Direct3DVolume9_Vtbl =
144 /* IUnknown */
145 IDirect3DVolume9Impl_QueryInterface,
146 IDirect3DVolume9Impl_AddRef,
147 IDirect3DVolume9Impl_Release,
148 /* IDirect3DVolume9 */
149 IDirect3DVolume9Impl_GetDevice,
150 IDirect3DVolume9Impl_SetPrivateData,
151 IDirect3DVolume9Impl_GetPrivateData,
152 IDirect3DVolume9Impl_FreePrivateData,
153 IDirect3DVolume9Impl_GetContainer,
154 IDirect3DVolume9Impl_GetDesc,
155 IDirect3DVolume9Impl_LockBox,
156 IDirect3DVolume9Impl_UnlockBox
160 /* Internal function called back during the CreateVolumeTexture */
161 HRESULT WINAPI D3D9CB_CreateVolume(IUnknown *pDevice, UINT Width, UINT Height, UINT Depth,
162 WINED3DFORMAT Format, D3DPOOL Pool, DWORD Usage,
163 IWineD3DVolume **ppVolume,
164 HANDLE * pSharedHandle) {
165 IDirect3DVolume9Impl *object;
166 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)pDevice;
167 HRESULT hrc = D3D_OK;
169 /* Allocate the storage for the device */
170 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolume9Impl));
171 if (NULL == object) {
172 FIXME("Allocation of memory failed\n");
173 *ppVolume = NULL;
174 return D3DERR_OUTOFVIDEOMEMORY;
177 object->lpVtbl = &Direct3DVolume9_Vtbl;
178 object->ref = 1;
179 hrc = IWineD3DDevice_CreateVolume(This->WineD3DDevice, Width, Height, Depth, Usage, Format,
180 Pool, &object->wineD3DVolume, pSharedHandle, (IUnknown *)object);
181 if (hrc != D3D_OK) {
182 /* free up object */
183 FIXME("(%p) call to IWineD3DDevice_CreateVolume failed\n", This);
184 HeapFree(GetProcessHeap(), 0, object);
185 *ppVolume = NULL;
186 } else {
187 *ppVolume = (IWineD3DVolume *)object->wineD3DVolume;
189 TRACE("(%p) Created volume %p\n", This, *ppVolume);
190 return hrc;