Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/ddraw/tests/ddraw1.c | 158 ++++++++++++++++++++++++++++++++++- dlls/ddraw/tests/ddraw2.c | 158 ++++++++++++++++++++++++++++++++++- dlls/ddraw/tests/ddraw4.c | 168 +++++++++++++++++++++++++++++++++++-- dlls/ddraw/tests/ddraw7.c | 169 ++++++++++++++++++++++++++++++++++++-- 4 files changed, 636 insertions(+), 17 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index 4e27ecfb796..0e1de7909dd 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -12093,10 +12093,30 @@ static void test_clear(void)
struct enum_surfaces_param { + IDirectDraw *ddraw; + DDSURFACEDESC modes[20]; + unsigned int mode_count; + IDirectDrawSurface *surfaces[8]; unsigned int count; };
+static HRESULT CALLBACK build_mode_list_cb(DDSURFACEDESC *desc, void *context) +{ + struct enum_surfaces_param *param = context; + IDirectDrawSurface *surface; + + if (SUCCEEDED(IDirectDraw_CreateSurface(param->ddraw, desc, &surface, NULL))) + { + if (param->mode_count < ARRAY_SIZE(param->modes)) + param->modes[param->mode_count] = *desc; + ++param->mode_count; + IDirectDrawSurface_Release(surface); + } + + return DDENUMRET_OK; +} + static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface *surface, DDSURFACEDESC *desc, void *context) { struct enum_surfaces_param *param = context; @@ -12119,18 +12139,54 @@ static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface *surface, DDSURFACEDES return DDENUMRET_OK; }
+static HRESULT WINAPI enum_surfaces_create_cb(IDirectDrawSurface *surface, DDSURFACEDESC *desc, void *context) +{ + static const DWORD expect_flags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH | DDSD_PIXELFORMAT; + struct enum_surfaces_param *param = context; + + ok(!surface, "Unexpected surface %p.\n", surface); + ok((desc->dwFlags & expect_flags) == expect_flags, "Got unexpected flags %#x.\n", desc->dwFlags); + if (param->count < ARRAY_SIZE(param->modes)) + { + const DDSURFACEDESC *expect = ¶m->modes[param->count]; + ok(desc->dwWidth == expect->dwWidth, "Expected width %u, got %u.\n", expect->dwWidth, desc->dwWidth); + ok(desc->dwHeight == expect->dwHeight, "Expected height %u, got %u.\n", expect->dwHeight, desc->dwHeight); + ok(!memcmp(&U4(*desc).ddpfPixelFormat, &U4(*expect).ddpfPixelFormat, sizeof(U4(*desc).ddpfPixelFormat)), + "Pixel formats didn't match.\n"); + } + + ++param->count; + + return DDENUMRET_OK; +} + static void test_enum_surfaces(void) { - struct enum_surfaces_param param = {{0}}; + struct enum_surfaces_param param = {0}; + DDPIXELFORMAT current_format; IDirectDraw *ddraw; DDSURFACEDESC desc; HRESULT hr;
ddraw = create_ddraw(); ok(!!ddraw, "Failed to create a ddraw object.\n"); + param.ddraw = ddraw; + + memset(&desc, 0, sizeof(desc)); + desc.dwSize = sizeof(desc); + hr = IDirectDraw_GetDisplayMode(ddraw, &desc); + ok(hr == DD_OK, "Failed to get display mode, hr %#x.\n", hr); + current_format = desc.ddpfPixelFormat;
hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL); - ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr); + ok(hr == DD_OK, "Failed to set cooperative level, hr %#x.\n", hr); + + hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_ALL, NULL, NULL, enum_surfaces_cb); + todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + + hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL, + NULL, NULL, enum_surfaces_cb); + todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
memset(&desc, 0, sizeof(desc)); desc.dwSize = sizeof(desc); @@ -12150,6 +12206,7 @@ static void test_enum_surfaces(void) ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr); ok(!param.surfaces[3], "Got unexpected pointer %p.\n", param.surfaces[3]);
+ param.count = 0; hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, &desc, ¶m, enum_surfaces_cb); ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr); @@ -12161,9 +12218,106 @@ static void test_enum_surfaces(void) ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr); ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
+ desc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT; + param.count = 0; + hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); + + param.count = 0; + hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_NOMATCH, + &desc, ¶m, enum_surfaces_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + todo_wine ok(param.count == 2, "Got unexpected number of enumerated surfaces %u.\n", param.count); + + desc.dwFlags = 0; + param.count = 0; + hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count); + + desc.dwFlags = 0; + param.count = 0; + hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST, &desc, ¶m, enum_surfaces_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count); + IDirectDrawSurface_Release(param.surfaces[2]); IDirectDrawSurface_Release(param.surfaces[1]); IDirectDrawSurface_Release(param.surfaces[0]); + + param.count = 0; + hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, + NULL, ¶m, enum_surfaces_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(!param.count, "Got unexpected number of enumerated surfaces %u.\n", param.count); + + memset(&desc, 0, sizeof(desc)); + desc.dwSize = sizeof(desc); + desc.dwFlags = DDSD_CAPS; + desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE; + + hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL, + &desc, ¶m, enum_surfaces_create_cb); + todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + + hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_NOMATCH, + &desc, ¶m, enum_surfaces_create_cb); + todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + + hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED, + &desc, ¶m, enum_surfaces_create_cb); + todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + + /* When not passed width and height, the callback is called with every + * available display resolution. */ + + param.mode_count = 0; + desc.dwFlags |= DDSD_PIXELFORMAT; + U4(desc).ddpfPixelFormat = current_format; + hr = IDirectDraw_EnumDisplayModes(ddraw, 0, &desc, ¶m, build_mode_list_cb); + ok(hr == DD_OK, "Failed to build mode list, hr %#x.\n", hr); + + param.count = 0; + desc.dwFlags &= ~DDSD_PIXELFORMAT; + hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_create_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + todo_wine ok(param.count == param.mode_count, "Expected %u surfaces, got %u.\n", param.mode_count, param.count); + + desc.dwFlags |= DDSD_WIDTH | DDSD_HEIGHT; + desc.dwWidth = desc.dwHeight = 32; + + param.modes[0].dwWidth = param.modes[0].dwHeight = 32; + + param.count = 0; + hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_create_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + todo_wine ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); + + hr = IDirectDraw_CreateSurface(ddraw, &desc, ¶m.surfaces[0], NULL); + ok(hr == DD_OK, "Failed to create surface, hr %#x.\n", hr); + param.count = 0; + hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_create_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + todo_wine ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); + IDirectDrawSurface_Release(param.surfaces[0]); + + desc.dwFlags |= DDSD_PIXELFORMAT; + desc.ddpfPixelFormat.dwSize = sizeof(desc.ddpfPixelFormat); + desc.ddpfPixelFormat.dwFlags = DDPF_FOURCC; + desc.ddpfPixelFormat.dwFourCC = 0xdeadbeef; + + param.count = 0; + hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_create_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(!param.count, "Got unexpected number of enumerated surfaces %u.\n", param.count); + IDirectDraw_Release(ddraw); }
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index 7c25b2be557..8d38344520c 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -13069,10 +13069,30 @@ static void test_clear(void)
struct enum_surfaces_param { + IDirectDraw2 *ddraw; + DDSURFACEDESC modes[20]; + unsigned int mode_count; + IDirectDrawSurface *surfaces[8]; unsigned int count; };
+static HRESULT CALLBACK build_mode_list_cb(DDSURFACEDESC *desc, void *context) +{ + struct enum_surfaces_param *param = context; + IDirectDrawSurface *surface; + + if (SUCCEEDED(IDirectDraw2_CreateSurface(param->ddraw, desc, &surface, NULL))) + { + if (param->mode_count < ARRAY_SIZE(param->modes)) + param->modes[param->mode_count] = *desc; + ++param->mode_count; + IDirectDrawSurface_Release(surface); + } + + return DDENUMRET_OK; +} + static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface *surface, DDSURFACEDESC *desc, void *context) { struct enum_surfaces_param *param = context; @@ -13095,18 +13115,54 @@ static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface *surface, DDSURFACEDES return DDENUMRET_OK; }
+static HRESULT WINAPI enum_surfaces_create_cb(IDirectDrawSurface *surface, DDSURFACEDESC *desc, void *context) +{ + static const DWORD expect_flags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH | DDSD_PIXELFORMAT; + struct enum_surfaces_param *param = context; + + ok(!surface, "Unexpected surface %p.\n", surface); + ok((desc->dwFlags & expect_flags) == expect_flags, "Got unexpected flags %#x.\n", desc->dwFlags); + if (param->count < ARRAY_SIZE(param->modes)) + { + const DDSURFACEDESC *expect = ¶m->modes[param->count]; + ok(desc->dwWidth == expect->dwWidth, "Expected width %u, got %u.\n", expect->dwWidth, desc->dwWidth); + ok(desc->dwHeight == expect->dwHeight, "Expected height %u, got %u.\n", expect->dwHeight, desc->dwHeight); + ok(!memcmp(&U4(*desc).ddpfPixelFormat, &U4(*expect).ddpfPixelFormat, sizeof(U4(*desc).ddpfPixelFormat)), + "Pixel formats didn't match.\n"); + } + + ++param->count; + + return DDENUMRET_OK; +} + static void test_enum_surfaces(void) { - struct enum_surfaces_param param = {{0}}; + struct enum_surfaces_param param = {0}; + DDPIXELFORMAT current_format; IDirectDraw2 *ddraw; DDSURFACEDESC desc; HRESULT hr;
ddraw = create_ddraw(); ok(!!ddraw, "Failed to create a ddraw object.\n"); + param.ddraw = ddraw; + + memset(&desc, 0, sizeof(desc)); + desc.dwSize = sizeof(desc); + hr = IDirectDraw2_GetDisplayMode(ddraw, &desc); + ok(hr == DD_OK, "Failed to get display mode, hr %#x.\n", hr); + current_format = desc.ddpfPixelFormat;
hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL); - ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr); + ok(hr == DD_OK, "Failed to set cooperative level, hr %#x.\n", hr); + + hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_ALL, NULL, NULL, enum_surfaces_cb); + todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + + hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL, + NULL, NULL, enum_surfaces_cb); + todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
memset(&desc, 0, sizeof(desc)); desc.dwSize = sizeof(desc); @@ -13126,6 +13182,7 @@ static void test_enum_surfaces(void) ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr); ok(!param.surfaces[3], "Got unexpected pointer %p.\n", param.surfaces[3]);
+ param.count = 0; hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, &desc, ¶m, enum_surfaces_cb); ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr); @@ -13137,9 +13194,106 @@ static void test_enum_surfaces(void) ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr); ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
+ desc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT; + param.count = 0; + hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); + + param.count = 0; + hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_NOMATCH, + &desc, ¶m, enum_surfaces_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + todo_wine ok(param.count == 2, "Got unexpected number of enumerated surfaces %u.\n", param.count); + + desc.dwFlags = 0; + param.count = 0; + hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count); + + desc.dwFlags = 0; + param.count = 0; + hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST, &desc, ¶m, enum_surfaces_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count); + IDirectDrawSurface_Release(param.surfaces[2]); IDirectDrawSurface_Release(param.surfaces[1]); IDirectDrawSurface_Release(param.surfaces[0]); + + param.count = 0; + hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, + NULL, ¶m, enum_surfaces_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(!param.count, "Got unexpected number of enumerated surfaces %u.\n", param.count); + + memset(&desc, 0, sizeof(desc)); + desc.dwSize = sizeof(desc); + desc.dwFlags = DDSD_CAPS; + desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE; + + hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL, + &desc, ¶m, enum_surfaces_create_cb); + todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + + hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_NOMATCH, + &desc, ¶m, enum_surfaces_create_cb); + todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + + hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED, + &desc, ¶m, enum_surfaces_create_cb); + todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + + /* When not passed width and height, the callback is called with every + * available display resolution. */ + + param.mode_count = 0; + desc.dwFlags |= DDSD_PIXELFORMAT; + U4(desc).ddpfPixelFormat = current_format; + hr = IDirectDraw2_EnumDisplayModes(ddraw, 0, &desc, ¶m, build_mode_list_cb); + ok(hr == DD_OK, "Failed to build mode list, hr %#x.\n", hr); + + param.count = 0; + desc.dwFlags &= ~DDSD_PIXELFORMAT; + hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_create_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + todo_wine ok(param.count == param.mode_count, "Expected %u surfaces, got %u.\n", param.mode_count, param.count); + + desc.dwFlags |= DDSD_WIDTH | DDSD_HEIGHT; + desc.dwWidth = desc.dwHeight = 32; + + param.modes[0].dwWidth = param.modes[0].dwHeight = 32; + + param.count = 0; + hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_create_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + todo_wine ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); + + hr = IDirectDraw2_CreateSurface(ddraw, &desc, ¶m.surfaces[0], NULL); + ok(hr == DD_OK, "Failed to create surface, hr %#x.\n", hr); + param.count = 0; + hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_create_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + todo_wine ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); + IDirectDrawSurface2_Release(param.surfaces[0]); + + desc.dwFlags |= DDSD_PIXELFORMAT; + desc.ddpfPixelFormat.dwSize = sizeof(desc.ddpfPixelFormat); + desc.ddpfPixelFormat.dwFlags = DDPF_FOURCC; + desc.ddpfPixelFormat.dwFourCC = 0xdeadbeef; + + param.count = 0; + hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_create_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(!param.count, "Got unexpected number of enumerated surfaces %u.\n", param.count); + IDirectDraw2_Release(ddraw); }
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index c38c0b3ce5a..3a3983639de 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -15657,10 +15657,30 @@ static void test_clear(void)
struct enum_surfaces_param { + IDirectDraw4 *ddraw; + DDSURFACEDESC2 modes[20]; + unsigned int mode_count; + IDirectDrawSurface4 *surfaces[8]; unsigned int count; };
+static HRESULT CALLBACK build_mode_list_cb(DDSURFACEDESC2 *desc, void *context) +{ + struct enum_surfaces_param *param = context; + IDirectDrawSurface4 *surface; + + if (SUCCEEDED(IDirectDraw4_CreateSurface(param->ddraw, desc, &surface, NULL))) + { + if (param->mode_count < ARRAY_SIZE(param->modes)) + param->modes[param->mode_count] = *desc; + ++param->mode_count; + IDirectDrawSurface4_Release(surface); + } + + return DDENUMRET_OK; +} + static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface4 *surface, DDSURFACEDESC2 *desc, void *context) { struct enum_surfaces_param *param = context; @@ -15683,18 +15703,54 @@ static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface4 *surface, DDSURFACEDE return DDENUMRET_OK; }
+static HRESULT WINAPI enum_surfaces_create_cb(IDirectDrawSurface4 *surface, DDSURFACEDESC2 *desc, void *context) +{ + static const DWORD expect_flags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH | DDSD_PIXELFORMAT; + struct enum_surfaces_param *param = context; + + ok(!surface, "Unexpected surface %p.\n", surface); + ok((desc->dwFlags & expect_flags) == expect_flags, "Got unexpected flags %#x.\n", desc->dwFlags); + if (param->count < ARRAY_SIZE(param->modes)) + { + const DDSURFACEDESC2 *expect = ¶m->modes[param->count]; + ok(desc->dwWidth == expect->dwWidth, "Expected width %u, got %u.\n", expect->dwWidth, desc->dwWidth); + ok(desc->dwHeight == expect->dwHeight, "Expected height %u, got %u.\n", expect->dwHeight, desc->dwHeight); + ok(!memcmp(&U4(*desc).ddpfPixelFormat, &U4(*expect).ddpfPixelFormat, sizeof(U4(*desc).ddpfPixelFormat)), + "Pixel formats didn't match.\n"); + } + + ++param->count; + + return DDENUMRET_OK; +} + static void test_enum_surfaces(void) { - struct enum_surfaces_param param = {{0}}; + struct enum_surfaces_param param = {0}; + DDPIXELFORMAT current_format; DDSURFACEDESC2 desc; IDirectDraw4 *ddraw; HRESULT hr;
ddraw = create_ddraw(); ok(!!ddraw, "Failed to create a ddraw object.\n"); + param.ddraw = ddraw; + + memset(&desc, 0, sizeof(desc)); + desc.dwSize = sizeof(desc); + hr = IDirectDraw4_GetDisplayMode(ddraw, &desc); + ok(hr == DD_OK, "Failed to get display mode, hr %#x.\n", hr); + current_format = U4(desc).ddpfPixelFormat;
hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL); - ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr); + ok(hr == DD_OK, "Failed to set cooperative level, hr %#x.\n", hr); + + hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_ALL, NULL, NULL, enum_surfaces_cb); + todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + + hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL, + NULL, NULL, enum_surfaces_cb); + todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
memset(&desc, 0, sizeof(desc)); desc.dwSize = sizeof(desc); @@ -15704,30 +15760,128 @@ static void test_enum_surfaces(void) desc.dwWidth = 32; desc.dwHeight = 32; hr = IDirectDraw4_CreateSurface(ddraw, &desc, ¶m.surfaces[0], NULL); - ok(SUCCEEDED(hr), "Failed to create a surface, hr %#x.\n", hr); + ok(hr == DD_OK, "Failed to create a surface, hr %#x.\n", hr);
hr = IDirectDrawSurface4_GetAttachedSurface(param.surfaces[0], &desc.ddsCaps, ¶m.surfaces[1]); - ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr); + ok(hr == DD_OK, "Failed to get attached surface, hr %#x.\n", hr); hr = IDirectDrawSurface4_GetAttachedSurface(param.surfaces[1], &desc.ddsCaps, ¶m.surfaces[2]); - ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr); + ok(hr == DD_OK, "Failed to get attached surface, hr %#x.\n", hr); hr = IDirectDrawSurface4_GetAttachedSurface(param.surfaces[2], &desc.ddsCaps, ¶m.surfaces[3]); ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr); ok(!param.surfaces[3], "Got unexpected pointer %p.\n", param.surfaces[3]);
+ param.count = 0; hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, &desc, ¶m, enum_surfaces_cb); - ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
param.count = 0; hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, NULL, ¶m, enum_surfaces_cb); - ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count); + + desc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT; + param.count = 0; + hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); + + param.count = 0; + hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_NOMATCH, + &desc, ¶m, enum_surfaces_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + todo_wine ok(param.count == 2, "Got unexpected number of enumerated surfaces %u.\n", param.count); + + desc.dwFlags = 0; + param.count = 0; + hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count); + + desc.dwFlags = 0; + param.count = 0; + hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST, &desc, ¶m, enum_surfaces_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
IDirectDrawSurface4_Release(param.surfaces[2]); IDirectDrawSurface4_Release(param.surfaces[1]); IDirectDrawSurface4_Release(param.surfaces[0]); + + param.count = 0; + hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, + NULL, ¶m, enum_surfaces_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(!param.count, "Got unexpected number of enumerated surfaces %u.\n", param.count); + + memset(&desc, 0, sizeof(desc)); + desc.dwSize = sizeof(desc); + desc.dwFlags = DDSD_CAPS; + desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE; + + hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL, + &desc, ¶m, enum_surfaces_create_cb); + todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + + hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_NOMATCH, + &desc, ¶m, enum_surfaces_create_cb); + todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + + hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED, + &desc, ¶m, enum_surfaces_create_cb); + todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + + /* When not passed width and height, the callback is called with every + * available display resolution. */ + + param.mode_count = 0; + desc.dwFlags |= DDSD_PIXELFORMAT; + U4(desc).ddpfPixelFormat = current_format; + hr = IDirectDraw4_EnumDisplayModes(ddraw, 0, &desc, ¶m, build_mode_list_cb); + ok(hr == DD_OK, "Failed to build mode list, hr %#x.\n", hr); + + param.count = 0; + desc.dwFlags &= ~DDSD_PIXELFORMAT; + hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_create_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + todo_wine ok(param.count == param.mode_count, "Expected %u surfaces, got %u.\n", param.mode_count, param.count); + + desc.dwFlags |= DDSD_WIDTH | DDSD_HEIGHT; + desc.dwWidth = desc.dwHeight = 32; + + param.modes[0].dwWidth = param.modes[0].dwHeight = 32; + + param.count = 0; + hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_create_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + todo_wine ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); + + hr = IDirectDraw4_CreateSurface(ddraw, &desc, ¶m.surfaces[0], NULL); + ok(hr == DD_OK, "Failed to create surface, hr %#x.\n", hr); + param.count = 0; + hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_create_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + todo_wine ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); + IDirectDrawSurface4_Release(param.surfaces[0]); + + desc.dwFlags |= DDSD_PIXELFORMAT; + U4(desc).ddpfPixelFormat.dwSize = sizeof(U4(desc).ddpfPixelFormat); + U4(desc).ddpfPixelFormat.dwFlags = DDPF_FOURCC; + U4(desc).ddpfPixelFormat.dwFourCC = 0xdeadbeef; + + param.count = 0; + hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_create_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(!param.count, "Got unexpected number of enumerated surfaces %u.\n", param.count); + IDirectDraw4_Release(ddraw); }
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index d3ea36e9808..bf31d3915b9 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -15060,10 +15060,30 @@ static void test_clear(void)
struct enum_surfaces_param { + IDirectDraw7 *ddraw; + DDSURFACEDESC2 modes[20]; + unsigned int mode_count; + IDirectDrawSurface7 *surfaces[8]; unsigned int count; };
+static HRESULT CALLBACK build_mode_list_cb(DDSURFACEDESC2 *desc, void *context) +{ + struct enum_surfaces_param *param = context; + IDirectDrawSurface7 *surface; + + if (SUCCEEDED(IDirectDraw7_CreateSurface(param->ddraw, desc, &surface, NULL))) + { + if (param->mode_count < ARRAY_SIZE(param->modes)) + param->modes[param->mode_count] = *desc; + ++param->mode_count; + IDirectDrawSurface7_Release(surface); + } + + return DDENUMRET_OK; +} + static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface7 *surface, DDSURFACEDESC2 *desc, void *context) { struct enum_surfaces_param *param = context; @@ -15086,18 +15106,57 @@ static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface7 *surface, DDSURFACEDE return DDENUMRET_OK; }
+static HRESULT WINAPI enum_surfaces_create_cb(IDirectDrawSurface7 *surface, DDSURFACEDESC2 *desc, void *context) +{ + static const DWORD expect_flags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH | DDSD_PIXELFORMAT; + struct enum_surfaces_param *param = context; + + ok(!surface, "Unexpected surface %p.\n", surface); + ok((desc->dwFlags & expect_flags) == expect_flags, "Got unexpected flags %#x.\n", desc->dwFlags); + if (param->count < ARRAY_SIZE(param->modes)) + { + const DDSURFACEDESC2 *expect = ¶m->modes[param->count]; + ok(desc->dwWidth == expect->dwWidth, "Expected width %u, got %u.\n", expect->dwWidth, desc->dwWidth); + ok(desc->dwHeight == expect->dwHeight, "Expected height %u, got %u.\n", expect->dwHeight, desc->dwHeight); + ok(!memcmp(&U4(*desc).ddpfPixelFormat, &U4(*expect).ddpfPixelFormat, sizeof(U4(*desc).ddpfPixelFormat)), + "Pixel formats didn't match.\n"); + } + + ++param->count; + + return DDENUMRET_OK; +} + static void test_enum_surfaces(void) { - struct enum_surfaces_param param = {{0}}; + struct enum_surfaces_param param = {0}; + DDPIXELFORMAT current_format; DDSURFACEDESC2 desc; IDirectDraw7 *ddraw; HRESULT hr;
ddraw = create_ddraw(); ok(!!ddraw, "Failed to create a ddraw object.\n"); + param.ddraw = ddraw; + + memset(&desc, 0, sizeof(desc)); + desc.dwSize = sizeof(desc); + hr = IDirectDraw7_GetDisplayMode(ddraw, &desc); + ok(hr == DD_OK, "Failed to get display mode, hr %#x.\n", hr); + current_format = U4(desc).ddpfPixelFormat;
hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL); - ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr); + ok(hr == DD_OK, "Failed to set cooperative level, hr %#x.\n", hr); + + hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, NULL, NULL, NULL); + ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + + hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_ALL, NULL, NULL, enum_surfaces_cb); + todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + + hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL, + NULL, NULL, enum_surfaces_cb); + todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
memset(&desc, 0, sizeof(desc)); desc.dwSize = sizeof(desc); @@ -15114,27 +15173,125 @@ static void test_enum_surfaces(void) }
hr = IDirectDrawSurface7_GetAttachedSurface(param.surfaces[0], &desc.ddsCaps, ¶m.surfaces[1]); - ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr); + ok(hr == DD_OK, "Failed to get attached surface, hr %#x.\n", hr); hr = IDirectDrawSurface7_GetAttachedSurface(param.surfaces[1], &desc.ddsCaps, ¶m.surfaces[2]); - ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr); + ok(hr == DD_OK, "Failed to get attached surface, hr %#x.\n", hr); hr = IDirectDrawSurface7_GetAttachedSurface(param.surfaces[2], &desc.ddsCaps, ¶m.surfaces[3]); ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr); ok(!param.surfaces[3], "Got unexpected pointer %p.\n", param.surfaces[3]);
+ param.count = 0; hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, &desc, ¶m, enum_surfaces_cb); - ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
param.count = 0; hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, NULL, ¶m, enum_surfaces_cb); - ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count); + + desc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT; + param.count = 0; + hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); + + param.count = 0; + hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_NOMATCH, + &desc, ¶m, enum_surfaces_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + todo_wine ok(param.count == 2, "Got unexpected number of enumerated surfaces %u.\n", param.count); + + desc.dwFlags = 0; + param.count = 0; + hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count); + + desc.dwFlags = 0; + param.count = 0; + hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST, &desc, ¶m, enum_surfaces_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
IDirectDrawSurface7_Release(param.surfaces[2]); IDirectDrawSurface7_Release(param.surfaces[1]); IDirectDrawSurface7_Release(param.surfaces[0]); + + param.count = 0; + hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, + NULL, ¶m, enum_surfaces_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(!param.count, "Got unexpected number of enumerated surfaces %u.\n", param.count); + + memset(&desc, 0, sizeof(desc)); + desc.dwSize = sizeof(desc); + desc.dwFlags = DDSD_CAPS; + desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE; + + hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL, + &desc, ¶m, enum_surfaces_create_cb); + todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + + hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_NOMATCH, + &desc, ¶m, enum_surfaces_create_cb); + todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + + hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED, + &desc, ¶m, enum_surfaces_create_cb); + todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + + /* When not passed width and height, the callback is called with every + * available display resolution. */ + + param.mode_count = 0; + desc.dwFlags |= DDSD_PIXELFORMAT; + U4(desc).ddpfPixelFormat = current_format; + hr = IDirectDraw7_EnumDisplayModes(ddraw, 0, &desc, ¶m, build_mode_list_cb); + ok(hr == DD_OK, "Failed to build mode list, hr %#x.\n", hr); + + param.count = 0; + desc.dwFlags &= ~DDSD_PIXELFORMAT; + hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_create_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + todo_wine ok(param.count == param.mode_count, "Expected %u surfaces, got %u.\n", param.mode_count, param.count); + + desc.dwFlags |= DDSD_WIDTH | DDSD_HEIGHT; + desc.dwWidth = desc.dwHeight = 32; + + param.modes[0].dwWidth = param.modes[0].dwHeight = 32; + + param.count = 0; + hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_create_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + todo_wine ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); + + hr = IDirectDraw7_CreateSurface(ddraw, &desc, ¶m.surfaces[0], NULL); + ok(hr == DD_OK, "Failed to create surface, hr %#x.\n", hr); + param.count = 0; + hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_create_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + todo_wine ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); + IDirectDrawSurface7_Release(param.surfaces[0]); + + desc.dwFlags |= DDSD_PIXELFORMAT; + U4(desc).ddpfPixelFormat.dwSize = sizeof(U4(desc).ddpfPixelFormat); + U4(desc).ddpfPixelFormat.dwFlags = DDPF_FOURCC; + U4(desc).ddpfPixelFormat.dwFourCC = 0xdeadbeef; + + param.count = 0; + hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH, + &desc, ¶m, enum_surfaces_create_cb); + ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(!param.count, "Got unexpected number of enumerated surfaces %u.\n", param.count); + IDirectDraw7_Release(ddraw); }
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/ddraw/ddraw.c | 8 ++++---- dlls/ddraw/tests/ddraw1.c | 2 +- dlls/ddraw/tests/ddraw2.c | 2 +- dlls/ddraw/tests/ddraw4.c | 2 +- dlls/ddraw/tests/ddraw7.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index b7e7e6514a8..afd2875ea21 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -3213,7 +3213,7 @@ static HRESULT CALLBACK EnumSurfacesCallbackThunk(IDirectDrawSurface7 *surface, * DD_OK on success * *****************************************************************************/ -static HRESULT WINAPI ddraw7_EnumSurfaces(IDirectDraw7 *iface, DWORD Flags, +static HRESULT WINAPI ddraw7_EnumSurfaces(IDirectDraw7 *iface, DWORD flags, DDSURFACEDESC2 *DDSD, void *Context, LPDDENUMSURFACESCALLBACK7 Callback) { struct ddraw *ddraw = impl_from_IDirectDraw7(iface); @@ -3223,10 +3223,10 @@ static HRESULT WINAPI ddraw7_EnumSurfaces(IDirectDraw7 *iface, DWORD Flags, struct list *entry, *entry2;
TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n", - iface, Flags, DDSD, Context, Callback); + iface, flags, DDSD, Context, Callback);
- all = Flags & DDENUMSURFACES_ALL; - nomatch = Flags & DDENUMSURFACES_NOMATCH; + all = flags & DDENUMSURFACES_ALL; + nomatch = !!(flags & DDENUMSURFACES_NOMATCH);
if (!Callback) return DDERR_INVALIDPARAMS; diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index 0e1de7909dd..4a1818af6ab 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -12229,7 +12229,7 @@ static void test_enum_surfaces(void) hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_NOMATCH, &desc, ¶m, enum_surfaces_cb); ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); - todo_wine ok(param.count == 2, "Got unexpected number of enumerated surfaces %u.\n", param.count); + ok(param.count == 2, "Got unexpected number of enumerated surfaces %u.\n", param.count);
desc.dwFlags = 0; param.count = 0; diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index 8d38344520c..03615c61cea 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -13205,7 +13205,7 @@ static void test_enum_surfaces(void) hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_NOMATCH, &desc, ¶m, enum_surfaces_cb); ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); - todo_wine ok(param.count == 2, "Got unexpected number of enumerated surfaces %u.\n", param.count); + ok(param.count == 2, "Got unexpected number of enumerated surfaces %u.\n", param.count);
desc.dwFlags = 0; param.count = 0; diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 3a3983639de..ce6c8aaf228 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -15793,7 +15793,7 @@ static void test_enum_surfaces(void) hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_NOMATCH, &desc, ¶m, enum_surfaces_cb); ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); - todo_wine ok(param.count == 2, "Got unexpected number of enumerated surfaces %u.\n", param.count); + ok(param.count == 2, "Got unexpected number of enumerated surfaces %u.\n", param.count);
desc.dwFlags = 0; param.count = 0; diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index bf31d3915b9..466fcc544a9 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -15203,7 +15203,7 @@ static void test_enum_surfaces(void) hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_NOMATCH, &desc, ¶m, enum_surfaces_cb); ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); - todo_wine ok(param.count == 2, "Got unexpected number of enumerated surfaces %u.\n", param.count); + ok(param.count == 2, "Got unexpected number of enumerated surfaces %u.\n", param.count);
desc.dwFlags = 0; param.count = 0;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=71071
Your paranoid android.
=== w864 (64 bit report) ===
ddraw: ddraw2.c:3178: Test failed: Failed to create surface, hr 0x887601c2. 0c24:ddraw2: unhandled exception c0000005 at 0000000000472746
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=17233 Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/ddraw/ddraw.c | 137 ++++++++++++++++++++++++++++++-------- dlls/ddraw/tests/ddraw1.c | 16 ++--- dlls/ddraw/tests/ddraw2.c | 16 ++--- dlls/ddraw/tests/ddraw4.c | 16 ++--- dlls/ddraw/tests/ddraw7.c | 16 ++--- 5 files changed, 142 insertions(+), 59 deletions(-)
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index afd2875ea21..866b7089080 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -3174,6 +3174,9 @@ static HRESULT CALLBACK EnumSurfacesCallback2Thunk(IDirectDrawSurface7 *surface, struct ddraw_surface *surface_impl = impl_from_IDirectDrawSurface7(surface); struct surfacescallback2_context *cbcontext = context;
+ if (!surface) + return cbcontext->func(NULL, surface_desc, cbcontext->context); + IDirectDrawSurface4_AddRef(&surface_impl->IDirectDrawSurface4_iface); IDirectDrawSurface7_Release(surface);
@@ -3187,6 +3190,9 @@ static HRESULT CALLBACK EnumSurfacesCallbackThunk(IDirectDrawSurface7 *surface, struct ddraw_surface *surface_impl = impl_from_IDirectDrawSurface7(surface); struct surfacescallback_context *cbcontext = context;
+ if (!surface) + return cbcontext->func(NULL, (DDSURFACEDESC *)surface_desc, cbcontext->context); + IDirectDrawSurface_AddRef(&surface_impl->IDirectDrawSurface_iface); IDirectDrawSurface7_Release(surface);
@@ -3194,6 +3200,34 @@ static HRESULT CALLBACK EnumSurfacesCallbackThunk(IDirectDrawSurface7 *surface, (DDSURFACEDESC *)surface_desc, cbcontext->context); }
+struct enum_surface_mode_params +{ + IDirectDraw7 *ddraw; + const DDSURFACEDESC2 *desc; + LPDDENUMSURFACESCALLBACK7 callback; + void *context; +}; + +static HRESULT CALLBACK enum_surface_mode_callback(DDSURFACEDESC2 *surface_desc, void *context) +{ + const struct enum_surface_mode_params *params = context; + DDSURFACEDESC2 desc = *params->desc; + IDirectDrawSurface7 *surface; + + desc.dwFlags |= DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH | DDSD_PIXELFORMAT; + desc.dwWidth = surface_desc->dwWidth; + desc.dwHeight = surface_desc->dwHeight; + desc.u1.lPitch = surface_desc->u1.lPitch; + desc.u4.ddpfPixelFormat = surface_desc->u4.ddpfPixelFormat; + + if (SUCCEEDED(ddraw7_CreateSurface(params->ddraw, &desc, &surface, NULL))) + { + IDirectDrawSurface7_Release(surface); + return params->callback(NULL, &desc, params->context); + } + return DDENUMRET_OK; +} + /***************************************************************************** * IDirectDraw7::EnumSurfaces * @@ -3214,52 +3248,101 @@ static HRESULT CALLBACK EnumSurfacesCallbackThunk(IDirectDrawSurface7 *surface, * *****************************************************************************/ static HRESULT WINAPI ddraw7_EnumSurfaces(IDirectDraw7 *iface, DWORD flags, - DDSURFACEDESC2 *DDSD, void *Context, LPDDENUMSURFACESCALLBACK7 Callback) + DDSURFACEDESC2 *surface_desc, void *context, LPDDENUMSURFACESCALLBACK7 callback) { struct ddraw *ddraw = impl_from_IDirectDraw7(iface); - struct ddraw_surface *surf; - BOOL all, nomatch; - DDSURFACEDESC2 desc; - struct list *entry, *entry2; + HRESULT hr = DD_OK;
TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n", - iface, flags, DDSD, Context, Callback); - - all = flags & DDENUMSURFACES_ALL; - nomatch = !!(flags & DDENUMSURFACES_NOMATCH); + iface, flags, surface_desc, context, callback);
- if (!Callback) + if (!callback) return DDERR_INVALIDPARAMS;
- wined3d_mutex_lock(); - - /* Use the _SAFE enumeration, the app may destroy enumerated surfaces */ - LIST_FOR_EACH_SAFE(entry, entry2, &ddraw->surface_list) + if (flags & DDENUMSURFACES_CANBECREATED) { - surf = LIST_ENTRY(entry, struct ddraw_surface, surface_list_entry); + IDirectDrawSurface7 *surface; + + if ((flags & (DDENUMSURFACES_ALL | DDENUMSURFACES_MATCH | DDENUMSURFACES_NOMATCH)) != DDENUMSURFACES_MATCH) + return DDERR_INVALIDPARAMS;
- if (!surf->iface_count) + wined3d_mutex_lock(); + + if (surface_desc->dwFlags & (DDSD_WIDTH | DDSD_HEIGHT)) { - WARN("Not enumerating surface %p because it doesn't have any references.\n", surf); - continue; + if (SUCCEEDED(ddraw7_CreateSurface(iface, surface_desc, &surface, NULL))) + { + struct ddraw_surface *surface_impl = impl_from_IDirectDrawSurface7(surface); + callback(NULL, &surface_impl->surface_desc, context); + IDirectDrawSurface7_Release(surface); + } } - - if (all || (nomatch != ddraw_match_surface_desc(DDSD, &surf->surface_desc))) + else { - TRACE("Enumerating surface %p.\n", surf); - desc = surf->surface_desc; - IDirectDrawSurface7_AddRef(&surf->IDirectDrawSurface7_iface); - if (Callback(&surf->IDirectDrawSurface7_iface, &desc, Context) != DDENUMRET_OK) + DDSURFACEDESC2 desc = { + .dwSize = sizeof(desc), + .dwFlags = DDSD_PIXELFORMAT, + .u4.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT), + }; + struct enum_surface_mode_params params = + { + .ddraw = iface, + .desc = surface_desc, + .callback = callback, + .context = context, + }; + struct wined3d_display_mode mode; + + if (FAILED(hr = wined3d_output_get_display_mode(ddraw->wined3d_output, &mode, NULL))) + { + ERR("Failed to get display mode, hr %#x.\n", hr); wined3d_mutex_unlock(); - return DD_OK; + return hr_ddraw_from_wined3d(hr); } + + ddrawformat_from_wined3dformat(&desc.u4.ddpfPixelFormat, mode.format_id); + hr = ddraw7_EnumDisplayModes(iface, 0, &desc, ¶ms, enum_surface_mode_callback); } + + wined3d_mutex_unlock(); } + else if (flags & DDENUMSURFACES_DOESEXIST) + { + struct ddraw_surface *surface, *cursor; + BOOL nomatch = !!(flags & DDENUMSURFACES_NOMATCH);
- wined3d_mutex_unlock(); + wined3d_mutex_lock();
- return DD_OK; + /* Use the safe enumeration, as the callback may destroy surfaces. */ + LIST_FOR_EACH_ENTRY_SAFE(surface, cursor, &ddraw->surface_list, struct ddraw_surface, surface_list_entry) + { + if (!surface->iface_count) + { + WARN("Not enumerating surface %p because it doesn't have any references.\n", surface); + continue; + } + + if ((flags & DDENUMSURFACES_ALL) + || nomatch != ddraw_match_surface_desc(surface_desc, &surface->surface_desc)) + { + DDSURFACEDESC2 desc = surface->surface_desc; + + TRACE("Enumerating surface %p.\n", surface); + IDirectDrawSurface7_AddRef(&surface->IDirectDrawSurface7_iface); + if (callback(&surface->IDirectDrawSurface7_iface, &desc, context) != DDENUMRET_OK) + break; + } + } + + wined3d_mutex_unlock(); + } + else + { + return DDERR_INVALIDPARAMS; + } + + return hr; }
static HRESULT WINAPI ddraw4_EnumSurfaces(IDirectDraw4 *iface, DWORD flags, diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index 4a1818af6ab..f74d12d9fda 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -12182,11 +12182,11 @@ static void test_enum_surfaces(void) ok(hr == DD_OK, "Failed to set cooperative level, hr %#x.\n", hr);
hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_ALL, NULL, NULL, enum_surfaces_cb); - todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL, NULL, NULL, enum_surfaces_cb); - todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
memset(&desc, 0, sizeof(desc)); desc.dwSize = sizeof(desc); @@ -12261,15 +12261,15 @@ static void test_enum_surfaces(void)
hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL, &desc, ¶m, enum_surfaces_create_cb); - todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_NOMATCH, &desc, ¶m, enum_surfaces_create_cb); - todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED, &desc, ¶m, enum_surfaces_create_cb); - todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
/* When not passed width and height, the callback is called with every * available display resolution. */ @@ -12285,7 +12285,7 @@ static void test_enum_surfaces(void) hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH, &desc, ¶m, enum_surfaces_create_cb); ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); - todo_wine ok(param.count == param.mode_count, "Expected %u surfaces, got %u.\n", param.mode_count, param.count); + ok(param.count == param.mode_count, "Expected %u surfaces, got %u.\n", param.mode_count, param.count);
desc.dwFlags |= DDSD_WIDTH | DDSD_HEIGHT; desc.dwWidth = desc.dwHeight = 32; @@ -12296,7 +12296,7 @@ static void test_enum_surfaces(void) hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH, &desc, ¶m, enum_surfaces_create_cb); ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); - todo_wine ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); + ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count);
hr = IDirectDraw_CreateSurface(ddraw, &desc, ¶m.surfaces[0], NULL); ok(hr == DD_OK, "Failed to create surface, hr %#x.\n", hr); @@ -12304,7 +12304,7 @@ static void test_enum_surfaces(void) hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH, &desc, ¶m, enum_surfaces_create_cb); ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); - todo_wine ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); + ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); IDirectDrawSurface_Release(param.surfaces[0]);
desc.dwFlags |= DDSD_PIXELFORMAT; diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index 03615c61cea..d4e681c0164 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -13158,11 +13158,11 @@ static void test_enum_surfaces(void) ok(hr == DD_OK, "Failed to set cooperative level, hr %#x.\n", hr);
hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_ALL, NULL, NULL, enum_surfaces_cb); - todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL, NULL, NULL, enum_surfaces_cb); - todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
memset(&desc, 0, sizeof(desc)); desc.dwSize = sizeof(desc); @@ -13237,15 +13237,15 @@ static void test_enum_surfaces(void)
hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL, &desc, ¶m, enum_surfaces_create_cb); - todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_NOMATCH, &desc, ¶m, enum_surfaces_create_cb); - todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED, &desc, ¶m, enum_surfaces_create_cb); - todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
/* When not passed width and height, the callback is called with every * available display resolution. */ @@ -13261,7 +13261,7 @@ static void test_enum_surfaces(void) hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH, &desc, ¶m, enum_surfaces_create_cb); ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); - todo_wine ok(param.count == param.mode_count, "Expected %u surfaces, got %u.\n", param.mode_count, param.count); + ok(param.count == param.mode_count, "Expected %u surfaces, got %u.\n", param.mode_count, param.count);
desc.dwFlags |= DDSD_WIDTH | DDSD_HEIGHT; desc.dwWidth = desc.dwHeight = 32; @@ -13272,7 +13272,7 @@ static void test_enum_surfaces(void) hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH, &desc, ¶m, enum_surfaces_create_cb); ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); - todo_wine ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); + ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count);
hr = IDirectDraw2_CreateSurface(ddraw, &desc, ¶m.surfaces[0], NULL); ok(hr == DD_OK, "Failed to create surface, hr %#x.\n", hr); @@ -13280,7 +13280,7 @@ static void test_enum_surfaces(void) hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH, &desc, ¶m, enum_surfaces_create_cb); ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); - todo_wine ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); + ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); IDirectDrawSurface2_Release(param.surfaces[0]);
desc.dwFlags |= DDSD_PIXELFORMAT; diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index ce6c8aaf228..f50fc1cb53b 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -15746,11 +15746,11 @@ static void test_enum_surfaces(void) ok(hr == DD_OK, "Failed to set cooperative level, hr %#x.\n", hr);
hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_ALL, NULL, NULL, enum_surfaces_cb); - todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL, NULL, NULL, enum_surfaces_cb); - todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
memset(&desc, 0, sizeof(desc)); desc.dwSize = sizeof(desc); @@ -15825,15 +15825,15 @@ static void test_enum_surfaces(void)
hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL, &desc, ¶m, enum_surfaces_create_cb); - todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_NOMATCH, &desc, ¶m, enum_surfaces_create_cb); - todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED, &desc, ¶m, enum_surfaces_create_cb); - todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
/* When not passed width and height, the callback is called with every * available display resolution. */ @@ -15849,7 +15849,7 @@ static void test_enum_surfaces(void) hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH, &desc, ¶m, enum_surfaces_create_cb); ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); - todo_wine ok(param.count == param.mode_count, "Expected %u surfaces, got %u.\n", param.mode_count, param.count); + ok(param.count == param.mode_count, "Expected %u surfaces, got %u.\n", param.mode_count, param.count);
desc.dwFlags |= DDSD_WIDTH | DDSD_HEIGHT; desc.dwWidth = desc.dwHeight = 32; @@ -15860,7 +15860,7 @@ static void test_enum_surfaces(void) hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH, &desc, ¶m, enum_surfaces_create_cb); ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); - todo_wine ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); + ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count);
hr = IDirectDraw4_CreateSurface(ddraw, &desc, ¶m.surfaces[0], NULL); ok(hr == DD_OK, "Failed to create surface, hr %#x.\n", hr); @@ -15868,7 +15868,7 @@ static void test_enum_surfaces(void) hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH, &desc, ¶m, enum_surfaces_create_cb); ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); - todo_wine ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); + ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); IDirectDrawSurface4_Release(param.surfaces[0]);
desc.dwFlags |= DDSD_PIXELFORMAT; diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 466fcc544a9..1ddd3cdb0e2 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -15152,11 +15152,11 @@ static void test_enum_surfaces(void) ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_ALL, NULL, NULL, enum_surfaces_cb); - todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL, NULL, NULL, enum_surfaces_cb); - todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr); + ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
memset(&desc, 0, sizeof(desc)); desc.dwSize = sizeof(desc); @@ -15235,15 +15235,15 @@ static void test_enum_surfaces(void)
hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL, &desc, ¶m, enum_surfaces_create_cb); - todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_NOMATCH, &desc, ¶m, enum_surfaces_create_cb); - todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED, &desc, ¶m, enum_surfaces_create_cb); - todo_wine ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr); + ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
/* When not passed width and height, the callback is called with every * available display resolution. */ @@ -15259,7 +15259,7 @@ static void test_enum_surfaces(void) hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH, &desc, ¶m, enum_surfaces_create_cb); ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); - todo_wine ok(param.count == param.mode_count, "Expected %u surfaces, got %u.\n", param.mode_count, param.count); + ok(param.count == param.mode_count, "Expected %u surfaces, got %u.\n", param.mode_count, param.count);
desc.dwFlags |= DDSD_WIDTH | DDSD_HEIGHT; desc.dwWidth = desc.dwHeight = 32; @@ -15270,7 +15270,7 @@ static void test_enum_surfaces(void) hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH, &desc, ¶m, enum_surfaces_create_cb); ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); - todo_wine ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); + ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count);
hr = IDirectDraw7_CreateSurface(ddraw, &desc, ¶m.surfaces[0], NULL); ok(hr == DD_OK, "Failed to create surface, hr %#x.\n", hr); @@ -15278,7 +15278,7 @@ static void test_enum_surfaces(void) hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH, &desc, ¶m, enum_surfaces_create_cb); ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr); - todo_wine ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); + ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count); IDirectDrawSurface7_Release(param.surfaces[0]);
desc.dwFlags |= DDSD_PIXELFORMAT;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=71072
Your paranoid android.
=== w8 (32 bit report) ===
ddraw: 0d44:ddraw4: unhandled exception c0000005 at 69E53599
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=71070
Your paranoid android.
=== w8 (32 bit report) ===
ddraw: 0d60:ddraw2: unhandled exception c0000005 at 69E33599