ReactOS 0.4.16-dev-297-gc569aee
private_data.cpp File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

BOOL CreateSurface (LPDIRECTDRAWSURFACE7 *pSurface)
 
BOOL Test_PrivateData (INT *passed, INT *failed)
 

Function Documentation

◆ CreateSurface()

BOOL CreateSurface ( LPDIRECTDRAWSURFACE7 pSurface)

Definition at line 28 of file helper.cpp.

29{
32 HWND hwnd;
33
34 // Create DDraw Object
35 if (DirectDrawCreateEx(NULL, (VOID**)&DirectDraw, IID_IDirectDraw7, NULL) != DD_OK)
36 {
37 printf("ERROR: Failed to set up ddraw\n");
38 return FALSE;
39 }
40
41 if(!( hwnd = CreateBasicWindow() ))
42 {
43 printf("ERROR: Failed to create window\n");
44 DirectDraw->Release();
45 return FALSE;
46 }
47
48 if (DirectDraw->SetCooperativeLevel (hwnd, DDSCL_NORMAL) != DD_OK)
49 {
50 printf("ERROR: Could not set cooperative level\n");
51 DirectDraw->Release();
52 return 0;
53 }
54
55 // Creat Surface
56 DDSURFACEDESC2 Desc = { 0 };
57 Desc.dwHeight = 200;
58 Desc.dwWidth = 200;
59 Desc.dwSize = sizeof (DDSURFACEDESC2);
62
63 if(DirectDraw->CreateSurface(&Desc, &Surface, NULL) != DD_OK)
64 {
65 printf("ERROR: Faild to create Surface\n");
66 return FALSE;
67 }
68
69 DirectDraw->Release();
70
71 *pSurface = Surface;
72 return TRUE;
73}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HRESULT WINAPI DirectDrawCreateEx(LPGUID lpGUID, LPVOID *lplpDD, REFIID id, LPUNKNOWN pUnkOuter)
Definition: main.c:139
DWORD * LPDIRECTDRAW7
Definition: vmrender.idl:6
DWORD * LPDIRECTDRAWSURFACE7
Definition: vmrender.idl:7
#define printf
Definition: freeldr.h:97
HWND CreateBasicWindow(VOID)
Definition: helper.cpp:17
#define DDSD_WIDTH
Definition: ddraw.h:210
#define DDSCL_NORMAL
Definition: ddraw.h:535
struct _DDSURFACEDESC2 DDSURFACEDESC2
#define DDSD_HEIGHT
Definition: ddraw.h:209
#define DDSCAPS_OFFSCREENPLAIN
Definition: ddraw.h:255
#define DD_OK
Definition: ddraw.h:186
#define DDSD_CAPS
Definition: ddraw.h:208
DWORD dwCaps
Definition: ddraw.h:732
DWORD dwWidth
Definition: ddraw.h:1155
DWORD dwHeight
Definition: ddraw.h:1154
DDSCAPS2 ddsCaps
Definition: ddraw.h:1188
DWORD dwFlags
Definition: ddraw.h:1153
DWORD dwSize
Definition: ddraw.h:1152
_In_ DD_SURFACE_LOCAL * pSurface
Definition: winddi.h:3481
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Referenced by Blt_Test(), Test_Blt(), and Test_PrivateData().

◆ Test_PrivateData()

BOOL Test_PrivateData ( INT passed,
INT failed 
)

Definition at line 3 of file private_data.cpp.

4{
6 DWORD size, dummy = 0xBAADF00D;
7 GUID guid = { 0 };
8 GUID guid2 = { 0x1 };
9
10 if(!CreateSurface(&Surface))
11 return FALSE;
12
13 // General test
14 TEST(Surface->SetPrivateData(guid, NULL, 0, 0) == DDERR_INVALIDPARAMS);
15 TEST(Surface->SetPrivateData(guid, (LPVOID)&dummy, 0, 0) == DDERR_INVALIDPARAMS);
16 TEST(Surface->SetPrivateData(guid, (LPVOID)0xdeadbeef, sizeof(DWORD), 0) == DDERR_INVALIDPARAMS);
17 TEST(Surface->SetPrivateData(guid, (LPVOID)&dummy, sizeof(DWORD), 0) == DD_OK);
18
19 TEST(Surface->GetPrivateData(guid, NULL, 0) == DDERR_INVALIDPARAMS);
20 TEST(Surface->GetPrivateData(guid, &dummy, 0) == DDERR_INVALIDPARAMS);
21 size = 0;
22 TEST(Surface->GetPrivateData(guid, &dummy, &size) == DDERR_MOREDATA && size == sizeof(DWORD));
23 size = 2;
24 TEST(Surface->GetPrivateData(guid, NULL, &size) == DDERR_MOREDATA && size == sizeof(DWORD));
25 TEST(Surface->GetPrivateData(guid, NULL, &size) == DDERR_INVALIDPARAMS);
26 TEST(Surface->GetPrivateData(guid, &dummy, &size) == DD_OK && dummy == 0xBAADF00D);
27 TEST(Surface->GetPrivateData(guid2, NULL, 0) == DDERR_NOTFOUND);
28
29 TEST(Surface->FreePrivateData(guid) == DD_OK);
30 TEST(Surface->FreePrivateData(guid) == DDERR_NOTFOUND);
31
32 // Test for DDSPD_VOLATILE flag
33 TEST(Surface->SetPrivateData(guid, (LPVOID)&dummy, sizeof(DWORD), DDSPD_VOLATILE) == DD_OK);
34 size = 0;
35 TEST(Surface->GetPrivateData(guid, NULL, &size) == DDERR_MOREDATA && size == sizeof(DWORD));
36 TEST(Surface->GetPrivateData(guid, &dummy, &size) == DD_OK && dummy == 0xBAADF00D);
37
38 DDBLTFX bltfx;
39 bltfx.dwSize = sizeof(DDBLTFX);
40 bltfx.dwFillColor = RGB(0, 0, 0);
41 if(Surface->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &bltfx) != DD_OK)
42 printf("ERROR: Failed to draw to surface !");
43 TEST(Surface->GetPrivateData(guid, &dummy, &size) == DDERR_EXPIRED);
44
45 // TODO: Test for DDSPD_IUNKNOWNPOINTER (see http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/ddraw7/directdraw7/ddref_5qyf.asp)
46
47 Surface->Release();
48 return TRUE;
49}
#define RGB(r, g, b)
Definition: precomp.h:71
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
const GUID * guid
#define TEST(x)
Definition: precomp.h:20
static GUID guid2
Definition: devinst.c:42
BOOL CreateSurface(LPDIRECTDRAWSURFACE7 *pSurface)
Definition: helper.cpp:28
#define DDBLT_COLORFILL
Definition: ddraw.h:555
#define DDSPD_VOLATILE
Definition: ddraw.h:465
struct _DDBLTFX DDBLTFX
#define DDERR_NOTFOUND
Definition: ddraw.h:97
#define DDERR_MOREDATA
Definition: ddraw.h:176
#define DDBLT_WAIT
Definition: ddraw.h:569
#define DDERR_EXPIRED
Definition: ddraw.h:177
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
DWORD dwSize
Definition: ddraw.h:1272
DWORD dwFillColor
Definition: ddraw.h:1310