~ [ 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     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 
 56         if (ref == 1)
 57         {
 58             wined3d_mutex_lock();
 59             IWineD3DVolume_AddRef(This->wineD3DVolume);
 60             wined3d_mutex_unlock();
 61         }
 62 
 63         return ref;
 64     }
 65 }
 66 
 67 static ULONG WINAPI IDirect3DVolume8Impl_Release(LPDIRECT3DVOLUME8 iface) {
 68     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
 69 
 70     TRACE("(%p)\n", This);
 71 
 72     if (This->forwardReference) {
 73         /* Forward to the containerParent */
 74         TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
 75         return IUnknown_Release(This->forwardReference);
 76     }
 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 /* IDirect3DVolume8 Interface follow: */
 93 static HRESULT WINAPI IDirect3DVolume8Impl_GetDevice(LPDIRECT3DVOLUME8 iface, IDirect3DDevice8 **ppDevice) {
 94     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
 95     IWineD3DDevice       *myDevice = NULL;
 96 
 97     wined3d_mutex_lock();
 98     IWineD3DVolume_GetDevice(This->wineD3DVolume, &myDevice);
 99     IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
100     IWineD3DDevice_Release(myDevice);
101     wined3d_mutex_unlock();
102 
103     return D3D_OK;
104 }
105 
106 static HRESULT WINAPI IDirect3DVolume8Impl_SetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
107     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
108     HRESULT hr;
109     TRACE("(%p) Relay\n", This);
110 
111     wined3d_mutex_lock();
112     hr = IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
113     wined3d_mutex_unlock();
114 
115     return hr;
116 }
117 
118 static HRESULT WINAPI IDirect3DVolume8Impl_GetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID  refguid, void *pData, DWORD* pSizeOfData) {
119     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
120     HRESULT hr;
121     TRACE("(%p) Relay\n", This);
122 
123     wined3d_mutex_lock();
124     hr = IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
125     wined3d_mutex_unlock();
126 
127     return hr;
128 }
129 
130 static HRESULT WINAPI IDirect3DVolume8Impl_FreePrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid) {
131     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
132     HRESULT hr;
133     TRACE("(%p) Relay\n", This);
134 
135     wined3d_mutex_lock();
136     hr = IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
137     wined3d_mutex_unlock();
138 
139     return hr;
140 }
141 
142 static HRESULT WINAPI IDirect3DVolume8Impl_GetContainer(LPDIRECT3DVOLUME8 iface, REFIID riid, void **ppContainer) {
143     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
144     HRESULT res;
145 
146     TRACE("(This %p, riid %s, ppContainer %p)\n", This, debugstr_guid(riid), ppContainer);
147 
148     if (!This->container) return E_NOINTERFACE;
149 
150     if (!ppContainer) {
151         ERR("Called without a valid ppContainer.\n");
152     }
153 
154     res = IUnknown_QueryInterface(This->container, riid, ppContainer);
155 
156     TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer);
157 
158     return res;
159 }
160 
161 static HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface, D3DVOLUME_DESC *pDesc) {
162     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
163     HRESULT hr;
164     WINED3DVOLUME_DESC     wined3ddesc;
165 
166     TRACE("(%p) Relay\n", This);
167 
168     wined3d_mutex_lock();
169     hr = IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
170     wined3d_mutex_unlock();
171 
172     if (SUCCEEDED(hr))
173     {
174         pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.Format);
175         pDesc->Type = wined3ddesc.Type;
176         pDesc->Usage = wined3ddesc.Usage;
177         pDesc->Pool = wined3ddesc.Pool;
178         pDesc->Size = wined3ddesc.Size;
179         pDesc->Width = wined3ddesc.Width;
180         pDesc->Height = wined3ddesc.Height;
181         pDesc->Depth = wined3ddesc.Depth;
182     }
183 
184     return hr;
185 }
186 
187 static HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags) {
188     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
189     HRESULT hr;
190     TRACE("(%p) relay %p %p %p %d\n", This, This->wineD3DVolume, pLockedVolume, pBox, Flags);
191 
192     wined3d_mutex_lock();
193     hr = IWineD3DVolume_LockBox(This->wineD3DVolume, (WINED3DLOCKED_BOX *) pLockedVolume, (CONST WINED3DBOX *) pBox, Flags);
194     wined3d_mutex_unlock();
195 
196     return hr;
197 }
198 
199 static HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface) {
200     IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
201     HRESULT hr;
202     TRACE("(%p) relay %p\n", This, This->wineD3DVolume);
203 
204     wined3d_mutex_lock();
205     hr = IWineD3DVolume_UnlockBox(This->wineD3DVolume);
206     wined3d_mutex_unlock();
207 
208     return hr;
209 }
210 
211 static const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl =
212 {
213     /* IUnknown */
214     IDirect3DVolume8Impl_QueryInterface,
215     IDirect3DVolume8Impl_AddRef,
216     IDirect3DVolume8Impl_Release,
217     /* IDirect3DVolume8 */
218     IDirect3DVolume8Impl_GetDevice,
219     IDirect3DVolume8Impl_SetPrivateData,
220     IDirect3DVolume8Impl_GetPrivateData,
221     IDirect3DVolume8Impl_FreePrivateData,
222     IDirect3DVolume8Impl_GetContainer,
223     IDirect3DVolume8Impl_GetDesc,
224     IDirect3DVolume8Impl_LockBox,
225     IDirect3DVolume8Impl_UnlockBox
226 };
227 
228 static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void *parent)
229 {
230     HeapFree(GetProcessHeap(), 0, parent);
231 }
232 
233 static const struct wined3d_parent_ops d3d8_volume_wined3d_parent_ops =
234 {
235     volume_wined3d_object_destroyed,
236 };
237 
238 HRESULT volume_init(IDirect3DVolume8Impl *volume, IDirect3DDevice8Impl *device, UINT width, UINT height,
239         UINT depth, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool)
240 {
241     HRESULT hr;
242 
243     volume->lpVtbl = &Direct3DVolume8_Vtbl;
244     volume->ref = 1;
245 
246     hr = IWineD3DDevice_CreateVolume(device->WineD3DDevice, width, height, depth, usage,
247             format, pool, &volume->wineD3DVolume, (IUnknown *)volume, &d3d8_volume_wined3d_parent_ops);
248     if (FAILED(hr))
249     {
250         WARN("Failed to create wined3d volume, hr %#x.\n", hr);
251         return hr;
252     }
253 
254     return D3D_OK;
255 }
256 

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