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

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

~ [ 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.