[PATCH v2 10/12] d2d1/tests: Pass test context to get_surface_readback.

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


And to release_resource_readback for future use.

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

diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index 94d56338cd4..eb611aa1f20 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -311,8 +311,9 @@ static void cubic_to(ID2D1GeometrySink *sink, float x1, float y1, float x2, floa
     ID2D1GeometrySink_AddBezier(sink, &b);
 }
 
-static void get_surface_readback(IDXGISurface *surface, struct resource_readback *rb)
+static void get_surface_readback(struct d2d1_test_context *ctx, struct resource_readback *rb)
 {
+    IDXGISurface *surface = ctx->surface;
     D3D10_TEXTURE2D_DESC texture_desc;
     D3D10_MAPPED_TEXTURE2D map_desc;
     DXGI_SURFACE_DESC surface_desc;
@@ -354,7 +355,7 @@ static void get_surface_readback(IDXGISurface *surface, struct resource_readback
     rb->data = map_desc.pData;
 }
 
-static void release_resource_readback(struct resource_readback *rb)
+static void release_resource_readback(struct d2d1_test_context *ctx, struct resource_readback *rb)
 {
     ID3D10Texture2D_Unmap((ID3D10Texture2D *)rb->resource, 0);
     ID3D10Resource_Release(rb->resource);
@@ -466,9 +467,9 @@ static BOOL compare_surface(struct d2d1_test_context *ctx, const char *ref_sha1)
     struct resource_readback rb;
     BOOL ret;
 
-    get_surface_readback(ctx->surface, &rb);
+    get_surface_readback(ctx, &rb);
     ret = compare_sha1(rb.data, rb.pitch, 4, rb.width, rb.height, ref_sha1);
-    release_resource_readback(&rb);
+    release_resource_readback(ctx, &rb);
 
     return ret;
 }
@@ -638,7 +639,7 @@ static BOOL compare_figure(struct d2d1_test_context *ctx, unsigned int x, unsign
     unsigned int i, j, span, diff;
     struct resource_readback rb;
 
-    get_surface_readback(ctx->surface, &rb);
+    get_surface_readback(ctx, &rb);
 
     figure.span_count = 0;
     figure.spans_size = 64;
@@ -688,7 +689,7 @@ static BOOL compare_figure(struct d2d1_test_context *ctx, unsigned int x, unsign
 
     HeapFree(GetProcessHeap(), 0, ref_figure.spans);
     HeapFree(GetProcessHeap(), 0, figure.spans);
-    release_resource_readback(&rb);
+    release_resource_readback(ctx, &rb);
 
     return diff <= max_diff;
 }
@@ -2096,7 +2097,7 @@ static void test_linear_brush(void)
     hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL);
     ok(SUCCEEDED(hr), "Failed to end draw, hr %#x.\n", hr);
 
-    get_surface_readback(ctx.surface, &rb);
+    get_surface_readback(&ctx, &rb);
     for (i = 0; i < ARRAY_SIZE(test1); ++i)
     {
         DWORD colour;
@@ -2106,7 +2107,7 @@ static void test_linear_brush(void)
                 "Got unexpected colour 0x%08x at position {%u, %u}.\n",
                 colour, test1[i].x, test1[i].y);
     }
-    release_resource_readback(&rb);
+    release_resource_readback(&ctx, &rb);
 
     ID2D1RenderTarget_BeginDraw(rt);
 
@@ -2169,7 +2170,7 @@ static void test_linear_brush(void)
     hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL);
     ok(SUCCEEDED(hr), "Failed to end draw, hr %#x.\n", hr);
 
-    get_surface_readback(ctx.surface, &rb);
+    get_surface_readback(&ctx, &rb);
     for (i = 0; i < ARRAY_SIZE(test2); ++i)
     {
         DWORD colour;
@@ -2179,7 +2180,7 @@ static void test_linear_brush(void)
                 "Got unexpected colour 0x%08x at position {%u, %u}.\n",
                 colour, test2[i].x, test2[i].y);
     }
-    release_resource_readback(&rb);
+    release_resource_readback(&ctx, &rb);
 
     ID2D1LinearGradientBrush_Release(brush);
     refcount = ID2D1GradientStopCollection_Release(gradient);
@@ -2295,7 +2296,7 @@ static void test_radial_brush(void)
     hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL);
     ok(SUCCEEDED(hr), "Failed to end draw, hr %#x.\n", hr);
 
-    get_surface_readback(ctx.surface, &rb);
+    get_surface_readback(&ctx, &rb);
     for (i = 0; i < ARRAY_SIZE(test1); ++i)
     {
         DWORD colour;
@@ -2305,7 +2306,7 @@ static void test_radial_brush(void)
                 "Got unexpected colour 0x%08x at position {%u, %u}.\n",
                 colour, test1[i].x, test1[i].y);
     }
-    release_resource_readback(&rb);
+    release_resource_readback(&ctx, &rb);
 
     ID2D1RenderTarget_BeginDraw(rt);
 
@@ -2370,7 +2371,7 @@ static void test_radial_brush(void)
     hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL);
     ok(SUCCEEDED(hr), "Failed to end draw, hr %#x.\n", hr);
 
-    get_surface_readback(ctx.surface, &rb);
+    get_surface_readback(&ctx, &rb);
     for (i = 0; i < ARRAY_SIZE(test2); ++i)
     {
         DWORD colour;
@@ -2380,7 +2381,7 @@ static void test_radial_brush(void)
                 "Got unexpected colour 0x%08x at position {%u, %u}.\n",
                 colour, test2[i].x, test2[i].y);
     }
-    release_resource_readback(&rb);
+    release_resource_readback(&ctx, &rb);
 
     ID2D1RadialGradientBrush_Release(brush);
     refcount = ID2D1GradientStopCollection_Release(gradient);
-- 
2.29.2




More information about the wine-devel mailing list