~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/d3d8/volume.c

Version: ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * IDirect3DVolume8 implementation
  3  *
  4  * Copyright 2005 Oliver Stieber
  5  *
  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.
 10  *
 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.
 15  *
 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
 19  */
 20 
 21 #include "config.h"
 22 #include "d3d8_private.h"
 23 
 24 WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
 25 
 26 /* IDirect3DVolume8 IUnknown parts follow: */
 27 static HRESULT WINAPI IDirect3DVolume8Impl_QueryInterface(LPDIRECT3DVOLUME8 iface, REFIID riid, LPVOID *ppobj) {
 28     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
 29 
 30     TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
 31 
 32     if (IsEqualGUID(riid, &IID_IUnknown)
 33         || IsEqualGUID(riid, &IID_IDirect3DVolume8)) {
 34         IUnknown_AddRef(iface);
 35         *ppobj = This;
 36         return S_OK;
 37     }
 38 
 39     WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
 40     *ppobj = NULL;
 41     return E_NOINTERFACE;
 42 }
 43 
 44 static ULONG WINAPI IDirect3DVolume8Impl_AddRef(LPDIRECT3DVOLUME8 iface) {
 45     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
 46 
 47     TRACE("iface %p.\n", iface);
 48 
 49     if (This->forwardReference) {
 50         /* Forward to the containerParent */
 51         TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
 52         return IUnknown_AddRef(This->forwardReference);
 53     } else {
 54         /* No container, handle our own refcounting */
 55         ULONG ref = InterlockedIncrement(&This->ref);
 56 
 57         TRACE("%p increasing refcount to %u.\n", iface, ref);
 58 
 59         if (ref == 1)
 60         {
 61             wined3d_mutex_lock();
 62             IWineD3DVolume_AddRef(This->wineD3DVolume);
 63             wined3d_mutex_unlock();
 64         }
 65 
 66         return ref;
 67     }
 68 }
 69 
 70 static ULONG WINAPI IDirect3DVolume8Impl_Release(LPDIRECT3DVOLUME8 iface) {
 71     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
 72 
 73     TRACE("iface %p.\n", iface);
 74 
 75     if (This->forwardReference) {
 76         /* Forward to the containerParent */
 77         TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
 78         return IUnknown_Release(This->forwardReference);
 79     }
 80     else {
 81         /* No container, handle our own refcounting */
 82         ULONG ref = InterlockedDecrement(&This->ref);
 83 
 84         TRACE("%p decreasing refcount to %u.\n", iface, ref);
 85 
 86         if (ref == 0) {
 87             wined3d_mutex_lock();
 88             IWineD3DVolume_Release(This->wineD3DVolume);
 89             wined3d_mutex_unlock();
 90         }
 91 
 92         return ref;
 93     }
 94 }
 95 
 96 /* IDirect3DVolume8 Interface follow: */
 97 static HRESULT WINAPI IDirect3DVolume8Impl_GetDevice(LPDIRECT3DVOLUME8 iface, IDirect3DDevice8 **ppDevice) {
 98     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
 99     IWineD3DDevice       *myDevice = NULL;
100 
101     TRACE("iface %p, device %p.\n", iface, ppDevice);
102 
103     wined3d_mutex_lock();
104     IWineD3DVolume_GetDevice(This->wineD3DVolume, &myDevice);
105     IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
106     IWineD3DDevice_Release(myDevice);
107     wined3d_mutex_unlock();
108 
109     return D3D_OK;
110 }
111 
112 static HRESULT WINAPI IDirect3DVolume8Impl_SetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
113     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
114     HRESULT hr;
115 
116     TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
117             iface, debugstr_guid(refguid), pData, SizeOfData, Flags);
118 
119     wined3d_mutex_lock();
120     hr = IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
121     wined3d_mutex_unlock();
122 
123     return hr;
124 }
125 
126 static HRESULT WINAPI IDirect3DVolume8Impl_GetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID  refguid, void *pData, DWORD* pSizeOfData) {
127     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
128     HRESULT hr;
129 
130     TRACE("iface %p, guid %s, data %p, data_size %p.\n",
131             iface, debugstr_guid(refguid), pData, pSizeOfData);
132 
133     wined3d_mutex_lock();
134     hr = IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
135     wined3d_mutex_unlock();
136 
137     return hr;
138 }
139 
140 static HRESULT WINAPI IDirect3DVolume8Impl_FreePrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid) {
141     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
142     HRESULT hr;
143 
144     TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
145 
146     wined3d_mutex_lock();
147     hr = IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
148     wined3d_mutex_unlock();
149 
150     return hr;
151 }
152 
153 static HRESULT WINAPI IDirect3DVolume8Impl_GetContainer(LPDIRECT3DVOLUME8 iface, REFIID riid, void **ppContainer) {
154     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
155     HRESULT res;
156 
157     TRACE("iface %p, riid %s, container %p.\n",
158             iface, debugstr_guid(riid), ppContainer);
159 
160     if (!This->container) return E_NOINTERFACE;
161 
162     if (!ppContainer) {
163         ERR("Called without a valid ppContainer.\n");
164     }
165 
166     res = IUnknown_QueryInterface(This->container, riid, ppContainer);
167 
168     TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer);
169 
170     return res;
171 }
172 
173 static HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface, D3DVOLUME_DESC *pDesc) {
174     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
175     HRESULT hr;
176     WINED3DVOLUME_DESC     wined3ddesc;
177 
178     TRACE("iface %p, desc %p.\n", iface, pDesc);
179 
180     wined3d_mutex_lock();
181     hr = IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
182     wined3d_mutex_unlock();
183 
184     if (SUCCEEDED(hr))
185     {
186         pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.Format);
187         pDesc->Type = wined3ddesc.Type;
188         pDesc->Usage = wined3ddesc.Usage;
189         pDesc->Pool = wined3ddesc.Pool;
190         pDesc->Size = wined3ddesc.Size;
191         pDesc->Width = wined3ddesc.Width;
192         pDesc->Height = wined3ddesc.Height;
193         pDesc->Depth = wined3ddesc.Depth;
194     }
195 
196     return hr;
197 }
198 
199 static HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags) {
200     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
201     HRESULT hr;
202 
203     TRACE("iface %p, locked_box %p, box %p, flags %#x.\n",
204             iface, pLockedVolume, pBox, Flags);
205 
206     wined3d_mutex_lock();
207     hr = IWineD3DVolume_LockBox(This->wineD3DVolume, (WINED3DLOCKED_BOX *) pLockedVolume, (CONST WINED3DBOX *) pBox, Flags);
208     wined3d_mutex_unlock();
209 
210     return hr;
211 }
212 
213 static HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface) {
214     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
215     HRESULT hr;
216 
217     TRACE("iface %p.\n", iface);
218 
219     wined3d_mutex_lock();
220     hr = IWineD3DVolume_UnlockBox(This->wineD3DVolume);
221     wined3d_mutex_unlock();
222 
223     return hr;
224 }
225 
226 static const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl =
227 {
228     /* IUnknown */
229     IDirect3DVolume8Impl_QueryInterface,
230     IDirect3DVolume8Impl_AddRef,
231     IDirect3DVolume8Impl_Release,
232     /* IDirect3DVolume8 */
233     IDirect3DVolume8Impl_GetDevice,
234     IDirect3DVolume8Impl_SetPrivateData,
235     IDirect3DVolume8Impl_GetPrivateData,
236     IDirect3DVolume8Impl_FreePrivateData,
237     IDirect3DVolume8Impl_GetContainer,
238     IDirect3DVolume8Impl_GetDesc,
239     IDirect3DVolume8Impl_LockBox,
240     IDirect3DVolume8Impl_UnlockBox
241 };
242 
243 static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void *parent)
244 {
245     HeapFree(GetProcessHeap(), 0, parent);
246 }
247 
248 static const struct wined3d_parent_ops d3d8_volume_wined3d_parent_ops =
249 {
250     volume_wined3d_object_destroyed,
251 };
252 
253 HRESULT volume_init(IDirect3DVolume8Impl *volume, IDirect3DDevice8Impl *device, UINT width, UINT height,
254         UINT depth, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool)
255 {
256     HRESULT hr;
257 
258     volume->lpVtbl = &Direct3DVolume8_Vtbl;
259     volume->ref = 1;
260 
261     hr = IWineD3DDevice_CreateVolume(device->WineD3DDevice, width, height, depth, usage,
262             format, pool, &volume->wineD3DVolume, (IUnknown *)volume, &d3d8_volume_wined3d_parent_ops);
263     if (FAILED(hr))
264     {
265         WARN("Failed to create wined3d volume, hr %#x.\n", hr);
266         return hr;
267     }
268 
269     return D3D_OK;
270 }
271 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.