ReactOS 0.4.16-dev-334-g4d9f67c
d3d9_swapchain.c File Reference
#include "d3d9_swapchain.h"
#include <debug.h>
#include <ddraw.h>
#include "d3d9_helpers.h"
#include "d3d9_device.h"
#include "d3d9_cursor.h"
Include dependency graph for d3d9_swapchain.c:

Go to the source code of this file.

Macros

#define LOCK_D3DDEVICE9()   D3D9BaseObject_LockDevice(&This->BaseObject)
 
#define UNLOCK_D3DDEVICE9()   D3D9BaseObject_UnlockDevice(&This->BaseObject)
 

Functions

LPDIRECT3DSWAPCHAIN9_INT IDirect3DSwapChain9ToImpl (LPDIRECT3DSWAPCHAIN9 iface)
 
static HRESULT WINAPI Direct3DSwapChain9_QueryInterface (LPDIRECT3DSWAPCHAIN9 iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI Direct3DSwapChain9_AddRef (LPDIRECT3DSWAPCHAIN9 iface)
 
static ULONG WINAPI Direct3DSwapChain9_Release (LPDIRECT3DSWAPCHAIN9 iface)
 
static HRESULT WINAPI Direct3DSwapChain9_Present (LPDIRECT3DSWAPCHAIN9 iface, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion, DWORD dwFlags)
 
static HRESULT WINAPI Direct3DSwapChain9_GetFrontBufferData (LPDIRECT3DSWAPCHAIN9 iface, IDirect3DSurface9 *pDestSurface)
 
static HRESULT WINAPI Direct3DSwapChain9_GetBackBuffer (LPDIRECT3DSWAPCHAIN9 iface, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9 **ppBackBuffer)
 
static HRESULT WINAPI Direct3DSwapChain9_GetRasterStatus (LPDIRECT3DSWAPCHAIN9 iface, D3DRASTER_STATUS *pRasterStatus)
 
static HRESULT WINAPI Direct3DSwapChain9_GetDisplayMode (LPDIRECT3DSWAPCHAIN9 iface, D3DDISPLAYMODE *pMode)
 
static HRESULT WINAPI Direct3DSwapChain9_GetDevice (LPDIRECT3DSWAPCHAIN9 iface, IDirect3DDevice9 **ppDevice)
 
static HRESULT WINAPI Direct3DSwapChain9_GetPresentParameters (LPDIRECT3DSWAPCHAIN9 iface, D3DPRESENT_PARAMETERS *pPresentationParameters)
 
Direct3DSwapChain9_INTCreateDirect3DSwapChain9 (enum REF_TYPE RefType, struct _Direct3DDevice9_INT *pBaseDevice, DWORD ChainIndex)
 
VOID Direct3DSwapChain9_SetDisplayMode (Direct3DSwapChain9_INT *pThisSwapChain, D3DPRESENT_PARAMETERS *pPresentationParameters)
 
HRESULT Direct3DSwapChain9_Init (Direct3DSwapChain9_INT *pThisSwapChain, D3DPRESENT_PARAMETERS *pPresentationParameters)
 
HRESULT Direct3DSwapChain9_Reset (Direct3DSwapChain9_INT *pThisSwapChain, D3DPRESENT_PARAMETERS *pPresentationParameters)
 
VOID Direct3DSwapChain9_GetGammaRamp (Direct3DSwapChain9_INT *pThisSwapChain, D3DGAMMARAMP *pRamp)
 
VOID Direct3DSwapChain9_SetGammaRamp (Direct3DSwapChain9_INT *pThisSwapChain, DWORD Flags, CONST D3DGAMMARAMP *pRamp)
 

Variables

static IDirect3DSwapChain9Vtbl Direct3DSwapChain9_Vtbl
 

Macro Definition Documentation

◆ LOCK_D3DDEVICE9

#define LOCK_D3DDEVICE9 ( )    D3D9BaseObject_LockDevice(&This->BaseObject)

Definition at line 17 of file d3d9_swapchain.c.

◆ UNLOCK_D3DDEVICE9

#define UNLOCK_D3DDEVICE9 ( )    D3D9BaseObject_UnlockDevice(&This->BaseObject)

Definition at line 18 of file d3d9_swapchain.c.

Function Documentation

◆ CreateDirect3DSwapChain9()

Direct3DSwapChain9_INT * CreateDirect3DSwapChain9 ( enum REF_TYPE  RefType,
struct _Direct3DDevice9_INT pBaseDevice,
DWORD  ChainIndex 
)

Definition at line 183 of file d3d9_swapchain.c.

184{
185 Direct3DSwapChain9_INT* pThisSwapChain;
186 if (FAILED(AlignedAlloc((LPVOID*)&pThisSwapChain, sizeof(Direct3DSwapChain9_INT))))
187 {
188 DPRINT1("Could not create Direct3DSwapChain9_INT");
189 return NULL;
190 }
191
192 InitD3D9BaseObject((D3D9BaseObject*) &pThisSwapChain->BaseObject.lpVtbl, RefType, (IUnknown*) &pBaseDevice->lpVtbl);
193
194 pThisSwapChain->lpVtbl = &Direct3DSwapChain9_Vtbl;
195
196 pThisSwapChain->ChainIndex = ChainIndex;
197 pThisSwapChain->AdapterGroupIndex = ChainIndex;
198 pThisSwapChain->pUnknown6BC = pBaseDevice->DeviceData[ChainIndex].pUnknown6BC;
199 pThisSwapChain->pUnknown015c = (LPVOID)0xD3D9D3D9;
200
201 return pThisSwapChain;
202}
#define DPRINT1
Definition: precomp.h:8
VOID InitD3D9BaseObject(D3D9BaseObject *pBaseObject, enum REF_TYPE RefType, IUnknown *pUnknown)
HRESULT AlignedAlloc(IN OUT LPVOID *ppObject, IN SIZE_T dwSize)
Definition: d3d9_helpers.c:95
static IDirect3DSwapChain9Vtbl Direct3DSwapChain9_Vtbl
#define NULL
Definition: types.h:112
#define FAILED(hr)
Definition: intsafe.h:51
#define LPVOID
Definition: nt_native.h:45
struct _D3D9_Unknown6BC * pUnknown6BC
Definition: d3d9_private.h:142
D3D9_DEVICEDATA DeviceData[D3D9_INT_MAX_NUM_ADAPTERS]
Definition: d3d9_device.h:121
struct _IDirect3DDevice9Vtbl_INT * lpVtbl
Definition: d3d9_device.h:88

Referenced by IDirect3DDevice9Base_CreateAdditionalSwapChain(), and InitD3D9BaseDevice().

◆ Direct3DSwapChain9_AddRef()

static ULONG WINAPI Direct3DSwapChain9_AddRef ( LPDIRECT3DSWAPCHAIN9  iface)
static

Definition at line 45 of file d3d9_swapchain.c.

46{
48 return D3D9BaseObject_AddRef((D3D9BaseObject*) &This->BaseObject.lpVtbl);
49}
ULONG D3D9BaseObject_AddRef(D3D9BaseObject *pBaseObject)
LPDIRECT3DSWAPCHAIN9_INT IDirect3DSwapChain9ToImpl(LPDIRECT3DSWAPCHAIN9 iface)

◆ Direct3DSwapChain9_GetBackBuffer()

static HRESULT WINAPI Direct3DSwapChain9_GetBackBuffer ( LPDIRECT3DSWAPCHAIN9  iface,
UINT  iBackBuffer,
D3DBACKBUFFER_TYPE  Type,
IDirect3DSurface9 **  ppBackBuffer 
)
static

Definition at line 70 of file d3d9_swapchain.c.

71{
73 return D3D_OK;
74}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
#define D3D_OK
Definition: d3d.h:106

◆ Direct3DSwapChain9_GetDevice()

static HRESULT WINAPI Direct3DSwapChain9_GetDevice ( LPDIRECT3DSWAPCHAIN9  iface,
IDirect3DDevice9 **  ppDevice 
)
static

Definition at line 107 of file d3d9_swapchain.c.

108{
111
112 if (NULL == ppDevice)
113 {
114 DPRINT1("Invalid ppDevice parameter specified");
116 return D3DERR_INVALIDCALL;
117 }
118
119 if (FAILED(D3D9BaseObject_GetDevice(&This->BaseObject, ppDevice)))
120 {
121 DPRINT1("Invalid This parameter specified");
124 }
125
127 return D3D_OK;
128}
HRESULT D3D9BaseObject_GetDevice(D3D9BaseObject *pBaseObject, IDirect3DDevice9 **ppDevice)
#define UNLOCK_D3DDEVICE9()
#define LOCK_D3DDEVICE9()
#define D3DERR_INVALIDCALL
#define D3DERR_INVALIDDEVICE
Definition: d3d8.h:86

◆ Direct3DSwapChain9_GetDisplayMode()

static HRESULT WINAPI Direct3DSwapChain9_GetDisplayMode ( LPDIRECT3DSWAPCHAIN9  iface,
D3DDISPLAYMODE pMode 
)
static

Definition at line 82 of file d3d9_swapchain.c.

83{
85 return D3D_OK;
86}

◆ Direct3DSwapChain9_GetFrontBufferData()

static HRESULT WINAPI Direct3DSwapChain9_GetFrontBufferData ( LPDIRECT3DSWAPCHAIN9  iface,
IDirect3DSurface9 *  pDestSurface 
)
static

Definition at line 64 of file d3d9_swapchain.c.

65{
67 return D3D_OK;
68}

◆ Direct3DSwapChain9_GetGammaRamp()

VOID Direct3DSwapChain9_GetGammaRamp ( Direct3DSwapChain9_INT pThisSwapChain,
D3DGAMMARAMP pRamp 
)

Definition at line 248 of file d3d9_swapchain.c.

249{
250 memcpy(pRamp, &pThisSwapChain->GammaRamp, sizeof(D3DGAMMARAMP));
251}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

Referenced by IDirect3DDevice9Base_GetGammaRamp().

◆ Direct3DSwapChain9_GetPresentParameters()

static HRESULT WINAPI Direct3DSwapChain9_GetPresentParameters ( LPDIRECT3DSWAPCHAIN9  iface,
D3DPRESENT_PARAMETERS pPresentationParameters 
)
static

Definition at line 148 of file d3d9_swapchain.c.

149{
152
153 if (NULL == pPresentationParameters)
154 {
155 DPRINT1("Invalid pPresentationParameters parameter specified");
157 return D3DERR_INVALIDCALL;
158 }
159
160 *pPresentationParameters = This->PresentParameters;
161
163 return D3D_OK;
164}

◆ Direct3DSwapChain9_GetRasterStatus()

static HRESULT WINAPI Direct3DSwapChain9_GetRasterStatus ( LPDIRECT3DSWAPCHAIN9  iface,
D3DRASTER_STATUS pRasterStatus 
)
static

Definition at line 76 of file d3d9_swapchain.c.

77{
79 return D3D_OK;
80}

◆ Direct3DSwapChain9_Init()

HRESULT Direct3DSwapChain9_Init ( Direct3DSwapChain9_INT pThisSwapChain,
D3DPRESENT_PARAMETERS pPresentationParameters 
)

Definition at line 210 of file d3d9_swapchain.c.

211{
212 int i;
214
215 for (i = 0; i < 256; i++)
216 {
217 pThisSwapChain->GammaRamp.red[i] =
218 pThisSwapChain->GammaRamp.green[i] =
219 pThisSwapChain->GammaRamp.blue[i] = i;
220 }
221
222 pThisSwapChain->PresentParameters = pPresentationParameters[pThisSwapChain->ChainIndex];
223 pThisSwapChain->SwapEffect = pPresentationParameters->SwapEffect;
224 Direct3DSwapChain9_SetDisplayMode(pThisSwapChain, &pThisSwapChain->PresentParameters);
225
226 if (FAILED(D3D9BaseObject_GetDeviceInt(&pThisSwapChain->BaseObject, &pDevice)))
227 {
228 DPRINT1("Could not get the swapchain device");
229 return DDERR_GENERIC;
230 }
231
232 pThisSwapChain->pCursor = CreateD3D9Cursor(pDevice, pThisSwapChain);
233 if (NULL == pThisSwapChain->pCursor)
234 {
235 DPRINT1("Could not allocate D3D9Cursor");
236 return DDERR_OUTOFMEMORY;
237 }
238
239 return Direct3DSwapChain9_Reset(pThisSwapChain, pPresentationParameters);
240}
HRESULT D3D9BaseObject_GetDeviceInt(D3D9BaseObject *pBaseObject, DIRECT3DDEVICE9_INT **ppDevice)
D3D9Cursor * CreateD3D9Cursor(struct _Direct3DDevice9_INT *pBaseDevice, struct _Direct3DSwapChain9_INT *pSwapChain)
Definition: d3d9_cursor.c:18
VOID Direct3DSwapChain9_SetDisplayMode(Direct3DSwapChain9_INT *pThisSwapChain, D3DPRESENT_PARAMETERS *pPresentationParameters)
HRESULT Direct3DSwapChain9_Reset(Direct3DSwapChain9_INT *pThisSwapChain, D3DPRESENT_PARAMETERS *pPresentationParameters)
FxDevice * pDevice
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define DDERR_OUTOFMEMORY
Definition: ddraw.h:111
#define DDERR_GENERIC
Definition: ddraw.h:72
WORD blue[256]
Definition: d3d8types.h:1048
WORD green[256]
Definition: d3d8types.h:1047
WORD red[256]
Definition: d3d8types.h:1046
D3DSWAPEFFECT SwapEffect
Definition: d3d8types.h:1128
D3DPRESENT_PARAMETERS PresentParameters
struct _D3D9Cursor * pCursor
D3DSWAPEFFECT SwapEffect
D3D9BaseObject BaseObject

Referenced by IDirect3DDevice9Base_CreateAdditionalSwapChain(), and InitD3D9BaseDevice().

◆ Direct3DSwapChain9_Present()

static HRESULT WINAPI Direct3DSwapChain9_Present ( LPDIRECT3DSWAPCHAIN9  iface,
CONST RECT pSourceRect,
CONST RECT pDestRect,
HWND  hDestWindowOverride,
CONST RGNDATA pDirtyRegion,
DWORD  dwFlags 
)
static

Definition at line 58 of file d3d9_swapchain.c.

59{
61 return D3D_OK;
62}

◆ Direct3DSwapChain9_QueryInterface()

static HRESULT WINAPI Direct3DSwapChain9_QueryInterface ( LPDIRECT3DSWAPCHAIN9  iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 30 of file d3d9_swapchain.c.

31{
33
34 if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirect3DSwapChain9))
35 {
36 IUnknown_AddRef(iface);
37 *ppvObject = &This->lpVtbl;
38 return S_OK;
39 }
40
41 *ppvObject = NULL;
42 return E_NOINTERFACE;
43}
const GUID IID_IUnknown
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ Direct3DSwapChain9_Release()

