~ [ 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         return ref;
 57     }
 58 }
 59 
 60 static ULONG WINAPI IDirect3DVolume9Impl_Release(LPDIRECT3DVOLUME9 iface) {
 61     IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
 62 
 63     TRACE("(%p)\n", This);
 64 
 65     if (This->forwardReference) {
 66         /* Forward refcounting */
 67         TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
 68         return IUnknown_Release(This->forwardReference);
 69     } else {
 70         /* No container, handle our own refcounting */
 71         ULONG ref = InterlockedDecrement(&This->ref);
 72         TRACE("(%p) : ReleaseRef to %d\n", This, ref);
 73 
 74         if (ref == 0) {
 75             EnterCriticalSection(&d3d9_cs);
 76             IWineD3DVolume_Release(This->wineD3DVolume);
 77             LeaveCriticalSection(&d3d9_cs);
 78             HeapFree(GetProcessHeap(), 0, This);
 79         }
 80 
 81         return ref;
 82     }
 83 }
 84 
 85 /* IDirect3DVolume9 Interface follow: */
 86 static HRESULT WINAPI IDirect3DVolume9Impl_GetDevice(LPDIRECT3DVOLUME9 iface, IDirect3DDevice9** ppDevice) {
 87     IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
 88     IWineD3DDevice       *myDevice = NULL;
 89 
 90     TRACE("iface %p, ppDevice %p\n", iface, ppDevice);
 91 
 92     EnterCriticalSection(&d3d9_cs);
 93 
 94     IWineD3DVolume_GetDevice(This->wineD3DVolume, &myDevice);
 95     IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
 96     IWineD3DDevice_Release(myDevice);
 97 
 98     LeaveCriticalSection(&d3d9_cs);
 99 
100     return D3D_OK;
101 }
102 
103 static HRESULT WINAPI IDirect3DVolume9Impl_SetPrivateData(LPDIRECT3DVOLUME9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
104     IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
105     HRESULT hr;
106 
107     TRACE("(%p) Relay\n", This);
108 
109     EnterCriticalSection(&d3d9_cs);
110 
111     hr = IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
112 
113     LeaveCriticalSection(&d3d9_cs);
114 
115     return hr;
116 }
117 
118 static HRESULT WINAPI IDirect3DVolume9Impl_GetPrivateData(LPDIRECT3DVOLUME9 iface, REFGUID  refguid, void* pData, DWORD* pSizeOfData) {
119     IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
120     HRESULT hr;
121 
122     TRACE("(%p) Relay\n", This);
123 
124     EnterCriticalSection(&d3d9_cs);
125 
126     hr = IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
127 
128     LeaveCriticalSection(&d3d9_cs);
129 
130     return hr;
131 }
132 
133 static HRESULT WINAPI IDirect3DVolume9Impl_FreePrivateData(LPDIRECT3DVOLUME9 iface, REFGUID refguid) {
134     IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
135     HRESULT hr;
136 
137     TRACE("(%p) Relay\n", This);
138 
139     EnterCriticalSection(&d3d9_cs);
140 
141     hr = IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
142 
143     LeaveCriticalSection(&d3d9_cs);
144 
145     return hr;
146 }
147 
148 static HRESULT WINAPI IDirect3DVolume9Impl_GetContainer(LPDIRECT3DVOLUME9 iface, REFIID riid, void** ppContainer) {
149     IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
150     HRESULT res;
151 
152     TRACE("(This %p, riid %s, ppContainer %p)\n", This, debugstr_guid(riid), ppContainer);
153 
154     if (!This->container) return E_NOINTERFACE;
155 
156     if (!ppContainer) {
157         ERR("Called without a valid ppContainer.\n");
158     }
159 
160     res = IUnknown_QueryInterface(This->container, riid, ppContainer);
161 
162     TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer);
163 
164     return res;
165 }
166 
167 static HRESULT WINAPI IDirect3DVolume9Impl_GetDesc(LPDIRECT3DVOLUME9 iface, D3DVOLUME_DESC* pDesc) {
168     IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
169     WINED3DVOLUME_DESC     wined3ddesc;
170     UINT                   tmpInt = -1;
171     WINED3DFORMAT format;
172     HRESULT hr;
173 
174     TRACE("(%p) Relay\n", This);
175 
176     /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
177     wined3ddesc.Format              = &format;
178     wined3ddesc.Type                = (WINED3DRESOURCETYPE *)&pDesc->Type;
179     wined3ddesc.Usage               = &pDesc->Usage;
180     wined3ddesc.Pool                = (WINED3DPOOL *) &pDesc->Pool;
181     wined3ddesc.Size                = &tmpInt;
182     wined3ddesc.Width               = &pDesc->Width;
183     wined3ddesc.Height              = &pDesc->Height;
184     wined3ddesc.Depth               = &pDesc->Depth;
185 
186     EnterCriticalSection(&d3d9_cs);
187 
188     hr = IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
189 
190     LeaveCriticalSection(&d3d9_cs);
191 
192     if (SUCCEEDED(hr)) pDesc->Format = d3dformat_from_wined3dformat(format);
193 
194     return hr;
195 }
196 
197 static HRESULT WINAPI IDirect3DVolume9Impl_LockBox(LPDIRECT3DVOLUME9 iface, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
198     IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
199     HRESULT hr;
200 
201     TRACE("(%p) relay %p %p %p %d\n", This, This->wineD3DVolume, pLockedVolume, pBox, Flags);
202 
203     EnterCriticalSection(&d3d9_cs);
204 
205     hr = IWineD3DVolume_LockBox(This->wineD3DVolume, (WINED3DLOCKED_BOX *)pLockedVolume,
206             (const WINED3DBOX *)pBox, Flags);
207 
208     LeaveCriticalSection(&d3d9_cs);
209 
210     return hr;
211 }
212 
213 static HRESULT WINAPI IDirect3DVolume9Impl_UnlockBox(LPDIRECT3DVOLUME9 iface) {
214     IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
215     HRESULT hr;
216 
217     TRACE("(%p) relay %p\n", This, This->wineD3DVolume);
218 
219     EnterCriticalSection(&d3d9_cs);
220 
221     hr = IWineD3DVolume_UnlockBox(This->wineD3DVolume);
222 
223     LeaveCriticalSection(&d3d9_cs);
224 
225     return hr;
226 }
227 
228 const IDirect3DVolume9Vtbl Direct3DVolume9_Vtbl =
229 {
230     /* IUnknown */
231     IDirect3DVolume9Impl_QueryInterface,
232     IDirect3DVolume9Impl_AddRef,
233     IDirect3DVolume9Impl_Release,
234     /* IDirect3DVolume9 */
235     IDirect3DVolume9Impl_GetDevice,
236     IDirect3DVolume9Impl_SetPrivateData,
237     IDirect3DVolume9Impl_GetPrivateData,
238     IDirect3DVolume9Impl_FreePrivateData,
239     IDirect3DVolume9Impl_GetContainer,
240     IDirect3DVolume9Impl_GetDesc,
241     IDirect3DVolume9Impl_LockBox,
242     IDirect3DVolume9Impl_UnlockBox
243 };
244 
245 ULONG WINAPI D3D9CB_DestroyVolume(IWineD3DVolume *pVolume) {
246     IDirect3DVolume9Impl* volumeParent;
247 
248     IWineD3DVolume_GetParent(pVolume, (IUnknown **) &volumeParent);
249     /* GetParent's AddRef was forwarded to an object in destruction.
250      * Releasing it here again would cause an endless recursion. */
251     volumeParent->forwardReference = NULL;
252     return IDirect3DVolume9_Release((IDirect3DVolume9*) volumeParent);
253 }
254 

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