[PATCH 1/5] ddraw/tests: Add a surface flipping test.
Henri Verbeet
hverbeet at codeweavers.com
Tue Dec 3 02:59:15 CST 2013
---
dlls/ddraw/tests/ddraw1.c | 186 +++++++++++++++++++++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw2.c | 186 +++++++++++++++++++++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw4.c | 186 +++++++++++++++++++++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw7.c | 186 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 744 insertions(+)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index 9126b2f..e3ef214 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -3532,6 +3532,191 @@ static void test_surface_discard(void)
DestroyWindow(window);
}
+static void test_flip(void)
+{
+ const DWORD placement = DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY;
+ IDirectDrawSurface *primary, *backbuffer1, *backbuffer2, *backbuffer3, *surface;
+ DDSCAPS caps = {DDSCAPS_FLIP};
+ DDSURFACEDESC surface_desc;
+ BOOL sysmem_primary;
+ IDirectDraw *ddraw;
+ D3DCOLOR color;
+ ULONG refcount;
+ HWND window;
+ DDBLTFX fx;
+ HRESULT hr;
+
+ if (!(ddraw = create_ddraw()))
+ {
+ skip("Failed to create a ddraw object, skipping test.\n");
+ return;
+ }
+
+ window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+
+ hr = IDirectDraw_SetDisplayMode(ddraw, 640, 480, 32);
+ ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ surface_desc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
+ surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
+ surface_desc.dwBackBufferCount = 3;
+ hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &primary, NULL);
+ ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface_GetSurfaceDesc(primary, &surface_desc);
+ ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+ ok((surface_desc.ddsCaps.dwCaps & ~placement)
+ == (DDSCAPS_VISIBLE | DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER | DDSCAPS_FLIP | DDSCAPS_COMPLEX),
+ "Got unexpected caps %#x.\n", surface_desc.ddsCaps.dwCaps);
+ sysmem_primary = surface_desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY;
+
+ hr = IDirectDrawSurface_GetAttachedSurface(primary, &caps, &backbuffer1);
+ ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface_GetSurfaceDesc(backbuffer1, &surface_desc);
+ ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+ todo_wine ok((surface_desc.ddsCaps.dwCaps & ~placement) == (DDSCAPS_FLIP | DDSCAPS_COMPLEX | DDSCAPS_BACKBUFFER),
+ "Got unexpected caps %#x.\n", surface_desc.ddsCaps.dwCaps);
+
+ hr = IDirectDrawSurface_GetAttachedSurface(backbuffer1, &caps, &backbuffer2);
+ ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface_GetSurfaceDesc(backbuffer2, &surface_desc);
+ ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+ todo_wine ok((surface_desc.ddsCaps.dwCaps & ~placement) == (DDSCAPS_FLIP | DDSCAPS_COMPLEX),
+ "Got unexpected caps %#x.\n", surface_desc.ddsCaps.dwCaps);
+
+ hr = IDirectDrawSurface_GetAttachedSurface(backbuffer2, &caps, &backbuffer3);
+ ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface_GetSurfaceDesc(backbuffer3, &surface_desc);
+ ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+ todo_wine ok((surface_desc.ddsCaps.dwCaps & ~placement) == (DDSCAPS_FLIP | DDSCAPS_COMPLEX),
+ "Got unexpected caps %#x.\n", surface_desc.ddsCaps.dwCaps);
+
+ hr = IDirectDrawSurface_GetAttachedSurface(backbuffer3, &caps, &surface);
+ todo_wine ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+ todo_wine ok(surface == primary, "Got unexpected surface %p, expected %p.\n", surface, primary);
+ if (surface)
+ IDirectDrawSurface_Release(surface);
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
+ surface_desc.ddsCaps.dwCaps = 0;
+ surface_desc.dwWidth = 640;
+ surface_desc.dwHeight = 480;
+ hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
+ ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+ hr = IDirectDrawSurface_Flip(primary, surface, DDFLIP_WAIT);
+ todo_wine ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+ IDirectDrawSurface_Release(surface);
+
+ hr = IDirectDrawSurface_Flip(primary, primary, DDFLIP_WAIT);
+ todo_wine ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+ hr = IDirectDrawSurface_Flip(backbuffer1, NULL, DDFLIP_WAIT);
+ todo_wine ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+ hr = IDirectDrawSurface_Flip(backbuffer2, NULL, DDFLIP_WAIT);
+ todo_wine ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+ hr = IDirectDrawSurface_Flip(backbuffer3, NULL, DDFLIP_WAIT);
+ todo_wine ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+
+ memset(&fx, 0, sizeof(fx));
+ fx.dwSize = sizeof(fx);
+ U5(fx).dwFillColor = 0xffff0000;
+ hr = IDirectDrawSurface_Blt(backbuffer1, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+ U5(fx).dwFillColor = 0xff00ff00;
+ hr = IDirectDrawSurface_Blt(backbuffer2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+ U5(fx).dwFillColor = 0xff0000ff;
+ hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface_Flip(primary, NULL, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer1, 320, 240);
+ /* The testbot seems to just copy the contents of one surface to all the
+ * others, instead of properly flipping. */
+ todo_wine ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer2, 320, 240);
+ todo_wine ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+ U5(fx).dwFillColor = 0xffff0000;
+ hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface_Flip(primary, NULL, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer1, 320, 240);
+ todo_wine ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer2, 320, 240);
+ todo_wine ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+ U5(fx).dwFillColor = 0xff00ff00;
+ hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface_Flip(primary, NULL, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer1, 320, 240);
+ todo_wine ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer2, 320, 240);
+ ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+ U5(fx).dwFillColor = 0xff0000ff;
+ hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface_Flip(primary, backbuffer1, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer2, 320, 240);
+ ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer3, 320, 240);
+ ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+ U5(fx).dwFillColor = 0xffff0000;
+ hr = IDirectDrawSurface_Blt(backbuffer1, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface_Flip(primary, backbuffer2, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer1, 320, 240);
+ ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer3, 320, 240);
+ ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ U5(fx).dwFillColor = 0xff00ff00;
+ hr = IDirectDrawSurface_Blt(backbuffer2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface_Flip(primary, backbuffer3, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer1, 320, 240);
+ ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer2, 320, 240);
+ ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+
+ IDirectDrawSurface_Release(backbuffer3);
+ IDirectDrawSurface_Release(backbuffer2);
+ IDirectDrawSurface_Release(backbuffer1);
+ IDirectDrawSurface_Release(primary);
+ refcount = IDirectDraw_Release(ddraw);
+ ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+ DestroyWindow(window);
+}
+
START_TEST(ddraw1)
{
test_coop_level_create_device_window();
@@ -3559,4 +3744,5 @@ START_TEST(ddraw1)
test_rt_caps();
test_surface_lock();
test_surface_discard();
+ test_flip();
}
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index b84dd51..d85908d 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -4213,6 +4213,191 @@ static void test_surface_discard(void)
DestroyWindow(window);
}
+static void test_flip(void)
+{
+ const DWORD placement = DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY;
+ IDirectDrawSurface *primary, *backbuffer1, *backbuffer2, *backbuffer3, *surface;
+ DDSCAPS caps = {DDSCAPS_FLIP};
+ DDSURFACEDESC surface_desc;
+ BOOL sysmem_primary;
+ IDirectDraw2 *ddraw;
+ D3DCOLOR color;
+ ULONG refcount;
+ HWND window;
+ DDBLTFX fx;
+ HRESULT hr;
+
+ if (!(ddraw = create_ddraw()))
+ {
+ skip("Failed to create a ddraw object, skipping test.\n");
+ return;
+ }
+
+ window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+
+ hr = IDirectDraw2_SetDisplayMode(ddraw, 640, 480, 32, 0, 0);
+ ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ surface_desc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
+ surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
+ surface_desc.dwBackBufferCount = 3;
+ hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &primary, NULL);
+ ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface_GetSurfaceDesc(primary, &surface_desc);
+ ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+ ok((surface_desc.ddsCaps.dwCaps & ~placement)
+ == (DDSCAPS_VISIBLE | DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER | DDSCAPS_FLIP | DDSCAPS_COMPLEX),
+ "Got unexpected caps %#x.\n", surface_desc.ddsCaps.dwCaps);
+ sysmem_primary = surface_desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY;
+
+ hr = IDirectDrawSurface_GetAttachedSurface(primary, &caps, &backbuffer1);
+ ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface_GetSurfaceDesc(backbuffer1, &surface_desc);
+ ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+ todo_wine ok((surface_desc.ddsCaps.dwCaps & ~placement) == (DDSCAPS_FLIP | DDSCAPS_COMPLEX | DDSCAPS_BACKBUFFER),
+ "Got unexpected caps %#x.\n", surface_desc.ddsCaps.dwCaps);
+
+ hr = IDirectDrawSurface_GetAttachedSurface(backbuffer1, &caps, &backbuffer2);
+ ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface_GetSurfaceDesc(backbuffer2, &surface_desc);
+ ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+ todo_wine ok((surface_desc.ddsCaps.dwCaps & ~placement) == (DDSCAPS_FLIP | DDSCAPS_COMPLEX),
+ "Got unexpected caps %#x.\n", surface_desc.ddsCaps.dwCaps);
+
+ hr = IDirectDrawSurface_GetAttachedSurface(backbuffer2, &caps, &backbuffer3);
+ ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface_GetSurfaceDesc(backbuffer3, &surface_desc);
+ ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+ todo_wine ok((surface_desc.ddsCaps.dwCaps & ~placement) == (DDSCAPS_FLIP | DDSCAPS_COMPLEX),
+ "Got unexpected caps %#x.\n", surface_desc.ddsCaps.dwCaps);
+
+ hr = IDirectDrawSurface_GetAttachedSurface(backbuffer3, &caps, &surface);
+ todo_wine ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+ todo_wine ok(surface == primary, "Got unexpected surface %p, expected %p.\n", surface, primary);
+ if (surface)
+ IDirectDrawSurface_Release(surface);
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
+ surface_desc.ddsCaps.dwCaps = 0;
+ surface_desc.dwWidth = 640;
+ surface_desc.dwHeight = 480;
+ hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
+ ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+ hr = IDirectDrawSurface_Flip(primary, surface, DDFLIP_WAIT);
+ todo_wine ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+ IDirectDrawSurface_Release(surface);
+
+ hr = IDirectDrawSurface_Flip(primary, primary, DDFLIP_WAIT);
+ todo_wine ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+ hr = IDirectDrawSurface_Flip(backbuffer1, NULL, DDFLIP_WAIT);
+ todo_wine ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+ hr = IDirectDrawSurface_Flip(backbuffer2, NULL, DDFLIP_WAIT);
+ todo_wine ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+ hr = IDirectDrawSurface_Flip(backbuffer3, NULL, DDFLIP_WAIT);
+ todo_wine ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+
+ memset(&fx, 0, sizeof(fx));
+ fx.dwSize = sizeof(fx);
+ U5(fx).dwFillColor = 0xffff0000;
+ hr = IDirectDrawSurface_Blt(backbuffer1, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+ U5(fx).dwFillColor = 0xff00ff00;
+ hr = IDirectDrawSurface_Blt(backbuffer2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+ U5(fx).dwFillColor = 0xff0000ff;
+ hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface_Flip(primary, NULL, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer1, 320, 240);
+ /* The testbot seems to just copy the contents of one surface to all the
+ * others, instead of properly flipping. */
+ todo_wine ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer2, 320, 240);
+ todo_wine ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+ U5(fx).dwFillColor = 0xffff0000;
+ hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface_Flip(primary, NULL, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer1, 320, 240);
+ todo_wine ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer2, 320, 240);
+ todo_wine ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+ U5(fx).dwFillColor = 0xff00ff00;
+ hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface_Flip(primary, NULL, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer1, 320, 240);
+ todo_wine ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer2, 320, 240);
+ ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+ U5(fx).dwFillColor = 0xff0000ff;
+ hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface_Flip(primary, backbuffer1, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer2, 320, 240);
+ ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer3, 320, 240);
+ ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+ U5(fx).dwFillColor = 0xffff0000;
+ hr = IDirectDrawSurface_Blt(backbuffer1, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface_Flip(primary, backbuffer2, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer1, 320, 240);
+ ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer3, 320, 240);
+ ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ U5(fx).dwFillColor = 0xff00ff00;
+ hr = IDirectDrawSurface_Blt(backbuffer2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface_Flip(primary, backbuffer3, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer1, 320, 240);
+ ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer2, 320, 240);
+ ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+
+ IDirectDrawSurface_Release(backbuffer3);
+ IDirectDrawSurface_Release(backbuffer2);
+ IDirectDrawSurface_Release(backbuffer1);
+ IDirectDrawSurface_Release(primary);
+ refcount = IDirectDraw2_Release(ddraw);
+ ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+ DestroyWindow(window);
+}
+
START_TEST(ddraw2)
{
test_coop_level_create_device_window();
@@ -4244,4 +4429,5 @@ START_TEST(ddraw2)
test_rt_caps();
test_surface_lock();
test_surface_discard();
+ test_flip();
}
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index a35ee15..b639f86 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -4817,6 +4817,191 @@ static void test_surface_discard(void)
DestroyWindow(window);
}
+static void test_flip(void)
+{
+ const DWORD placement = DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY;
+ IDirectDrawSurface4 *primary, *backbuffer1, *backbuffer2, *backbuffer3, *surface;
+ DDSCAPS2 caps = {DDSCAPS_FLIP, 0, 0, 0};
+ DDSURFACEDESC2 surface_desc;
+ BOOL sysmem_primary;
+ IDirectDraw4 *ddraw;
+ D3DCOLOR color;
+ ULONG refcount;
+ HWND window;
+ DDBLTFX fx;
+ HRESULT hr;
+
+ if (!(ddraw = create_ddraw()))
+ {
+ skip("Failed to create a ddraw object, skipping test.\n");
+ return;
+ }
+
+ window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+
+ hr = IDirectDraw4_SetDisplayMode(ddraw, 640, 480, 32, 0, 0);
+ ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ surface_desc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
+ surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
+ surface_desc.dwBackBufferCount = 3;
+ hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &primary, NULL);
+ ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &surface_desc);
+ ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+ ok((surface_desc.ddsCaps.dwCaps & ~placement)
+ == (DDSCAPS_VISIBLE | DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER | DDSCAPS_FLIP | DDSCAPS_COMPLEX),
+ "Got unexpected caps %#x.\n", surface_desc.ddsCaps.dwCaps);
+ sysmem_primary = surface_desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY;
+
+ hr = IDirectDrawSurface4_GetAttachedSurface(primary, &caps, &backbuffer1);
+ ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface4_GetSurfaceDesc(backbuffer1, &surface_desc);
+ ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+ todo_wine ok((surface_desc.ddsCaps.dwCaps & ~placement) == (DDSCAPS_FLIP | DDSCAPS_COMPLEX | DDSCAPS_BACKBUFFER),
+ "Got unexpected caps %#x.\n", surface_desc.ddsCaps.dwCaps);
+
+ hr = IDirectDrawSurface4_GetAttachedSurface(backbuffer1, &caps, &backbuffer2);
+ ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface4_GetSurfaceDesc(backbuffer2, &surface_desc);
+ ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+ todo_wine ok((surface_desc.ddsCaps.dwCaps & ~placement) == (DDSCAPS_FLIP | DDSCAPS_COMPLEX),
+ "Got unexpected caps %#x.\n", surface_desc.ddsCaps.dwCaps);
+
+ hr = IDirectDrawSurface4_GetAttachedSurface(backbuffer2, &caps, &backbuffer3);
+ ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface4_GetSurfaceDesc(backbuffer3, &surface_desc);
+ ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+ todo_wine ok((surface_desc.ddsCaps.dwCaps & ~placement) == (DDSCAPS_FLIP | DDSCAPS_COMPLEX),
+ "Got unexpected caps %#x.\n", surface_desc.ddsCaps.dwCaps);
+
+ hr = IDirectDrawSurface4_GetAttachedSurface(backbuffer3, &caps, &surface);
+ todo_wine ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+ todo_wine ok(surface == primary, "Got unexpected surface %p, expected %p.\n", surface, primary);
+ if (surface)
+ IDirectDrawSurface4_Release(surface);
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
+ surface_desc.ddsCaps.dwCaps = 0;
+ surface_desc.dwWidth = 640;
+ surface_desc.dwHeight = 480;
+ hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
+ ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+ hr = IDirectDrawSurface4_Flip(primary, surface, DDFLIP_WAIT);
+ todo_wine ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+ IDirectDrawSurface4_Release(surface);
+
+ hr = IDirectDrawSurface4_Flip(primary, primary, DDFLIP_WAIT);
+ todo_wine ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+ hr = IDirectDrawSurface4_Flip(backbuffer1, NULL, DDFLIP_WAIT);
+ todo_wine ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+ hr = IDirectDrawSurface4_Flip(backbuffer2, NULL, DDFLIP_WAIT);
+ todo_wine ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+ hr = IDirectDrawSurface4_Flip(backbuffer3, NULL, DDFLIP_WAIT);
+ todo_wine ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+
+ memset(&fx, 0, sizeof(fx));
+ fx.dwSize = sizeof(fx);
+ U5(fx).dwFillColor = 0xffff0000;
+ hr = IDirectDrawSurface4_Blt(backbuffer1, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+ U5(fx).dwFillColor = 0xff00ff00;
+ hr = IDirectDrawSurface4_Blt(backbuffer2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+ U5(fx).dwFillColor = 0xff0000ff;
+ hr = IDirectDrawSurface4_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface4_Flip(primary, NULL, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer1, 320, 240);
+ /* The testbot seems to just copy the contents of one surface to all the
+ * others, instead of properly flipping. */
+ todo_wine ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer2, 320, 240);
+ todo_wine ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+ U5(fx).dwFillColor = 0xffff0000;
+ hr = IDirectDrawSurface4_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface4_Flip(primary, NULL, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer1, 320, 240);
+ todo_wine ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer2, 320, 240);
+ todo_wine ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+ U5(fx).dwFillColor = 0xff00ff00;
+ hr = IDirectDrawSurface4_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface4_Flip(primary, NULL, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer1, 320, 240);
+ todo_wine ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer2, 320, 240);
+ ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+ U5(fx).dwFillColor = 0xff0000ff;
+ hr = IDirectDrawSurface4_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface4_Flip(primary, backbuffer1, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer2, 320, 240);
+ ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer3, 320, 240);
+ ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+ U5(fx).dwFillColor = 0xffff0000;
+ hr = IDirectDrawSurface4_Blt(backbuffer1, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface4_Flip(primary, backbuffer2, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer1, 320, 240);
+ ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer3, 320, 240);
+ ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ U5(fx).dwFillColor = 0xff00ff00;
+ hr = IDirectDrawSurface4_Blt(backbuffer2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface4_Flip(primary, backbuffer3, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer1, 320, 240);
+ ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer2, 320, 240);
+ ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+
+ IDirectDrawSurface4_Release(backbuffer3);
+ IDirectDrawSurface4_Release(backbuffer2);
+ IDirectDrawSurface4_Release(backbuffer1);
+ IDirectDrawSurface4_Release(primary);
+ refcount = IDirectDraw4_Release(ddraw);
+ ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+ DestroyWindow(window);
+}
+
START_TEST(ddraw4)
{
test_process_vertices();
@@ -4853,4 +5038,5 @@ START_TEST(ddraw4)
test_rt_caps();
test_surface_lock();
test_surface_discard();
+ test_flip();
}
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 289d4fd..0c099a5 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -4704,6 +4704,191 @@ static void test_surface_discard(void)
DestroyWindow(window);
}
+static void test_flip(void)
+{
+ const DWORD placement = DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY;
+ IDirectDrawSurface7 *primary, *backbuffer1, *backbuffer2, *backbuffer3, *surface;
+ DDSCAPS2 caps = {DDSCAPS_FLIP, 0, 0, 0};
+ DDSURFACEDESC2 surface_desc;
+ BOOL sysmem_primary;
+ IDirectDraw7 *ddraw;
+ D3DCOLOR color;
+ ULONG refcount;
+ HWND window;
+ DDBLTFX fx;
+ HRESULT hr;
+
+ if (!(ddraw = create_ddraw()))
+ {
+ skip("Failed to create a ddraw object, skipping test.\n");
+ return;
+ }
+
+ window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+
+ hr = IDirectDraw7_SetDisplayMode(ddraw, 640, 480, 32, 0, 0);
+ ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ surface_desc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
+ surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
+ surface_desc.dwBackBufferCount = 3;
+ hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &primary, NULL);
+ ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &surface_desc);
+ ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+ ok((surface_desc.ddsCaps.dwCaps & ~placement)
+ == (DDSCAPS_VISIBLE | DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER | DDSCAPS_FLIP | DDSCAPS_COMPLEX),
+ "Got unexpected caps %#x.\n", surface_desc.ddsCaps.dwCaps);
+ sysmem_primary = surface_desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY;
+
+ hr = IDirectDrawSurface7_GetAttachedSurface(primary, &caps, &backbuffer1);
+ ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface7_GetSurfaceDesc(backbuffer1, &surface_desc);
+ ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+ todo_wine ok((surface_desc.ddsCaps.dwCaps & ~placement) == (DDSCAPS_FLIP | DDSCAPS_COMPLEX | DDSCAPS_BACKBUFFER),
+ "Got unexpected caps %#x.\n", surface_desc.ddsCaps.dwCaps);
+
+ hr = IDirectDrawSurface7_GetAttachedSurface(backbuffer1, &caps, &backbuffer2);
+ ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface7_GetSurfaceDesc(backbuffer2, &surface_desc);
+ ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+ todo_wine ok((surface_desc.ddsCaps.dwCaps & ~placement) == (DDSCAPS_FLIP | DDSCAPS_COMPLEX),
+ "Got unexpected caps %#x.\n", surface_desc.ddsCaps.dwCaps);
+
+ hr = IDirectDrawSurface7_GetAttachedSurface(backbuffer2, &caps, &backbuffer3);
+ ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface7_GetSurfaceDesc(backbuffer3, &surface_desc);
+ ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+ todo_wine ok((surface_desc.ddsCaps.dwCaps & ~placement) == (DDSCAPS_FLIP | DDSCAPS_COMPLEX),
+ "Got unexpected caps %#x.\n", surface_desc.ddsCaps.dwCaps);
+
+ hr = IDirectDrawSurface7_GetAttachedSurface(backbuffer3, &caps, &surface);
+ todo_wine ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+ todo_wine ok(surface == primary, "Got unexpected surface %p, expected %p.\n", surface, primary);
+ if (surface)
+ IDirectDrawSurface7_Release(surface);
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
+ surface_desc.ddsCaps.dwCaps = 0;
+ surface_desc.dwWidth = 640;
+ surface_desc.dwHeight = 480;
+ hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
+ ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+ hr = IDirectDrawSurface7_Flip(primary, surface, DDFLIP_WAIT);
+ todo_wine ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+ IDirectDrawSurface7_Release(surface);
+
+ hr = IDirectDrawSurface7_Flip(primary, primary, DDFLIP_WAIT);
+ todo_wine ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+ hr = IDirectDrawSurface7_Flip(backbuffer1, NULL, DDFLIP_WAIT);
+ todo_wine ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+ hr = IDirectDrawSurface7_Flip(backbuffer2, NULL, DDFLIP_WAIT);
+ todo_wine ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+ hr = IDirectDrawSurface7_Flip(backbuffer3, NULL, DDFLIP_WAIT);
+ todo_wine ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+
+ memset(&fx, 0, sizeof(fx));
+ fx.dwSize = sizeof(fx);
+ U5(fx).dwFillColor = 0xffff0000;
+ hr = IDirectDrawSurface7_Blt(backbuffer1, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+ U5(fx).dwFillColor = 0xff00ff00;
+ hr = IDirectDrawSurface7_Blt(backbuffer2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+ U5(fx).dwFillColor = 0xff0000ff;
+ hr = IDirectDrawSurface7_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface7_Flip(primary, NULL, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer1, 320, 240);
+ /* The testbot seems to just copy the contents of one surface to all the
+ * others, instead of properly flipping. */
+ todo_wine ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer2, 320, 240);
+ todo_wine ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+ U5(fx).dwFillColor = 0xffff0000;
+ hr = IDirectDrawSurface7_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface7_Flip(primary, NULL, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer1, 320, 240);
+ todo_wine ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer2, 320, 240);
+ todo_wine ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+ U5(fx).dwFillColor = 0xff00ff00;
+ hr = IDirectDrawSurface7_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface7_Flip(primary, NULL, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer1, 320, 240);
+ todo_wine ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer2, 320, 240);
+ ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+ U5(fx).dwFillColor = 0xff0000ff;
+ hr = IDirectDrawSurface7_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface7_Flip(primary, backbuffer1, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer2, 320, 240);
+ ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer3, 320, 240);
+ ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+ U5(fx).dwFillColor = 0xffff0000;
+ hr = IDirectDrawSurface7_Blt(backbuffer1, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface7_Flip(primary, backbuffer2, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer1, 320, 240);
+ ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer3, 320, 240);
+ ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ U5(fx).dwFillColor = 0xff00ff00;
+ hr = IDirectDrawSurface7_Blt(backbuffer2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
+ ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface7_Flip(primary, backbuffer3, DDFLIP_WAIT);
+ ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
+ color = get_surface_color(backbuffer1, 320, 240);
+ ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)),
+ "Got unexpected color 0x%08x.\n", color);
+ color = get_surface_color(backbuffer2, 320, 240);
+ ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+
+ IDirectDrawSurface7_Release(backbuffer3);
+ IDirectDrawSurface7_Release(backbuffer2);
+ IDirectDrawSurface7_Release(backbuffer1);
+ IDirectDrawSurface7_Release(primary);
+ refcount = IDirectDraw7_Release(ddraw);
+ ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+ DestroyWindow(window);
+}
+
START_TEST(ddraw7)
{
HMODULE module = GetModuleHandleA("ddraw.dll");
@@ -4748,4 +4933,5 @@ START_TEST(ddraw7)
test_rt_caps();
test_surface_lock();
test_surface_discard();
+ test_flip();
}
--
1.7.10.4
More information about the wine-patches
mailing list