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