2 * IDirect3DTexture8 implementation
4 * Copyright 2005 Oliver Stieber
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.
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.
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
22 #include "d3d8_private.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(d3d8
);
26 /* IDirect3DTexture8 IUnknown parts follow: */
27 static HRESULT WINAPI
IDirect3DTexture8Impl_QueryInterface(LPDIRECT3DTEXTURE8 iface
, REFIID riid
, LPVOID
*ppobj
) {
28 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
30 if (IsEqualGUID(riid
, &IID_IUnknown
)
31 || IsEqualGUID(riid
, &IID_IDirect3DResource8
)
32 || IsEqualGUID(riid
, &IID_IDirect3DBaseTexture8
)
33 || IsEqualGUID(riid
, &IID_IDirect3DTexture8
)) {
34 IUnknown_AddRef(iface
);
39 WARN("(%p)->(%s,%p) not found\n", This
, debugstr_guid(riid
), ppobj
);
44 static ULONG WINAPI
IDirect3DTexture8Impl_AddRef(LPDIRECT3DTEXTURE8 iface
) {
45 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
46 ULONG ref
= InterlockedIncrement(&This
->ref
);
48 TRACE("(%p) : AddRef from %d\n", This
, ref
- 1);
53 static ULONG WINAPI
IDirect3DTexture8Impl_Release(LPDIRECT3DTEXTURE8 iface
) {
54 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
55 ULONG ref
= InterlockedDecrement(&This
->ref
);
57 TRACE("(%p) : ReleaseRef to %d\n", This
, ref
);
60 EnterCriticalSection(&d3d8_cs
);
61 IWineD3DTexture_Destroy(This
->wineD3DTexture
, D3D8CB_DestroySurface
);
62 LeaveCriticalSection(&d3d8_cs
);
63 IUnknown_Release(This
->parentDevice
);
64 HeapFree(GetProcessHeap(), 0, This
);
69 /* IDirect3DTexture8 IDirect3DResource8 Interface follow: */
70 static HRESULT WINAPI
IDirect3DTexture8Impl_GetDevice(LPDIRECT3DTEXTURE8 iface
, IDirect3DDevice8
**ppDevice
) {
71 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
72 IWineD3DDevice
*wined3d_device
;
74 TRACE("(%p) Relay\n", This
);
75 EnterCriticalSection(&d3d8_cs
);
76 hr
= IWineD3DTexture_GetDevice(This
->wineD3DTexture
, &wined3d_device
);
79 IWineD3DDevice_GetParent(wined3d_device
, (IUnknown
**)ppDevice
);
80 IWineD3DDevice_Release(wined3d_device
);
82 LeaveCriticalSection(&d3d8_cs
);
86 static HRESULT WINAPI
IDirect3DTexture8Impl_SetPrivateData(LPDIRECT3DTEXTURE8 iface
, REFGUID refguid
, CONST
void *pData
, DWORD SizeOfData
, DWORD Flags
) {
87 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
89 TRACE("(%p) Relay\n", This
);
91 EnterCriticalSection(&d3d8_cs
);
92 hr
= IWineD3DTexture_SetPrivateData(This
->wineD3DTexture
, refguid
, pData
, SizeOfData
, Flags
);
93 LeaveCriticalSection(&d3d8_cs
);
97 static HRESULT WINAPI
IDirect3DTexture8Impl_GetPrivateData(LPDIRECT3DTEXTURE8 iface
, REFGUID refguid
, void *pData
, DWORD
* pSizeOfData
) {
98 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
100 TRACE("(%p) Relay\n", This
);
102 EnterCriticalSection(&d3d8_cs
);
103 hr
= IWineD3DTexture_GetPrivateData(This
->wineD3DTexture
, refguid
, pData
, pSizeOfData
);
104 LeaveCriticalSection(&d3d8_cs
);
108 static HRESULT WINAPI
IDirect3DTexture8Impl_FreePrivateData(LPDIRECT3DTEXTURE8 iface
, REFGUID refguid
) {
109 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
111 TRACE("(%p) Relay\n", This
);
113 EnterCriticalSection(&d3d8_cs
);
114 hr
= IWineD3DTexture_FreePrivateData(This
->wineD3DTexture
, refguid
);
115 LeaveCriticalSection(&d3d8_cs
);
119 static DWORD WINAPI
IDirect3DTexture8Impl_SetPriority(LPDIRECT3DTEXTURE8 iface
, DWORD PriorityNew
) {
120 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
122 TRACE("(%p) Relay\n", This
);
124 EnterCriticalSection(&d3d8_cs
);
125 ret
= IWineD3DTexture_SetPriority(This
->wineD3DTexture
, PriorityNew
);
126 LeaveCriticalSection(&d3d8_cs
);
130 static DWORD WINAPI
IDirect3DTexture8Impl_GetPriority(LPDIRECT3DTEXTURE8 iface
) {
131 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
133 TRACE("(%p) Relay\n", This
);
135 EnterCriticalSection(&d3d8_cs
);
136 ret
= IWineD3DTexture_GetPriority(This
->wineD3DTexture
);
137 LeaveCriticalSection(&d3d8_cs
);
141 static void WINAPI
IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface
) {
142 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
143 TRACE("(%p) Relay\n", This
);
145 EnterCriticalSection(&d3d8_cs
);
146 IWineD3DTexture_PreLoad(This
->wineD3DTexture
);
147 LeaveCriticalSection(&d3d8_cs
);
150 static D3DRESOURCETYPE WINAPI
IDirect3DTexture8Impl_GetType(LPDIRECT3DTEXTURE8 iface
) {
151 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
152 D3DRESOURCETYPE type
;
153 TRACE("(%p) Relay\n", This
);
155 EnterCriticalSection(&d3d8_cs
);
156 type
= IWineD3DTexture_GetType(This
->wineD3DTexture
);
157 LeaveCriticalSection(&d3d8_cs
);
161 /* IDirect3DTexture8 IDirect3DBaseTexture8 Interface follow: */
162 static DWORD WINAPI
IDirect3DTexture8Impl_SetLOD(LPDIRECT3DTEXTURE8 iface
, DWORD LODNew
) {
163 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
165 TRACE("(%p) Relay\n", This
);
167 EnterCriticalSection(&d3d8_cs
);
168 ret
= IWineD3DTexture_SetLOD(This
->wineD3DTexture
, LODNew
);
169 LeaveCriticalSection(&d3d8_cs
);
173 static DWORD WINAPI
IDirect3DTexture8Impl_GetLOD(LPDIRECT3DTEXTURE8 iface
) {
174 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
176 TRACE("(%p) Relay\n", This
);
178 EnterCriticalSection(&d3d8_cs
);
179 ret
= IWineD3DTexture_GetLOD(This
->wineD3DTexture
);
180 LeaveCriticalSection(&d3d8_cs
);
184 static DWORD WINAPI
IDirect3DTexture8Impl_GetLevelCount(LPDIRECT3DTEXTURE8 iface
) {
185 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
187 TRACE("(%p) Relay\n", This
);
189 EnterCriticalSection(&d3d8_cs
);
190 ret
= IWineD3DTexture_GetLevelCount(This
->wineD3DTexture
);
191 LeaveCriticalSection(&d3d8_cs
);
195 /* IDirect3DTexture8 Interface follow: */
196 static HRESULT WINAPI
IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 iface
, UINT Level
, D3DSURFACE_DESC
*pDesc
) {
197 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
200 WINED3DSURFACE_DESC wined3ddesc
;
201 TRACE("(%p) Relay\n", This
);
203 /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
204 memset(&wined3ddesc
, 0, sizeof(wined3ddesc
));
205 wined3ddesc
.Format
= (WINED3DFORMAT
*)&pDesc
->Format
;
206 wined3ddesc
.Type
= (WINED3DRESOURCETYPE
*)&pDesc
->Type
;
207 wined3ddesc
.Usage
= &pDesc
->Usage
;
208 wined3ddesc
.Pool
= (WINED3DPOOL
*) &pDesc
->Pool
;
209 wined3ddesc
.Size
= &pDesc
->Size
;
210 wined3ddesc
.MultiSampleType
= (WINED3DMULTISAMPLE_TYPE
*) &pDesc
->MultiSampleType
;
211 wined3ddesc
.Width
= &pDesc
->Width
;
212 wined3ddesc
.Height
= &pDesc
->Height
;
214 EnterCriticalSection(&d3d8_cs
);
215 hr
= IWineD3DTexture_GetLevelDesc(This
->wineD3DTexture
, Level
, &wined3ddesc
);
216 LeaveCriticalSection(&d3d8_cs
);
218 if (SUCCEEDED(hr
)) pDesc
->Format
= d3dformat_from_wined3dformat(pDesc
->Format
);
223 static HRESULT WINAPI
IDirect3DTexture8Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE8 iface
, UINT Level
, IDirect3DSurface8
**ppSurfaceLevel
) {
224 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
225 HRESULT hrc
= D3D_OK
;
226 IWineD3DSurface
*mySurface
= NULL
;
228 TRACE("(%p) Relay\n", This
);
229 EnterCriticalSection(&d3d8_cs
);
230 hrc
= IWineD3DTexture_GetSurfaceLevel(This
->wineD3DTexture
, Level
, &mySurface
);
231 if (hrc
== D3D_OK
&& NULL
!= ppSurfaceLevel
) {
232 IWineD3DSurface_GetParent(mySurface
, (IUnknown
**)ppSurfaceLevel
);
233 IWineD3DSurface_Release(mySurface
);
235 LeaveCriticalSection(&d3d8_cs
);
239 static HRESULT WINAPI
IDirect3DTexture8Impl_LockRect(LPDIRECT3DTEXTURE8 iface
, UINT Level
, D3DLOCKED_RECT
*pLockedRect
, CONST RECT
*pRect
, DWORD Flags
) {
240 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
242 TRACE("(%p) Relay\n", This
);
244 EnterCriticalSection(&d3d8_cs
);
245 hr
= IWineD3DTexture_LockRect(This
->wineD3DTexture
, Level
, (WINED3DLOCKED_RECT
*) pLockedRect
, pRect
, Flags
);
246 LeaveCriticalSection(&d3d8_cs
);
250 static HRESULT WINAPI
IDirect3DTexture8Impl_UnlockRect(LPDIRECT3DTEXTURE8 iface
, UINT Level
) {
251 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
253 TRACE("(%p) Relay\n", This
);
255 EnterCriticalSection(&d3d8_cs
);
256 hr
= IWineD3DTexture_UnlockRect(This
->wineD3DTexture
, Level
);
257 LeaveCriticalSection(&d3d8_cs
);
261 static HRESULT WINAPI
IDirect3DTexture8Impl_AddDirtyRect(LPDIRECT3DTEXTURE8 iface
, CONST RECT
*pDirtyRect
) {
262 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
264 TRACE("(%p) Relay\n", This
);
266 EnterCriticalSection(&d3d8_cs
);
267 hr
= IWineD3DTexture_AddDirtyRect(This
->wineD3DTexture
, pDirtyRect
);
268 LeaveCriticalSection(&d3d8_cs
);
272 const IDirect3DTexture8Vtbl Direct3DTexture8_Vtbl
=
275 IDirect3DTexture8Impl_QueryInterface
,
276 IDirect3DTexture8Impl_AddRef
,
277 IDirect3DTexture8Impl_Release
,
278 /* IDirect3DResource8 */
279 IDirect3DTexture8Impl_GetDevice
,
280 IDirect3DTexture8Impl_SetPrivateData
,
281 IDirect3DTexture8Impl_GetPrivateData
,
282 IDirect3DTexture8Impl_FreePrivateData
,
283 IDirect3DTexture8Impl_SetPriority
,
284 IDirect3DTexture8Impl_GetPriority
,
285 IDirect3DTexture8Impl_PreLoad
,
286 IDirect3DTexture8Impl_GetType
,
287 /* IDirect3dBaseTexture8 */
288 IDirect3DTexture8Impl_SetLOD
,
289 IDirect3DTexture8Impl_GetLOD
,
290 IDirect3DTexture8Impl_GetLevelCount
,
291 /* IDirect3DTexture8 */
292 IDirect3DTexture8Impl_GetLevelDesc
,
293 IDirect3DTexture8Impl_GetSurfaceLevel
,
294 IDirect3DTexture8Impl_LockRect
,
295 IDirect3DTexture8Impl_UnlockRect
,
296 IDirect3DTexture8Impl_AddDirtyRect