ReactOS  0.4.12-dev-918-g6c6e7b8
display_modes.cpp
Go to the documentation of this file.
1 typedef struct
2 {
7 
8 BOOL Test_GetMonitorFrequency (INT* passed, INT* failed);
9 
11 {
12  return DDENUMRET_OK;
13 }
14 
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 }
41 
42 BOOL Test_DisplayModes (INT* passed, INT* failed)
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 }
86 
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 }
DWORD dwFlags
Definition: ddraw.h:1153
#define TRUE
Definition: types.h:120
DWORD dwFlags
Definition: ddraw.h:1071
LPDIRECTDRAW7 DirectDraw
HRESULT(WINAPI * LPDDENUMMODESCALLBACK2)(LPDDSURFACEDESC2, LPVOID)
Definition: ddraw.h:1259
#define DDERR_UNSUPPORTED
Definition: ddraw.h:127
#define DDEDM_REFRESHRATES
Definition: ddraw.h:529
#define CALLBACK
Definition: compat.h:27
HRESULT WINAPI DirectDrawCreateEx(LPGUID lpGUID, LPVOID *lplpDD, REFIID id, LPUNKNOWN pUnkOuter)
Definition: main.c:139
int32_t INT
Definition: typedefs.h:56
HRESULT CALLBACK EnumDisplayModes(LPDDSURFACEDESC2 pDDSD, ENUMCONTEXT *Context)
HRESULT CALLBACK DummyEnumDisplayModes(LPDDSURFACEDESC2 pDDSD, ENUMCONTEXT *Context)
DWORD dwWidth
Definition: ddraw.h:1155
#define DD_OK
Definition: ddraw.h:186
unsigned int BOOL
Definition: ntddk_ex.h:94
DDPIXELFORMAT ddpfPixelFormat
Definition: ddraw.h:1185
smooth NULL
Definition: ftsmooth.c:416
#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
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL Test_DisplayModes(INT *passed, INT *failed)
#define DDPF_PALETTEINDEXED8
Definition: ddraw.h:506
static VIDEODISPLAYMODE DisplayMode
Definition: pcvideo.c:116
#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
LPDIRECTDRAW7 DirectDraw
Definition: create.cpp:3
static calc_node_t temp
Definition: rpn_ieee.c:38
#define DDEDM_STANDARDVGAMODES
Definition: ddraw.h:530
DWORD * PDWORD
Definition: pedump.c:68
DWORD * LPDIRECTDRAW7
Definition: vmrender.idl:4
struct _DDSURFACEDESC2 DDSURFACEDESC2
BOOL Test_GetMonitorFrequency(INT *passed, INT *failed)
struct _DDRAWI_DIRECTDRAW_INT * LPDDRAWI_DIRECTDRAW_INT
Definition: ddrawi.h:124
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
#define printf
Definition: config.h:203
#define DDSD_PITCH
Definition: ddraw.h:211