Add support for .gnu_debuglink.
[wine] / dlls / d3d9 / cubetexture.c
1 /*
2  * IDirect3DCubeTexture9 implementation
3  *
4  * Copyright 2002-2003 Jason Edmeades
5  *                     Raphael Junqueira
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #include "config.h"
23
24 #include <stdarg.h>
25
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winuser.h"
31 #include "wingdi.h"
32 #include "wine/debug.h"
33
34 #include "d3d9_private.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
37
38 /* IDirect3DCubeTexture9 IUnknown parts follow: */
39 HRESULT WINAPI IDirect3DCubeTexture9Impl_QueryInterface(LPDIRECT3DCUBETEXTURE9 iface, REFIID riid, LPVOID* ppobj) {
40     IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
41
42     if (IsEqualGUID(riid, &IID_IUnknown)
43         || IsEqualGUID(riid, &IID_IDirect3DResource9)
44         || IsEqualGUID(riid, &IID_IDirect3DBaseTexture9)
45         || IsEqualGUID(riid, &IID_IDirect3DCubeTexture9)) {
46         IDirect3DCubeTexture9Impl_AddRef(iface);
47         *ppobj = This;
48         return D3D_OK;
49     }
50
51     WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
52     return E_NOINTERFACE;
53 }
54
55 ULONG WINAPI IDirect3DCubeTexture9Impl_AddRef(LPDIRECT3DCUBETEXTURE9 iface) {
56     IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
57     TRACE("(%p) : AddRef from %ld\n", This, This->ref);
58     return ++(This->ref);
59 }
60
61 ULONG WINAPI IDirect3DCubeTexture9Impl_Release(LPDIRECT3DCUBETEXTURE9 iface) {
62     IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
63     ULONG ref = --This->ref;
64     unsigned int i, j;
65
66     TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
67     if (ref == 0) {
68         for (i = 0; i < This->levels; i++) {
69           for (j = 0; j < 6; j++) { 
70             if (This->surfaces[j][i] != NULL) {
71               TRACE("(%p) : Releasing surface %p\n", This, This->surfaces[j][i]);
72               IDirect3DSurface9Impl_Release((LPDIRECT3DSURFACE9) This->surfaces[j][i]);
73             }
74           }
75         }
76         HeapFree(GetProcessHeap(), 0, This);
77     }
78     return ref;
79 }
80
81 /* IDirect3DCubeTexture9 IDirect3DResource9 Interface follow: */
82 HRESULT WINAPI IDirect3DCubeTexture9Impl_GetDevice(LPDIRECT3DCUBETEXTURE9 iface, IDirect3DDevice9** ppDevice) {
83     IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
84     return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
85 }
86
87 HRESULT WINAPI IDirect3DCubeTexture9Impl_SetPrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
88     IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
89     FIXME("(%p) : stub\n", This);    
90     return D3D_OK;
91 }
92
93 HRESULT WINAPI IDirect3DCubeTexture9Impl_GetPrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
94     IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
95     FIXME("(%p) : stub\n", This);    
96     return D3D_OK;
97 }
98
99 HRESULT WINAPI IDirect3DCubeTexture9Impl_FreePrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid) {
100     IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
101     FIXME("(%p) : stub\n", This);    
102     return D3D_OK;
103 }
104
105 DWORD WINAPI IDirect3DCubeTexture9Impl_SetPriority(LPDIRECT3DCUBETEXTURE9 iface, DWORD PriorityNew) {
106     IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
107     return IDirect3DResource9Impl_SetPriority((LPDIRECT3DRESOURCE9) This, PriorityNew);
108 }
109
110 DWORD WINAPI IDirect3DCubeTexture9Impl_GetPriority(LPDIRECT3DCUBETEXTURE9 iface) {
111     IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
112     return IDirect3DResource9Impl_GetPriority((LPDIRECT3DRESOURCE9) This);
113 }
114
115 void WINAPI IDirect3DCubeTexture9Impl_PreLoad(LPDIRECT3DCUBETEXTURE9 iface) {
116     IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
117     FIXME("(%p) : stub\n", This);    
118     return ;
119 }
120
121 D3DRESOURCETYPE WINAPI IDirect3DCubeTexture9Impl_GetType(LPDIRECT3DCUBETEXTURE9 iface) {
122     IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
123     return IDirect3DResource9Impl_GetType((LPDIRECT3DRESOURCE9) This);
124 }
125
126 /* IDirect3DCubeTexture9 IDirect3DBaseTexture9 Interface follow: */
127 DWORD WINAPI IDirect3DCubeTexture9Impl_SetLOD(LPDIRECT3DCUBETEXTURE9 iface, DWORD LODNew) {
128     IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
129     return IDirect3DBaseTexture9Impl_SetLOD((LPDIRECT3DBASETEXTURE9) This, LODNew);
130 }
131
132 DWORD WINAPI IDirect3DCubeTexture9Impl_GetLOD(LPDIRECT3DCUBETEXTURE9 iface) {
133     IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
134     return IDirect3DBaseTexture9Impl_GetLOD((LPDIRECT3DBASETEXTURE9) This);
135 }
136
137 DWORD WINAPI IDirect3DCubeTexture9Impl_GetLevelCount(LPDIRECT3DCUBETEXTURE9 iface) {
138     IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
139     return IDirect3DBaseTexture9Impl_GetLevelCount((LPDIRECT3DBASETEXTURE9) This);
140 }
141
142 HRESULT WINAPI IDirect3DCubeTexture9Impl_SetAutoGenFilterType(LPDIRECT3DCUBETEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType) {
143   IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
144     return IDirect3DBaseTexture9Impl_SetAutoGenFilterType((LPDIRECT3DBASETEXTURE9) This, FilterType);
145 }
146
147 D3DTEXTUREFILTERTYPE WINAPI IDirect3DCubeTexture9Impl_GetAutoGenFilterType(LPDIRECT3DCUBETEXTURE9 iface) {
148   IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
149   return IDirect3DBaseTexture9Impl_GetAutoGenFilterType((LPDIRECT3DBASETEXTURE9) This);
150 }
151
152 void WINAPI IDirect3DCubeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DCUBETEXTURE9 iface) {
153   IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
154   FIXME("(%p) : stub\n", This);
155   return ;
156 }
157
158 /* IDirect3DCubeTexture9 Interface follow: */
159 HRESULT WINAPI IDirect3DCubeTexture9Impl_GetLevelDesc(LPDIRECT3DCUBETEXTURE9 iface, UINT Level, D3DSURFACE_DESC* pDesc) {
160     IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
161     if (Level < This->levels) {
162         TRACE("(%p) level (%d)\n", This, Level);
163         return IDirect3DSurface9Impl_GetDesc((LPDIRECT3DSURFACE9) This->surfaces[0][Level], pDesc);
164     } else {
165         FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
166         return D3DERR_INVALIDCALL;
167     }
168     return D3D_OK;
169 }
170
171 HRESULT WINAPI IDirect3DCubeTexture9Impl_GetCubeMapSurface(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface9** ppCubeMapSurface) {
172     IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
173     if (Level < This->levels) {
174         *ppCubeMapSurface = (LPDIRECT3DSURFACE9) This->surfaces[FaceType][Level];
175         IDirect3DSurface9Impl_AddRef((LPDIRECT3DSURFACE9) *ppCubeMapSurface);
176         TRACE("(%p) -> faceType(%d) level(%d) returning surface@%p \n", This, FaceType, Level, This->surfaces[FaceType][Level]);
177     } else {
178         FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
179         return D3DERR_INVALIDCALL;
180     }
181     return D3D_OK;
182 }
183
184 HRESULT WINAPI IDirect3DCubeTexture9Impl_LockRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
185     HRESULT hr;
186     IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
187     if (Level < This->levels) {
188       /**
189        * Not dirtified while Surfaces don't notify dirtification
190        * This->Dirty = TRUE;
191        */
192       hr = IDirect3DSurface9Impl_LockRect((LPDIRECT3DSURFACE9) This->surfaces[FaceType][Level], pLockedRect, pRect, Flags);
193       TRACE("(%p) -> faceType(%d) level(%d) returning memory@%p success(%lu)\n", This, FaceType, Level, pLockedRect->pBits, hr);
194     } else {
195       FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
196       return D3DERR_INVALIDCALL;
197     }
198     return hr;
199 }
200
201 HRESULT WINAPI IDirect3DCubeTexture9Impl_UnlockRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level) {
202     HRESULT hr;
203     IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
204     if (Level < This->levels) {
205       hr = IDirect3DSurface9Impl_UnlockRect((LPDIRECT3DSURFACE9) This->surfaces[FaceType][Level]);
206       TRACE("(%p) -> faceType(%d) level(%d) success(%lu)\n", This, FaceType, Level, hr);
207     } else {
208       FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
209       return D3DERR_INVALIDCALL;
210     }
211     return hr;
212 }
213
214 HRESULT  WINAPI IDirect3DCubeTexture9Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect) {
215     IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
216     FIXME("(%p) : stub\n", This);
217     This->Dirty = TRUE;
218     return D3D_OK;
219 }
220
221
222 IDirect3DCubeTexture9Vtbl Direct3DCubeTexture9_Vtbl =
223 {
224     IDirect3DCubeTexture9Impl_QueryInterface,
225     IDirect3DCubeTexture9Impl_AddRef,
226     IDirect3DCubeTexture9Impl_Release,
227     IDirect3DCubeTexture9Impl_GetDevice,
228     IDirect3DCubeTexture9Impl_SetPrivateData,
229     IDirect3DCubeTexture9Impl_GetPrivateData,
230     IDirect3DCubeTexture9Impl_FreePrivateData,
231     IDirect3DCubeTexture9Impl_SetPriority,
232     IDirect3DCubeTexture9Impl_GetPriority,
233     IDirect3DCubeTexture9Impl_PreLoad,
234     IDirect3DCubeTexture9Impl_GetType,
235     IDirect3DCubeTexture9Impl_SetLOD,
236     IDirect3DCubeTexture9Impl_GetLOD,
237     IDirect3DCubeTexture9Impl_GetLevelCount,
238     IDirect3DCubeTexture9Impl_SetAutoGenFilterType,
239     IDirect3DCubeTexture9Impl_GetAutoGenFilterType,
240     IDirect3DCubeTexture9Impl_GenerateMipSubLevels,
241     IDirect3DCubeTexture9Impl_GetLevelDesc,
242     IDirect3DCubeTexture9Impl_GetCubeMapSurface,
243     IDirect3DCubeTexture9Impl_LockRect,
244     IDirect3DCubeTexture9Impl_UnlockRect,
245     IDirect3DCubeTexture9Impl_AddDirtyRect
246 };
247
248
249 /* IDirect3DDevice9 IDirect3DCubeTexture9 Methods follow: */
250 HRESULT  WINAPI  IDirect3DDevice9Impl_CreateCubeTexture(LPDIRECT3DDEVICE9 iface, 
251                                                         UINT EdgeLength, UINT Levels, DWORD Usage, 
252                                                         D3DFORMAT Format, D3DPOOL Pool, 
253                                                         IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle) {
254
255     IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
256     FIXME("(%p) : stub\n", This);
257     return D3D_OK;
258 }