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 | if (IsEqualGUID(riid, &IID_IUnknown)
|
---|
39 | || IsEqualGUID(riid, &IID_IDirect3DResource8)
|
---|
40 | || IsEqualGUID(riid, &IID_IDirect3DBaseTexture8)
|
---|
41 | || IsEqualGUID(riid, &IID_IDirect3DCubeTexture8)) {
|
---|
42 | IUnknown_AddRef(iface);
|
---|
43 | *ppobj = This;
|
---|
44 | return S_OK;
|
---|
45 | }
|
---|
46 |
|
---|
47 | WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
|
---|
48 | *ppobj = NULL;
|
---|
49 | return E_NOINTERFACE;
|
---|
50 | }
|
---|
51 |
|
---|
52 | static ULONG WINAPI IDirect3DCubeTexture8Impl_AddRef(LPDIRECT3DCUBETEXTURE8 iface) {
|
---|
53 | IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
|
---|
54 | ULONG ref = InterlockedIncrement(&This->ref);
|
---|
55 |
|
---|
56 | TRACE("(%p) : AddRef from %d\n", This, ref - 1);
|
---|
57 |
|
---|
58 | return ref;
|
---|
59 | }
|
---|
60 |
|
---|
61 | static ULONG WINAPI IDirect3DCubeTexture8Impl_Release(LPDIRECT3DCUBETEXTURE8 iface) {
|
---|
62 | IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
|
---|
63 | ULONG ref = InterlockedDecrement(&This->ref);
|
---|
64 |
|
---|
65 | TRACE("(%p) : ReleaseRef to %d\n", This, ref);
|
---|
66 |
|
---|
67 | if (ref == 0) {
|
---|
68 | TRACE("Releasing child %p\n", This->wineD3DCubeTexture);
|
---|
69 | EnterCriticalSection(&d3d8_cs);
|
---|
70 | IWineD3DCubeTexture_Destroy(This->wineD3DCubeTexture, D3D8CB_DestroySurface);
|
---|
71 | LeaveCriticalSection(&d3d8_cs);
|
---|
72 | IUnknown_Release(This->parentDevice);
|
---|
73 | HeapFree(GetProcessHeap(), 0, This);
|
---|
74 | }
|
---|
75 | return ref;
|
---|
76 | }
|
---|
77 |
|
---|
78 | /* IDirect3DCubeTexture8 IDirect3DResource8 Interface follow: */
|
---|
79 | static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetDevice(LPDIRECT3DCUBETEXTURE8 iface, IDirect3DDevice8 **ppDevice) {
|
---|
80 | IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
|
---|
81 | IWineD3DDevice *wined3d_device;
|
---|
82 | HRESULT hr;
|
---|
83 | TRACE("(%p) Relay\n" , This);
|
---|
84 |
|
---|
85 | EnterCriticalSection(&d3d8_cs);
|
---|
86 | hr = IWineD3DCubeTexture_GetDevice(This->wineD3DCubeTexture, &wined3d_device);
|
---|
87 | if (SUCCEEDED(hr))
|
---|
88 | {
|
---|
89 | IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
|
---|
90 | IWineD3DDevice_Release(wined3d_device);
|
---|
91 | }
|
---|
92 | LeaveCriticalSection(&d3d8_cs);
|
---|
93 | return hr;
|
---|
94 | }
|
---|
95 |
|
---|
96 | static HRESULT WINAPI IDirect3DCubeTexture8Impl_SetPrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
|
---|
97 | IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
|
---|
98 | HRESULT hr;
|
---|
99 | TRACE("(%p) Relay\n", This);
|
---|
100 |
|
---|
101 | EnterCriticalSection(&d3d8_cs);
|
---|
102 | hr = IWineD3DCubeTexture_SetPrivateData(This->wineD3DCubeTexture,refguid,pData,SizeOfData,Flags);
|
---|
103 | LeaveCriticalSection(&d3d8_cs);
|
---|
104 | return hr;
|
---|
105 | }
|
---|
106 |
|
---|
107 | static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetPrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
|
---|
108 | IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
|
---|
109 | HRESULT hr;
|
---|
110 | TRACE("(%p) Relay\n", This);
|
---|
111 |
|
---|
112 | EnterCriticalSection(&d3d8_cs);
|
---|
113 | hr = IWineD3DCubeTexture_GetPrivateData(This->wineD3DCubeTexture,refguid,pData,pSizeOfData);
|
---|
114 | LeaveCriticalSection(&d3d8_cs);
|
---|
115 | return hr;
|
---|
116 | }
|
---|
117 |
|
---|
118 | static HRESULT WINAPI IDirect3DCubeTexture8Impl_FreePrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid) {
|
---|
119 | IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
|
---|
120 | HRESULT hr;
|
---|
121 | TRACE("(%p) Relay\n", This);
|
---|
122 |
|
---|
123 | EnterCriticalSection(&d3d8_cs);
|
---|
124 | hr = IWineD3DCubeTexture_FreePrivateData(This->wineD3DCubeTexture,refguid);
|
---|
125 | LeaveCriticalSection(&d3d8_cs);
|
---|
126 | return hr;
|
---|
127 | }
|
---|
128 |
|
---|
129 | static DWORD WINAPI IDirect3DCubeTexture8Impl_SetPriority(LPDIRECT3DCUBETEXTURE8 iface, DWORD PriorityNew) {
|
---|
130 | IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
|
---|
131 | DWORD ret;
|
---|
132 | TRACE("(%p) Relay\n", This);
|
---|
133 |
|
---|
134 | EnterCriticalSection(&d3d8_cs);
|
---|
135 | ret = IWineD3DCubeTexture_SetPriority(This->wineD3DCubeTexture, PriorityNew);
|
---|
136 | LeaveCriticalSection(&d3d8_cs);
|
---|
137 | return ret;
|
---|
138 | }
|
---|
139 |
|
---|
140 | static DWORD WINAPI IDirect3DCubeTexture8Impl_GetPriority(LPDIRECT3DCUBETEXTURE8 iface) {
|
---|
141 | IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
|
---|
142 | DWORD ret;
|
---|
143 | TRACE("(%p) Relay\n", This);
|
---|
144 |
|
---|
145 | EnterCriticalSection(&d3d8_cs);
|
---|
146 | ret = IWineD3DCubeTexture_GetPriority(This->wineD3DCubeTexture);
|
---|
147 | LeaveCriticalSection(&d3d8_cs);
|
---|
148 | return ret;
|
---|
149 | }
|
---|
150 |
|
---|
151 | static void WINAPI IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8 iface) {
|
---|
152 | IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
|
---|
153 | TRACE("(%p) Relay\n", This);
|
---|
154 |
|
---|
155 | EnterCriticalSection(&d3d8_cs);
|
---|
156 | IWineD3DCubeTexture_PreLoad(This->wineD3DCubeTexture);
|
---|
157 | LeaveCriticalSection(&d3d8_cs);
|
---|
158 | }
|
---|
159 |
|
---|
160 | static D3DRESOURCETYPE WINAPI IDirect3DCubeTexture8Impl_GetType(LPDIRECT3DCUBETEXTURE8 iface) {
|
---|
161 | IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
|
---|
162 | D3DRESOURCETYPE type;
|
---|
163 | TRACE("(%p) Relay\n", This);
|
---|
164 |
|
---|
165 | EnterCriticalSection(&d3d8_cs);
|
---|
166 | type = IWineD3DCubeTexture_GetType(This->wineD3DCubeTexture);
|
---|
167 | LeaveCriticalSection(&d3d8_cs);
|
---|
168 | return type;
|
---|
169 | }
|
---|
170 |
|
---|
171 | /* IDirect3DCubeTexture8 IDirect3DBaseTexture8 Interface follow: */
|
---|
172 | static DWORD WINAPI IDirect3DCubeTexture8Impl_SetLOD(LPDIRECT3DCUBETEXTURE8 iface, DWORD LODNew) {
|
---|
173 | IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
|
---|
174 | DWORD lod;
|
---|
175 | TRACE("(%p) Relay\n", This);
|
---|
176 |
|
---|
177 | EnterCriticalSection(&d3d8_cs);
|
---|
178 | lod = IWineD3DCubeTexture_SetLOD(This->wineD3DCubeTexture, LODNew);
|
---|
179 | LeaveCriticalSection(&d3d8_cs);
|
---|
180 | return lod;
|
---|
181 | }
|
---|
182 |
|
---|
183 | static DWORD WINAPI IDirect3DCubeTexture8Impl_GetLOD(LPDIRECT3DCUBETEXTURE8 iface) {
|
---|
184 | IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
|
---|
185 | DWORD lod;
|
---|
186 | TRACE("(%p) Relay\n", This);
|
---|
187 |
|
---|
188 | EnterCriticalSection(&d3d8_cs);
|
---|
189 | lod = IWineD3DCubeTexture_GetLOD((LPDIRECT3DBASETEXTURE8) This);
|
---|
190 | LeaveCriticalSection(&d3d8_cs);
|
---|
191 | return lod;
|
---|
192 | }
|
---|
193 |
|
---|
194 | static DWORD WINAPI IDirect3DCubeTexture8Impl_GetLevelCount(LPDIRECT3DCUBETEXTURE8 iface) {
|
---|
195 | IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
|
---|
196 | DWORD cnt;
|
---|
197 | TRACE("(%p) Relay\n", This);
|
---|
198 |
|
---|
199 | EnterCriticalSection(&d3d8_cs);
|
---|
200 | cnt = IWineD3DCubeTexture_GetLevelCount(This->wineD3DCubeTexture);
|
---|
201 | LeaveCriticalSection(&d3d8_cs);
|
---|
202 | return cnt;
|
---|
203 | }
|
---|
204 |
|
---|
205 | /* IDirect3DCubeTexture8 Interface follow: */
|
---|
206 | static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetLevelDesc(LPDIRECT3DCUBETEXTURE8 iface, UINT Level, D3DSURFACE_DESC *pDesc) {
|
---|
207 | IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
|
---|
208 | HRESULT hr;
|
---|
209 | WINED3DSURFACE_DESC wined3ddesc;
|
---|
210 |
|
---|
211 | TRACE("(%p) Relay\n", This);
|
---|
212 |
|
---|
213 | /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
|
---|
214 | wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
|
---|
215 | wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
|
---|
216 | wined3ddesc.Usage = &pDesc->Usage;
|
---|
217 | wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
|
---|
218 | wined3ddesc.Size = &pDesc->Size;
|
---|
219 | wined3ddesc.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pDesc->MultiSampleType;
|
---|
220 | wined3ddesc.MultiSampleQuality = NULL; /* DirectX9 only */
|
---|
221 | wined3ddesc.Width = &pDesc->Width;
|
---|
222 | wined3ddesc.Height = &pDesc->Height;
|
---|
223 |
|
---|
224 | EnterCriticalSection(&d3d8_cs);
|
---|
225 | hr = IWineD3DCubeTexture_GetLevelDesc(This->wineD3DCubeTexture, Level, &wined3ddesc);
|
---|
226 | LeaveCriticalSection(&d3d8_cs);
|
---|
227 |
|
---|
228 | if (SUCCEEDED(hr)) pDesc->Format = d3dformat_from_wined3dformat(pDesc->Format);
|
---|
229 |
|
---|
230 | return hr;
|
---|
231 | }
|
---|
232 |
|
---|
233 | static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetCubeMapSurface(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface8 **ppCubeMapSurface) {
|
---|
234 | IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
|
---|
235 | HRESULT hrc = D3D_OK;
|
---|
236 | IWineD3DSurface *mySurface = NULL;
|
---|
237 |
|
---|
238 | TRACE("(%p) Relay\n", This);
|
---|
239 |
|
---|
240 | EnterCriticalSection(&d3d8_cs);
|
---|
241 | hrc = IWineD3DCubeTexture_GetCubeMapSurface(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, &mySurface);
|
---|
242 | if (hrc == D3D_OK && NULL != ppCubeMapSurface) {
|
---|
243 | IWineD3DCubeTexture_GetParent(mySurface, (IUnknown **)ppCubeMapSurface);
|
---|
244 | IWineD3DCubeTexture_Release(mySurface);
|
---|
245 | }
|
---|
246 | LeaveCriticalSection(&d3d8_cs);
|
---|
247 | return hrc;
|
---|
248 | }
|
---|
249 |
|
---|
250 | static HRESULT WINAPI IDirect3DCubeTexture8Impl_LockRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT *pRect, DWORD Flags) {
|
---|
251 | IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
|
---|
252 | HRESULT hr;
|
---|
253 | TRACE("(%p) Relay\n", This);
|
---|
254 |
|
---|
255 | EnterCriticalSection(&d3d8_cs);
|
---|
256 | hr = IWineD3DCubeTexture_LockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
|
---|
257 | LeaveCriticalSection(&d3d8_cs);
|
---|
258 | return hr;
|
---|
259 | }
|
---|
260 |
|
---|
261 | static HRESULT WINAPI IDirect3DCubeTexture8Impl_UnlockRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level) {
|
---|
262 | IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
|
---|
263 | HRESULT hr;
|
---|
264 | TRACE("(%p) Relay\n", This);
|
---|
265 |
|
---|
266 | EnterCriticalSection(&d3d8_cs);
|
---|
267 | hr = IWineD3DCubeTexture_UnlockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level);
|
---|
268 | LeaveCriticalSection(&d3d8_cs);
|
---|
269 | return hr;
|
---|
270 | }
|
---|
271 |
|
---|
272 | static HRESULT WINAPI IDirect3DCubeTexture8Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, CONST RECT *pDirtyRect) {
|
---|
273 | IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
|
---|
274 | HRESULT hr;
|
---|
275 | TRACE("(%p) Relay\n", This);
|
---|
276 |
|
---|
277 | EnterCriticalSection(&d3d8_cs);
|
---|
278 | hr = IWineD3DCubeTexture_AddDirtyRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, pDirtyRect);
|
---|
279 | LeaveCriticalSection(&d3d8_cs);
|
---|
280 | return hr;
|
---|
281 | }
|
---|
282 |
|
---|
283 |
|
---|
284 | const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl =
|
---|
285 | {
|
---|
286 | /* IUnknown */
|
---|
287 | IDirect3DCubeTexture8Impl_QueryInterface,
|
---|
288 | IDirect3DCubeTexture8Impl_AddRef,
|
---|
289 | IDirect3DCubeTexture8Impl_Release,
|
---|
290 | /* IDirect3DResource8 */
|
---|
291 | IDirect3DCubeTexture8Impl_GetDevice,
|
---|
292 | IDirect3DCubeTexture8Impl_SetPrivateData,
|
---|
293 | IDirect3DCubeTexture8Impl_GetPrivateData,
|
---|
294 | IDirect3DCubeTexture8Impl_FreePrivateData,
|
---|
295 | IDirect3DCubeTexture8Impl_SetPriority,
|
---|
296 | IDirect3DCubeTexture8Impl_GetPriority,
|
---|
297 | IDirect3DCubeTexture8Impl_PreLoad,
|
---|
298 | IDirect3DCubeTexture8Impl_GetType,
|
---|
299 | /* IDirect3DBaseTexture8 */
|
---|
300 | IDirect3DCubeTexture8Impl_SetLOD,
|
---|
301 | IDirect3DCubeTexture8Impl_GetLOD,
|
---|
302 | IDirect3DCubeTexture8Impl_GetLevelCount,
|
---|
303 | /* IDirect3DCubeTexture8 */
|
---|
304 | IDirect3DCubeTexture8Impl_GetLevelDesc,
|
---|
305 | IDirect3DCubeTexture8Impl_GetCubeMapSurface,
|
---|
306 | IDirect3DCubeTexture8Impl_LockRect,
|
---|
307 | IDirect3DCubeTexture8Impl_UnlockRect,
|
---|
308 | IDirect3DCubeTexture8Impl_AddDirtyRect
|
---|
309 | };
|
---|