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

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

Version: ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  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     if (IsEqualGUID(riid, &IID_IUnknown)
 31         || IsEqualGUID(riid, &IID_IDirect3DVolume8)) {
 32         IUnknown_AddRef(iface);
 33         *ppobj = This;
 34         return S_OK;
 35     }
 36 
 37     WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
 38     *ppobj = NULL;
 39     return E_NOINTERFACE;
 40 }
 41 
 42 static ULONG WINAPI IDirect3DVolume8Impl_AddRef(LPDIRECT3DVOLUME8 iface) {
 43     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
 44 
 45     TRACE("(%p)\n", This);
 46 
 47     if (This->forwardReference) {
 48         /* Forward to the containerParent */
 49         TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
 50         return IUnknown_AddRef(This->forwardReference);
 51     } else {
 52         /* No container, handle our own refcounting */
 53         ULONG ref = InterlockedIncrement(&This->ref);
 54         TRACE("(%p) : AddRef from %d\n", This, ref - 1);
 55         return ref;
 56     }
 57 }
 58 
 59 static ULONG WINAPI IDirect3DVolume8Impl_Release(LPDIRECT3DVOLUME8 iface) {
 60     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
 61 
 62     TRACE("(%p)\n", This);
 63 
 64     if (This->forwardReference) {
 65         /* Forward to the containerParent */
 66         TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
 67         return IUnknown_Release(This->forwardReference);
 68     }
 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(&d3d8_cs);
 76             IWineD3DVolume_Release(This->wineD3DVolume);
 77             LeaveCriticalSection(&d3d8_cs);
 78             HeapFree(GetProcessHeap(), 0, This);
 79         }
 80 
 81         return ref;
 82     }
 83 }
 84 
 85 /* IDirect3DVolume8 Interface follow: */
 86 static HRESULT WINAPI IDirect3DVolume8Impl_GetDevice(LPDIRECT3DVOLUME8 iface, IDirect3DDevice8 **ppDevice) {
 87     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
 88     IWineD3DDevice       *myDevice = NULL;
 89 
 90     EnterCriticalSection(&d3d8_cs);
 91     IWineD3DVolume_GetDevice(This->wineD3DVolume, &myDevice);
 92     IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
 93     IWineD3DDevice_Release(myDevice);
 94     LeaveCriticalSection(&d3d8_cs);
 95     return D3D_OK;
 96 }
 97 
 98 static HRESULT WINAPI IDirect3DVolume8Impl_SetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
 99     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
