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

Wine Cross Reference
wine/dlls/d3d8/cubetexture.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  * IDirect3DCubeTexture8 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 /* IDirect3DCubeTexture8 IUnknown parts follow: */
 27 static HRESULT WINAPI IDirect3DCubeTexture8Impl_QueryInterface(LPDIRECT3DCUBETEXTURE8 iface, REFIID riid, LPVOID *ppobj) {
 28     IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)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_IDirect3DResource8)
 34         || IsEqualGUID(riid, &IID_IDirect3DBaseTexture8)
 35         || IsEqualGUID(riid, &IID_IDirect3DCubeTexture8)) {
 36         IUnknown_AddRef(iface);
 37         *ppobj = This;
 38         return S_OK;
 39     }
 40 
 41     WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
 42     *ppobj = NULL;
 43     return E_NOINTERFACE;
 44 }
 45 
 46 static ULONG WINAPI IDirect3DCubeTexture8Impl_AddRef(LPDIRECT3DCUBETEXTURE8 iface) {
 47     IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
 48     ULONG ref = InterlockedIncrement(&This->ref);
 49 
 50     TRACE("%p increasing refcount to %u.\n", iface, ref);
 51 
 52     if (ref == 1)
 53     {
 54         IUnknown_AddRef(This->parentDevice);
 55         wined3d_mutex_lock();
 56         IWineD3DCubeTexture_AddRef(This->wineD3DCubeTexture);
 57         wined3d_mutex_unlock();
 58     }
 59 
 60     return ref;
 61 }
 62 
 63 static ULONG WINAPI IDirect3DCubeTexture8Impl_Release(LPDIRECT3DCUBETEXTURE8 iface) {
 64     IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
 65     ULONG ref = InterlockedDecrement(&This->ref);
 66 
 67     TRACE("%p decreasing refcount to %u.\n", iface, ref);
 68 
 69     if (ref == 0) {
 70         IDirect3DDevice8 *parentDevice = This->parentDevice;
 71 
 72         TRACE("Releasing child %p\n", This->wineD3DCubeTexture);
 73 
 74         wined3d_mutex_lock();
 75         IWineD3DCubeTexture_Release(This->wineD3DCubeTexture);
 76         wined3d_mutex_unlock();
 77 
 78         /* Release the device last, as it may cause the device to be destroyed. */
 79         IDirect3DDevice8_Release(parentDevice);
 80     }
 81     return ref;
 82 }
 83 
 84 /* IDirect3DCubeTexture8 IDirect3DResource8 Interface follow: */
 85 static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetDevice(LPDIRECT3DCUBETEXTURE8 iface, IDirect3DDevice8 **ppDevice) {
 86     IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
 87     IWineD3DDevice *wined3d_device;
 88     HRESULT hr;
 89 
 90     TRACE("iface %p, device %p.\n", iface, ppDevice);
 91 
 92     wined3d_mutex_lock();
 93     hr = IWineD3DCubeTexture_GetDevice(This->wineD3DCubeTexture, &wined3d_device);
 94     if (SUCCEEDED(hr))
 95     {
 96         IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
 97         IWineD3DDevice_Release(wined3d_device);
 98     }
 99     wined3d_mutex_unlock();
100 
101     return hr;
102 }
103 
104 static HRESULT WINAPI IDirect3DCubeTexture8Impl_SetPrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
105     IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
106     HRESULT hr;
107 
108     TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
109             iface, debugstr_guid(refguid), pData, SizeOfData, Flags);
110 
111     wined3d_mutex_lock();
112     hr = IWineD3DCubeTexture_SetPrivateData(This->wineD3DCubeTexture,refguid,pData,SizeOfData,Flags);
113     wined3d_mutex_unlock();
114 
115     return hr;
116 }
117 
118 static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetPrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
119     IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
120     HRESULT hr;
121 
122     TRACE("iface %p, guid %s, data %p, data_size %p.\n",
123             iface, debugstr_guid(refguid), pData, pSizeOfData);
124 
125     wined3d_mutex_lock();
126     hr = IWineD3DCubeTexture_GetPrivateData(This->wineD3DCubeTexture,refguid,pData,pSizeOfData);
127     wined3d_mutex_unlock();
128 
129     return hr;
130 }
131 
132 static HRESULT WINAPI IDirect3DCubeTexture8Impl_FreePrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid) {
133     IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
134     HRESULT hr;
135 
136     TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
137 
138     wined3d_mutex_lock();
139     hr = IWineD3DCubeTexture_FreePrivateData(This->wineD3DCubeTexture,refguid);
140     wined3d_mutex_unlock();
141 
142     return hr;
143 }
144 
145 static DWORD WINAPI IDirect3DCubeTexture8Impl_SetPriority(LPDIRECT3DCUBETEXTURE8 iface, DWORD PriorityNew) {
146     IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
147     DWORD ret;
148 
149     TRACE("iface %p, priority %u.\n", iface, PriorityNew);
150 
151     wined3d_mutex_lock();
152     ret = IWineD3DCubeTexture_SetPriority(This->wineD3DCubeTexture, PriorityNew);
153     wined3d_mutex_unlock();
154 
155     return ret;
156 }
157 
158 static DWORD WINAPI IDirect3DCubeTexture8Impl_GetPriority(LPDIRECT3DCUBETEXTURE8 iface) {
159     IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
160     DWORD ret;
161 
162     TRACE("iface %p.\n", iface);
163 
164     wined3d_mutex_lock();
165     ret =  IWineD3DCubeTexture_GetPriority(This->wineD3DCubeTexture);
166     wined3d_mutex_unlock();
167 
168     return ret;
169 }
170 
171 static void WINAPI IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8 iface) {
172     IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
173 
174     TRACE("iface %p.\n", iface);
175 
176     wined3d_mutex_lock();
177     IWineD3DCubeTexture_PreLoad(This->wineD3DCubeTexture);
178     wined3d_mutex_unlock();
179 }
180 
181 static D3DRESOURCETYPE WINAPI IDirect3DCubeTexture8Impl_GetType(LPDIRECT3DCUBETEXTURE8 iface) {
182     IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
183     D3DRESOURCETYPE type;
184 
185     TRACE("iface %p.\n", iface);
186 
187     wined3d_mutex_lock();
188     type = IWineD3DCubeTexture_GetType(This->wineD3DCubeTexture);
189     wined3d_mutex_unlock();
190 
191     return type;
192 }
193 
194 /* IDirect3DCubeTexture8 IDirect3DBaseTexture8 Interface follow: */
195 static DWORD WINAPI IDirect3DCubeTexture8Impl_SetLOD(LPDIRECT3DCUBETEXTURE8 iface, DWORD LODNew) {
196     IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
197     DWORD lod;
198 
199     TRACE("iface %p, lod %u.\n", iface, LODNew);
200 
201     wined3d_mutex_lock();
202     lod = IWineD3DCubeTexture_SetLOD(This->wineD3DCubeTexture, LODNew);
203     wined3d_mutex_unlock();
204 
205     return lod;
206 }
207 
208 static DWORD WINAPI IDirect3DCubeTexture8Impl_GetLOD(LPDIRECT3DCUBETEXTURE8 iface) {
209     IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
210     DWORD lod;
211 
212     TRACE("iface %p.\n", iface);
213 
214     wined3d_mutex_lock();
215     lod = IWineD3DCubeTexture_GetLOD((LPDIRECT3DBASETEXTURE8) This);
216     wined3d_mutex_unlock();
217 
218     return lod;
219 }
220 
221 static DWORD WINAPI IDirect3DCubeTexture8Impl_GetLevelCount(LPDIRECT3DCUBETEXTURE8 iface) {
222     IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
223     DWORD cnt;
224 
225     TRACE("iface %p.\n", iface);
226 
227     wined3d_mutex_lock();
228     cnt = IWineD3DCubeTexture_GetLevelCount(This->wineD3DCubeTexture);
229     wined3d_mutex_unlock();
230 
231     return cnt;
232 }
233 
234 /* IDirect3DCubeTexture8 Interface follow: */
235 static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetLevelDesc(LPDIRECT3DCUBETEXTURE8 iface, UINT Level, D3DSURFACE_DESC *pDesc) {
236     IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
237     HRESULT hr;
238     WINED3DSURFACE_DESC    wined3ddesc;
239 
240     TRACE("iface %p, level %u, desc %p.\n", iface, Level, pDesc);
241 
242     wined3d_mutex_lock();
243     hr = IWineD3DCubeTexture_GetLevelDesc(This->wineD3DCubeTexture, Level, &wined3ddesc);
244     wined3d_mutex_unlock();
245 
246     if (SUCCEEDED(hr))
247     {
248         pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.format);
249         pDesc->Type = wined3ddesc.resource_type;
250         pDesc->Usage = wined3ddesc.usage;
251         pDesc->Pool = wined3ddesc.pool;
252         pDesc->Size = wined3ddesc.size;
253         pDesc->MultiSampleType = wined3ddesc.multisample_type;
254         pDesc->Width = wined3ddesc.width;
255         pDesc->Height = wined3ddesc.height;
256     }
257 
258     return hr;
259 }
260 
261 static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetCubeMapSurface(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface8 **ppCubeMapSurface) {
262     IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
263     HRESULT hrc = D3D_OK;
264     IWineD3DSurface *mySurface = NULL;
265 
266     TRACE("iface %p, face %#x, level %u, surface %p.\n", iface, FaceType, Level, ppCubeMapSurface);
267 
268     wined3d_mutex_lock();
269     hrc = IWineD3DCubeTexture_GetCubeMapSurface(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, &mySurface);
270     if (hrc == D3D_OK && NULL != ppCubeMapSurface) {
271        IWineD3DCubeTexture_GetParent(mySurface, (IUnknown **)ppCubeMapSurface);
272        IWineD3DCubeTexture_Release(mySurface);
273     }
274     wined3d_mutex_unlock();
275 
276     return hrc;
277 }
278 
279 static HRESULT WINAPI IDirect3DCubeTexture8Impl_LockRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT *pRect, DWORD Flags) {
280     IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
281     HRESULT hr;
282 
283     TRACE("iface %p, face %#x, level %u, locked_rect %p, rect %p, flags %#x.\n",
284             iface, FaceType, Level, pLockedRect, pRect, Flags);
285 
286     wined3d_mutex_lock();
287     hr = IWineD3DCubeTexture_LockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
288     wined3d_mutex_unlock();
289 
290     return hr;
291 }
292 
293 static HRESULT WINAPI IDirect3DCubeTexture8Impl_UnlockRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level) {
294     IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
295     HRESULT hr;
296 
297     TRACE("iface %p, face %#x, level %u.\n", iface, FaceType, Level);
298 
299     wined3d_mutex_lock();
300     hr = IWineD3DCubeTexture_UnlockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level);
301     wined3d_mutex_unlock();
302 
303     return hr;
304 }
305 
306 static HRESULT WINAPI IDirect3DCubeTexture8Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, CONST RECT *pDirtyRect) {
307     IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
308     HRESULT hr;
309 
310     TRACE("iface %p, face %#x, dirty_rect %p.\n", iface, FaceType, pDirtyRect);
311 
312     wined3d_mutex_lock();
313     hr = IWineD3DCubeTexture_AddDirtyRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, pDirtyRect);
314     wined3d_mutex_unlock();
315 
316     return hr;
317 }
318 
319 static const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl =
320 {
321     /* IUnknown */
322     IDirect3DCubeTexture8Impl_QueryInterface,
323     IDirect3DCubeTexture8Impl_AddRef,
324     IDirect3DCubeTexture8Impl_Release,
325     /* IDirect3DResource8 */
326     IDirect3DCubeTexture8Impl_GetDevice,
327     IDirect3DCubeTexture8Impl_SetPrivateData,
328     IDirect3DCubeTexture8Impl_GetPrivateData,
329     IDirect3DCubeTexture8Impl_FreePrivateData,
330     IDirect3DCubeTexture8Impl_SetPriority,
331     IDirect3DCubeTexture8Impl_GetPriority,
332     IDirect3DCubeTexture8Impl_PreLoad,
333     IDirect3DCubeTexture8Impl_GetType,
334     /* IDirect3DBaseTexture8 */
335     IDirect3DCubeTexture8Impl_SetLOD,
336     IDirect3DCubeTexture8Impl_GetLOD,
337     IDirect3DCubeTexture8Impl_GetLevelCount,
338     /* IDirect3DCubeTexture8 */
339     IDirect3DCubeTexture8Impl_GetLevelDesc,
340     IDirect3DCubeTexture8Impl_GetCubeMapSurface,
341     IDirect3DCubeTexture8Impl_LockRect,
342     IDirect3DCubeTexture8Impl_UnlockRect,
343     IDirect3DCubeTexture8Impl_AddDirtyRect
344 };
345 
346 static void STDMETHODCALLTYPE d3d8_cubetexture_wined3d_object_destroyed(void *parent)
347 {
348     HeapFree(GetProcessHeap(), 0, parent);
349 }
350 
351 static const struct wined3d_parent_ops d3d8_cubetexture_wined3d_parent_ops =
352 {
353     d3d8_cubetexture_wined3d_object_destroyed,
354 };
355 
356 HRESULT cubetexture_init(IDirect3DCubeTexture8Impl *texture, IDirect3DDevice8Impl *device,
357         UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool)
358 {
359     HRESULT hr;
360 
361     texture->lpVtbl = &Direct3DCubeTexture8_Vtbl;
362     texture->ref = 1;
363 
364     wined3d_mutex_lock();
365     hr = IWineD3DDevice_CreateCubeTexture(device->WineD3DDevice, edge_length, levels, usage & WINED3DUSAGE_MASK,
366             wined3dformat_from_d3dformat(format), pool, &texture->wineD3DCubeTexture,
367             (IUnknown *)texture, &d3d8_cubetexture_wined3d_parent_ops);
368     wined3d_mutex_unlock();
369     if (FAILED(hr))
370     {
371         WARN("Failed to create wined3d cube texture, hr %#x.\n", hr);
372         return hr;
373     }
374 
375     texture->parentDevice = (IDirect3DDevice8 *)device;
376     IDirect3DDevice8_AddRef(texture->parentDevice);
377 
378     return D3D_OK;
379 }
380 

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