ReactOS  0.4.15-dev-3302-ga37d9a4
display_modes.cpp File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ENUMCONTEXT
 

Functions

BOOL Test_GetMonitorFrequency (INT *passed, INT *failed)
 
HRESULT CALLBACK DummyEnumDisplayModes (LPDDSURFACEDESC2 pDDSD, ENUMCONTEXT *Context)
 
HRESULT CALLBACK EnumDisplayModes (LPDDSURFACEDESC2 pDDSD, ENUMCONTEXT *Context)
 
BOOL Test_DisplayModes (INT *passed, INT *failed)
 

Function Documentation

◆ DummyEnumDisplayModes()

HRESULT CALLBACK DummyEnumDisplayModes ( LPDDSURFACEDESC2  pDDSD,
ENUMCONTEXT Context 
)

Definition at line 10 of file display_modes.cpp.

11 {
12  return DDENUMRET_OK;
13 }
#define DDENUMRET_OK
Definition: ddraw.h:189

Referenced by Test_DisplayModes().

◆ EnumDisplayModes()

HRESULT CALLBACK EnumDisplayModes ( LPDDSURFACEDESC2  pDDSD,
ENUMCONTEXT Context 
)

Definition at line 15 of file display_modes.cpp.

16 {
17  static int setcout = 0;
18  if(setcout >= 5)
19  return DDENUMRET_OK;
20 
21  DWORD lpdwFrequency = 0;
22  INT* passed = Context->passed;
23  INT* failed = Context->failed;
25  DisplayMode.dwSize = sizeof(DDSURFACEDESC2);
26 
29  TEST ( Context->DirectDraw->SetDisplayMode (pDDSD->dwWidth, pDDSD->dwHeight, pDDSD->ddpfPixelFormat.dwRGBBitCount, pDDSD->dwRefreshRate, 0) == DD_OK);
30  TEST ( Context->DirectDraw->GetMonitorFrequency (&lpdwFrequency) == DD_OK && lpdwFrequency == pDDSD->dwRefreshRate);
31  TEST ( Context->DirectDraw->GetDisplayMode (&DisplayMode) == DD_OK
32  && pDDSD->dwHeight == DisplayMode.dwHeight
33  && pDDSD->dwWidth == DisplayMode.dwWidth
34  && pDDSD->dwRefreshRate == DisplayMode.dwRefreshRate
35  && pDDSD->ddpfPixelFormat.dwRGBBitCount == DisplayMode.ddpfPixelFormat.dwRGBBitCount
37 
38  setcout++;
39  return DDENUMRET_OK;
40 }
DWORD dwFlags
Definition: ddraw.h:1153
DWORD dwFlags
Definition: ddraw.h:1071
int32_t INT
Definition: typedefs.h:58
DWORD dwWidth
Definition: ddraw.h:1155
#define DD_OK
Definition: ddraw.h:186
DDPIXELFORMAT ddpfPixelFormat
Definition: ddraw.h:1185
#define DDSD_HEIGHT
Definition: ddraw.h:209
DWORD dwRGBBitCount
Definition: ddraw.h:1075
#define DDPF_RGB
Definition: ddraw.h:507
DWORD dwRefreshRate
Definition: ddraw.h:1169
#define TEST(x)
Definition: precomp.h:20
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DDPF_PALETTEINDEXED8
Definition: ddraw.h:506
static VIDEODISPLAYMODE DisplayMode
Definition: pcvideo.c:117
#define DDENUMRET_OK
Definition: ddraw.h:189
DWORD dwHeight
Definition: ddraw.h:1154
#define DDSD_WIDTH
Definition: ddraw.h:210
#define DDSD_PIXELFORMAT
Definition: ddraw.h:216
#define DDSD_REFRESHRATE
Definition: ddraw.h:222
struct _DDSURFACEDESC2 DDSURFACEDESC2
#define DDSD_PITCH
Definition: ddraw.h:211

Referenced by Test_DisplayModes().

◆ Test_DisplayModes()

BOOL Test_DisplayModes ( INT passed,
INT failed 
)

Definition at line 42 of file display_modes.cpp.

43 {
44  /*** FIXME: Also test with surface as parameter; try busy/locked surface as well ***/
46 
47  /* Preparations */
48  if (DirectDrawCreateEx(NULL, (VOID**)&DirectDraw, IID_IDirectDraw7, NULL) != DD_OK)
49  {
50  printf("ERROR: Failed to set up ddraw\n");
51  return FALSE;
52  }
53 
54  ENUMCONTEXT Context = {passed, failed, DirectDraw};
55 
56  /* The Test */
57 
58  Test_GetMonitorFrequency(passed, failed);
59 
60  /* First try with some generic display modes */
61  TEST ( DirectDraw->SetDisplayMode (1586, 895, 0, 0, 0) == DDERR_UNSUPPORTED );
62  TEST ( DirectDraw->SetDisplayMode (0, 0, 0, 0, 0x123) == DDERR_INVALIDPARAMS );
63 
64  // does this change the display mode to DDSCL_EXCLUSIVE ?
65  TEST ( DirectDraw->SetDisplayMode (0, 0, 0, 0, 0) == DD_OK );
66  TEST ( DirectDraw->SetDisplayMode (800, 600, 0, 0, 0) == DD_OK );
67  TEST ( DirectDraw->SetDisplayMode (0, 0, 16, 0, 0) == DD_OK );
68 
69  TEST ( DirectDraw->GetDisplayMode (NULL) == DDERR_INVALIDPARAMS );
71  TEST ( DirectDraw->GetDisplayMode (&DisplayMode) == DDERR_INVALIDPARAMS );
72 
73  //* Now try getting vaild modes from drive */
79 
80  TEST (DirectDraw->RestoreDisplayMode() == DD_OK);
81 
82  DirectDraw->Release();
83 
84  return TRUE;
85 }
HRESULT(WINAPI * LPDDENUMMODESCALLBACK2)(LPDDSURFACEDESC2, LPVOID)
Definition: ddraw.h:1259
#define DDERR_UNSUPPORTED
Definition: ddraw.h:127
#define DDEDM_REFRESHRATES
Definition: ddraw.h:529
#define TRUE
Definition: types.h:120
HRESULT WINAPI DirectDrawCreateEx(LPGUID lpGUID, LPVOID *lplpDD, REFIID id, LPUNKNOWN pUnkOuter)
Definition: main.c:139
HRESULT CALLBACK EnumDisplayModes(LPDDSURFACEDESC2 pDDSD, ENUMCONTEXT *Context)
HRESULT CALLBACK DummyEnumDisplayModes(LPDDSURFACEDESC2 pDDSD, ENUMCONTEXT *Context)
#define DD_OK
Definition: ddraw.h:186
#define FALSE
Definition: types.h:117
#define TEST(x)
Definition: precomp.h:20
static VIDEODISPLAYMODE DisplayMode
Definition: pcvideo.c:117
LPDIRECTDRAW7 DirectDraw
Definition: create.cpp:3
#define DDEDM_STANDARDVGAMODES
Definition: ddraw.h:530
#define NULL
Definition: types.h:112
DWORD * LPDIRECTDRAW7
Definition: vmrender.idl:4
BOOL Test_GetMonitorFrequency(INT *passed, INT *failed)
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
#define printf
Definition: config.h:203

◆ Test_GetMonitorFrequency()

BOOL Test_GetMonitorFrequency ( INT passed,
INT failed 
)

Definition at line 87 of file display_modes.cpp.

88 {
91 
92  /* Preparations */
93  if (DirectDrawCreateEx(NULL, (VOID**)&DirectDraw, IID_IDirectDraw7, NULL) != DD_OK)
94  {
95  printf("ERROR: Failed to set up ddraw\n");
96  return FALSE;
97  }
99 
100  /* Here we go */
101  DWORD lpFreq;
102  DWORD temp;
103  HRESULT retVal;
104  TEST (DirectDraw->GetMonitorFrequency((PDWORD)0xdeadbeef) == DDERR_INVALIDPARAMS);
105  TEST (DirectDraw->GetMonitorFrequency(NULL) == DDERR_INVALIDPARAMS);
106 
107  // result depends on our graphices card
108  retVal = DirectDraw->GetMonitorFrequency((PDWORD)&lpFreq);
109  TEST ( retVal == DD_OK || retVal == DDERR_UNSUPPORTED);
110 
111  /* Test by hacking interal structures */
112 
113  // should return DDERR_UNSUPPORTED
114  This->lpLcl->lpGbl->dwMonitorFrequency = 0;
115  TEST (DirectDraw->GetMonitorFrequency(&temp) == DDERR_UNSUPPORTED);
116 
117  // should return DD_OK
118  This->lpLcl->lpGbl->dwMonitorFrequency = 85;
119  TEST (DirectDraw->GetMonitorFrequency(&temp) == DD_OK);
120 
121  /* Restore */
122  This->lpLcl->lpGbl->dwMonitorFrequency = lpFreq;
123 
124  DirectDraw->Release();
125 
126  return TRUE;
127 }
#define DDERR_UNSUPPORTED
Definition: ddraw.h:127
#define TRUE
Definition: types.h:120
HRESULT WINAPI DirectDrawCreateEx(LPGUID lpGUID, LPVOID *lplpDD, REFIID id, LPUNKNOWN pUnkOuter)
Definition: main.c:139
#define DD_OK
Definition: ddraw.h:186
#define FALSE
Definition: types.h:117
#define TEST(x)
Definition: precomp.h:20
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
LPDIRECTDRAW7 DirectDraw
Definition: create.cpp:3
static calc_node_t temp
Definition: rpn_ieee.c:38
#define NULL
Definition: types.h:112
DWORD * PDWORD
Definition: pedump.c:68
DWORD * LPDIRECTDRAW7
Definition: vmrender.idl:4
struct _DDRAWI_DIRECTDRAW_INT * LPDDRAWI_DIRECTDRAW_INT
Definition: ddrawi.h:124
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
#define printf
Definition: config.h:203

Referenced by Test_DisplayModes().