ddraw/tests: Rewrite offscreen_test().

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2016-02-05 21:31:00 +01:00 committed by Alexandre Julliard
parent b2b61094e0
commit 03ef393ae4
5 changed files with 312 additions and 41 deletions

View File

@ -8333,6 +8333,83 @@ done:
DestroyWindow(window);
}
static void test_offscreen_overlay(void)
{
IDirectDrawSurface *overlay, *offscreen, *primary;
DDSURFACEDESC surface_desc;
IDirectDraw *ddraw;
HWND window;
HRESULT hr;
HDC dc;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, 0, 0, 0, 0);
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
if (!(overlay = create_overlay(ddraw, 64, 64, MAKEFOURCC('U','Y','V','Y'))))
{
skip("Failed to create a UYVY overlay, skipping test.\n");
goto done;
}
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS;
surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &primary, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
/* On Windows 7, and probably Vista, UpdateOverlay() will return
* DDERR_OUTOFCAPS if the dwm is active. Calling GetDC() on the primary
* surface prevents this by disabling the dwm. */
hr = IDirectDrawSurface_GetDC(primary, &dc);
ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
hr = IDirectDrawSurface_ReleaseDC(primary, dc);
ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
/* Try to overlay a NULL surface. */
hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, NULL, NULL, DDOVER_SHOW, NULL);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, NULL, NULL, DDOVER_HIDE, NULL);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
/* Try to overlay an offscreen surface. */
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
surface_desc.dwWidth = 64;
surface_desc.dwHeight = 64;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
surface_desc.ddpfPixelFormat.dwSize = sizeof(surface_desc.ddpfPixelFormat);
surface_desc.ddpfPixelFormat.dwFlags = DDPF_RGB;
surface_desc.ddpfPixelFormat.dwFourCC = 0;
U1(surface_desc.ddpfPixelFormat).dwRGBBitCount = 16;
U2(surface_desc.ddpfPixelFormat).dwRBitMask = 0xf800;
U3(surface_desc.ddpfPixelFormat).dwGBitMask = 0x07e0;
U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x001f;
hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &offscreen, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, offscreen, NULL, DDOVER_SHOW, NULL);
ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
/* Try to overlay the primary with a non-overlay surface. */
hr = IDirectDrawSurface_UpdateOverlay(offscreen, NULL, primary, NULL, DDOVER_SHOW, NULL);
ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface_UpdateOverlay(offscreen, NULL, primary, NULL, DDOVER_HIDE, NULL);
ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#x.\n", hr);
IDirectDrawSurface_Release(offscreen);
IDirectDrawSurface_Release(primary);
IDirectDrawSurface_Release(overlay);
done:
IDirectDraw_Release(ddraw);
DestroyWindow(window);
}
START_TEST(ddraw1)
{
IDirectDraw *ddraw;
@ -8407,4 +8484,5 @@ START_TEST(ddraw1)
test_shademode();
test_lockrect_invalid();
test_yv12_overlay();
test_offscreen_overlay();
}

View File

@ -9440,6 +9440,83 @@ done:
DestroyWindow(window);
}
static void test_offscreen_overlay(void)
{
IDirectDrawSurface *overlay, *offscreen, *primary;
DDSURFACEDESC surface_desc;
IDirectDraw2 *ddraw;
HWND window;
HRESULT hr;
HDC dc;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, 0, 0, 0, 0);
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
if (!(overlay = create_overlay(ddraw, 64, 64, MAKEFOURCC('U','Y','V','Y'))))
{
skip("Failed to create a UYVY overlay, skipping test.\n");
goto done;
}
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS;
surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &primary, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
/* On Windows 7, and probably Vista, UpdateOverlay() will return
* DDERR_OUTOFCAPS if the dwm is active. Calling GetDC() on the primary
* surface prevents this by disabling the dwm. */
hr = IDirectDrawSurface_GetDC(primary, &dc);
ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
hr = IDirectDrawSurface_ReleaseDC(primary, dc);
ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
/* Try to overlay a NULL surface. */
hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, NULL, NULL, DDOVER_SHOW, NULL);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, NULL, NULL, DDOVER_HIDE, NULL);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
/* Try to overlay an offscreen surface. */
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
surface_desc.dwWidth = 64;
surface_desc.dwHeight = 64;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
surface_desc.ddpfPixelFormat.dwSize = sizeof(surface_desc.ddpfPixelFormat);
surface_desc.ddpfPixelFormat.dwFlags = DDPF_RGB;
surface_desc.ddpfPixelFormat.dwFourCC = 0;
U1(surface_desc.ddpfPixelFormat).dwRGBBitCount = 16;
U2(surface_desc.ddpfPixelFormat).dwRBitMask = 0xf800;
U3(surface_desc.ddpfPixelFormat).dwGBitMask = 0x07e0;
U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x001f;
hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &offscreen, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, offscreen, NULL, DDOVER_SHOW, NULL);
ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
/* Try to overlay the primary with a non-overlay surface. */
hr = IDirectDrawSurface_UpdateOverlay(offscreen, NULL, primary, NULL, DDOVER_SHOW, NULL);
ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface_UpdateOverlay(offscreen, NULL, primary, NULL, DDOVER_HIDE, NULL);
ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#x.\n", hr);
IDirectDrawSurface_Release(offscreen);
IDirectDrawSurface_Release(primary);
IDirectDrawSurface_Release(overlay);
done:
IDirectDraw2_Release(ddraw);
DestroyWindow(window);
}
START_TEST(ddraw2)
{
IDirectDraw2 *ddraw;
@ -9521,4 +9598,5 @@ START_TEST(ddraw2)
test_shademode();
test_lockrect_invalid();
test_yv12_overlay();
test_offscreen_overlay();
}

