ReactOS  0.4.15-dev-499-g1f31905
d3d9_mipmap.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS ReactX
4  * FILE: dll/directx/d3d9/d3d9_mipmap.c
5  * PURPOSE: d3d9.dll internal mip map surface functions
6  * PROGRAMERS: Gregor Gullwi <gbrunmar (dot) ros (at) gmail (dot) com>
7  */
8 #include "d3d9_mipmap.h"
9 #include "debug.h"
10 #include "d3d9_texture.h"
11 #include "d3d9_device.h"
12 #include "d3d9_helpers.h"
13 #include <d3d9.h>
14 
15 #define LOCK_D3DDEVICE9() D3D9BaseObject_LockDevice(&This->BaseTexture.BaseResource.BaseObject)
16 #define UNLOCK_D3DDEVICE9() D3D9BaseObject_UnlockDevice(&This->BaseTexture.BaseResource.BaseObject)
17 
18 /* Convert a IDirect3DTexture9 pointer safely to the internal implementation struct */
20 {
21  if (NULL == iface)
22  return NULL;
23 
24  return (LPD3D9MIPMAP)((ULONG_PTR)iface - FIELD_OFFSET(D3D9MipMap, lpVtbl));
25 }
26 
27 /* IUnknown */
29 {
31 
32  if (IsEqualGUID(riid, &IID_IUnknown) ||
33  IsEqualGUID(riid, &IID_IDirect3DTexture9) ||
34  IsEqualGUID(riid, &IID_IDirect3DBaseTexture9) ||
35  IsEqualGUID(riid, &IID_IDirect3DResource9))
36  {
37  IUnknown_AddRef(iface);
38  *ppvObject = &This->lpVtbl;
39  return D3D_OK;
40  }
41 
42  *ppvObject = NULL;
43  return E_NOINTERFACE;
44 }
45 
47 {
49  return D3D9BaseObject_AddRef(&This->BaseTexture.BaseResource.BaseObject);
50 }
51 
53 {
55  return D3D9BaseObject_Release(&This->BaseTexture.BaseResource.BaseObject);
56 }
57 
58 /* IDirect3DResource9 */
59 
60 /*++
61 * @name IDirect3DTexture9::GetDevice
62 * @implemented
63 *
64 * The function D3D9MipMap_GetDevice sets the ppDevice argument
65 * to the device connected to create the swap chain.
66 *
67 * @param LPDIRECT3DTEXTURE9 iface
68 * Pointer to a IDirect3DTexture9 object returned from IDirect3D9Device::CreateTexture()
69 *
70 * @param IDirect3DDevice9** ppDevice
71 * Pointer to a IDirect3DDevice9* structure to be set to the device object.
72 *
73 * @return HRESULT
74 * If the method successfully sets the ppDevice value, the return value is D3D_OK.
75 * If ppDevice is a bad pointer the return value will be D3DERR_INVALIDCALL.
76 * If the texture didn't contain any device, the return value will be D3DERR_INVALIDDEVICE.
77 *
78 */
79 HRESULT WINAPI D3D9MipMap_GetDevice(LPDIRECT3DTEXTURE9 iface, IDirect3DDevice9** ppDevice)
80 {
83 
84  if (NULL == ppDevice)
85  {
86  DPRINT1("Invalid ppDevice parameter specified");
88  return D3DERR_INVALIDCALL;
89  }
90 
91  if (FAILED(D3D9BaseObject_GetDevice(&This->BaseTexture.BaseResource.BaseObject, ppDevice)))
92  {
93  DPRINT1("Invalid This parameter specified");
95  return D3DERR_INVALIDDEVICE;
96  }
97 
99  return D3D_OK;
100 }
101 
103 {
105  return D3D_OK;
106 }
107 
109 {
111  return D3D_OK;
112 }
113 
115 {
117  return D3D_OK;
118 }
119 
121 {
123  return 0;
124 }
125 
127 {
129  return 0;
130 }
131 
133 {
135 }
136 
137 /* IDirect3DBaseTexture9 */
139 {
141  return D3DRTYPE_TEXTURE;
142 }
143 
145 {
147  return 0;
148 }
149 
150 /*++
151 * @name IDirect3DTexture9::GetLOD
152 * @implemented
153 *
154 * The function D3D9MipMap_GetLOD returns the number
155 * max LODs for the specified texture, if it's managed.
156 *
157 * @param LPDIRECT3DTEXTURE9 iface
158 * Pointer to a IDirect3DTexture9 object returned from IDirect3D9Device::CreateTexture().
159 *
160 * @return DWORD
161 * Returns the number of LODs in the specified texture if it's managed.
162 *
163 */
165 {
167  return D3D9Texture_GetLOD( (IDirect3DBaseTexture9*)&This->BaseTexture.lpVtbl );
168 }
169 
170 /*++
171 * @name IDirect3DTexture9::GetLevelCount
172 * @implemented
173 *
174 * The function D3D9MipMap_GetLevelCount returns the number of mip map levels
175 * in the specified texture.
176 *
177 * @param LPDIRECT3DTEXTURE9 iface
178 * Pointer to a IDirect3DTexture9 object returned from IDirect3D9Device::CreateTexture().
179 *
180 * @return DWORD
181 * Returns the number of levels in the specified texture.
182 *
183 */
185 {
187  return D3D9Texture_GetLevelCount( (IDirect3DBaseTexture9*)&This->BaseTexture.lpVtbl );
188 }
189 
191 {
193  return D3D_OK;
194 }
195 
196 /*++
197 * @name IDirect3DTexture9::GetAutoGenFilterType
198 * @implemented
199 *
200 * The function D3D9MipMap_GetAutoGenFilterType returns filter type
201 * that is used when automated mipmaping is set.
202 *
203 * @param LPDIRECT3DTEXTURE9 iface
204 * Pointer to a IDirect3DTexture9 object returned from IDirect3D9Device::CreateTexture().
205 *
206 * @return D3DTEXTUREFILTERTYPE
207 * Filter type used when automated mipmaping is set for the specified texture.
208 *
209 */
211 {
213  return D3D9Texture_GetAutoGenFilterType( (IDirect3DBaseTexture9*)&This->BaseTexture.lpVtbl );
214 }
215 
217 {
219 }
220 
221 /* IDirect3DTexture9 */
223 {
225  return D3D_OK;
226 }
227 
228 HRESULT WINAPI D3D9MipMap_GetSurfaceLevel(LPDIRECT3DTEXTURE9 iface, UINT Level, IDirect3DSurface9** ppSurfaceLevel)
229 {
231  return D3D_OK;
232 }
233 
235 {
237  return D3D_OK;
238 }
239 
241 {
243  return D3D_OK;
244 }
245 
247 {
249  return D3D_OK;
250 }
251 
252 #if !defined(__cplusplus) || defined(CINTERFACE)
253 static IDirect3DTexture9Vtbl D3D9MipMap_Vtbl =
254 {
255  /* IUnknown methods */
259 
260  /* IDirect3DBaseTexture9 methods */
268 
269  /* IDirect3DBaseTexture9 methods */
277 
278  /* IDirect3DTexture9 methods */
284 };
285 #endif // !defined(__cplusplus) || defined(CINTERFACE)
286 
287 HRESULT CreateD3D9MipMap(DIRECT3DDEVICE9_INT* pDevice, UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture)
288 {
289  LPD3D9MIPMAP pThisTexture;
290  if (FAILED(AlignedAlloc((LPVOID*)&pThisTexture, sizeof(D3D9MipMap))))
291  {
292  DPRINT1("Could not create D3D9MipMap");
293  return E_OUTOFMEMORY;
294  }
295 
296  InitDirect3DBaseTexture9(&pThisTexture->BaseTexture, (IDirect3DBaseTexture9Vtbl*)&D3D9MipMap_Vtbl, Usage, Levels, Format, Pool, pDevice, RT_EXTERNAL);
297 
298  pThisTexture->lpVtbl = &D3D9MipMap_Vtbl;
299 
300  pThisTexture->Usage = Usage;
301  pThisTexture->dwWidth = Width;
302  pThisTexture->dwHeight = Height;
303  pThisTexture->Format = Format;
304 
305  *ppTexture = (IDirect3DTexture9*)&pThisTexture->lpVtbl;
306 
308  return D3D_OK;
309 }
D3DRESOURCETYPE WINAPI D3D9MipMap_GetType(LPDIRECT3DTEXTURE9 iface)
Definition: d3d9_mipmap.c:138
DWORD WINAPI D3D9Texture_GetLevelCount(LPDIRECT3DBASETEXTURE9 iface)
Definition: d3d9_texture.c:111
ULONG D3D9BaseObject_AddRef(D3D9BaseObject *pBaseObject)
DWORD WINAPI D3D9MipMap_GetLevelCount(LPDIRECT3DTEXTURE9 iface)
Definition: d3d9_mipmap.c:184
#define REFIID
Definition: guiddef.h:118
#define E_NOINTERFACE
Definition: winerror.h:2364
HRESULT WINAPI D3D9MipMap_LockRect(LPDIRECT3DTEXTURE9 iface, UINT Level, D3DLOCKED_RECT *pLockedRect, CONST RECT *pRect, DWORD Flags)
Definition: d3d9_mipmap.c:234
Definition: scsiwmi.h:51
static HRESULT WINAPI D3D9MipMap_QueryInterface(LPDIRECT3DTEXTURE9 iface, REFIID riid, void **ppvObject)
Definition: d3d9_mipmap.c:28
#define LOCK_D3DDEVICE9()
Definition: d3d9_mipmap.c:15
REFIID riid
Definition: precomp.h:44
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:382
LPD3D9MIPMAP IDirect3DTexture9ToImpl(LPDIRECT3DTEXTURE9 iface)
Definition: d3d9_mipmap.c:19
ULONG WINAPI D3D9MipMap_Release(LPDIRECT3DTEXTURE9 iface)
Definition: d3d9_mipmap.c:52
enum _D3DPOOL D3DPOOL
DWORD WINAPI D3D9Texture_GetLOD(LPDIRECT3DBASETEXTURE9 iface)
Definition: d3d9_texture.c:84
#define D3DERR_INVALIDCALL
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
HRESULT WINAPI D3D9MipMap_GetPrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData)
Definition: d3d9_mipmap.c:108
ULONG D3D9BaseObject_Release(D3D9BaseObject *pBaseObject)
HRESULT WINAPI D3D9MipMap_SetPrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags)
Definition: d3d9_mipmap.c:102
void WINAPI D3D9MipMap_GenerateMipSubLevels(LPDIRECT3DTEXTURE9 iface)
Definition: d3d9_mipmap.c:216
#define D3DERR_INVALIDDEVICE
Definition: d3d8.h:86
struct IDirect3DTexture9 * LPDIRECT3DTEXTURE9
Definition: d3d9.h:160
HRESULT WINAPI D3D9MipMap_GetLevelDesc(LPDIRECT3DTEXTURE9 iface, UINT Level, D3DSURFACE_DESC *pDesc)
Definition: d3d9_mipmap.c:222
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT D3D9BaseObject_GetDevice(D3D9BaseObject *pBaseObject, IDirect3DDevice9 **ppDevice)
HRESULT WINAPI D3D9MipMap_GetSurfaceLevel(LPDIRECT3DTEXTURE9 iface, UINT Level, IDirect3DSurface9 **ppSurfaceLevel)
Definition: d3d9_mipmap.c:228
smooth NULL
Definition: ftsmooth.c:416
HRESULT AlignedAlloc(IN OUT LPVOID *ppObject, IN SIZE_T dwSize)
Definition: d3d9_helpers.c:95
enum _D3DFORMAT D3DFORMAT
DWORD WINAPI D3D9MipMap_SetPriority(LPDIRECT3DTEXTURE9 iface, DWORD PriorityNew)
Definition: d3d9_mipmap.c:120
HRESULT CreateD3D9MipMap(DIRECT3DDEVICE9_INT *pDevice, UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9 **ppTexture)
Definition: d3d9_mipmap.c:287
static IDirect3DTexture9Vtbl D3D9MipMap_Vtbl
Definition: d3d9_mipmap.c:253
HRESULT WINAPI D3D9MipMap_UnlockRect(LPDIRECT3DTEXTURE9 iface, UINT Level)
Definition: d3d9_mipmap.c:240
ULONG WINAPI D3D9MipMap_AddRef(LPDIRECT3DTEXTURE9 iface)
Definition: d3d9_mipmap.c:46
LONG HRESULT
Definition: typedefs.h:78
const GUID IID_IUnknown
#define WINAPI
Definition: msvc.h:6
Definition: bufpool.h:50
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI D3D9MipMap_SetLOD(LPDIRECT3DTEXTURE9 iface, DWORD LODNew)
Definition: d3d9_mipmap.c:144
void WINAPI D3D9MipMap_PreLoad(LPDIRECT3DTEXTURE9 iface)
Definition: d3d9_mipmap.c:132
REFIID LPVOID * ppvObject
Definition: precomp.h:44
D3DTEXTUREFILTERTYPE WINAPI D3D9MipMap_GetAutoGenFilterType(LPDIRECT3DTEXTURE9 iface)
Definition: d3d9_mipmap.c:210
HRESULT WINAPI D3D9MipMap_FreePrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid)
Definition: d3d9_mipmap.c:114
DWORD WINAPI D3D9MipMap_GetPriority(LPDIRECT3DTEXTURE9 iface)
Definition: d3d9_mipmap.c:126
HRESULT WINAPI D3D9MipMap_SetAutoGenFilterType(LPDIRECT3DTEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType)
Definition: d3d9_mipmap.c:190
#define D3D_OK
Definition: d3d.h:106
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
DWORD WINAPI D3D9MipMap_GetLOD(LPDIRECT3DTEXTURE9 iface)
Definition: d3d9_mipmap.c:164
#define DPRINT1
Definition: precomp.h:8
enum _D3DTEXTUREFILTERTYPE D3DTEXTUREFILTERTYPE
#define UNLOCK_D3DDEVICE9()
Definition: d3d9_mipmap.c:16
unsigned int ULONG
Definition: retypes.h:1
#define UNIMPLEMENTED
Definition: debug.h:115
#define ULONG_PTR
Definition: config.h:101
D3DTEXTUREFILTERTYPE WINAPI D3D9Texture_GetAutoGenFilterType(LPDIRECT3DBASETEXTURE9 iface)
Definition: d3d9_texture.c:58
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
HRESULT WINAPI D3D9MipMap_AddDirtyRect(LPDIRECT3DTEXTURE9 iface, CONST RECT *pDirtyRect)
Definition: d3d9_mipmap.c:246
#define CONST
Definition: pedump.c:81
enum _D3DRESOURCETYPE D3DRESOURCETYPE
HRESULT WINAPI D3D9MipMap_GetDevice(LPDIRECT3DTEXTURE9 iface, IDirect3DDevice9 **ppDevice)
Definition: d3d9_mipmap.c:79
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char * Format
Definition: acpixf.h:1216
void InitDirect3DBaseTexture9(Direct3DBaseTexture9_INT *pBaseTexture, IDirect3DBaseTexture9Vtbl *pVtbl, DWORD Usage, UINT Levels, D3DFORMAT Format, D3DPOOL Pool, struct _Direct3DDevice9_INT *pDevice, enum REF_TYPE RefType)
Definition: d3d9_texture.c:22