ddraw/tests: Add test for display mode surface pixel format.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2017-01-12 11:36:27 +01:00 committed by Alexandre Julliard
parent 06cf77b343
commit 0bcc46874f
4 changed files with 332 additions and 0 deletions

View File

@ -9711,6 +9711,88 @@ static void test_transform_vertices(void)
DestroyWindow(window);
}
static void test_display_mode_surface_pixel_format(void)
{
unsigned int width, height, bpp;
IDirectDrawSurface *surface;
DDSURFACEDESC surface_desc;
IDirectDraw *ddraw;
ULONG refcount;
HWND window;
HRESULT hr;
if (!(ddraw = create_ddraw()))
{
skip("Failed to create ddraw.\n");
return;
}
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDraw_GetDisplayMode(ddraw, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get display mode, hr %#x.\n", hr);
width = surface_desc.dwWidth;
height = surface_desc.dwHeight;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, width, height, NULL, NULL, NULL, NULL);
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
bpp = 0;
if (SUCCEEDED(IDirectDraw_SetDisplayMode(ddraw, width, height, 16)))
bpp = 16;
if (SUCCEEDED(IDirectDraw_SetDisplayMode(ddraw, width, height, 24)))
bpp = 24;
if (SUCCEEDED(IDirectDraw_SetDisplayMode(ddraw, width, height, 32)))
bpp = 32;
ok(bpp, "Set display mode failed.\n");
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDraw_GetDisplayMode(ddraw, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get display mode, hr %#x.\n", hr);
ok(surface_desc.dwWidth == width, "Got width %u, expected %u.\n", surface_desc.dwWidth, width);
ok(surface_desc.dwHeight == height, "Got height %u, expected %u.\n", surface_desc.dwHeight, height);
ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
U1(surface_desc.ddpfPixelFormat).dwRGBBitCount, bpp);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
U5(surface_desc).dwBackBufferCount = 1;
surface_desc.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_PRIMARYSURFACE;
hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(surface_desc.dwWidth == width, "Got width %u, expected %u.\n", surface_desc.dwWidth, width);
ok(surface_desc.dwHeight == height, "Got height %u, expected %u.\n", surface_desc.dwHeight, height);
ok(surface_desc.ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#x.\n",
surface_desc.ddpfPixelFormat.dwFlags);
ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
U1(surface_desc.ddpfPixelFormat).dwRGBBitCount, bpp);
IDirectDrawSurface_Release(surface);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
surface_desc.dwWidth = width;
surface_desc.dwHeight = height;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(surface_desc.ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#x.\n",
surface_desc.ddpfPixelFormat.dwFlags);
ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
U1(surface_desc.ddpfPixelFormat).dwRGBBitCount, bpp);
IDirectDrawSurface_Release(surface);
refcount = IDirectDraw_Release(ddraw);
ok(!refcount, "DirectDraw has %u references left.\n", refcount);
DestroyWindow(window);
}
START_TEST(ddraw1)
{
IDirectDraw *ddraw;
@ -9794,4 +9876,5 @@ START_TEST(ddraw1)
test_blt();
test_getdc();
test_transform_vertices();
test_display_mode_surface_pixel_format();
}

View File

