[PATCH 1/3] d3drm/tests: Add test for IDirect3DRM*::CreateDeviceFromClipper (try 3).

Aaryaman Vasishta jem456.vasishta at gmail.com
Thu Jun 18 13:41:28 CDT 2015


---
 dlls/d3drm/tests/d3drm.c | 149 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 149 insertions(+)

diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c
index 5dcfddc..e92b49c 100644
--- a/dlls/d3drm/tests/d3drm.c
+++ b/dlls/d3drm/tests/d3drm.c
@@ -1947,6 +1947,154 @@ static void test_frame_qi(void)
     IDirect3DRM_Release(d3drm1);
 }
 
+static void test_create_device_from_clipper(void)
+{
+    DDSCAPS caps = { DDSCAPS_ZBUFFER };
+    IDirect3DRM *d3drm1 = NULL;
+    IDirect3DRM2 *d3drm2 = NULL;
+    IDirect3DRMDevice2 *device2 = NULL;
+    IDirect3DDevice2 *d3ddevice2 = NULL;
+    IDirectDrawClipper *clipper = NULL, *rclipper = NULL;
+    IDirectDrawSurface *surface = NULL, *ds = NULL;
+    DDSURFACEDESC desc, surface_desc;
+    DWORD expected_flags;
+    HWND window;
+    GUID driver = IID_IDirect3DRGBDevice;
+    HRESULT hr;
+    ULONG ref1, ref2, cref1, cref2;
+    DEVMODEW devmode;
+    LONG ret;
+    RECT rc;
+
+    window = CreateWindowA("static", "d3drm_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 500, 400, 0, 0, 0, 0);
+    GetClientRect(window, &rc);
+    hr = DirectDrawCreateClipper(0, &clipper, NULL);
+    ok(hr == DD_OK, "Cannot get IDirectDrawClipper interface (hr = %x).\n", hr);
+    hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
+    ok(hr == DD_OK, "Cannot set HWnd to Clipper (hr = %x).\n", hr);
+
+    hr = Direct3DRMCreate(&d3drm1);
+    ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x).\n", hr);
+    ref1 = get_refcount((IUnknown *)d3drm1);
+    cref1 = get_refcount((IUnknown *)clipper);
+
+    hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void **)&d3drm2);
+    ok(hr == D3DRM_OK, "Cannot get IDirect3DRM2 interface (hr = %x).\n", hr);
+
+    hr = IDirect3DRM2_CreateDeviceFromClipper(d3drm2, clipper, &driver, 0, 0, &device2);
+    todo_wine ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
+
+    /* If NULL is passed for clipper, CreateDeviceFromClipper returns D3DRMERR_BADVALUE */
+    hr = IDirect3DRM2_CreateDeviceFromClipper(d3drm2, clipper, &driver, 300, 200, &device2);
+    ok(hr == D3DRM_OK, "Cannot create IDirect3DRMDevice2 interface (hr = %x).\n", hr);
+    ref2 = get_refcount((IUnknown *)d3drm1);
+    cref2 = get_refcount((IUnknown *)clipper);
+    todo_wine ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1, ref2);
+    todo_wine ok(cref2 > cref1, "expected cref2 > cref1, got cref1 = %u , cref2 = %u.\n", cref1, cref2);
+
+    /* Fetch immediate mode device in order to access render target */
+    hr = IDirect3DRMDevice2_GetDirect3DDevice2(device2, &d3ddevice2);
+    todo_wine ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr);
+    if (FAILED(hr))
+        goto cleanup;
+
+    hr = IDirect3DDevice2_GetRenderTarget(d3ddevice2, &surface);
+    ok(hr == DD_OK, "Cannot get surface to the render target (hr = %x).\n", hr);
+
+    hr = IDirectDrawSurface_GetClipper(surface, &rclipper);
+    ok(hr == DDERR_NOCLIPPERATTACHED, "Expected hr == DDERR_NOCLIPPERATTACHED, got %x.\n", hr);
+
+    /* Check properties of render target and depth surface */
+    surface_desc.dwSize = sizeof(surface_desc);
+    hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
+    ok(hr == DD_OK, "Cannot get surface desc structure (hr = %x).\n", hr);
+
+    ok((surface_desc.dwWidth == 300) && (surface_desc.dwHeight == 200), "Expected surface dimentions = 300, 200, got %d, %d.\n",
+        surface_desc.dwWidth, surface_desc.dwHeight);
+    ok((surface_desc.ddsCaps.dwCaps & (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE)) == (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE),
+            "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE, surface_desc.ddsCaps.dwCaps);
+    expected_flags = DDSD_PIXELFORMAT | DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH;
+    ok(surface_desc.dwFlags == expected_flags, "Expected %x for flags, got %x.\n", expected_flags, surface_desc.dwFlags);
+    ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
+    ok(ret, "Failed to get display mode.\n");
+    ok(devmode.dmBitsPerPel == surface_desc.ddpfPixelFormat.dwRGBBitCount, "Expected render target bpp == %dbpp, got %dbpp.\n",
+            devmode.dmBitsPerPel, surface_desc.ddpfPixelFormat.dwRGBBitCount);
+
+    hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds);
+    ok(hr == DD_OK, "Cannot get attached depth surface (hr = %x).\n", hr);
+
+    desc.dwSize = sizeof(desc);
+    hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
+    ok(hr == DD_OK, "Cannot get z surface desc structure (hr = %x).\n", hr);
+
+    ok((desc.dwWidth == 300) && (desc.dwHeight == 200), "Expected surface dimentions = 300, 200, got %d, %d.\n",
+            desc.dwWidth, desc.dwHeight);
+    ok((desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER) == DDSCAPS_ZBUFFER, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER, desc.ddsCaps.dwCaps);
+    expected_flags = DDSD_ZBUFFERBITDEPTH | DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH;
+    ok(desc.dwFlags == expected_flags, "Expected %x for flags, got %x.\n", expected_flags, desc.dwFlags);
+    ok(desc.dwZBufferBitDepth == 16, "Expected 16 for Z buffer bit depth, got %d.\n", desc.dwZBufferBitDepth);
+    ok(desc.ddpfPixelFormat.dwStencilBitMask == 0, "Expected 0 stencil bits, got %x.\n", desc.ddpfPixelFormat.dwStencilBitMask);
+
+    /* Release old objects and check refcount of device and clipper */
+    IDirect3DRMDevice2_Release(device2);
+    ref2 = get_refcount((IUnknown *)d3drm1);
+    cref2 = get_refcount((IUnknown *)clipper);
+    ok(ref1 == ref2, "expected ref1 == ref2, got ref1 = %u, ref2 = %u.\n", ref1, ref2);
+    ok(cref1 == cref2, "expected cref1 == cref2, got cref1 = %u, cref2 = %u.\n", cref1, cref2);
+    IDirectDrawSurface_Release(ds);
+    ds = NULL;
+    IDirectDrawSurface_Release(surface);
+    surface = NULL;
+    IDirect3DDevice2_Release(d3ddevice2);
+    d3ddevice2 = NULL;
+
+    /* Test if render target format follows the screen format */
+    memset(&devmode, 0, sizeof(devmode));
+    devmode.dmSize = sizeof(devmode);
+    devmode.dmFields = DM_BITSPERPEL;
+    devmode.dmBitsPerPel = 16;
+    ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+    ok(ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", ret);
+
+    hr = IDirect3DRM2_CreateDeviceFromClipper(d3drm2, clipper, &driver, rc.right, rc.bottom, &device2);
+    ok(hr == D3DRM_OK, "Cannot create IDirect3DRMDevice2 interface (hr = %x).\n", hr);
+
+    hr = IDirect3DRMDevice2_GetDirect3DDevice2(device2, &d3ddevice2);
+    todo_wine ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr);
+    if (FAILED(hr))
+        goto cleanup;
+
+    hr = IDirect3DDevice2_GetRenderTarget(d3ddevice2, &surface);
+    ok(hr == DD_OK, "Cannot get surface to the render target (hr = %x).\n", hr);
+
+    surface_desc.dwSize = sizeof(surface_desc);
+    hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
+    ok(hr == DD_OK, "Cannot get surface desc structure (hr = %x).\n", hr);
+
+    ok(surface_desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16bpp, got %dbpp.\n",
+            surface_desc.ddpfPixelFormat.dwRGBBitCount);
+    ret = ChangeDisplaySettingsW(NULL, 0);
+    ok(ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", ret);
+
+
+cleanup:
+    if (ds)
+        IDirectDrawSurface_Release(ds);
+    if (surface)
+        IDirectDrawSurface_Release(surface);
+    if (d3ddevice2)
+        IDirect3DDevice2_Release(d3ddevice2);
+    if (device2)
+        IDirect3DRMDevice2_Release(device2);
+    if (d3drm2)
+        IDirect3DRM2_Release(d3drm2);
+    if (d3drm1)
+        IDirect3DRM_Release(d3drm1);
+    if (clipper)
+        IDirectDrawClipper_Release(clipper);
+    DestroyWindow(window);
+}
+
 START_TEST(d3drm)
 {
     test_MeshBuilder();
@@ -1964,4 +2112,5 @@ START_TEST(d3drm)
     test_frame_mesh_materials();
     test_d3drm_qi();
     test_frame_qi();
+    test_create_device_from_clipper();
 }
-- 
1.9.3 (Apple Git-50)




More information about the wine-patches mailing list