[PATCH v2 11/12] d2d1/tests: Use IDXGIDevice interface instead of ID3D10Device1.

Rémi Bernon rbernon at codeweavers.com
Tue Jan 12 05:34:51 CST 2021


Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 dlls/d2d1/tests/d2d1.c | 68 +++++++++++++++++++++++++++---------------
 1 file changed, 44 insertions(+), 24 deletions(-)

diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index eb611aa1f20..798f98c335b 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -44,7 +44,7 @@ size_t mt_tests_size, mt_test_count;
 
 struct d2d1_test_context
 {
-    ID3D10Device1 *device;
+    IDXGIDevice *device;
     HWND window;
     IDXGISwapChain *swapchain;
     IDXGISurface *surface;
@@ -694,7 +694,7 @@ static BOOL compare_figure(struct d2d1_test_context *ctx, unsigned int x, unsign
     return diff <= max_diff;
 }
 
-static ID3D10Device1 *create_device(void)
+static ID3D10Device1 *create_d3d10_device(void)
 {
     ID3D10Device1 *device;
 
@@ -711,6 +711,25 @@ static ID3D10Device1 *create_device(void)
     return NULL;
 }
 
+static IDXGIDevice *create_device(void)
+{
+    ID3D10Device1 *d3d10_device;
+    IDXGIDevice *device;
+    HRESULT hr;
+
+    if (!(d3d10_device = create_d3d10_device()))
+        return NULL;
+
+    hr = ID3D10Device1_QueryInterface(d3d10_device, &IID_IDXGIDevice, (void **)&device);
+    ok(SUCCEEDED(hr), "Failed to get DXGI device, hr %#x.\n", hr);
+    ID3D10Device1_Release(d3d10_device);
+
+    if (FAILED(hr))
+        return NULL;
+
+    return device;
+}
+
 static HWND create_window(void)
 {
     RECT r = {0, 0, 640, 480};
@@ -721,20 +740,16 @@ static HWND create_window(void)
             0, 0, r.right - r.left, r.bottom - r.top, NULL, NULL, NULL, NULL);
 }
 
-static IDXGISwapChain *create_swapchain(ID3D10Device1 *device, HWND window, BOOL windowed)
+static IDXGISwapChain *create_swapchain(IDXGIDevice *device, HWND window, BOOL windowed)
 {
     IDXGISwapChain *swapchain;
     DXGI_SWAP_CHAIN_DESC desc;
-    IDXGIDevice *dxgi_device;
     IDXGIAdapter *adapter;
     IDXGIFactory *factory;
     HRESULT hr;
 
-    hr = ID3D10Device1_QueryInterface(device, &IID_IDXGIDevice, (void **)&dxgi_device);
-    ok(SUCCEEDED(hr), "Failed to get DXGI device, hr %#x.\n", hr);
-    hr = IDXGIDevice_GetAdapter(dxgi_device, &adapter);
+    hr = IDXGIDevice_GetAdapter(device, &adapter);
     ok(SUCCEEDED(hr), "Failed to get adapter, hr %#x.\n", hr);
-    IDXGIDevice_Release(dxgi_device);
     hr = IDXGIAdapter_GetParent(adapter, &IID_IDXGIFactory, (void **)&factory);
     ok(SUCCEEDED(hr), "Failed to get factory, hr %#x.\n", hr);
     IDXGIAdapter_Release(adapter);
@@ -763,6 +778,19 @@ static IDXGISwapChain *create_swapchain(ID3D10Device1 *device, HWND window, BOOL
     return swapchain;
 }
 
+static IDXGISwapChain *create_d3d10_swapchain(ID3D10Device1 *device, HWND window, BOOL windowed)
+{
+    IDXGISwapChain *swapchain;
+    IDXGIDevice *dxgi_device;
+    HRESULT hr;
+
+    hr = ID3D10Device1_QueryInterface(device, &IID_IDXGIDevice, (void **)&dxgi_device);
+    ok(SUCCEEDED(hr), "Failed to get DXGI device, hr %#x.\n", hr);
+    swapchain = create_swapchain(dxgi_device, window, windowed);
+    IDXGIDevice_Release(dxgi_device);
+    return swapchain;
+}
+
 static ID2D1RenderTarget *create_render_target_desc(IDXGISurface *surface, const D2D1_RENDER_TARGET_PROPERTIES *desc)
 {
     ID2D1RenderTarget *render_target;
@@ -811,7 +839,7 @@ static void release_test_context_(unsigned int line, struct d2d1_test_context *c
     if (ctx->surface) IDXGISurface_Release(ctx->surface);
     if (ctx->swapchain) IDXGISwapChain_Release(ctx->swapchain);
     if (ctx->window) DestroyWindow(ctx->window);
-    ID3D10Device1_Release(ctx->device);
+    IDXGIDevice_Release(ctx->device);
 }
 
 #define init_test_context(ctx) init_test_context_(__LINE__, ctx)
@@ -4184,7 +4212,7 @@ static void test_shared_bitmap(void)
     ID2D1RenderTarget *rt1, *rt2, *rt3;
     IDXGISurface *surface2;
     ID2D1Factory *factory1, *factory2;
-    ID3D10Device1 *device2;
+    IDXGIDevice *device2;
     IWICImagingFactory *wic_factory;
     ID2D1Bitmap *bitmap1, *bitmap2;
     DXGI_SURFACE_DESC surface_desc;
@@ -4414,7 +4442,7 @@ static void test_shared_bitmap(void)
     IWICBitmap_Release(wic_bitmap1);
     IDXGISurface_Release(surface2);
     IDXGISwapChain_Release(swapchain2);
-    ID3D10Device1_Release(device2);
+    IDXGIDevice_Release(device2);
     release_test_context(&ctx);
     DestroyWindow(window2);
     CoUninitialize();
@@ -7753,8 +7781,7 @@ static void test_create_device(void)
         return;
     }
 
-    hr = ID3D10Device1_QueryInterface(ctx.device, &IID_IDXGIDevice, (void **)&dxgi_device);
-    ok(SUCCEEDED(hr), "Failed to get IDXGIDevice interface, hr %#x.\n", hr);
+    IDXGIDevice_AddRef(dxgi_device = ctx.device);
 
     hr = ID2D1Factory1_CreateDevice(factory, dxgi_device, &device);
     ok(SUCCEEDED(hr), "Failed to get ID2D1Device, hr %#x.\n", hr);
@@ -8049,8 +8076,7 @@ static void test_bitmap_surface(void)
     ID2D1RenderTarget_Release(rt);
 
     /* Bitmap created from DXGI surface. */
-    hr = ID3D10Device1_QueryInterface(ctx.device, &IID_IDXGIDevice, (void **)&dxgi_device);
-    ok(SUCCEEDED(hr), "Failed to get IDXGIDevice interface, hr %#x.\n", hr);
+    IDXGIDevice_AddRef(dxgi_device = ctx.device);
 
     hr = ID2D1Factory1_CreateDevice(factory, dxgi_device, &device);
     ok(SUCCEEDED(hr), "Failed to get ID2D1Device, hr %#x.\n", hr);
@@ -8253,8 +8279,7 @@ static void test_device_context(void)
         return;
     }
 