@ -11165,6 +11165,88 @@ static void test_transform_vertices(void)
DestroyWindow(window);
}
static void test_display_mode_surface_pixel_format(void)
{
unsigned int width, height, bpp;
IDirectDrawSurface *surface;
DDSURFACEDESC surface_desc;
IDirectDraw2 *ddraw;
ULONG refcount;
HWND window;
HRESULT hr;
if (!(ddraw = create_ddraw()))
{
skip("Failed to create ddraw.\n");
return;
}
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDraw2_GetDisplayMode(ddraw, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get display mode, hr %#x.\n", hr);
width = surface_desc.dwWidth;
height = surface_desc.dwHeight;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, width, height, NULL, NULL, NULL, NULL);
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
bpp = 0;
if (SUCCEEDED(IDirectDraw2_SetDisplayMode(ddraw, width, height, 16, 0, 0)))
bpp = 16;
if (SUCCEEDED(IDirectDraw2_SetDisplayMode(ddraw, width, height, 24, 0, 0)))
bpp = 24;
if (SUCCEEDED(IDirectDraw2_SetDisplayMode(ddraw, width, height, 32, 0, 0)))
bpp = 32;
ok(bpp, "Set display mode failed.\n");
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDraw2_GetDisplayMode(ddraw, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get display mode, hr %#x.\n", hr);
ok(surface_desc.dwWidth == width, "Got width %u, expected %u.\n", surface_desc.dwWidth, width);
ok(surface_desc.dwHeight == height, "Got height %u, expected %u.\n", surface_desc.dwHeight, height);
ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
U1(surface_desc.ddpfPixelFormat).dwRGBBitCount, bpp);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
U5(surface_desc).dwBackBufferCount = 1;
surface_desc.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_PRIMARYSURFACE;
hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(surface_desc.dwWidth == width, "Got width %u, expected %u.\n", surface_desc.dwWidth, width);
ok(surface_desc.dwHeight == height, "Got height %u, expected %u.\n", surface_desc.dwHeight, height);
ok(surface_desc.ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#x.\n",
surface_desc.ddpfPixelFormat.dwFlags);
ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
U1(surface_desc.ddpfPixelFormat).dwRGBBitCount, bpp);
IDirectDrawSurface_Release(surface);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
surface_desc.dwWidth = width;
surface_desc.dwHeight = height;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(surface_desc.ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#x.\n",
surface_desc.ddpfPixelFormat.dwFlags);
ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
U1(surface_desc.ddpfPixelFormat).dwRGBBitCount, bpp);
IDirectDrawSurface_Release(surface);
refcount = IDirectDraw2_Release(ddraw);
ok(!refcount, "DirectDraw has %u references left.\n", refcount);
DestroyWindow(window);
}
START_TEST(ddraw2)
{
IDirectDraw2 *ddraw;
@ -11257,4 +11339,5 @@ START_TEST(ddraw2)
test_draw_primitive();
test_edge_antialiasing_blending();
test_transform_vertices();
test_display_mode_surface_pixel_format();
}

View File

@ -12450,6 +12450,88 @@ static void test_transform_vertices(void)
DestroyWindow(window);
}
static void test_display_mode_surface_pixel_format(void)
{
unsigned int width, height, bpp;
IDirectDrawSurface4 *surface;
DDSURFACEDESC2 surface_desc;
IDirectDraw4 *ddraw;
ULONG refcount;
HWND window;
HRESULT hr;
if (!(ddraw = create_ddraw()))
{
skip("Failed to create ddraw.\n");
return;
}
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDraw4_GetDisplayMode(ddraw, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get display mode, hr %#x.\n", hr);
width = surface_desc.dwWidth;
height = surface_desc.dwHeight;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, width, height, NULL, NULL, NULL, NULL);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
bpp = 0;
if (SUCCEEDED(IDirectDraw4_SetDisplayMode(ddraw, width, height, 16, 0, 0)))
bpp = 16;
if (SUCCEEDED(IDirectDraw4_SetDisplayMode(ddraw, width, height, 24, 0, 0)))
bpp = 24;
if (SUCCEEDED(IDirectDraw4_SetDisplayMode(ddraw, width, height, 32, 0, 0)))
bpp = 32;
ok(bpp, "Set display mode failed.\n");
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDraw4_GetDisplayMode(ddraw, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get display mode, hr %#x.\n", hr);
ok(surface_desc.dwWidth == width, "Got width %u, expected %u.\n", surface_desc.dwWidth, width);
ok(surface_desc.dwHeight == height, "Got height %u, expected %u.\n", surface_desc.dwHeight, height);
ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount, bpp);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
U5(surface_desc).dwBackBufferCount = 1;
surface_desc.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_PRIMARYSURFACE;
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(surface_desc.dwWidth == width, "Got width %u, expected %u.\n", surface_desc.dwWidth, width);
ok(surface_desc.dwHeight == height, "Got height %u, expected %u.\n", surface_desc.dwHeight, height);
ok(U4(surface_desc).ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#x.\n",
U4(surface_desc).ddpfPixelFormat.dwFlags);
ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount, bpp);
IDirectDrawSurface4_Release(surface);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
surface_desc.dwWidth = width;
surface_desc.dwHeight = height;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(U4(surface_desc).ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#x.\n",
U4(surface_desc).ddpfPixelFormat.dwFlags);
ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount, bpp);
IDirectDrawSurface4_Release(surface);
refcount = IDirectDraw4_Release(ddraw);
ok(!refcount, "DirectDraw has %u references left.\n", refcount);
DestroyWindow(window);
}
START_TEST(ddraw4)
{
IDirectDraw4 *ddraw;
@ -12550,4 +12632,5 @@ START_TEST(ddraw4)
test_draw_primitive();
test_edge_antialiasing_blending();
test_transform_vertices();
test_display_mode_surface_pixel_format();
}

