2 * IDirect3DCubeTexture8 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 /* IDirect3DCubeTexture8 IUnknown parts follow: */
27 static HRESULT WINAPI
IDirect3DCubeTexture8Impl_QueryInterface(LPDIRECT3DCUBETEXTURE8 iface
, REFIID riid
, LPVOID
*ppobj
) {
28 IDirect3DCubeTexture8Impl
*This
= (IDirect3DCubeTexture8Impl
*)iface
;
29 if (IsEqualGUID(riid
, &IID_IUnknown
)
30 || IsEqualGUID(riid
, &IID_IDirect3DResource8
)
31 || IsEqualGUID(riid
, &IID_IDirect3DBaseTexture8
)
32 || IsEqualGUID(riid
, &IID_IDirect3DCubeTexture8
)) {
33 IUnknown_AddRef(iface
);
38 WARN("(%p)->(%s,%p),not found\n", This
, debugstr_guid(riid
), ppobj
);
43 static ULONG WINAPI
IDirect3DCubeTexture8Impl_AddRef(LPDIRECT3DCUBETEXTURE8 iface
) {
44 IDirect3DCubeTexture8Impl
*This
= (IDirect3DCubeTexture8Impl
*)iface
;
45 ULONG ref
= InterlockedIncrement(&This
->ref
);
47 TRACE("(%p) : AddRef from %d\n", This
, ref
- 1);
52 static ULONG WINAPI
IDirect3DCubeTexture8Impl_Release(LPDIRECT3DCUBETEXTURE8 iface
) {
53 IDirect3DCubeTexture8Impl
*This
= (IDirect3DCubeTexture8Impl
*)iface
;
54 ULONG ref
= InterlockedDecrement(&This
->ref
);
56 TRACE("(%p) : ReleaseRef to %d\n", This
, ref
);
59 TRACE("Releasing child %p\n", This
->wineD3DCubeTexture
);
60 EnterCriticalSection(&d3d8_cs
);
61 IWineD3DCubeTexture_Destroy(This
->wineD3DCubeTexture
, D3D8CB_DestroySurface
);
62 LeaveCriticalSection(&d3d8_cs
);
63 IUnknown_Release(This
->parentDevice
);
64 HeapFree(GetProcessHeap(), 0, This
);
69 /* IDirect3DCubeTexture8 IDirect3DResource8 Interface follow: */
70 static HRESULT WINAPI
IDirect3DCubeTexture8Impl_GetDevice(LPDIRECT3DCUBETEXTURE8 iface
, IDirect3DDevice8
**ppDevice
) {
71 IDirect3DCubeTexture8Impl
*This
= (IDirect3DCubeTexture8Impl
*)iface
;
72 IWineD3DDevice
*wined3d_device
;
74 TRACE("(%p) Relay\n" , This
);
76 EnterCriticalSection(&d3d8_cs
);
77 hr
= IWineD3DCubeTexture_GetDevice(This
->wineD3DCubeTexture
, &wined3d_device
);
80 IWineD3DDevice_GetParent(wined3d_device
, (IUnknown
**)ppDevice
);
81 IWineD3DDevice_Release(wined3d_device
);
83 LeaveCriticalSection(&d3d8_cs
);
87 static HRESULT WINAPI
IDirect3DCubeTexture8Impl_SetPrivateData(LPDIRECT3DCUBETEXTURE8 iface
, REFGUID refguid
, CONST
void* pData
, DWORD SizeOfData
, DWORD Flags
) {
88 IDirect3DCubeTexture8Impl
*This
= (IDirect3DCubeTexture8Impl
*)iface
;
90 TRACE("(%p) Relay\n", This
);
92 EnterCriticalSection(&d3d8_cs
);
93 hr
= IWineD3DCubeTexture_SetPrivateData(This
->wineD3DCubeTexture
,refguid
,pData
,SizeOfData
,Flags
);
94 LeaveCriticalSection(&d3d8_cs
);
98 static HRESULT WINAPI
IDirect3DCubeTexture8Impl_GetPrivateData(LPDIRECT3DCUBETEXTURE8 iface
, REFGUID refguid
, void *pData
, DWORD
*pSizeOfData
) {
99 IDirect3DCubeTexture8Impl
*This
= (IDirect3DCubeTexture8Impl
*)iface
;
101 TRACE("(%p) Relay\n", This
);
103 EnterCriticalSection(&d3d8_cs
);
104 hr
= IWineD3DCubeTexture_GetPrivateData(This
->wineD3DCubeTexture
,refguid
,pData
,pSizeOfData
);
105 LeaveCriticalSection(&d3d8_cs
);
109 static HRESULT WINAPI
IDirect3DCubeTexture8Impl_FreePrivateData(LPDIRECT3DCUBETEXTURE8 iface
, REFGUID refguid
) {
110 IDirect3DCubeTexture8Impl
*This
= (IDirect3DCubeTexture8Impl
*)iface
;
112 TRACE("(%p) Relay\n", This
);
114 EnterCriticalSection(&d3d8_cs
);
115 hr
= IWineD3DCubeTexture_FreePrivateData(This
->wineD3DCubeTexture
,refguid
);
116 LeaveCriticalSection(&d3d8_cs
);
120 static DWORD WINAPI
IDirect3DCubeTexture8Impl_SetPriority(LPDIRECT3DCUBETEXTURE8 iface
, DWORD PriorityNew
) {
121 IDirect3DCubeTexture8Impl
*This
= (IDirect3DCubeTexture8Impl
*)iface
;
123 TRACE("(%p) Relay\n", This
);
125 EnterCriticalSection(&d3d8_cs
);
126 ret
= IWineD3DCubeTexture_SetPriority(This
->wineD3DCubeTexture
, PriorityNew
);
127 LeaveCriticalSection(&d3d8_cs
);
131 static DWORD WINAPI
IDirect3DCubeTexture8Impl_GetPriority(LPDIRECT3DCUBETEXTURE8 iface
) {
132 IDirect3DCubeTexture8Impl
*This
= (IDirect3DCubeTexture8Impl
*)iface
;
134 TRACE("(%p) Relay\n", This
);
136 EnterCriticalSection(&d3d8_cs
);
137 ret
= IWineD3DCubeTexture_GetPriority(This
->wineD3DCubeTexture
);
138 LeaveCriticalSection(&d3d8_cs
);
142 static void WINAPI
IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8 iface
) {
143 IDirect3DCubeTexture8Impl
*This
= (IDirect3DCubeTexture8Impl
*)iface
;
144 TRACE("(%p) Relay\n", This
);
146 EnterCriticalSection(&d3d8_cs
);
147 IWineD3DCubeTexture_PreLoad(This
->wineD3DCubeTexture
);
148 LeaveCriticalSection(&d3d8_cs
);
151 static D3DRESOURCETYPE WINAPI
IDirect3DCubeTexture8Impl_GetType(LPDIRECT3DCUBETEXTURE8 iface
) {
152 IDirect3DCubeTexture8Impl
*This
= (IDirect3DCubeTexture8Impl
*)iface
;
153 D3DRESOURCETYPE type
;
154 TRACE("(%p) Relay\n", This
);
156 EnterCriticalSection(&d3d8_cs
);
157 type
= IWineD3DCubeTexture_GetType(This
->wineD3DCubeTexture
);
158 LeaveCriticalSection(&d3d8_cs
);
162 /* IDirect3DCubeTexture8 IDirect3DBaseTexture8 Interface follow: */
163 static DWORD WINAPI
IDirect3DCubeTexture8Impl_SetLOD(LPDIRECT3DCUBETEXTURE8 iface
, DWORD LODNew
) {
164 IDirect3DCubeTexture8Impl
*This
= (IDirect3DCubeTexture8Impl
*)iface
;
166 TRACE("(%p) Relay\n", This
);
168 EnterCriticalSection(&d3d8_cs
);
169 lod
= IWineD3DCubeTexture_SetLOD(This
->wineD3DCubeTexture
, LODNew
);
170 LeaveCriticalSection(&d3d8_cs
);
174 static DWORD WINAPI
IDirect3DCubeTexture8Impl_GetLOD(LPDIRECT3DCUBETEXTURE8 iface
) {
175 IDirect3DCubeTexture8Impl
*This
= (IDirect3DCubeTexture8Impl
*)iface
;
177 TRACE("(%p) Relay\n", This
);
179 EnterCriticalSection(&d3d8_cs
);
180 lod
= IWineD3DCubeTexture_GetLOD((LPDIRECT3DBASETEXTURE8
) This
);
181 LeaveCriticalSection(&d3d8_cs
);
185 static DWORD WINAPI
IDirect3DCubeTexture8Impl_GetLevelCount(LPDIRECT3DCUBETEXTURE8 iface
) {
186 IDirect3DCubeTexture8Impl
*This
= (IDirect3DCubeTexture8Impl
*)iface
;
188 TRACE("(%p) Relay\n", This
);
190 EnterCriticalSection(&d3d8_cs
);
191 cnt
= IWineD3DCubeTexture_GetLevelCount(This
->wineD3DCubeTexture
);
192 LeaveCriticalSection(&d3d8_cs
);
196 /* IDirect3DCubeTexture8 Interface follow: */
197 static HRESULT WINAPI
IDirect3DCubeTexture8Impl_GetLevelDesc(LPDIRECT3DCUBETEXTURE8 iface
, UINT Level
, D3DSURFACE_DESC
*pDesc
) {
198 IDirect3DCubeTexture8Impl
*This
= (IDirect3DCubeTexture8Impl
*)iface
;
200 WINED3DSURFACE_DESC wined3ddesc
;
202 TRACE("(%p) Relay\n", This
);
204 /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
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
.MultiSampleQuality
= NULL
; /* DirectX9 only */
212 wined3ddesc
.Width
= &pDesc
->Width
;
213 wined3ddesc
.Height
= &pDesc
->Height
;
215 EnterCriticalSection(&d3d8_cs
);
216 hr
= IWineD3DCubeTexture_GetLevelDesc(This
->wineD3DCubeTexture
, Level
, &wined3ddesc
);
217 LeaveCriticalSection(&d3d8_cs
);
219 if (SUCCEEDED(hr
)) pDesc
->Format
= d3dformat_from_wined3dformat(pDesc
->Format
);
224 static HRESULT WINAPI
IDirect3DCubeTexture8Impl_GetCubeMapSurface(LPDIRECT3DCUBETEXTURE8 iface
, D3DCUBEMAP_FACES FaceType
, UINT Level
, IDirect3DSurface8
**ppCubeMapSurface
) {
225 IDirect3DCubeTexture8Impl
*This
= (IDirect3DCubeTexture8Impl
*)iface
;
226 HRESULT hrc
= D3D_OK
;
227 IWineD3DSurface
*mySurface
= NULL
;
229 TRACE("(%p) Relay\n", This
);
231 EnterCriticalSection(&d3d8_cs
);
232 hrc
= IWineD3DCubeTexture_GetCubeMapSurface(This
->wineD3DCubeTexture
, (WINED3DCUBEMAP_FACES
) FaceType
, Level
, &mySurface
);
233 if (hrc
== D3D_OK
&& NULL
!= ppCubeMapSurface
) {
234 IWineD3DCubeTexture_GetParent(mySurface
, (IUnknown
**)ppCubeMapSurface
);
235 IWineD3DCubeTexture_Release(mySurface
);
237 LeaveCriticalSection(&d3d8_cs
);
241 static HRESULT WINAPI
IDirect3DCubeTexture8Impl_LockRect(LPDIRECT3DCUBETEXTURE8 iface
, D3DCUBEMAP_FACES FaceType
, UINT Level
, D3DLOCKED_RECT
* pLockedRect
, CONST RECT
*pRect
, DWORD Flags
) {
242 IDirect3DCubeTexture8Impl
*This
= (IDirect3DCubeTexture8Impl
*)iface
;
244 TRACE("(%p) Relay\n", This
);
246 EnterCriticalSection(&d3d8_cs
);
247 hr
= IWineD3DCubeTexture_LockRect(This
->wineD3DCubeTexture
, (WINED3DCUBEMAP_FACES
) FaceType
, Level
, (WINED3DLOCKED_RECT
*) pLockedRect
, pRect
, Flags
);
248 LeaveCriticalSection(&d3d8_cs
);
252 static HRESULT WINAPI
IDirect3DCubeTexture8Impl_UnlockRect(LPDIRECT3DCUBETEXTURE8 iface
, D3DCUBEMAP_FACES FaceType
, UINT Level
) {
253 IDirect3DCubeTexture8Impl
*This
= (IDirect3DCubeTexture8Impl
*)iface
;
255 TRACE("(%p) Relay\n", This
);
257 EnterCriticalSection(&d3d8_cs
);
258 hr
= IWineD3DCubeTexture_UnlockRect(This
->wineD3DCubeTexture
, (WINED3DCUBEMAP_FACES
) FaceType
, Level
);
259 LeaveCriticalSection(&d3d8_cs
);
263 static HRESULT WINAPI
IDirect3DCubeTexture8Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE8 iface
, D3DCUBEMAP_FACES FaceType
, CONST RECT
*pDirtyRect
) {
264 IDirect3DCubeTexture8Impl
*This
= (IDirect3DCubeTexture8Impl
*)iface
;
266 TRACE("(%p) Relay\n", This
);
268 EnterCriticalSection(&d3d8_cs
);
269 hr
= IWineD3DCubeTexture_AddDirtyRect(This
->wineD3DCubeTexture
, (WINED3DCUBEMAP_FACES
) FaceType
, pDirtyRect
);
270 LeaveCriticalSection(&d3d8_cs
);
275 const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl
=
278 IDirect3DCubeTexture8Impl_QueryInterface
,
279 IDirect3DCubeTexture8Impl_AddRef
,
280 IDirect3DCubeTexture8Impl_Release
,
281 /* IDirect3DResource8 */
282 IDirect3DCubeTexture8Impl_GetDevice
,
283 IDirect3DCubeTexture8Impl_SetPrivateData
,
284 IDirect3DCubeTexture8Impl_GetPrivateData
,
285 IDirect3DCubeTexture8Impl_FreePrivateData
,
286 IDirect3DCubeTexture8Impl_SetPriority
,
287 IDirect3DCubeTexture8Impl_GetPriority
,
288 IDirect3DCubeTexture8Impl_PreLoad
,
289 IDirect3DCubeTexture8Impl_GetType
,
290 /* IDirect3DBaseTexture8 */
291 IDirect3DCubeTexture8Impl_SetLOD
,
292 IDirect3DCubeTexture8Impl_GetLOD
,
293 IDirect3DCubeTexture8Impl_GetLevelCount
,
294 /* IDirect3DCubeTexture8 */
295 IDirect3DCubeTexture8Impl_GetLevelDesc
,
296 IDirect3DCubeTexture8Impl_GetCubeMapSurface
,
297 IDirect3DCubeTexture8Impl_LockRect
,
298 IDirect3DCubeTexture8Impl_UnlockRect
,
299 IDirect3DCubeTexture8Impl_AddDirtyRect