ddraw/tests: Add more tests for EnumSurfaces().
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
1962a1f969
commit
2389fae064
|
@ -12093,10 +12093,30 @@ static void test_clear(void)
|
||||||
|
|
||||||
struct enum_surfaces_param
|
struct enum_surfaces_param
|
||||||
{
|
{
|
||||||
|
IDirectDraw *ddraw;
|
||||||
|
DDSURFACEDESC modes[20];
|
||||||
|
unsigned int mode_count;
|
||||||
|
|
||||||
IDirectDrawSurface *surfaces[8];
|
IDirectDrawSurface *surfaces[8];
|
||||||
unsigned int count;
|
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)
|
static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface *surface, DDSURFACEDESC *desc, void *context)
|
||||||
{
|
{
|
||||||
struct enum_surfaces_param *param = context;
|
struct enum_surfaces_param *param = context;
|
||||||
|
@ -12119,18 +12139,54 @@ static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface *surface, DDSURFACEDES
|
||||||
return DDENUMRET_OK;
|
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)
|
static void test_enum_surfaces(void)
|
||||||
{
|
{
|
||||||
struct enum_surfaces_param param = {{0}};
|
struct enum_surfaces_param param = {0};
|
||||||
|
DDPIXELFORMAT current_format;
|
||||||
IDirectDraw *ddraw;
|
IDirectDraw *ddraw;
|
||||||
DDSURFACEDESC desc;
|
DDSURFACEDESC desc;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
ddraw = create_ddraw();
|
ddraw = create_ddraw();
|
||||||
ok(!!ddraw, "Failed to create a ddraw object.\n");
|
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);
|
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));
|
memset(&desc, 0, sizeof(desc));
|
||||||
desc.dwSize = 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(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
|
||||||
ok(!param.surfaces[3], "Got unexpected pointer %p.\n", param.surfaces[3]);
|
ok(!param.surfaces[3], "Got unexpected pointer %p.\n", param.surfaces[3]);
|
||||||
|
|
||||||
|
param.count = 0;
|
||||||
hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
|
hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
|
||||||
&desc, ¶m, enum_surfaces_cb);
|
&desc, ¶m, enum_surfaces_cb);
|
||||||
ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr);
|
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(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr);
|
||||||
ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
|
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[2]);
|
||||||
IDirectDrawSurface_Release(param.surfaces[1]);
|
IDirectDrawSurface_Release(param.surfaces[1]);
|
||||||
IDirectDrawSurface_Release(param.surfaces[0]);
|
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);
|
IDirectDraw_Release(ddraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13069,10 +13069,30 @@ static void test_clear(void)
|
||||||
|
|
||||||
struct enum_surfaces_param
|
struct enum_surfaces_param
|
||||||
{
|
{
|
||||||
|
IDirectDraw2 *ddraw;
|
||||||
|
DDSURFACEDESC modes[20];
|
||||||
|
unsigned int mode_count;
|
||||||
|
|
||||||
IDirectDrawSurface *surfaces[8];
|
IDirectDrawSurface *surfaces[8];
|
||||||
unsigned int count;
|
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)
|
static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface *surface, DDSURFACEDESC *desc, void *context)
|
||||||
{
|
{
|
||||||
struct enum_surfaces_param *param = context;
|
struct enum_surfaces_param *param = context;
|
||||||
|
@ -13095,18 +13115,54 @@ static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface *surface, DDSURFACEDES
|
||||||
return DDENUMRET_OK;
|
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)
|
static void test_enum_surfaces(void)
|
||||||
{
|
{
|
||||||
struct enum_surfaces_param param = {{0}};
|
struct enum_surfaces_param param = {0};
|
||||||
|
DDPIXELFORMAT current_format;
|
||||||
IDirectDraw2 *ddraw;
|
IDirectDraw2 *ddraw;
|
||||||
DDSURFACEDESC desc;
|
DDSURFACEDESC desc;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
ddraw = create_ddraw();
|
ddraw = create_ddraw();
|
||||||
ok(!!ddraw, "Failed to create a ddraw object.\n");
|
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);
|
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));
|
memset(&desc, 0, sizeof(desc));
|
||||||
desc.dwSize = 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(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
|
||||||
ok(!param.surfaces[3], "Got unexpected pointer %p.\n", param.surfaces[3]);
|
ok(!param.surfaces[3], "Got unexpected pointer %p.\n", param.surfaces[3]);
|
||||||
|
|
||||||
|
param.count = 0;
|
||||||
hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
|
hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
|
||||||
&desc, ¶m, enum_surfaces_cb);
|
&desc, ¶m, enum_surfaces_cb);
|
||||||
ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr);
|
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(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr);
|
||||||
ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
|
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[2]);
|
||||||
IDirectDrawSurface_Release(param.surfaces[1]);
|
IDirectDrawSurface_Release(param.surfaces[1]);
|
||||||
IDirectDrawSurface_Release(param.surfaces[0]);
|
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);
|
IDirectDraw2_Release(ddraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15657,10 +15657,30 @@ static void test_clear(void)
|
||||||
|
|
||||||
struct enum_surfaces_param
|
struct enum_surfaces_param
|
||||||
{
|
{
|
||||||
|
IDirectDraw4 *ddraw;
|
||||||
|
DDSURFACEDESC2 modes[20];
|
||||||
|
unsigned int mode_count;
|
||||||
|
|
||||||
IDirectDrawSurface4 *surfaces[8];
|
IDirectDrawSurface4 *surfaces[8];
|
||||||
unsigned int count;
|
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)
|
static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface4 *surface, DDSURFACEDESC2 *desc, void *context)
|
||||||
{
|
{
|
||||||
struct enum_surfaces_param *param = context;
|
struct enum_surfaces_param *param = context;
|
||||||
|
@ -15683,18 +15703,54 @@ static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface4 *surface, DDSURFACEDE
|
||||||
return DDENUMRET_OK;
|
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)
|
static void test_enum_surfaces(void)
|
||||||
{
|
{
|
||||||
struct enum_surfaces_param param = {{0}};
|
struct enum_surfaces_param param = {0};
|
||||||
|
DDPIXELFORMAT current_format;
|
||||||
DDSURFACEDESC2 desc;
|
DDSURFACEDESC2 desc;
|
||||||
IDirectDraw4 *ddraw;
|
IDirectDraw4 *ddraw;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
ddraw = create_ddraw();
|
ddraw = create_ddraw();
|
||||||
ok(!!ddraw, "Failed to create a ddraw object.\n");
|
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);
|
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));
|
memset(&desc, 0, sizeof(desc));
|
||||||
desc.dwSize = sizeof(desc);
|
desc.dwSize = sizeof(desc);
|
||||||
|
@ -15704,30 +15760,128 @@ static void test_enum_surfaces(void)
|
||||||
desc.dwWidth = 32;
|
desc.dwWidth = 32;
|
||||||
desc.dwHeight = 32;
|
desc.dwHeight = 32;
|
||||||
hr = IDirectDraw4_CreateSurface(ddraw, &desc, ¶m.surfaces[0], NULL);
|
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]);
|
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]);
|
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]);
|
hr = IDirectDrawSurface4_GetAttachedSurface(param.surfaces[2], &desc.ddsCaps, ¶m.surfaces[3]);
|
||||||
ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
|
ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
|
||||||
ok(!param.surfaces[3], "Got unexpected pointer %p.\n", param.surfaces[3]);
|
ok(!param.surfaces[3], "Got unexpected pointer %p.\n", param.surfaces[3]);
|
||||||
|
|
||||||
|
param.count = 0;
|
||||||
hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
|
hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
|
||||||
&desc, ¶m, enum_surfaces_cb);
|
&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);
|
ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
|
||||||
|
|
||||||
param.count = 0;
|
param.count = 0;
|
||||||
hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
|
hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
|
||||||
NULL, ¶m, enum_surfaces_cb);
|
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);
|
ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
|
||||||
|
|
||||||
IDirectDrawSurface4_Release(param.surfaces[2]);
|
IDirectDrawSurface4_Release(param.surfaces[2]);
|
||||||
IDirectDrawSurface4_Release(param.surfaces[1]);
|
IDirectDrawSurface4_Release(param.surfaces[1]);
|
||||||
IDirectDrawSurface4_Release(param.surfaces[0]);
|
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);
|
IDirectDraw4_Release(ddraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15060,10 +15060,30 @@ static void test_clear(void)
|
||||||
|
|
||||||
struct enum_surfaces_param
|
struct enum_surfaces_param
|
||||||
{
|
{
|
||||||
|
IDirectDraw7 *ddraw;
|
||||||
|
DDSURFACEDESC2 modes[20];
|
||||||
|
unsigned int mode_count;
|
||||||
|
|
||||||
IDirectDrawSurface7 *surfaces[8];
|
IDirectDrawSurface7 *surfaces[8];
|
||||||
unsigned int count;
|
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)
|
static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface7 *surface, DDSURFACEDESC2 *desc, void *context)
|
||||||
{
|
{
|
||||||
struct enum_surfaces_param *param = context;
|
struct enum_surfaces_param *param = context;
|
||||||
|
@ -15086,18 +15106,57 @@ static HRESULT WINAPI enum_surfaces_cb(IDirectDrawSurface7 *surface, DDSURFACEDE
|
||||||
return DDENUMRET_OK;
|
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)
|
static void test_enum_surfaces(void)
|
||||||
{
|
{
|
||||||
struct enum_surfaces_param param = {{0}};
|
struct enum_surfaces_param param = {0};
|
||||||
|
DDPIXELFORMAT current_format;
|
||||||
DDSURFACEDESC2 desc;
|
DDSURFACEDESC2 desc;
|
||||||
IDirectDraw7 *ddraw;
|
IDirectDraw7 *ddraw;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
ddraw = create_ddraw();
|
ddraw = create_ddraw();
|
||||||
ok(!!ddraw, "Failed to create a ddraw object.\n");
|
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);
|
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));
|
memset(&desc, 0, sizeof(desc));
|
||||||
desc.dwSize = 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]);
|
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]);
|
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]);
|
hr = IDirectDrawSurface7_GetAttachedSurface(param.surfaces[2], &desc.ddsCaps, ¶m.surfaces[3]);
|
||||||
ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
|
ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
|
||||||
ok(!param.surfaces[3], "Got unexpected pointer %p.\n", param.surfaces[3]);
|
ok(!param.surfaces[3], "Got unexpected pointer %p.\n", param.surfaces[3]);
|
||||||
|
|
||||||
|
param.count = 0;
|
||||||
hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
|
hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
|
||||||
&desc, ¶m, enum_surfaces_cb);
|
&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);
|
ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
|
||||||
|
|
||||||
param.count = 0;
|
param.count = 0;
|
||||||
hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
|
hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
|
||||||
NULL, ¶m, enum_surfaces_cb);
|
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);
|
ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
|
||||||
|
|
||||||
IDirectDrawSurface7_Release(param.surfaces[2]);
|
IDirectDrawSurface7_Release(param.surfaces[2]);
|
||||||
IDirectDrawSurface7_Release(param.surfaces[1]);
|
IDirectDrawSurface7_Release(param.surfaces[1]);
|
||||||
IDirectDrawSurface7_Release(param.surfaces[0]);
|
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);
|
IDirectDraw7_Release(ddraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue