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

Stefan Dösinger stefan at codeweavers.com
Mon Jul 6 16:47:25 CDT 2015


---
 dlls/d3d9/tests/visual.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)

diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index cfdfc3f..40fd2ac 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -19288,6 +19288,97 @@ 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};
+
+    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);
+
+    color = getPixelColorFromSurface(surface, 99 + offset.x, 99 + offset.y);
+    ok(color_match(color, 0x00ffffff, 1), "Got color 0x%08x.\n", color);
+    color = getPixelColorFromSurface(surface, 101 + offset.x, 99 + offset.y);
+    ok(color_match(color, 0x00ffffff, 1), "Got color 0x%08x.\n", color);
+    color = getPixelColorFromSurface(surface, 99 + offset.x, 101 + offset.y);
+    ok(color_match(color, 0x00ffffff, 1), "Got color 0x%08x.\n", color);
+    color = getPixelColorFromSurface(surface, 101 + offset.x, 101 + offset.y);
+    ok(color_match(color, 0x0000ff00, 1), "Got color 0x%08x.\n", color);
+
+    color = getPixelColorFromSurface(surface, 399 + offset.x, 99 + offset.y);
+    ok(color_match(color, 0x00ffffff, 1), "Got color 0x%08x.\n", color);
+    color = getPixelColorFromSurface(surface, 401 + offset.x, 99 + offset.y);
+    ok(color_match(color, 0x00ffffff, 1), "Got color 0x%08x.\n", color);
+    color = getPixelColorFromSurface(surface, 399 + offset.x, 101 + offset.y);
+    ok(color_match(color, 0x0000ff00, 1), "Got color 0x%08x.\n", color);
+    color = getPixelColorFromSurface(surface, 401 + offset.x, 101 + offset.y);
+    ok(color_match(color, 0x00ffffff, 1), "Got color 0x%08x.\n", color);
+
+    color = getPixelColorFromSurface(surface, 99 + offset.x, 199 + offset.y);
+    ok(color_match(color, 0x00ffffff, 1), "Got color 0x%08x.\n", color);
+    color = getPixelColorFromSurface(surface, 101 + offset.x, 199 + offset.y);
+    ok(color_match(color, 0x0000ff00, 1), "Got color 0x%08x.\n", color);
+    color = getPixelColorFromSurface(surface, 99 + offset.x, 201 + offset.y);
+    ok(color_match(color, 0x00ffffff, 1), "Got color 0x%08x.\n", color);
+    color = getPixelColorFromSurface(surface, 101 + offset.x, 201 + offset.y);
+    ok(color_match(color, 0x00ffffff, 1), "Got color 0x%08x.\n", color);
+
+    color = getPixelColorFromSurface(surface, 399 + offset.x, 199 + offset.y);
+    ok(color_match(color, 0x0000ff00, 1), "Got color 0x%08x.\n", color);
+    color = getPixelColorFromSurface(surface, 401 + offset.x, 199 + offset.y);
+    ok(color_match(color, 0x00ffffff, 1), "Got color 0x%08x.\n", color);
+    color = getPixelColorFromSurface(surface, 399 + offset.x, 201 + offset.y);
+    ok(color_match(color, 0x00ffffff, 1), "Got color 0x%08x.\n", color);
+    color = getPixelColorFromSurface(surface, 401 + offset.x, 201 + offset.y);
+    ok(color_match(color, 0x00ffffff, 1), "Got color 0x%08x.\n", color);
+
+    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 +19495,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