ReactOS 0.4.16-dev-122-g325d74c
blt.cpp File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

DWORD GetPixel (LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
 
VOID Blt_Test (LPDIRECTDRAWSURFACE7 Surface, INT *passed, INT *failed)
 
VOID GetBltStatus_Test (LPDIRECTDRAWSURFACE7 Surface, INT *passed, INT *failed)
 
BOOL Test_Blt (INT *passed, INT *failed)
 

Function Documentation

◆ Blt_Test()

VOID Blt_Test ( LPDIRECTDRAWSURFACE7  Surface,
INT passed,
INT failed 
)

Definition at line 25 of file blt.cpp.

26{
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);
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
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}
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
#define NULL
Definition: types.h:112
#define RGB(r, g, b)
Definition: precomp.h:71
DWORD * LPDIRECTDRAWSURFACE7
Definition: vmrender.idl:7
BOOL CreateSurface(LPDIRECTDRAWSURFACE7 *pSurface)
Definition: helper.cpp:28
#define TEST(x)
Definition: precomp.h:20
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
#define DDBLT_COLORFILL
Definition: ddraw.h:555
#define DDERR_NOSTRETCHHW
Definition: ddraw.h:102
#define DDERR_INVALIDRECT
Definition: ddraw.h:81
#define DDBLTFX_MIRRORUPDOWN
Definition: ddraw.h:636
struct _DDBLTFX DDBLTFX
#define DDBLT_ROP
Definition: ddraw.h:562
#define DDBLT_DDFX
Definition: ddraw.h:556
#define DDBLT_ROTATIONANGLE
Definition: ddraw.h:563
#define DDERR_NODDROPSHW
Definition: ddraw.h:150
#define DD_OK
Definition: ddraw.h:186
#define DDBLT_WAIT
Definition: ddraw.h:569
#define DDBLTFX_ROTATE180
Definition: ddraw.h:638
#define DDBLT_DDROPS
Definition: ddraw.h:557
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
#define DDBLTFX_NOTEARING
Definition: ddraw.h:637
#define DDERR_NOROTATIONHW
Definition: ddraw.h:101
#define DDERR_NORASTEROPHW
Definition: ddraw.h:100
#define DDBLTFX_ARITHSTRETCHY
Definition: ddraw.h:634
#define DDBLTFX_MIRRORLEFTRIGHT
Definition: ddraw.h:635
& rect
Definition: startmenu.cpp:1413
DWORD dwSize
Definition: ddraw.h:1272
DWORD dwROP
Definition: ddraw.h:1274
DWORD dwFillColor
Definition: ddraw.h:1310
DWORD dwDDROP
Definition: ddraw.h:1275
DWORD dwDDFX
Definition: ddraw.h:1273
LONG right
Definition: windef.h:308
#define BLACKNESS
Definition: wingdi.h:323
#define WHITENESS
Definition: wingdi.h:337
#define SRCCOPY
Definition: wingdi.h:333
#define SRCAND
Definition: wingdi.h:330

Referenced by Test_Blt().

◆ GetBltStatus_Test()

VOID GetBltStatus_Test ( LPDIRECTDRAWSURFACE7  Surface,
INT passed,
INT failed 
)

Definition at line 109 of file blt.cpp.

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}
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
static const WCHAR desc[]
Definition: protectdata.c:36
struct _DDSURFACEDESC2 DDSURFACEDESC2
#define DDERR_WASSTILLDRAWING
Definition: ddraw.h:132
#define DDGBS_CANBLT
Definition: ddraw.h:656
#define DDLOCK_WAIT
Definition: ddraw.h:622
#define DDGBS_ISBLTDONE
Definition: ddraw.h:657

Referenced by Test_Blt().

◆ GetPixel()

DWORD GetPixel ( LPDIRECTDRAWSURFACE7  Surface,
UINT  x,
UINT  y 
)

Definition at line 2 of file blt.cpp.

3{
5 RECT rect = {x, y, x+1, y+1};
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}
unsigned long DWORD
Definition: ntddk_ex.h:95
#define printf
Definition: freeldr.h:97
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define DDLOCK_READONLY
Definition: ddraw.h:624
int ret

Referenced by _test_color(), ANIMATE_PaintFrame(), Blt_Test(), cdtDrawExt(), check_alpha_draw(), check_bits(), check_DrawIcon(), check_DrawIconEx(), check_DrawState_Color(), check_DrawState_Size(), CheckBitmapBitsWithLine(), ConvertBitmapTo32Bpp(), DoEntry(), DoTestEntry(), draw_graphics(), draw_text_2(), DrawCardCorner(), ColorTool::fetchColor(), Fill(), FsmStep(), ImageList_AddMasked(), InitLogo(), StartMenuRoot::Paint(), PROPSHEET_Paint(), ReadBits(), Replace(), Rotate90DegreeBlt(), SetMatrixMessage(), START_TEST(), STATIC_PaintBitmapfn(), test_alpha_hdc(), test_begin_paint(), test_bitmap_colors(), Test_Blt(), test_clip_xform(), test_createhbitmap(), test_D3DKMTCreateDCFromMemory(), test_DC_bitmap(), test_DIB_PAL_COLORS(), Test_DIBSectionEntry(), test_FillRect(), test_fromMemoryBitmap(), Test_GetPixel_1bpp(), Test_PatBlt_Params(), test_printer_dc(), Test_Rectangle(), test_Render(), test_scrolldc(), test_scrollwindow(), Test_SetDCPenColor(), Test_SetDIBits_1bpp(), Test_SrcMono(), Test_SrcMono1(), test_updates(), test_WM_PAINT(), and TestRedrawWindow().

◆ Test_Blt()

BOOL Test_Blt ( INT passed,
INT failed 
)

Definition at line 136 of file blt.cpp.

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}
VOID Blt_Test(LPDIRECTDRAWSURFACE7 Surface, INT *passed, INT *failed)
Definition: blt.cpp:25
VOID GetBltStatus_Test(LPDIRECTDRAWSURFACE7 Surface, INT *passed, INT *failed)
Definition: blt.cpp:109
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define DDERR_UNSUPPORTED
Definition: ddraw.h:127