Added a stub for NetStatisticsGet.
[wine] / dlls / d3d9 / texture.c
1 /*
2  * IDirect3DTexture9 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 #define NONAMELESSUNION
25 #define NONAMELESSSTRUCT
26 #include <stdarg.h>
27
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 /* IDirect3DTexture9 IUnknown parts follow: */
39 HRESULT WINAPI IDirect3DTexture9Impl_QueryInterface(LPDIRECT3DTEXTURE9 iface, REFIID riid, LPVOID* ppobj) {
40     ICOM_THIS(IDirect3DTexture9Impl,iface);
41
42     if (IsEqualGUID(riid, &IID_IUnknown)
43         || IsEqualGUID(riid, &IID_IDirect3DResource9)
44         || IsEqualGUID(riid, &IID_IDirect3DBaseTexture9)
45         || IsEqualGUID(riid, &IID_IDirect3DTexture9)) {
46         IDirect3DTexture9Impl_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 IDirect3DTexture9Impl_AddRef(LPDIRECT3DTEXTURE9 iface) {
56     ICOM_THIS(IDirect3DTexture9Impl,iface);
57     TRACE("(%p) : AddRef from %ld\n", This, This->ref);
58     return ++(This->ref);
59 }
60
61 ULONG WINAPI IDirect3DTexture9Impl_Release(LPDIRECT3DTEXTURE9 iface) {
62     ICOM_THIS(IDirect3DTexture9Impl,iface);
63     ULONG ref = --This->ref;
64     int i;
65
66     TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
67     if (ref == 0) {
68         for (i = 0; i < This->levels; i++) {
69             if (NULL != This->surfaces[i]) {
70                 TRACE("(%p) : Releasing surface %p\n", This, This->surfaces[i]);
71                 IDirect3DSurface9Impl_Release((LPDIRECT3DSURFACE9) This->surfaces[i]);
72             }
73         }
74         HeapFree(GetProcessHeap(), 0, This);
75     }
76     return ref;
77 }
78
79 /* IDirect3DTexture9 IDirect3DResource9 Interface follow: */
80 HRESULT WINAPI IDirect3DTexture9Impl_GetDevice(LPDIRECT3DTEXTURE9 iface, IDirect3DDevice9** ppDevice) {
81     ICOM_THIS(IDirect3DTexture9Impl,iface);
82     return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
83 }
84
85 HRESULT WINAPI IDirect3DTexture9Impl_SetPrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
86     ICOM_THIS(IDirect3DTexture9Impl,iface);
87     FIXME("(%p) : stub\n", This);
88     return D3D_OK;
89 }
90
91 HRESULT WINAPI IDirect3DTexture9Impl_GetPrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
92     ICOM_THIS(IDirect3DTexture9Impl,iface);
93     FIXME("(%p) : stub\n", This);
94     return D3D_OK;
95 }
96
97 HRESULT WINAPI IDirect3DTexture9Impl_FreePrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid) {
98     ICOM_THIS(IDirect3DTexture9Impl,iface);
99     FIXME("(%p) : stub\n", This);
100     return D3D_OK;
101 }
102
103 DWORD WINAPI IDirect3DTexture9Impl_SetPriority(LPDIRECT3DTEXTURE9 iface, DWORD PriorityNew) {
104     ICOM_THIS(IDirect3DTexture9Impl,iface);
105     return IDirect3DResource9Impl_SetPriority((LPDIRECT3DRESOURCE9) This, PriorityNew);
106 }
107
108 DWORD WINAPI IDirect3DTexture9Impl_GetPriority(LPDIRECT3DTEXTURE9 iface) {
109     ICOM_THIS(IDirect3DTexture9Impl,iface);
110     return IDirect3DResource9Impl_GetPriority((LPDIRECT3DRESOURCE9) This);
111 }
112
113 void WINAPI IDirect3DTexture9Impl_PreLoad(LPDIRECT3DTEXTURE9 iface) {
114     ICOM_THIS(IDirect3DTexture9Impl,iface);
115     FIXME("(%p) : stub\n", This);
116     return ;
117 }
118
119 D3DRESOURCETYPE WINAPI IDirect3DTexture9Impl_GetType(LPDIRECT3DTEXTURE9 iface) {
120     ICOM_THIS(IDirect3DTexture9Impl,iface);
121     return IDirect3DResource9Impl_GetType((LPDIRECT3DRESOURCE9) This);
122 }
123
124 /* IDirect3DTexture9 IDirect3DBaseTexture9 Interface follow: */
125 DWORD WINAPI IDirect3DTexture9Impl_SetLOD(LPDIRECT3DTEXTURE9 iface, DWORD LODNew) {
126     ICOM_THIS(IDirect3DTexture9Impl,iface);
127     return IDirect3DBaseTexture9Impl_SetLOD((LPDIRECT3DBASETEXTURE9) This, LODNew);
128 }
129
130 DWORD WINAPI IDirect3DTexture9Impl_GetLOD(LPDIRECT3DTEXTURE9 iface) {
131     ICOM_THIS(IDirect3DTexture9Impl,iface);
132     return IDirect3DBaseTexture9Impl_GetLOD((LPDIRECT3DBASETEXTURE9) This);
133 }
134
135 DWORD WINAPI IDirect3DTexture9Impl_GetLevelCount(LPDIRECT3DTEXTURE9 iface) {
136     ICOM_THIS(IDirect3DTexture9Impl,iface);
137     return IDirect3DBaseTexture9Impl_GetLevelCount((LPDIRECT3DBASETEXTURE9) This);
138 }
139
140 HRESULT WINAPI IDirect3DTexture9Impl_SetAutoGenFilterType(LPDIRECT3DTEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType) {
141     ICOM_THIS(IDirect3DTexture9Impl,iface);
142     return IDirect3DBaseTexture9Impl_SetAutoGenFilterType((LPDIRECT3DBASETEXTURE9) This, FilterType);
143 }
144
145 D3DTEXTUREFILTERTYPE WINAPI IDirect3DTexture9Impl_GetAutoGenFilterType(LPDIRECT3DTEXTURE9 iface) {
146     ICOM_THIS(IDirect3DTexture9Impl,iface);
147     return IDirect3DBaseTexture9Impl_GetAutoGenFilterType((LPDIRECT3DBASETEXTURE9) This);
148 }
149
150 void WINAPI IDirect3DTexture9Impl_GenerateMipSubLevels(LPDIRECT3DTEXTURE9 iface) {
151     ICOM_THIS(IDirect3DTexture9Impl,iface);
152     FIXME("(%p) : stub\n", This);
153     return ;
154 }
155
156 /* IDirect3DTexture9 Interface follow: */
157 HRESULT WINAPI IDirect3DTexture9Impl_GetLevelDesc(LPDIRECT3DTEXTURE9 iface, UINT Level, D3DSURFACE_DESC* pDesc) {
158     ICOM_THIS(IDirect3DTexture9Impl,iface);
159
160     if (Level < This->levels) {
161         TRACE("(%p) Level (%d)\n", This, Level);
162         return IDirect3DSurface9Impl_GetDesc((LPDIRECT3DSURFACE9) This->surfaces[Level], pDesc);
163     } else {
164         FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
165         return D3DERR_INVALIDCALL;
166     }
167     return D3D_OK;
168 }
169
170 HRESULT WINAPI IDirect3DTexture9Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE9 iface, UINT Level, IDirect3DSurface9** ppSurfaceLevel) {
171     ICOM_THIS(IDirect3DTexture9Impl,iface);
172     *ppSurfaceLevel = (LPDIRECT3DSURFACE9) This->surfaces[Level];
173     IDirect3DSurface9Impl_AddRef((LPDIRECT3DSURFACE9) This->surfaces[Level]);
174     TRACE("(%p) : returning %p for level %d\n", This, *ppSurfaceLevel, Level);
175     return D3D_OK;
176 }
177
178 HRESULT WINAPI IDirect3DTexture9Impl_LockRect(LPDIRECT3DTEXTURE9 iface, UINT Level,D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
179     HRESULT hr;
180     ICOM_THIS(IDirect3DTexture9Impl,iface);
181     if (Level < This->levels) {
182         /**
183          * Not dirtified while Surfaces don't notify dirtification
184          * This->impl.parent.Dirty = TRUE;
185          */
186         hr = IDirect3DSurface9Impl_LockRect((LPDIRECT3DSURFACE9) This->surfaces[Level], pLockedRect, pRect, Flags);
187         TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
188     } else {
189         FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
190         return D3DERR_INVALIDCALL;
191     }
192     return hr;
193 }
194
195 HRESULT WINAPI IDirect3DTexture9Impl_UnlockRect(LPDIRECT3DTEXTURE9 iface, UINT Level) {
196     HRESULT hr;
197     ICOM_THIS(IDirect3DTexture9Impl,iface);
198     if (Level < This->levels) {
199         hr = IDirect3DSurface9Impl_UnlockRect((LPDIRECT3DSURFACE9) This->surfaces[Level]);
200         TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
201     } else {
202         FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
203         return D3DERR_INVALIDCALL;
204     }
205     return hr;
206 }
207
208 HRESULT WINAPI IDirect3DTexture9Impl_AddDirtyRect(LPDIRECT3DTEXTURE9 iface, CONST RECT* pDirtyRect) {
209     ICOM_THIS(IDirect3DTexture9Impl,iface);
210     FIXME("(%p) : stub\n", This);
211     This->Dirty = TRUE;
212     return D3D_OK;
213 }
214
215
216 ICOM_VTABLE(IDirect3DTexture9) Direct3DTexture9_Vtbl =
217 {
218     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
219     IDirect3DTexture9Impl_QueryInterface,
220     IDirect3DTexture9Impl_AddRef,
221     IDirect3DTexture9Impl_Release,
222     IDirect3DTexture9Impl_GetDevice,
223     IDirect3DTexture9Impl_SetPrivateData,
224     IDirect3DTexture9Impl_GetPrivateData,
225     IDirect3DTexture9Impl_FreePrivateData,
226     IDirect3DTexture9Impl_SetPriority,
227     IDirect3DTexture9Impl_GetPriority,
228     IDirect3DTexture9Impl_PreLoad,
229     IDirect3DTexture9Impl_GetType,
230     IDirect3DTexture9Impl_SetLOD,
231     IDirect3DTexture9Impl_GetLOD,
232     IDirect3DTexture9Impl_GetLevelCount,
233     IDirect3DTexture9Impl_SetAutoGenFilterType,
234     IDirect3DTexture9Impl_GetAutoGenFilterType,
235     IDirect3DTexture9Impl_GenerateMipSubLevels,
236     IDirect3DTexture9Impl_GetLevelDesc,
237     IDirect3DTexture9Impl_GetSurfaceLevel,
238     IDirect3DTexture9Impl_LockRect,
239     IDirect3DTexture9Impl_UnlockRect,
240     IDirect3DTexture9Impl_AddDirtyRect
241 };
242
243
244 /* IDirect3DDevice9 IDirect3DTexture9 Methods follow: */
245 HRESULT  WINAPI  IDirect3DDevice9Impl_CreateTexture(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, UINT Levels, DWORD Usage,
246                                                     D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle) {
247     ICOM_THIS(IDirect3DDevice9Impl,iface);
248     FIXME("(%p) : stub\n", This);    
249     return D3D_OK;
250 }