[PATCH 1/4] d3d9/tests: Add a windowed GetFrontBufferData test (v2).

Stefan Dösinger stefan at codeweavers.com
Tue Jul 7 09:26:30 CDT 2015


Version 2: Skip if the window is obscured to make the testbot happy.
---
 dlls/d3d9/tests/visual.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 99 insertions(+)

diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index cfdfc3f..f2fa52b 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -19288,6 +19288,104 @@ done:
     DestroyWindow(window);
 }
 
+static void test_windowed_get_front_buffer_data(void)
+{
+    HRESULT hr;
+    IDirect3DDevice9 *device;
+    IDirect3D9 *d3d;
+    ULONG refcount;
+    HWND window;
+    D3DCOLOR color;
+    IDirect3DSurface9 *surface;
+    static const D3DRECT clear_rect = {100, 100, 400, 200};
+    D3DDISPLAYMODE mode;
+    POINT offset = {0, 0};
+    RECT win_rect = {30, 50, 640 + 30, 480 + 50};
+    static const struct
+    {
+        unsigned int x, y;
+        D3DCOLOR color;
+    }
+    tests[] =
+    {
+        { 99,  99, 0x00ffffff},
+        {101,  99, 0x00ffffff},
+        { 99, 101, 0x00ffffff},
+        {101, 101, 0x0000ff00},
+
+        {399,  99, 0x00ffffff},
+        {401,  99, 0x00ffffff},
+        {399, 101, 0x0000ff00},
+        {401, 101, 0x00ffffff},
+
+        { 99, 199, 0x00ffffff},
+        {101, 199, 0x0000ff00},
+        { 99, 201, 0x00ffffff},
+        {101, 201, 0x00ffffff},
+
+        {399, 199, 0x0000ff00},
+        {401, 299, 0x00ffffff},
+        {399, 201, 0x00ffffff},
+        {401, 201, 0x00ffffff},
+    };
+    unsigned int i;
+
+    AdjustWindowRect(&win_rect, WS_OVERLAPPEDWINDOW | WS_VISIBLE, FALSE);
+    window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+            win_rect.left, win_rect.top, win_rect.right - win_rect.left, win_rect.bottom - win_rect.top,
+            NULL, NULL, NULL, NULL);
+    d3d = Direct3DCreate9(D3D_SDK_VERSION);
+    ok(!!d3d, "Failed to create a D3D object.\n");
+
+    if (!(device = create_device(d3d, window, window, TRUE)))
+    {
+        skip("Failed to create a D3D device, skipping tests.\n");
+        IDirect3D9_Release(d3d);
+        DestroyWindow(window);
+        return;
+    }
+
+    hr = IDirect3DDevice9_GetDisplayMode(device, 0, &mode);
+    ok(SUCCEEDED(hr), "Failed to get display mode, hr %#x.\n", hr);
+    hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, mode.Width, mode.Height,
+            D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &surface, NULL);
+    ok(SUCCEEDED(hr), "Failed to create readback surface, hr %#x.\n", hr);
+
+    hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00ffffff, 0.0f, 0);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    hr = IDirect3DDevice9_Clear(device, 1, &clear_rect, D3DCLEAR_TARGET, 0x0000ff00, 0.0f, 0);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+
+    hr = IDirect3DDevice9_GetFrontBufferData(device, 0, surface);
+    ok(SUCCEEDED(hr), "Failed to get front buffer data, hr %#x.\n", hr);
+
+    ClientToScreen(window, &offset);
+
+    for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
+    {
+        POINT p = {tests[i].x + offset.x, tests[i].y + offset.y};
+
+        if (ChildWindowFromPoint(GetDesktopWindow(), p) != window)
+        {
+            skip("Window is covered by another window, skipping GetFrontBufferData test.\n");
+            break;
+        }
+
+        color = getPixelColorFromSurface(surface, p.x, p.y);
+        ok(color_match(color, tests[i].color, 1), "Got color 0x%08x, expected 0x%08x, test %u, %ux%u.\n",
+                color, tests[i].color, i, p.x, p.y);
+    }
+
+    IDirect3DSurface9_Release(surface);
+
+    refcount = IDirect3DDevice9_Release(device);
+    ok(!refcount, "Device has %u references left.\n", refcount);
+    IDirect3D9_Release(d3d);
+    DestroyWindow(window);
+}
+
 START_TEST(visual)
 {
     D3DADAPTER_IDENTIFIER9 identifier;
@@ -19404,4 +19502,5 @@ START_TEST(visual)
     test_multisample_mismatch();
     test_texcoordindex();
     test_vertex_blending();
+    test_windowed_get_front_buffer_data();
 }
-- 
2.3.6




More information about the wine-patches mailing list