1 | /*
|
---|
2 | * IDirect3DTexture8 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 | /* IDirect3DTexture8 IUnknown parts follow: */
|
---|
36 | static HRESULT WINAPI IDirect3DTexture8Impl_QueryInterface(LPDIRECT3DTEXTURE8 iface, REFIID riid, LPVOID *ppobj) {
|
---|
37 | IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
|
---|
38 |
|
---|
39 | if (IsEqualGUID(riid, &IID_IUnknown)
|
---|
40 | || IsEqualGUID(riid, &IID_IDirect3DResource8)
|
---|
41 | || IsEqualGUID(riid, &IID_IDirect3DBaseTexture8)
|
---|
42 | || IsEqualGUID(riid, &IID_IDirect3DTexture8)) {
|
---|
43 | IUnknown_AddRef(iface);
|
---|
44 | *ppobj = This;
|
---|
45 | return S_OK;
|
---|
46 | }
|
---|
47 |
|
---|
48 | WARN("(%p)->(%s,%p) not found\n", This, debugstr_guid(riid), ppobj);
|
---|
49 | *ppobj = NULL;
|
---|
50 | return E_NOINTERFACE;
|
---|
51 | }
|
---|
52 |
|
---|
53 | static ULONG WINAPI IDirect3DTexture8Impl_AddRef(LPDIRECT3DTEXTURE8 iface) {
|
---|
54 | IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
|
---|
55 | ULONG ref = InterlockedIncrement(&This->ref);
|
---|
56 |
|
---|
57 | TRACE("(%p) : AddRef from %d\n", This, ref - 1);
|
---|
58 |
|
---|
59 | return ref;
|
---|
60 | }
|
---|
61 |
|
---|
62 | static ULONG WINAPI IDirect3DTexture8Impl_Release(LPDIRECT3DTEXTURE8 iface) {
|
---|
63 | IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
|
---|
64 | ULONG ref = InterlockedDecrement(&This->ref);
|
---|
65 |
|
---|
66 | TRACE("(%p) : ReleaseRef to %d\n", This, ref);
|
---|
67 |
|
---|
68 | if (ref == 0) {
|
---|
69 | EnterCriticalSection(&d3d8_cs);
|
---|
70 | IWineD3DTexture_Destroy(This->wineD3DTexture, D3D8CB_DestroySurface);
|
---|
71 | LeaveCriticalSection(&d3d8_cs);
|
---|
72 | IUnknown_Release(This->parentDevice);
|
---|
73 | HeapFree(GetProcessHeap(), 0, This);
|
---|
74 | }
|
---|
75 | return ref;
|
---|
76 | }
|
---|
77 |
|
---|
78 | /* IDirect3DTexture8 IDirect3DResource8 Interface follow: */
|
---|
79 | static HRESULT WINAPI IDirect3DTexture8Impl_GetDevice(LPDIRECT3DTEXTURE8 iface, IDirect3DDevice8 **ppDevice) {
|
---|
80 | IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
|
---|
81 | IWineD3DDevice *wined3d_device;
|
---|
82 | HRESULT hr;
|
---|
83 | TRACE("(%p) Relay\n", This);
|
---|
84 | EnterCriticalSection(&d3d8_cs);
|
---|
85 | hr = IWineD3DTexture_GetDevice(This->wineD3DTexture, &wined3d_device);
|
---|
86 | if (SUCCEEDED(hr))
|
---|
87 | {
|
---|
88 | IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
|
---|
89 | IWineD3DDevice_Release(wined3d_device);
|
---|
90 | }
|
---|
91 | LeaveCriticalSection(&d3d8_cs);
|
---|
92 | return hr;
|
---|
93 | }
|
---|
94 |
|
---|
95 | static HRESULT WINAPI IDirect3DTexture8Impl_SetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
|
---|
96 | IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
|
---|
97 | HRESULT hr;
|
---|
98 | TRACE("(%p) Relay\n", This);
|
---|
99 |
|
---|
100 | EnterCriticalSection(&d3d8_cs);
|
---|
101 | hr = IWineD3DTexture_SetPrivateData(This->wineD3DTexture, refguid, pData, SizeOfData, Flags);
|
---|
102 | LeaveCriticalSection(&d3d8_cs);
|
---|
103 | return hr;
|
---|
104 | }
|
---|
105 |
|
---|
106 | static HRESULT WINAPI IDirect3DTexture8Impl_GetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, void *pData, DWORD* pSizeOfData) {
|
---|
107 | IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
|
---|
108 | HRESULT hr;
|
---|
109 | TRACE("(%p) Relay\n", This);
|
---|
110 |
|
---|
111 | EnterCriticalSection(&d3d8_cs);
|
---|
112 | hr = IWineD3DTexture_GetPrivateData(This->wineD3DTexture, refguid, pData, pSizeOfData);
|
---|
113 | LeaveCriticalSection(&d3d8_cs);
|
---|
114 | return hr;
|
---|
115 | }
|
---|
116 |
|
---|
117 | static HRESULT WINAPI IDirect3DTexture8Impl_FreePrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid) {
|
---|
118 | IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
|
---|
119 | HRESULT hr;
|
---|
120 | TRACE("(%p) Relay\n", This);
|
---|
121 |
|
---|
122 | EnterCriticalSection(&d3d8_cs);
|
---|
123 | hr = IWineD3DTexture_FreePrivateData(This->wineD3DTexture, refguid);
|
---|
124 | LeaveCriticalSection(&d3d8_cs);
|
---|
125 | return hr;
|
---|
126 | }
|
---|
127 |
|
---|
128 | static DWORD WINAPI IDirect3DTexture8Impl_SetPriority(LPDIRECT3DTEXTURE8 iface, DWORD PriorityNew) {
|
---|
129 | IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
|
---|
130 | DWORD ret;
|
---|
131 | TRACE("(%p) Relay\n", This);
|
---|
132 |
|
---|
133 | EnterCriticalSection(&d3d8_cs);
|
---|
134 | ret = IWineD3DTexture_SetPriority(This->wineD3DTexture, PriorityNew);
|
---|
135 | LeaveCriticalSection(&d3d8_cs);
|
---|
136 | return ret;
|
---|
137 | }
|
---|
138 |
|
---|
139 | static DWORD WINAPI IDirect3DTexture8Impl_GetPriority(LPDIRECT3DTEXTURE8 iface) {
|
---|
140 | IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
|
---|
141 | DWORD ret;
|
---|
142 | TRACE("(%p) Relay\n", This);
|
---|
143 |
|
---|
144 | EnterCriticalSection(&d3d8_cs);
|
---|
145 | ret = IWineD3DTexture_GetPriority(This->wineD3DTexture);
|
---|
146 | LeaveCriticalSection(&d3d8_cs);
|
---|
147 | return ret;
|
---|
148 | }
|
---|
149 |
|
---|
150 | static void WINAPI IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface) {
|
---|
151 | IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
|
---|
152 | TRACE("(%p) Relay\n", This);
|
---|
153 |
|
---|
154 | EnterCriticalSection(&d3d8_cs);
|
---|
155 | IWineD3DTexture_PreLoad(This->wineD3DTexture);
|
---|
156 | LeaveCriticalSection(&d3d8_cs);
|
---|
157 | }
|
---|
158 |
|
---|
159 | static D3DRESOURCETYPE WINAPI IDirect3DTexture8Impl_GetType(LPDIRECT3DTEXTURE8 iface) {
|
---|
160 | IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
|
---|
161 | D3DRESOURCETYPE type;
|
---|
162 | TRACE("(%p) Relay\n", This);
|
---|
163 |
|
---|
164 | EnterCriticalSection(&d3d8_cs);
|
---|
165 | type = IWineD3DTexture_GetType(This->wineD3DTexture);
|
---|
166 | LeaveCriticalSection(&d3d8_cs);
|
---|
167 | return type;
|
---|
168 | }
|
---|
169 |
|
---|
170 | /* IDirect3DTexture8 IDirect3DBaseTexture8 Interface follow: */
|
---|
171 | static DWORD WINAPI IDirect3DTexture8Impl_SetLOD(LPDIRECT3DTEXTURE8 iface, DWORD LODNew) {
|
---|
172 | IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
|
---|
173 | DWORD ret;
|
---|
174 | TRACE("(%p) Relay\n", This);
|
---|
175 |
|
---|
176 | EnterCriticalSection(&d3d8_cs);
|
---|
177 | ret = IWineD3DTexture_SetLOD(This->wineD3DTexture, LODNew);
|
---|
178 | LeaveCriticalSection(&d3d8_cs);
|
---|
179 | return ret;
|
---|
180 | }
|
---|
181 |
|
---|
182 | static DWORD WINAPI IDirect3DTexture8Impl_GetLOD(LPDIRECT3DTEXTURE8 iface) {
|
---|
183 | IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
|
---|
184 | DWORD ret;
|
---|
185 | TRACE("(%p) Relay\n", This);
|
---|
186 |
|
---|
187 | EnterCriticalSection(&d3d8_cs);
|
---|
188 | ret = IWineD3DTexture_GetLOD(This->wineD3DTexture);
|
---|
189 | LeaveCriticalSection(&d3d8_cs);
|
---|
190 | return ret;
|
---|
191 | }
|
---|
192 |
|
---|
193 | static DWORD WINAPI IDirect3DTexture8Impl_GetLevelCount(LPDIRECT3DTEXTURE8 iface) {
|
---|
194 | IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
|
---|
195 | DWORD ret;
|
---|
196 | TRACE("(%p) Relay\n", This);
|
---|
197 |
|
---|
198 | EnterCriticalSection(&d3d8_cs);
|
---|
199 | ret = IWineD3DTexture_GetLevelCount(This->wineD3DTexture);
|
---|
200 | LeaveCriticalSection(&d3d8_cs);
|
---|
201 | return ret;
|
---|
202 | }
|
---|
203 |
|
---|
204 | /* IDirect3DTexture8 Interface follow: */
|
---|
205 | static HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 iface, UINT Level, D3DSURFACE_DESC *pDesc) {
|
---|
206 | IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
|
---|
207 | HRESULT hr;
|
---|
208 |
|
---|
209 | WINED3DSURFACE_DESC wined3ddesc;
|
---|
210 | TRACE("(%p) Relay\n", This);
|
---|
211 |
|
---|
212 | EnterCriticalSection(&d3d8_cs);
|
---|
213 | hr = IWineD3DTexture_GetLevelDesc(This->wineD3DTexture, Level, &wined3ddesc);
|
---|
214 | LeaveCriticalSection(&d3d8_cs);
|
---|
215 |
|
---|
216 | if (SUCCEEDED(hr))
|
---|
217 | {
|
---|
218 | pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.format);
|
---|
219 | pDesc->Type = wined3ddesc.resource_type;
|
---|
220 | pDesc->Usage = wined3ddesc.usage;
|
---|
221 | pDesc->Pool = wined3ddesc.pool;
|
---|
222 | pDesc->Size = wined3ddesc.size;
|
---|
223 | pDesc->MultiSampleType = wined3ddesc.multisample_type;
|
---|
224 | pDesc->Width = wined3ddesc.width;
|
---|
225 | pDesc->Height = wined3ddesc.height;
|
---|
226 | }
|
---|
227 |
|
---|
228 | return hr;
|
---|
229 | }
|
---|
230 |
|
---|
231 | static HRESULT WINAPI IDirect3DTexture8Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE8 iface, UINT Level, IDirect3DSurface8 **ppSurfaceLevel) {
|
---|
232 | IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
|
---|
233 | HRESULT hrc = D3D_OK;
|
---|
234 | IWineD3DSurface *mySurface = NULL;
|
---|
235 |
|
---|
236 | TRACE("(%p) Relay\n", This);
|
---|
237 | EnterCriticalSection(&d3d8_cs);
|
---|
238 | hrc = IWineD3DTexture_GetSurfaceLevel(This->wineD3DTexture, Level, &mySurface);
|
---|
239 | if (hrc == D3D_OK && NULL != ppSurfaceLevel) {
|
---|
240 | IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppSurfaceLevel);
|
---|
241 | IWineD3DSurface_Release(mySurface);
|
---|
242 | }
|
---|
243 | LeaveCriticalSection(&d3d8_cs);
|
---|
244 | return hrc;
|
---|
245 | }
|
---|
246 |
|
---|
247 | static HRESULT WINAPI IDirect3DTexture8Impl_LockRect(LPDIRECT3DTEXTURE8 iface, UINT Level, D3DLOCKED_RECT *pLockedRect, CONST RECT *pRect, DWORD Flags) {
|
---|
248 | IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
|
---|
249 | HRESULT hr;
|
---|
250 | TRACE("(%p) Relay\n", This);
|
---|
251 |
|
---|
252 | EnterCriticalSection(&d3d8_cs);
|
---|
253 | hr = IWineD3DTexture_LockRect(This->wineD3DTexture, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
|
---|
254 | LeaveCriticalSection(&d3d8_cs);
|
---|
255 | return hr;
|
---|
256 | }
|
---|
257 |
|
---|
258 | static HRESULT WINAPI IDirect3DTexture8Impl_UnlockRect(LPDIRECT3DTEXTURE8 iface, UINT Level) {
|
---|
259 | IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
|
---|
260 | HRESULT hr;
|
---|
261 | TRACE("(%p) Relay\n", This);
|
---|
262 |
|
---|
263 | EnterCriticalSection(&d3d8_cs);
|
---|
264 | hr = IWineD3DTexture_UnlockRect(This->wineD3DTexture, Level);
|
---|
265 | LeaveCriticalSection(&d3d8_cs);
|
---|
266 | return hr;
|
---|
267 | }
|
---|
268 |
|
---|
269 | static HRESULT WINAPI IDirect3DTexture8Impl_AddDirtyRect(LPDIRECT3DTEXTURE8 iface, CONST RECT *pDirtyRect) {
|
---|
270 | IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
|
---|
271 | HRESULT hr;
|
---|
272 | TRACE("(%p) Relay\n", This);
|
---|
273 |
|
---|
274 | EnterCriticalSection(&d3d8_cs);
|
---|
275 | hr = IWineD3DTexture_AddDirtyRect(This->wineD3DTexture, pDirtyRect);
|
---|
276 | LeaveCriticalSection(&d3d8_cs);
|
---|
277 | return hr;
|
---|
278 | }
|
---|
279 |
|
---|
280 | const IDirect3DTexture8Vtbl Direct3DTexture8_Vtbl =
|
---|
281 | {
|
---|
282 | /* IUnknown */
|
---|
283 | IDirect3DTexture8Impl_QueryInterface,
|
---|
284 | IDirect3DTexture8Impl_AddRef,
|
---|
285 | IDirect3DTexture8Impl_Release,
|
---|
286 | /* IDirect3DResource8 */
|
---|
287 | IDirect3DTexture8Impl_GetDevice,
|
---|
288 | IDirect3DTexture8Impl_SetPrivateData,
|
---|
289 | IDirect3DTexture8Impl_GetPrivateData,
|
---|
290 | IDirect3DTexture8Impl_FreePrivateData,
|
---|
291 | IDirect3DTexture8Impl_SetPriority,
|
---|
292 | IDirect3DTexture8Impl_GetPriority,
|
---|
293 | IDirect3DTexture8Impl_PreLoad,
|
---|
294 | IDirect3DTexture8Impl_GetType,
|
---|
295 | /* IDirect3dBaseTexture8 */
|
---|
296 | IDirect3DTexture8Impl_SetLOD,
|
---|
297 | IDirect3DTexture8Impl_GetLOD,
|
---|
298 | IDirect3DTexture8Impl_GetLevelCount,
|
---|
299 | /* IDirect3DTexture8 */
|
---|
300 | IDirect3DTexture8Impl_GetLevelDesc,
|
---|
301 | IDirect3DTexture8Impl_GetSurfaceLevel,
|
---|
302 | IDirect3DTexture8Impl_LockRect,
|
---|
303 | IDirect3DTexture8Impl_UnlockRect,
|
---|
304 | IDirect3DTexture8Impl_AddDirtyRect
|
---|
305 | };
|
---|