ReactOS  0.4.12-dev-418-g3df31a8
blt.cpp
Go to the documentation of this file.
1 
3 {
4  DWORD ret;
5  RECT rect = {x, y, x+1, y+1};
6  DDSURFACEDESC2 desc = {0};
7  desc.dwSize = sizeof(DDSURFACEDESC2);
8 
9  if(Surface->Lock(&rect, &desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL))
10  {
11  printf("ERROR: Unable to lock surface\n");
12  return 0xdeadbeef;
13  }
14 
15  ret = *((DWORD *)desc.lpSurface);
16 
17  if(Surface->Unlock (&rect) != DD_OK)
18  {
19  printf("ERROR: Unable to unlock surface ?!\n");
20  }
21 
22  return ret;
23 }
24 
25 VOID Blt_Test (LPDIRECTDRAWSURFACE7 Surface, INT* passed, INT* failed)
26 {
28  if(!CreateSurface(&Source))
29  return;
30 
31  // The following has been tested with Nvidea hardware
32  // the results might differently with other graphic
33  // card drivers. - mbosma
34 
35  // FIXME: Test Color Key (DDBLT_KEYDEST / DDBLT_KEYSRC / DDBLT_KEYDESTOVERRIDE / DDBLT_KEYSRCOVERRIDE)
36 
37  // General Tests
38  DDBLTFX bltfx;
39  TEST (Surface->Blt(NULL, NULL, NULL, 0, NULL) == DDERR_INVALIDPARAMS);
40  TEST (Surface->Blt(NULL, Surface, NULL, 0, NULL) == DD_OK ); // blting to itself
41 
42  TEST (Surface->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_DDFX, &bltfx) == DDERR_INVALIDPARAMS);
43  bltfx.dwDDFX = DDBLTFX_NOTEARING;
44  TEST (Surface->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_DDFX, &bltfx) == DDERR_INVALIDPARAMS);
45  bltfx.dwSize = sizeof(DDBLTFX);
46  TEST (Surface->Blt(NULL, NULL, NULL, DDBLT_WAIT, &bltfx) == DDERR_INVALIDPARAMS);
47  TEST (Surface->Blt(NULL, Source, NULL, DDBLT_WAIT|DDBLT_DDFX, &bltfx) == DD_OK); // don't know why this works on a offscreen surfaces
48 
49  // Test color filling
50  bltfx.dwFillColor = RGB(0, 255, 0);
51  TEST (Source->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &bltfx) == DD_OK);
52  RECT rect = {100, 100, 200, 200};
53  bltfx.dwFillColor = RGB(255, 255, 0);
54  TEST (Source->Blt(&rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &bltfx) == DD_OK);
55  TEST (GetPixel(Source, 0, 0) == RGB(0, 255, 0));
56  TEST (GetPixel(Source, 100, 100) == RGB(255, 255, 0));
57 
58  // Test DestRect and SrcRect
59  RECT SourceRect = {100, 100, 200, 200};
60  RECT DestRect = {0, 0, 200, 100};
61 
62  TEST (Surface->Blt(&SourceRect, Source, &DestRect, 0, NULL) == DD_OK);
63  TEST (GetPixel(Surface, 100, 100) == RGB(0, 255, 0)); // Src bigger: normal blt
64 
65  TEST (Surface->Blt(&DestRect, Source, &SourceRect, 0, NULL) == DD_OK);
66  TEST (GetPixel(Surface, 0, 0) == 0x00ffbf); // Dest bigger: wtf ??
67 
68  DestRect.right = 100; // both are same size now
69  TEST (Surface->Blt(&DestRect, Source, &SourceRect, 0, NULL) == DD_OK);
70  TEST (GetPixel(Surface, 0, 0) == RGB(255, 255, 0));
71 
72  RECT TooBig = {100, 100, 200, 250};
73  TEST (Surface->Blt(&TooBig, Source, &SourceRect, 0, NULL) == DDERR_INVALIDRECT);
74  TEST (Surface->Blt(&DestRect, Source, &TooBig, 0, NULL) == DDERR_INVALIDRECT);
75 
76  // Test Rotation
78  TEST (Surface->Blt(NULL, Source, NULL, DDBLT_WAIT|DDBLT_DDFX, &bltfx) == DD_OK);
79  TEST (GetPixel(Surface, 0, 0) == RGB(255, 255, 0));
80 
81  bltfx.dwDDFX = DDBLTFX_ROTATE180;
82  TEST (Surface->Blt(NULL, Source, NULL, DDBLT_DDFX, &bltfx) == DDERR_NOROTATIONHW);
83 
84  //bltfx.dwRotationAngle =
85  TEST (Surface->Blt(NULL, Source, NULL, DDBLT_ROTATIONANGLE, &bltfx) == DDERR_NOROTATIONHW);
86 
87  // Test Raster Operations
88  bltfx.dwROP = BLACKNESS;
89  TEST (Surface->Blt(NULL, Source, NULL, DDBLT_WAIT|DDBLT_ROP, &bltfx) == DD_OK);
90  TEST(GetPixel(Surface, 0, 0) == RGB(0, 0, 0));
91  bltfx.dwROP = WHITENESS;
92  TEST (Surface->Blt(NULL, Source, NULL, DDBLT_WAIT|DDBLT_ROP, &bltfx) == DD_OK);
93  TEST(GetPixel(Surface, 0, 0) == RGB(255, 255, 255));
94  bltfx.dwROP = SRCCOPY; // this flag actually does nothing
95  TEST (Surface->Blt(NULL, Source, NULL, DDBLT_WAIT|DDBLT_ROP, &bltfx) == DD_OK);
96  TEST(GetPixel(Surface, 0, 0) == RGB(0, 255, 0));
97  bltfx.dwROP = SRCAND;
98  TEST (Surface->Blt(NULL, Source, NULL, DDBLT_WAIT|DDBLT_ROP, &bltfx) == DDERR_NORASTEROPHW);
99 
100  // Test Direct Draw Raster Operations
101  bltfx.dwDDROP = 0x123;
102  TEST (Surface->Blt(NULL, Source, NULL, DDBLT_WAIT|DDBLT_DDROPS, &bltfx) == DDERR_NODDROPSHW);
103 
104  // Streching
106  TEST (Surface->Blt(NULL, Source, NULL, DDBLT_WAIT|DDBLT_DDFX, &bltfx) == DDERR_NOSTRETCHHW);
107 }
108 
109 VOID GetBltStatus_Test (LPDIRECTDRAWSURFACE7 Surface, INT* passed, INT* failed)
110 {
111  TEST (Surface->GetBltStatus(0) == DDERR_INVALIDPARAMS);
112  TEST (Surface->GetBltStatus(DDGBS_CANBLT) == DD_OK);
113  //TEST (Surface->GetBltStatus(DDGBS_ISBLTDONE) == DD_OK);
114 
115  // Lock Surface
116  DDSURFACEDESC2 desc = {0};
117  desc.dwSize = sizeof(DDSURFACEDESC2);
118  Surface->Lock(NULL, &desc, DDLOCK_WAIT, NULL);
119  TEST (Surface->GetBltStatus(DDGBS_ISBLTDONE) == DD_OK);
120  TEST (Surface->GetBltStatus(DDGBS_CANBLT) == DD_OK); // does not return DDERR_SURFACEBUSY for me as msdn says (xp,nvidea)
121  Surface->Unlock (NULL);
122 
123  // Try to produce busy surface by filling it 500 times
124  DDBLTFX bltfx;
125  bltfx.dwSize = sizeof(DDBLTFX);
126  bltfx.dwFillColor = RGB(0, 0, 0);
127 
128  int i;
129  for(i=0; i<500; i++)
130  Surface->Blt(NULL, NULL, NULL, DDBLT_COLORFILL, &bltfx);
131 
132  TEST (Surface->GetBltStatus(DDGBS_ISBLTDONE) == DDERR_WASSTILLDRAWING);
133  TEST (Surface->GetBltStatus(DDGBS_CANBLT) == DD_OK);
134 }
135 
136 BOOL Test_Blt (INT* passed, INT* failed)
137 {
138  LPDIRECTDRAWSURFACE7 Surface;
139  if(!CreateSurface(&Surface))
140  return FALSE;
141 
142  // Test GetPixel (needs Lock API)
143  DDBLTFX bltfx;
144  bltfx.dwSize = sizeof(DDBLTFX);
145  bltfx.dwFillColor = RGB(0, 0, 0);
146  Surface->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &bltfx);
147  if(GetPixel(Surface, 0, 0) != RGB(0, 0, 0))
148  return FALSE;
149 
150  // The tests
151  TEST(Surface->BltBatch(NULL, 0, 0) == DDERR_UNSUPPORTED);
152  Blt_Test (Surface, passed, failed);
153  GetBltStatus_Test (Surface, passed, failed);
154 
155  Surface->Release();
156  return TRUE;
157 }
DWORD dwFillColor
Definition: ddraw.h:1310
#define TRUE
Definition: types.h:120
BOOL Test_Blt(INT *passed, INT *failed)
Definition: blt.cpp:136
#define DDBLT_ROTATIONANGLE
Definition: ddraw.h:563
#define DDBLTFX_MIRRORUPDOWN
Definition: ddraw.h:636
#define DDBLTFX_MIRRORLEFTRIGHT
Definition: ddraw.h:635
#define DDERR_UNSUPPORTED
Definition: ddraw.h:127
#define DDBLTFX_ARITHSTRETCHY
Definition: ddraw.h:634
#define DDBLT_DDROPS
Definition: ddraw.h:557
DWORD dwSize
Definition: ddraw.h:1272
#define DDLOCK_READONLY
Definition: ddraw.h:624
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
LONG right
Definition: windef.h:293
int32_t INT
Definition: typedefs.h:56
& rect
Definition: startmenu.cpp:1413
#define DDBLT_DDFX
Definition: ddraw.h:556
DWORD dwDDROP
Definition: ddraw.h:1275
#define DDBLTFX_NOTEARING
Definition: ddraw.h:637
BOOL CreateSurface(LPDIRECTDRAWSURFACE7 *pSurface)
Definition: helper.cpp:28
INT INT y
Definition: msvc.h:62
#define DD_OK
Definition: ddraw.h:186
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
VOID GetBltStatus_Test(LPDIRECTDRAWSURFACE7 Surface, INT *passed, INT *failed)
Definition: blt.cpp:109
#define DDERR_NOSTRETCHHW
Definition: ddraw.h:102
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
smooth NULL
Definition: ftsmooth.c:416
#define DDERR_NODDROPSHW
Definition: ddraw.h:150
#define DDBLT_COLORFILL
Definition: ddraw.h:555
#define DDBLT_WAIT
Definition: ddraw.h:569
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TEST(x)
Definition: precomp.h:20
struct _DDBLTFX DDBLTFX
#define RGB(r, g, b)
Definition: wingdi.h:2918
unsigned int UINT
Definition: ndis.h:50
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DDBLTFX_ROTATE180
Definition: ddraw.h:638
int ret
#define DDERR_NORASTEROPHW
Definition: ddraw.h:100
DWORD dwROP
Definition: ddraw.h:1274
#define WHITENESS
Definition: wingdi.h:336
#define DDERR_INVALIDRECT
Definition: ddraw.h:81
#define DDGBS_ISBLTDONE
Definition: ddraw.h:657
#define DDLOCK_WAIT
Definition: ddraw.h:622
#define DDERR_WASSTILLDRAWING
Definition: ddraw.h:132
#define BLACKNESS
Definition: wingdi.h:322
INT x
Definition: msvc.h:62
VOID Blt_Test(LPDIRECTDRAWSURFACE7 Surface, INT *passed, INT *failed)
Definition: blt.cpp:25
#define SRCAND
Definition: wingdi.h:329
struct _DDSURFACEDESC2 DDSURFACEDESC2
DWORD dwDDFX
Definition: ddraw.h:1273
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3149
#define DDERR_NOROTATIONHW
Definition: ddraw.h:101
#define DDBLT_ROP
Definition: ddraw.h:562
#define SRCCOPY
Definition: wingdi.h:332
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
#define DDGBS_CANBLT
Definition: ddraw.h:656
DWORD * LPDIRECTDRAWSURFACE7
Definition: vmrender.idl:7
#define printf
Definition: config.h:203