static ULONG WINAPI Direct3DSwapChain9_Release ( LPDIRECT3DSWAPCHAIN9  iface)
static

Definition at line 51 of file d3d9_swapchain.c.

52{
54 return D3D9BaseObject_Release((D3D9BaseObject*) &This->BaseObject.lpVtbl);
55}
ULONG D3D9BaseObject_Release(D3D9BaseObject *pBaseObject)

◆ Direct3DSwapChain9_Reset()

HRESULT Direct3DSwapChain9_Reset ( Direct3DSwapChain9_INT pThisSwapChain,
D3DPRESENT_PARAMETERS pPresentationParameters 
)

Definition at line 242 of file d3d9_swapchain.c.

243{
244 // TODO: Do all the dirty work...
245 return D3D_OK;
246}

Referenced by Direct3DSwapChain9_Init().

◆ Direct3DSwapChain9_SetDisplayMode()

VOID Direct3DSwapChain9_SetDisplayMode ( Direct3DSwapChain9_INT pThisSwapChain,
D3DPRESENT_PARAMETERS pPresentationParameters 
)

Definition at line 204 of file d3d9_swapchain.c.

205{
206 pThisSwapChain->dwWidth = pPresentationParameters->BackBufferWidth;
207 pThisSwapChain->dwHeight = pPresentationParameters->BackBufferHeight;
208}