View File

@ -10615,6 +10615,83 @@ done:
DestroyWindow(window);
}
static void test_offscreen_overlay(void)
{
IDirectDrawSurface4 *overlay, *offscreen, *primary;
DDSURFACEDESC2 surface_desc;
IDirectDraw4 *ddraw;
HWND window;
HRESULT hr;
HDC dc;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, 0, 0, 0, 0);
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
if (!(overlay = create_overlay(ddraw, 64, 64, MAKEFOURCC('U','Y','V','Y'))))
{
skip("Failed to create a UYVY overlay, skipping test.\n");
goto done;
}
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS;
surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &primary, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
/* On Windows 7, and probably Vista, UpdateOverlay() will return
* DDERR_OUTOFCAPS if the dwm is active. Calling GetDC() on the primary
* surface prevents this by disabling the dwm. */
hr = IDirectDrawSurface4_GetDC(primary, &dc);
ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
hr = IDirectDrawSurface4_ReleaseDC(primary, dc);
ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
/* Try to overlay a NULL surface. */
hr = IDirectDrawSurface4_UpdateOverlay(overlay, NULL, NULL, NULL, DDOVER_SHOW, NULL);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface4_UpdateOverlay(overlay, NULL, NULL, NULL, DDOVER_HIDE, NULL);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
/* Try to overlay an offscreen surface. */
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
surface_desc.dwWidth = 64;
surface_desc.dwHeight = 64;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
U4(surface_desc).ddpfPixelFormat.dwSize = sizeof(U4(surface_desc).ddpfPixelFormat);
U4(surface_desc).ddpfPixelFormat.dwFlags = DDPF_RGB;
U4(surface_desc).ddpfPixelFormat.dwFourCC = 0;
U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount = 16;
U2(U4(surface_desc).ddpfPixelFormat).dwRBitMask = 0xf800;
U3(U4(surface_desc).ddpfPixelFormat).dwGBitMask = 0x07e0;
U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x001f;
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &offscreen, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_UpdateOverlay(overlay, NULL, offscreen, NULL, DDOVER_SHOW, NULL);
ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
/* Try to overlay the primary with a non-overlay surface. */
hr = IDirectDrawSurface4_UpdateOverlay(offscreen, NULL, primary, NULL, DDOVER_SHOW, NULL);
ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface4_UpdateOverlay(offscreen, NULL, primary, NULL, DDOVER_HIDE, NULL);
ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#x.\n", hr);
IDirectDrawSurface4_Release(offscreen);
IDirectDrawSurface4_Release(primary);
IDirectDrawSurface4_Release(overlay);
done:
IDirectDraw4_Release(ddraw);
DestroyWindow(window);
}
START_TEST(ddraw4)
{
IDirectDraw4 *ddraw;
@ -10703,4 +10780,5 @@ START_TEST(ddraw4)
test_shademode();
test_lockrect_invalid();
test_yv12_overlay();
test_offscreen_overlay();
}

View File