100     HRESULT hr;
101     TRACE("(%p) Relay\n", This);
102 
103     EnterCriticalSection(&d3d8_cs);
104     hr = IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
105     LeaveCriticalSection(&d3d8_cs);
106     return hr;
107 }
108 
109 static HRESULT WINAPI IDirect3DVolume8Impl_GetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID  refguid, void *pData, DWORD* pSizeOfData) {
110     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
111     HRESULT hr;
112     TRACE("(%p) Relay\n", This);
113 
114     EnterCriticalSection(&d3d8_cs);
115     hr = IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
116     LeaveCriticalSection(&d3d8_cs);
117     return hr;
118 }
119 
120 static HRESULT WINAPI IDirect3DVolume8Impl_FreePrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid) {
121     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
122     HRESULT hr;
123     TRACE("(%p) Relay\n", This);
124 
125     EnterCriticalSection(&d3d8_cs);
126     hr = IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
127     LeaveCriticalSection(&d3d8_cs);
128     return hr;
129 }
130 
131 static HRESULT WINAPI IDirect3DVolume8Impl_GetContainer(LPDIRECT3DVOLUME8 iface, REFIID riid, void **ppContainer) {
132     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
133     HRESULT res;
134 
135     TRACE("(This %p, riid %s, ppContainer %p)\n", This, debugstr_guid(riid), ppContainer);
136 
137     if (!This->container) return E_NOINTERFACE;
138 
139     if (!ppContainer) {
140         ERR("Called without a valid ppContainer.\n");
141     }
142 
143     res = IUnknown_QueryInterface(This->container, riid, ppContainer);
144 
145     TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer);
146 
147     return res;
148 }
149 
150 static HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface, D3DVOLUME_DESC *pDesc) {
151     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
152     HRESULT hr;
153     WINED3DVOLUME_DESC     wined3ddesc;
154 
155     TRACE("(%p) Relay\n", This);
156 
157     /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
158     wined3ddesc.Format              = (WINED3DFORMAT *)&pDesc->Format;
159     wined3ddesc.Type                = (WINED3DRESOURCETYPE *)&pDesc->Type;
160     wined3ddesc.Usage               = &pDesc->Usage;
161     wined3ddesc.Pool                = (WINED3DPOOL *) &pDesc->Pool;
162     wined3ddesc.Size                = &pDesc->Size;
163     wined3ddesc.Width               = &pDesc->Width;
164     wined3ddesc.Height              = &pDesc->Height;
165     wined3ddesc.Depth               = &pDesc->Depth;
166 
167     EnterCriticalSection(&d3d8_cs);
168     hr = IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
169     LeaveCriticalSection(&d3d8_cs);
170     return hr;
171 }
172 
173 static HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags) {
174     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
175     HRESULT hr;
176     TRACE("(%p) relay %p %p %p %d\n", This, This->wineD3DVolume, pLockedVolume, pBox, Flags);
177 
178     EnterCriticalSection(&d3d8_cs);
179     hr = IWineD3DVolume_LockBox(This->wineD3DVolume, (WINED3DLOCKED_BOX *) pLockedVolume, (CONST WINED3DBOX *) pBox, Flags);
180     LeaveCriticalSection(&d3d8_cs);
181     return hr;
182 }
183 
184 static HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface) {
185     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
186     HRESULT hr;
187     TRACE("(%p) relay %p\n", This, This->wineD3DVolume);
188 
189     EnterCriticalSection(&d3d8_cs);
190     hr = IWineD3DVolume_UnlockBox(This->wineD3DVolume);
191     LeaveCriticalSection(&d3d8_cs);
192     return hr;
193 }
194 
195 static const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl =
196 {
197     /* IUnknown */
198     IDirect3DVolume8Impl_QueryInterface,
199     IDirect3DVolume8Impl_AddRef,
200     IDirect3DVolume8Impl_Release,
201     /* IDirect3DVolume8 */
202     IDirect3DVolume8Impl_GetDevice,
203     IDirect3DVolume8Impl_SetPrivateData,
204     IDirect3DVolume8Impl_GetPrivateData,
205     IDirect3DVolume8Impl_FreePrivateData,
206     IDirect3DVolume8Impl_GetContainer,
207     IDirect3DVolume8Impl_GetDesc,
208     IDirect3DVolume8Impl_LockBox,
209     IDirect3DVolume8Impl_UnlockBox
210 };
211 
212 
213 /* Internal function called back during the CreateVolumeTexture */
214 HRESULT WINAPI D3D8CB_CreateVolume(IUnknown  *pDevice, IUnknown *pSuperior, UINT Width, UINT Height, UINT Depth,
215                                    WINED3DFORMAT  Format, WINED3DPOOL Pool, DWORD Usage,
216                                    IWineD3DVolume **ppVolume,
217                                    HANDLE   * pSharedHandle) {
218     IDirect3DVolume8Impl *object;
219     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)pDevice;
220     HRESULT hrc = D3D_OK;
221 
222     /* Allocate the storage for the device */
223     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolume8Impl));
224     if (NULL == object) {
225         FIXME("Allocation of memory failed\n");
226         *ppVolume = NULL;
227         return D3DERR_OUTOFVIDEOMEMORY;
228     }
229 
230     object->lpVtbl = &Direct3DVolume8_Vtbl;
231     object->ref = 1;
232     hrc = IWineD3DDevice_CreateVolume(This->WineD3DDevice, Width, Height, Depth, Usage, Format, 
233                                        Pool, &object->wineD3DVolume, pSharedHandle, (IUnknown *)object);
234     if (hrc != D3D_OK) {
235         /* free up object */ 
236         FIXME("(%p) call to IWineD3DDevice_CreateVolume failed\n", This);
237         HeapFree(GetProcessHeap(), 0, object);
238         *ppVolume = NULL;
239     } else {
240         *ppVolume = object->wineD3DVolume;
241         object->container = pSuperior;
242         object->forwardReference = pSuperior;
243     }
244     TRACE("(%p) Created volume %p\n", This, *ppVolume);
245     return hrc;
246 }
247 
248 ULONG WINAPI D3D8CB_DestroyVolume(IWineD3DVolume *pVolume) {
249     IDirect3DVolume8Impl* volumeParent;
250 
251     IWineD3DVolume_GetParent(pVolume, (IUnknown **) &volumeParent);
252     /* GetParent's AddRef was forwarded to an object in destruction.
253      * Releasing it here again would cause an endless recursion. */
254     volumeParent->forwardReference = NULL;
255     return IDirect3DVolume8_Release((IDirect3DVolume8*) volumeParent);
256 }
257 

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