Referenced by Direct3DSwapChain9_Init().

◆ Direct3DSwapChain9_SetGammaRamp()

VOID Direct3DSwapChain9_SetGammaRamp ( Direct3DSwapChain9_INT pThisSwapChain,
DWORD  Flags,
CONST D3DGAMMARAMP pRamp 
)

Definition at line 253 of file d3d9_swapchain.c.

254{
256}

Referenced by IDirect3DDevice9Base_SetGammaRamp().

◆ IDirect3DSwapChain9ToImpl()

Variable Documentation

◆ Direct3DSwapChain9_Vtbl

IDirect3DSwapChain9Vtbl Direct3DSwapChain9_Vtbl
static
Initial value:
=
{
}
static ULONG WINAPI Direct3DSwapChain9_AddRef(LPDIRECT3DSWAPCHAIN9 iface)
static HRESULT WINAPI Direct3DSwapChain9_GetRasterStatus(LPDIRECT3DSWAPCHAIN9 iface, D3DRASTER_STATUS *pRasterStatus)
static HRESULT WINAPI Direct3DSwapChain9_GetFrontBufferData(LPDIRECT3DSWAPCHAIN9 iface, IDirect3DSurface9 *pDestSurface)
static HRESULT WINAPI Direct3DSwapChain9_GetPresentParameters(LPDIRECT3DSWAPCHAIN9 iface, D3DPRESENT_PARAMETERS *pPresentationParameters)
static HRESULT WINAPI Direct3DSwapChain9_GetDisplayMode(LPDIRECT3DSWAPCHAIN9 iface, D3DDISPLAYMODE *pMode)
static ULONG WINAPI Direct3DSwapChain9_Release(LPDIRECT3DSWAPCHAIN9 iface)
static HRESULT WINAPI Direct3DSwapChain9_GetBackBuffer(LPDIRECT3DSWAPCHAIN9 iface, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9 **ppBackBuffer)
static HRESULT WINAPI Direct3DSwapChain9_QueryInterface(LPDIRECT3DSWAPCHAIN9 iface, REFIID riid, void **ppvObject)
static HRESULT WINAPI Direct3DSwapChain9_GetDevice(LPDIRECT3DSWAPCHAIN9 iface, IDirect3DDevice9 **ppDevice)
static HRESULT WINAPI Direct3DSwapChain9_Present(LPDIRECT3DSWAPCHAIN9 iface, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion, DWORD dwFlags)

Definition at line 166 of file d3d9_swapchain.c.

Referenced by CreateDirect3DSwapChain9().