ReactOS 0.4.15-dev-7889-g76290a6
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
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*/
79HRESULT 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");
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
228HRESULT 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)
253static 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
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}
#define DPRINT1
Definition: precomp.h:8
const GUID IID_IUnknown
#define UNIMPLEMENTED
Definition: debug.h:115
Definition: bufpool.h:50
enum _D3DRESOURCETYPE D3DRESOURCETYPE
@ D3DRTYPE_TEXTURE
Definition: d3d8types.h:812
enum _D3DPOOL D3DPOOL
enum _D3DFORMAT D3DFORMAT
enum _D3DTEXTUREFILTERTYPE D3DTEXTUREFILTERTYPE
struct IDirect3DTexture9 * LPDIRECT3DTEXTURE9
Definition: d3d9.h:160
HRESULT D3D9BaseObject_GetDevice(D3D9BaseObject *pBaseObject, IDirect3DDevice9 **ppDevice)
ULONG D3D9BaseObject_Release(D3D9BaseObject *pBaseObject)
ULONG D3D9BaseObject_AddRef(D3D9BaseObject *pBaseObject)
@ RT_EXTERNAL
HRESULT AlignedAlloc(IN OUT LPVOID *ppObject, IN SIZE_T dwSize)
Definition: d3d9_helpers.c:95
HRESULT WINAPI D3D9MipMap_LockRect(LPDIRECT3DTEXTURE9 iface, UINT Level, D3DLOCKED_RECT *pLockedRect, CONST RECT *pRect, DWORD Flags)
Definition: d3d9_mipmap.c:234
ULONG WINAPI D3D9MipMap_AddRef(LPDIRECT3DTEXTURE9 iface)
Definition: d3d9_mipmap.c:46
HRESULT WINAPI D3D9MipMap_GetLevelDesc(LPDIRECT3DTEXTURE9 iface, UINT Level, D3DSURFACE_DESC *pDesc)
Definition: d3d9_mipmap.c:222
LPD3D9MIPMAP IDirect3DTexture9ToImpl(LPDIRECT3DTEXTURE9 iface)
Definition: d3d9_mipmap.c:19
HRESULT CreateD3D9MipMap(DIRECT3DDEVICE9_INT *pDevice, UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9 **ppTexture)
Definition: d3d9_mipmap.c:287
ULONG WINAPI D3D9MipMap_Release(LPDIRECT3DTEXTURE9 iface)
Definition: d3d9_mipmap.c:52
#define UNLOCK_D3DDEVICE9()
Definition: d3d9_mipmap.c:16
void WINAPI D3D9MipMap_GenerateMipSubLevels(LPDIRECT3DTEXTURE9 iface)
Definition: d3d9_mipmap.c:216
#define LOCK_D3DDEVICE9()
Definition: d3d9_mipmap.c:15
HRESULT WINAPI D3D9MipMap_GetDevice(LPDIRECT3DTEXTURE9 iface, IDirect3DDevice9 **ppDevice)
Definition: d3d9_mipmap.c:79
DWORD WINAPI D3D9MipMap_SetLOD(LPDIRECT3DTEXTURE9 iface, DWORD LODNew)
Definition: d3d9_mipmap.c:144
DWORD WINAPI D3D9MipMap_GetLevelCount(LPDIRECT3DTEXTURE9 iface)
Definition: d3d9_mipmap.c:184
HRESULT WINAPI D3D9MipMap_SetPrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags)
Definition: d3d9_mipmap.c:102
HRESULT WINAPI D3D9MipMap_AddDirtyRect(LPDIRECT3DTEXTURE9 iface, CONST RECT *pDirtyRect)
Definition: d3d9_mipmap.c:246
static HRESULT WINAPI D3D9MipMap_QueryInterface(LPDIRECT3DTEXTURE9 iface, REFIID riid, void **ppvObject)
Definition: d3d9_mipmap.c:28
DWORD WINAPI D3D9MipMap_SetPriority(LPDIRECT3DTEXTURE9 iface, DWORD PriorityNew)
Definition: d3d9_mipmap.c:120
DWORD WINAPI D3D9MipMap_GetPriority(LPDIRECT3DTEXTURE9 iface)
Definition: d3d9_mipmap.c:126
DWORD WINAPI D3D9MipMap_GetLOD(LPDIRECT3DTEXTURE9 iface)
Definition: d3d9_mipmap.c:164
void WINAPI D3D9MipMap_PreLoad(LPDIRECT3DTEXTURE9 iface)
Definition: d3d9_mipmap.c:132
D3DRESOURCETYPE WINAPI D3D9MipMap_GetType(LPDIRECT3DTEXTURE9 iface)
Definition: d3d9_mipmap.c:138
HRESULT WINAPI D3D9MipMap_SetAutoGenFilterType(LPDIRECT3DTEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType)
Definition: d3d9_mipmap.c:190
HRESULT WINAPI D3D9MipMap_GetSurfaceLevel(LPDIRECT3DTEXTURE9 iface, UINT Level, IDirect3DSurface9 **ppSurfaceLevel)
Definition: d3d9_mipmap.c:228
HRESULT WINAPI D3D9MipMap_GetPrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData)
Definition: d3d9_mipmap.c:108
HRESULT WINAPI D3D9MipMap_FreePrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid)
Definition: d3d9_mipmap.c:114
D3DTEXTUREFILTERTYPE WINAPI D3D9MipMap_GetAutoGenFilterType(LPDIRECT3DTEXTURE9 iface)
Definition: d3d9_mipmap.c:210
HRESULT WINAPI D3D9MipMap_UnlockRect(LPDIRECT3DTEXTURE9 iface, UINT Level)
Definition: d3d9_mipmap.c:240
static IDirect3DTexture9Vtbl D3D9MipMap_Vtbl
Definition: d3d9_mipmap.c:253
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
DWORD WINAPI D3D9Texture_GetLOD(LPDIRECT3DBASETEXTURE9 iface)
Definition: d3d9_texture.c:84
DWORD WINAPI D3D9Texture_GetLevelCount(LPDIRECT3DBASETEXTURE9 iface)
Definition: d3d9_texture.c:111
D3DTEXTUREFILTERTYPE WINAPI D3D9Texture_GetAutoGenFilterType(LPDIRECT3DBASETEXTURE9 iface)
Definition: d3d9_texture.c:58
#define D3D_OK
Definition: d3d.h:106
#define D3DERR_INVALIDCALL
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define NULL
Definition: types.h:112
#define ULONG_PTR
Definition: config.h:101
unsigned long DWORD
Definition: ntddk_ex.h:95
FxDevice * pDevice
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:384
REFIID riid
Definition: atlbase.h:39
#define FAILED(hr)
Definition: intsafe.h:51
unsigned int UINT
Definition: ndis.h:50
#define CONST
Definition: pedump.c:81
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define D3DERR_INVALIDDEVICE
Definition: d3d8.h:86
Direct3DBaseTexture9_INT BaseTexture
Definition: d3d9_mipmap.h:17
DWORD dwHeight
Definition: d3d9_mipmap.h:27
D3DFORMAT Format
Definition: d3d9_mipmap.h:20
struct IDirect3DTexture9Vtbl * lpVtbl
Definition: d3d9_mipmap.h:18
DWORD dwWidth
Definition: d3d9_mipmap.h:26
DWORD Usage
Definition: d3d9_mipmap.h:22
Definition: scsiwmi.h:51
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint32_t ULONG
Definition: typedefs.h:59
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:2364
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170