ddraw/tests: New visual back buffer flipping tests.

This commit is contained in:
Oldřich Jedlička 2010-08-25 22:07:06 +02:00 committed by Alexandre Julliard
parent c293424319
commit 964500a61a
1 changed files with 122 additions and 0 deletions

View File

@ -2920,6 +2920,127 @@ static void depth_clamp_test(IDirect3DDevice7 *device)
ok(SUCCEEDED(hr), "SetViewport failed, hr %#x.\n", hr);
}
static void DX1_BackBufferFlipTest(void)
{
HRESULT hr;
IDirectDraw *DirectDraw1 = NULL;
IDirectDrawSurface *Primary = NULL;
IDirectDrawSurface *Backbuffer = NULL;
WNDCLASS wc = {0};
DDSURFACEDESC ddsd;
DDBLTFX ddbltfx;
COLORREF color;
const DWORD white = 0xffffff;
const DWORD red = 0xff0000;
BOOL attached = FALSE;
wc.lpfnWndProc = DefWindowProc;
wc.lpszClassName = "DX1_BackBufferFlipTest_wc";
RegisterClass(&wc);
window = CreateWindow("DX1_BackBufferFlipTest_wc", "DX1_BackBufferFlipTest",
WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION , 0, 0, 640, 480, 0, 0, 0, 0);
hr = DirectDrawCreate( NULL, &DirectDraw1, NULL );
ok(hr==DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreate returned: %x\n", hr);
if(FAILED(hr)) goto out;
hr = IDirectDraw_SetCooperativeLevel(DirectDraw1, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(hr==DD_OK, "SetCooperativeLevel returned: %x\n", hr);
if(FAILED(hr)) goto out;
hr = IDirectDraw_SetDisplayMode(DirectDraw1, 640, 480, 32);
if(FAILED(hr)) {
/* 24 bit is fine too */
hr = IDirectDraw_SetDisplayMode(DirectDraw1, 640, 480, 24);
}
ok(hr==DD_OK || hr == DDERR_UNSUPPORTED, "SetDisplayMode returned: %x\n", hr);
if (FAILED(hr)) {
goto out;
}
memset(&ddsd, 0, sizeof(DDSURFACEDESC));
ddsd.dwSize = sizeof(DDSURFACEDESC);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &Primary, NULL);
ok(hr==DD_OK, "IDirectDraw_CreateSurface returned: %08x\n", hr);
memset(&ddsd, 0, sizeof(DDSURFACEDESC));
ddsd.dwSize = sizeof(DDSURFACEDESC);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
ddsd.dwWidth = 640;
ddsd.dwHeight = 480;
ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 32;
U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x00ff0000;
U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &Backbuffer, NULL);
todo_wine ok(hr==DD_OK, "IDirectDraw_CreateSurface returned: %08x\n", hr);
if(FAILED(hr)) goto out;
hr = IDirectDrawSurface_AddAttachedSurface(Primary, Backbuffer);
todo_wine ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
"Attaching a back buffer to a front buffer returned %08x\n", hr);
if (FAILED(hr)) goto out;
attached = TRUE;
memset(&ddbltfx, 0, sizeof(ddbltfx));
ddbltfx.dwSize = sizeof(ddbltfx);
U5(ddbltfx).dwFillColor = red;
hr = IDirectDrawSurface_Blt(Backbuffer, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
ok(hr == DD_OK, "IDirectDrawSurface_Blt returned: %x\n", hr);
U5(ddbltfx).dwFillColor = white;
hr = IDirectDrawSurface_Blt(Primary, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
ok(hr == DD_OK, "IDirectDrawSurface_Blt returned: %x\n", hr);
/* Check it out */
color = getPixelColor_GDI(Primary, 5, 5);
ok(GetRValue(color) == 0xFF && GetGValue(color) == 0xFF && GetBValue(color) == 0xFF,
"got R %02X G %02X B %02X, expected R FF G FF B FF\n",
GetRValue(color), GetGValue(color), GetBValue(color));
color = getPixelColor_GDI(Backbuffer, 5, 5);
ok(GetRValue(color) == 0xFF && GetGValue(color) == 0 && GetBValue(color) == 0,
"got R %02X G %02X B %02X, expected R FF G 00 B 00\n",
GetRValue(color), GetGValue(color), GetBValue(color));
hr = IDirectDrawSurface_Flip(Primary, NULL, DDFLIP_WAIT);
todo_wine ok(hr == DD_OK, "IDirectDrawSurface_Flip returned 0x%08x\n", hr);
if (hr == DD_OK)
{
color = getPixelColor_GDI(Primary, 5, 5);
ok(GetRValue(color) == 0xFF && GetGValue(color) == 0 && GetBValue(color) == 0,
"got R %02X G %02X B %02X, expected R FF G 00 B 00\n",
GetRValue(color), GetGValue(color), GetBValue(color));
color = getPixelColor_GDI(Backbuffer, 5, 5);
ok((GetRValue(color) == 0xFF && GetGValue(color) == 0xFF && GetBValue(color) == 0xFF) ||
broken(GetRValue(color) == 0xFF && GetGValue(color) == 0 && GetBValue(color) == 0), /* broken driver */
"got R %02X G %02X B %02X, expected R FF G FF B FF\n",
GetRValue(color), GetGValue(color), GetBValue(color));
}
out:
if (Backbuffer)
{
if (attached)
IDirectDrawSurface_DeleteAttachedSurface(Primary, 0, Backbuffer);
IDirectDrawSurface_Release(Backbuffer);
}
if (Primary) IDirectDrawSurface_Release(Primary);
if (DirectDraw1) IDirectDraw_Release(DirectDraw1);
if (window) DestroyWindow(window);
}
START_TEST(visual)
{
HRESULT hr;
@ -2983,6 +3104,7 @@ START_TEST(visual)
D3D3_ViewportClearTest();
p8_primary_test();
DX1_BackBufferFlipTest();
return ;