View File

@ -12111,6 +12111,88 @@ static void test_edge_antialiasing_blending(void)
DestroyWindow(window);
}
static void test_display_mode_surface_pixel_format(void)
{
unsigned int width, height, bpp;
IDirectDrawSurface7 *surface;
DDSURFACEDESC2 surface_desc;
IDirectDraw7 *ddraw;
ULONG refcount;
HWND window;
HRESULT hr;
if (!(ddraw = create_ddraw()))
{
skip("Failed to create ddraw.\n");
return;
}
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDraw7_GetDisplayMode(ddraw, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get display mode, hr %#x.\n", hr);
width = surface_desc.dwWidth;
height = surface_desc.dwHeight;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, width, height, NULL, NULL, NULL, NULL);
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
bpp = 0;
if (SUCCEEDED(IDirectDraw7_SetDisplayMode(ddraw, width, height, 16, 0, 0)))
bpp = 16;
if (SUCCEEDED(IDirectDraw7_SetDisplayMode(ddraw, width, height, 24, 0, 0)))
bpp = 24;
if (SUCCEEDED(IDirectDraw7_SetDisplayMode(ddraw, width, height, 32, 0, 0)))
bpp = 32;
ok(bpp, "Set display mode failed.\n");
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDraw7_GetDisplayMode(ddraw, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get display mode, hr %#x.\n", hr);
ok(surface_desc.dwWidth == width, "Got width %u, expected %u.\n", surface_desc.dwWidth, width);
ok(surface_desc.dwHeight == height, "Got height %u, expected %u.\n", surface_desc.dwHeight, height);
ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount, bpp);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
U5(surface_desc).dwBackBufferCount = 1;
surface_desc.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_PRIMARYSURFACE;
hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(surface_desc.dwWidth == width, "Got width %u, expected %u.\n", surface_desc.dwWidth, width);
ok(surface_desc.dwHeight == height, "Got height %u, expected %u.\n", surface_desc.dwHeight, height);
ok(U4(surface_desc).ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#x.\n",
U4(surface_desc).ddpfPixelFormat.dwFlags);
ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount, bpp);
IDirectDrawSurface7_Release(surface);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
surface_desc.dwWidth = width;
surface_desc.dwHeight = height;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(U4(surface_desc).ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#x.\n",
U4(surface_desc).ddpfPixelFormat.dwFlags);
ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount, bpp);
IDirectDrawSurface7_Release(surface);
refcount = IDirectDraw7_Release(ddraw);
ok(!refcount, "DirectDraw has %u references left.\n", refcount);
DestroyWindow(window);
}
START_TEST(ddraw7)
{
HMODULE module = GetModuleHandleA("ddraw.dll");
@ -12221,4 +12303,5 @@ START_TEST(ddraw7)
test_getdc();
test_draw_primitive();
test_edge_antialiasing_blending();
test_display_mode_surface_pixel_format();
}