@ -10894,6 +10894,83 @@ done:
DestroyWindow(window);
}
static void test_offscreen_overlay(void)
{
IDirectDrawSurface7 *overlay, *offscreen, *primary;
DDSURFACEDESC2 surface_desc;
IDirectDraw7 *ddraw;
HWND window;
HRESULT hr;
HDC dc;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, 0, 0, 0, 0);
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
if (!(overlay = create_overlay(ddraw, 64, 64, MAKEFOURCC('U','Y','V','Y'))))
{
skip("Failed to create a UYVY overlay, skipping test.\n");
goto done;
}
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS;
surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &primary, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
/* On Windows 7, and probably Vista, UpdateOverlay() will return
* DDERR_OUTOFCAPS if the dwm is active. Calling GetDC() on the primary
* surface prevents this by disabling the dwm. */
hr = IDirectDrawSurface7_GetDC(primary, &dc);
ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
hr = IDirectDrawSurface7_ReleaseDC(primary, dc);
ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
/* Try to overlay a NULL surface. */
hr = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, NULL, NULL, DDOVER_SHOW, NULL);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, NULL, NULL, DDOVER_HIDE, NULL);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
/* Try to overlay an offscreen surface. */
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
surface_desc.dwWidth = 64;
surface_desc.dwHeight = 64;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
U4(surface_desc).ddpfPixelFormat.dwSize = sizeof(U4(surface_desc).ddpfPixelFormat);
U4(surface_desc).ddpfPixelFormat.dwFlags = DDPF_RGB;
U4(surface_desc).ddpfPixelFormat.dwFourCC = 0;
U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount = 16;
U2(U4(surface_desc).ddpfPixelFormat).dwRBitMask = 0xf800;
U3(U4(surface_desc).ddpfPixelFormat).dwGBitMask = 0x07e0;
U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x001f;
hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &offscreen, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, offscreen, NULL, DDOVER_SHOW, NULL);
ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
/* Try to overlay the primary with a non-overlay surface. */
hr = IDirectDrawSurface7_UpdateOverlay(offscreen, NULL, primary, NULL, DDOVER_SHOW, NULL);
ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface7_UpdateOverlay(offscreen, NULL, primary, NULL, DDOVER_HIDE, NULL);
ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#x.\n", hr);
IDirectDrawSurface7_Release(offscreen);
IDirectDrawSurface7_Release(primary);
IDirectDrawSurface7_Release(overlay);
done:
IDirectDraw7_Release(ddraw);
DestroyWindow(window);
}
START_TEST(ddraw7)
{
HMODULE module = GetModuleHandleA("ddraw.dll");
@ -10993,4 +11070,5 @@ START_TEST(ddraw7)
test_shademode();
test_lockrect_invalid();
test_yv12_overlay();
test_offscreen_overlay();
}

View File

@ -151,46 +151,6 @@ static void rectangle_settings(void) {
IDirectDrawSurface7_Release(overlay);
}
static void offscreen_test(void) {
IDirectDrawSurface7 *overlay = create_overlay(64, 64, MAKEFOURCC('U','Y','V','Y')), *offscreen = NULL;
HRESULT hr;
DDSURFACEDESC2 ddsd;
/* Try to overlay a NULL surface */
hr = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, NULL, NULL, DDOVER_SHOW, NULL);
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface7_UpdateOverlay failed with hr=0x%08x\n", hr);
hr = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, NULL, NULL, DDOVER_HIDE, NULL);
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface7_UpdateOverlay failed with hr=0x%08x\n", hr);
/* Try to overlay an offscreen surface */
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
ddsd.dwWidth = 64;
ddsd.dwHeight = 64;
U4(ddsd).ddpfPixelFormat.dwSize = sizeof(U4(ddsd).ddpfPixelFormat);
U4(ddsd).ddpfPixelFormat.dwFlags = DDPF_RGB;
U4(ddsd).ddpfPixelFormat.dwFourCC = 0;
U1(U4(ddsd).ddpfPixelFormat).dwRGBBitCount = 16;
U2(U4(ddsd).ddpfPixelFormat).dwRBitMask = 0xF800;
U3(U4(ddsd).ddpfPixelFormat).dwGBitMask = 0x07e0;
U4(U4(ddsd).ddpfPixelFormat).dwBBitMask = 0x001F;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &offscreen, NULL);
ok(hr == DD_OK, "IDirectDraw7_CreateSurface failed with hr=0x%08x\n", hr);
hr = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, offscreen, NULL, DDOVER_SHOW, NULL);
ok(hr == DD_OK || broken(hr == E_NOTIMPL),
"IDirectDrawSurface7_UpdateOverlay failed with hr=0x%08x\n", hr);
/* Try to overlay the primary with a non-overlay surface */
hr = IDirectDrawSurface7_UpdateOverlay(offscreen, NULL, primary, NULL, DDOVER_SHOW, NULL);
ok(hr == DDERR_NOTAOVERLAYSURFACE, "IDirectDrawSurface7_UpdateOverlay failed with hr=0x%08x\n", hr);
IDirectDrawSurface7_Release(offscreen);
IDirectDrawSurface7_Release(overlay);
}
START_TEST(overlay)
{
if(CreateDirectDraw() == FALSE) {
@ -199,7 +159,6 @@ START_TEST(overlay)
}
rectangle_settings();
offscreen_test();
if(primary) IDirectDrawSurface7_Release(primary);
if(ddraw) IDirectDraw7_Release(ddraw);