-    hr = ID3D10Device1_QueryInterface(ctx.device, &IID_IDXGIDevice, (void **)&dxgi_device);
-    ok(SUCCEEDED(hr), "Failed to get IDXGIDevice interface, hr %#x.\n", hr);
+    IDXGIDevice_AddRef(dxgi_device = ctx.device);
 
     hr = ID2D1Factory1_CreateDevice(factory, dxgi_device, &device);
     ok(SUCCEEDED(hr), "Failed to get ID2D1Device, hr %#x.\n", hr);
@@ -8535,19 +8560,14 @@ static void test_skew_matrix(void)
     }
 }
 
-static ID2D1DeviceContext *create_device_context(ID2D1Factory1 *factory, ID3D10Device1 *d3d_device)
+static ID2D1DeviceContext *create_device_context(ID2D1Factory1 *factory, IDXGIDevice *dxgi_device)
 {
     ID2D1DeviceContext *device_context;
-    IDXGIDevice *dxgi_device;
     ID2D1Device *device;
     HRESULT hr;
 
-    hr = ID3D10Device1_QueryInterface(d3d_device, &IID_IDXGIDevice, (void **)&dxgi_device);
-    ok(SUCCEEDED(hr), "Failed to get IDXGIDevice interface, hr %#x.\n", hr);
-
     hr = ID2D1Factory1_CreateDevice(factory, dxgi_device, &device);
     ok(SUCCEEDED(hr), "Failed to get ID2D1Device, hr %#x.\n", hr);
-    IDXGIDevice_Release(dxgi_device);
 
     hr = ID2D1Device_CreateDeviceContext(device, D2D1_DEVICE_CONTEXT_OPTIONS_NONE, &device_context);
     ok(SUCCEEDED(hr), "Failed to create device context, hr %#x.\n", hr);
@@ -8855,7 +8875,7 @@ static void test_max_bitmap_size(void)
         }
 
         window = create_window();
-        swapchain = create_swapchain(device, window, TRUE);
+        swapchain = create_d3d10_swapchain(device, window, TRUE);
         hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface);
         ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
 
-- 
2.29.2




More information about the wine-devel mailing list