2 * IDirect3DCubeTexture9 implementation
4 * Copyright 2002-2005 Jason Edmeades
5 * Copyright 2002-2005 Raphael Junqueira
6 * Copyright 2005 Oliver Stieber
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "d3d9_private.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3d9
);
29 /* IDirect3DCubeTexture9 IUnknown parts follow: */
30 static HRESULT WINAPI
IDirect3DCubeTexture9Impl_QueryInterface(LPDIRECT3DCUBETEXTURE9 iface
, REFIID riid
, LPVOID
* ppobj
) {
31 IDirect3DCubeTexture9Impl
*This
= (IDirect3DCubeTexture9Impl
*)iface
;
32 if (IsEqualGUID(riid
, &IID_IUnknown
)
33 || IsEqualGUID(riid
, &IID_IDirect3DResource9
)
34 || IsEqualGUID(riid
, &IID_IDirect3DBaseTexture9
)
35 || IsEqualGUID(riid
, &IID_IDirect3DCubeTexture9
)) {
36 IUnknown_AddRef(iface
);
41 WARN("(%p)->(%s,%p),not found\n", This
, debugstr_guid(riid
), ppobj
);
46 static ULONG WINAPI
IDirect3DCubeTexture9Impl_AddRef(LPDIRECT3DCUBETEXTURE9 iface
) {
47 IDirect3DCubeTexture9Impl
*This
= (IDirect3DCubeTexture9Impl
*)iface
;
48 ULONG ref
= InterlockedIncrement(&This
->ref
);
50 TRACE("(%p) : AddRef from %d\n", This
, ref
- 1);
55 static ULONG WINAPI
IDirect3DCubeTexture9Impl_Release(LPDIRECT3DCUBETEXTURE9 iface
) {
56 IDirect3DCubeTexture9Impl
*This
= (IDirect3DCubeTexture9Impl
*)iface
;
57 ULONG ref
= InterlockedDecrement(&This
->ref
);
59 TRACE("(%p) : ReleaseRef to %d\n", This
, ref
);
62 TRACE("Releasing child %p\n", This
->wineD3DCubeTexture
);
63 IWineD3DCubeTexture_Destroy(This
->wineD3DCubeTexture
, D3D9CB_DestroySurface
);
64 IUnknown_Release(This
->parentDevice
);
65 HeapFree(GetProcessHeap(), 0, This
);
70 /* IDirect3DCubeTexture9 IDirect3DResource9 Interface follow: */
71 static HRESULT WINAPI
IDirect3DCubeTexture9Impl_GetDevice(LPDIRECT3DCUBETEXTURE9 iface
, IDirect3DDevice9
** ppDevice
) {
72 IDirect3DCubeTexture9Impl
*This
= (IDirect3DCubeTexture9Impl
*)iface
;
73 TRACE("(%p) Relay\n" , This
);
74 return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9
) This
, ppDevice
);
77 static HRESULT WINAPI
IDirect3DCubeTexture9Impl_SetPrivateData(LPDIRECT3DCUBETEXTURE9 iface
, REFGUID refguid
, CONST
void* pData
, DWORD SizeOfData
, DWORD Flags
) {
78 IDirect3DCubeTexture9Impl
*This
= (IDirect3DCubeTexture9Impl
*)iface
;
79 TRACE("(%p) Relay\n", This
);
80 return IWineD3DCubeTexture_SetPrivateData(This
->wineD3DCubeTexture
,refguid
,pData
,SizeOfData
,Flags
);
83 static HRESULT WINAPI
IDirect3DCubeTexture9Impl_GetPrivateData(LPDIRECT3DCUBETEXTURE9 iface
, REFGUID refguid
, void* pData
, DWORD
* pSizeOfData
) {
84 IDirect3DCubeTexture9Impl
*This
= (IDirect3DCubeTexture9Impl
*)iface
;
85 TRACE("(%p) Relay\n", This
);
86 return IWineD3DCubeTexture_GetPrivateData(This
->wineD3DCubeTexture
,refguid
,pData
,pSizeOfData
);
89 static HRESULT WINAPI
IDirect3DCubeTexture9Impl_FreePrivateData(LPDIRECT3DCUBETEXTURE9 iface
, REFGUID refguid
) {
90 IDirect3DCubeTexture9Impl
*This
= (IDirect3DCubeTexture9Impl
*)iface
;
91 TRACE("(%p) Relay\n", This
);
92 return IWineD3DCubeTexture_FreePrivateData(This
->wineD3DCubeTexture
,refguid
);
95 static DWORD WINAPI
IDirect3DCubeTexture9Impl_SetPriority(LPDIRECT3DCUBETEXTURE9 iface
, DWORD PriorityNew
) {
96 IDirect3DCubeTexture9Impl
*This
= (IDirect3DCubeTexture9Impl
*)iface
;
97 TRACE("(%p) Relay\n", This
);
98 return IWineD3DCubeTexture_SetPriority(This
->wineD3DCubeTexture
, PriorityNew
);
101 static DWORD WINAPI
IDirect3DCubeTexture9Impl_GetPriority(LPDIRECT3DCUBETEXTURE9 iface
) {
102 IDirect3DCubeTexture9Impl
*This
= (IDirect3DCubeTexture9Impl
*)iface
;
103 TRACE("(%p) Relay\n", This
);
104 return IWineD3DCubeTexture_GetPriority(This
->wineD3DCubeTexture
);
107 static void WINAPI
IDirect3DCubeTexture9Impl_PreLoad(LPDIRECT3DCUBETEXTURE9 iface
) {
108 IDirect3DCubeTexture9Impl
*This
= (IDirect3DCubeTexture9Impl
*)iface
;
109 TRACE("(%p) Relay\n", This
);
110 return IWineD3DCubeTexture_PreLoad(This
->wineD3DCubeTexture
);
113 static D3DRESOURCETYPE WINAPI
IDirect3DCubeTexture9Impl_GetType(LPDIRECT3DCUBETEXTURE9 iface
) {
114 IDirect3DCubeTexture9Impl
*This
= (IDirect3DCubeTexture9Impl
*)iface
;
115 TRACE("(%p) Relay\n", This
);
116 return IWineD3DCubeTexture_GetType(This
->wineD3DCubeTexture
);
119 /* IDirect3DCubeTexture9 IDirect3DBaseTexture9 Interface follow: */
120 static DWORD WINAPI
IDirect3DCubeTexture9Impl_SetLOD(LPDIRECT3DCUBETEXTURE9 iface
, DWORD LODNew
) {
121 IDirect3DCubeTexture9Impl
*This
= (IDirect3DCubeTexture9Impl
*)iface
;
122 TRACE("(%p) Relay\n", This
);
123 return IWineD3DCubeTexture_SetLOD(This
->wineD3DCubeTexture
, LODNew
);
126 static DWORD WINAPI
IDirect3DCubeTexture9Impl_GetLOD(LPDIRECT3DCUBETEXTURE9 iface
) {
127 IDirect3DCubeTexture9Impl
*This
= (IDirect3DCubeTexture9Impl
*)iface
;
128 TRACE("(%p) Relay\n", This
);
129 return IDirect3DBaseTexture9Impl_GetLOD((LPDIRECT3DBASETEXTURE9
) This
);
132 static DWORD WINAPI
IDirect3DCubeTexture9Impl_GetLevelCount(LPDIRECT3DCUBETEXTURE9 iface
) {
133 IDirect3DCubeTexture9Impl
*This
= (IDirect3DCubeTexture9Impl
*)iface
;
134 TRACE("(%p) Relay\n", This
);
135 return IWineD3DCubeTexture_GetLevelCount(This
->wineD3DCubeTexture
);
138 static HRESULT WINAPI
IDirect3DCubeTexture9Impl_SetAutoGenFilterType(LPDIRECT3DCUBETEXTURE9 iface
, D3DTEXTUREFILTERTYPE FilterType
) {
139 IDirect3DCubeTexture9Impl
*This
= (IDirect3DCubeTexture9Impl
*)iface
;
140 TRACE("(%p) Relay\n", This
);
141 return IWineD3DCubeTexture_SetAutoGenFilterType(This
->wineD3DCubeTexture
, (WINED3DTEXTUREFILTERTYPE
) FilterType
);
144 static D3DTEXTUREFILTERTYPE WINAPI
IDirect3DCubeTexture9Impl_GetAutoGenFilterType(LPDIRECT3DCUBETEXTURE9 iface
) {
145 IDirect3DCubeTexture9Impl
*This
= (IDirect3DCubeTexture9Impl
*)iface
;
146 TRACE("(%p) Relay\n", This
);
147 return (D3DTEXTUREFILTERTYPE
) IWineD3DCubeTexture_GetAutoGenFilterType(This
->wineD3DCubeTexture
);
150 static void WINAPI
IDirect3DCubeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DCUBETEXTURE9 iface
) {
151 IDirect3DCubeTexture9Impl
*This
= (IDirect3DCubeTexture9Impl
*)iface
;
152 TRACE("(%p) Relay\n", This
);
153 return IWineD3DCubeTexture_GenerateMipSubLevels(This
->wineD3DCubeTexture
);
156 /* IDirect3DCubeTexture9 Interface follow: */
157 static HRESULT WINAPI
IDirect3DCubeTexture9Impl_GetLevelDesc(LPDIRECT3DCUBETEXTURE9 iface
, UINT Level
, D3DSURFACE_DESC
* pDesc
) {
158 IDirect3DCubeTexture9Impl
*This
= (IDirect3DCubeTexture9Impl
*)iface
;
159 WINED3DSURFACE_DESC wined3ddesc
;
162 TRACE("(%p) Relay\n", This
);
164 /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
165 wined3ddesc
.Format
= (WINED3DFORMAT
*)&pDesc
->Format
;
166 wined3ddesc
.Type
= (WINED3DRESOURCETYPE
*) &pDesc
->Type
;
167 wined3ddesc
.Usage
= &pDesc
->Usage
;
168 wined3ddesc
.Pool
= (WINED3DPOOL
*) &pDesc
->Pool
;
169 wined3ddesc
.Size
= &tmpInt
;
170 wined3ddesc
.MultiSampleType
= (WINED3DMULTISAMPLE_TYPE
*) &pDesc
->MultiSampleType
;
171 wined3ddesc
.MultiSampleQuality
= &pDesc
->MultiSampleQuality
;
172 wined3ddesc
.Width
= &pDesc
->Width
;
173 wined3ddesc
.Height
= &pDesc
->Height
;
175 return IWineD3DCubeTexture_GetLevelDesc(This
->wineD3DCubeTexture
, Level
, &wined3ddesc
);
178 static HRESULT WINAPI
IDirect3DCubeTexture9Impl_GetCubeMapSurface(LPDIRECT3DCUBETEXTURE9 iface
, D3DCUBEMAP_FACES FaceType
, UINT Level
, IDirect3DSurface9
** ppCubeMapSurface
) {
179 IDirect3DCubeTexture9Impl
*This
= (IDirect3DCubeTexture9Impl
*)iface
;
180 HRESULT hrc
= D3D_OK
;
181 IWineD3DSurface
*mySurface
= NULL
;
183 TRACE("(%p) Relay\n", This
);
185 hrc
= IWineD3DCubeTexture_GetCubeMapSurface(This
->wineD3DCubeTexture
, (WINED3DCUBEMAP_FACES
) FaceType
, Level
, &mySurface
);
186 if (hrc
== D3D_OK
&& NULL
!= ppCubeMapSurface
) {
187 IWineD3DCubeTexture_GetParent(mySurface
, (IUnknown
**)ppCubeMapSurface
);
188 IWineD3DCubeTexture_Release(mySurface
);
193 static HRESULT WINAPI
IDirect3DCubeTexture9Impl_LockRect(LPDIRECT3DCUBETEXTURE9 iface
, D3DCUBEMAP_FACES FaceType
, UINT Level
, D3DLOCKED_RECT
* pLockedRect
, CONST RECT
* pRect
, DWORD Flags
) {
194 IDirect3DCubeTexture9Impl
*This
= (IDirect3DCubeTexture9Impl
*)iface
;
195 TRACE("(%p) Relay\n", This
);
196 return IWineD3DCubeTexture_LockRect(This
->wineD3DCubeTexture
, (WINED3DCUBEMAP_FACES
) FaceType
, Level
, (WINED3DLOCKED_RECT
*) pLockedRect
, pRect
, Flags
);
199 static HRESULT WINAPI
IDirect3DCubeTexture9Impl_UnlockRect(LPDIRECT3DCUBETEXTURE9 iface
, D3DCUBEMAP_FACES FaceType
, UINT Level
) {
200 IDirect3DCubeTexture9Impl
*This
= (IDirect3DCubeTexture9Impl
*)iface
;
201 TRACE("(%p) Relay\n", This
);
202 return IWineD3DCubeTexture_UnlockRect(This
->wineD3DCubeTexture
, (WINED3DCUBEMAP_FACES
) FaceType
, Level
);
205 static HRESULT WINAPI
IDirect3DCubeTexture9Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE9 iface
, D3DCUBEMAP_FACES FaceType
, CONST RECT
* pDirtyRect
) {
206 IDirect3DCubeTexture9Impl
*This
= (IDirect3DCubeTexture9Impl
*)iface
;
207 TRACE("(%p) Relay\n", This
);
208 return IWineD3DCubeTexture_AddDirtyRect(This
->wineD3DCubeTexture
, (WINED3DCUBEMAP_FACES
) FaceType
, pDirtyRect
);
212 static const IDirect3DCubeTexture9Vtbl Direct3DCubeTexture9_Vtbl
=
215 IDirect3DCubeTexture9Impl_QueryInterface
,
216 IDirect3DCubeTexture9Impl_AddRef
,
217 IDirect3DCubeTexture9Impl_Release
,
218 /* IDirect3DResource9 */
219 IDirect3DCubeTexture9Impl_GetDevice
,
220 IDirect3DCubeTexture9Impl_SetPrivateData
,
221 IDirect3DCubeTexture9Impl_GetPrivateData
,
222 IDirect3DCubeTexture9Impl_FreePrivateData
,
223 IDirect3DCubeTexture9Impl_SetPriority
,
224 IDirect3DCubeTexture9Impl_GetPriority
,
225 IDirect3DCubeTexture9Impl_PreLoad
,
226 IDirect3DCubeTexture9Impl_GetType
,
227 /* IDirect3DBaseTexture9 */
228 IDirect3DCubeTexture9Impl_SetLOD
,
229 IDirect3DCubeTexture9Impl_GetLOD
,
230 IDirect3DCubeTexture9Impl_GetLevelCount
,
231 IDirect3DCubeTexture9Impl_SetAutoGenFilterType
,
232 IDirect3DCubeTexture9Impl_GetAutoGenFilterType
,
233 IDirect3DCubeTexture9Impl_GenerateMipSubLevels
,
234 IDirect3DCubeTexture9Impl_GetLevelDesc
,
235 IDirect3DCubeTexture9Impl_GetCubeMapSurface
,
236 IDirect3DCubeTexture9Impl_LockRect
,
237 IDirect3DCubeTexture9Impl_UnlockRect
,
238 IDirect3DCubeTexture9Impl_AddDirtyRect
244 /* IDirect3DDevice9 IDirect3DCubeTexture9 Methods follow: */
245 HRESULT WINAPI
IDirect3DDevice9Impl_CreateCubeTexture(LPDIRECT3DDEVICE9 iface
,
246 UINT EdgeLength
, UINT Levels
, DWORD Usage
,
247 D3DFORMAT Format
, D3DPOOL Pool
,
248 IDirect3DCubeTexture9
** ppCubeTexture
, HANDLE
* pSharedHandle
) {
250 IDirect3DCubeTexture9Impl
*object
;
251 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
254 TRACE("(%p) : ELen(%d) Lvl(%d) Usage(%d) fmt(%u), Pool(%d) Shared(%p)\n", This
, EdgeLength
, Levels
, Usage
, Format
, Pool
, pSharedHandle
);
256 /* Allocate the storage for the device */
257 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
259 if (NULL
== object
) {
260 FIXME("(%p) allocation of CubeTexture failed\n", This
);
261 return D3DERR_OUTOFVIDEOMEMORY
;
263 object
->lpVtbl
= &Direct3DCubeTexture9_Vtbl
;
265 hr
= IWineD3DDevice_CreateCubeTexture(This
->WineD3DDevice
, EdgeLength
, Levels
, Usage
,
266 (WINED3DFORMAT
)Format
, (WINED3DPOOL
) Pool
, &object
->wineD3DCubeTexture
, pSharedHandle
, (IUnknown
*)object
,
267 D3D9CB_CreateSurface
);
272 FIXME("(%p) call to IWineD3DDevice_CreateCubeTexture failed\n", This
);
273 HeapFree(GetProcessHeap(), 0, object
);
275 IUnknown_AddRef(iface
);
276 object
->parentDevice
= iface
;
277 *ppCubeTexture
= (LPDIRECT3DCUBETEXTURE9
) object
;
278 TRACE("(%p) : Created cube texture %p\n", This
, object
);
281 TRACE("(%p) returning %p\n",This
, *ppCubeTexture
);