Rémi Bernon : d2d1/tests: Store the resource data pointer and row-pitch directly in struct resource_readback.

Alexandre Julliard julliard at winehq.org
Fri Jan 15 15:39:46 CST 2021


Module: wine
Branch: master
Commit: aab3f4b7fe8ba0d7f6da015872e7a6726846a588
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=aab3f4b7fe8ba0d7f6da015872e7a6726846a588

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Fri Jan 15 21:47:59 2021 +0330

d2d1/tests: Store the resource data pointer and row-pitch directly in struct resource_readback.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/d2d1/tests/d2d1.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index c8c0e83df1c..a1869dcaaaa 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -54,8 +54,8 @@ struct d2d1_test_context
 struct resource_readback
 {
     ID3D10Resource *resource;
-    D3D10_MAPPED_TEXTURE2D map_desc;
-    unsigned int width, height;
+    unsigned int pitch, width, height;
+    void *data;
 };
 
 struct figure
@@ -314,6 +314,7 @@ static void cubic_to(ID2D1GeometrySink *sink, float x1, float y1, float x2, floa
 static void get_surface_readback(IDXGISurface *surface, struct resource_readback *rb)
 {
     D3D10_TEXTURE2D_DESC texture_desc;
+    D3D10_MAPPED_TEXTURE2D map_desc;
     DXGI_SURFACE_DESC surface_desc;
     ID3D10Resource *src_resource;
     ID3D10Device *device;
@@ -346,8 +347,11 @@ static void get_surface_readback(IDXGISurface *surface, struct resource_readback
     ID3D10Resource_Release(src_resource);
     ID3D10Device_Release(device);
 
-    hr = ID3D10Texture2D_Map((ID3D10Texture2D *)rb->resource, 0, D3D10_MAP_READ, 0, &rb->map_desc);
+    hr = ID3D10Texture2D_Map((ID3D10Texture2D *)rb->resource, 0, D3D10_MAP_READ, 0, &map_desc);
     ok(SUCCEEDED(hr), "Failed to map texture, hr %#x.\n", hr);
+
+    rb->pitch = map_desc.RowPitch;
+    rb->data = map_desc.pData;
 }
 
 static void release_resource_readback(struct resource_readback *rb)
@@ -358,7 +362,7 @@ static void release_resource_readback(struct resource_readback *rb)
 
 static DWORD get_readback_colour(struct resource_readback *rb, unsigned int x, unsigned int y)
 {
-    return ((DWORD *)((BYTE *)rb->map_desc.pData + y * rb->map_desc.RowPitch))[x];
+    return ((DWORD *)((BYTE *)rb->data + y * rb->pitch))[x];
 }
 
 static BOOL compare_uint(unsigned int x, unsigned int y, unsigned int max_diff)
@@ -463,8 +467,7 @@ static BOOL compare_surface(IDXGISurface *surface, const char *ref_sha1)
     BOOL ret;
 
     get_surface_readback(surface, &rb);
-    ret = compare_sha1(rb.map_desc.pData, rb.map_desc.RowPitch, 4,
-            rb.width, rb.height, ref_sha1);
+    ret = compare_sha1(rb.data, rb.pitch, 4, rb.width, rb.height, ref_sha1);
     release_resource_readback(&rb);
 
     return ret;
@@ -641,7 +644,7 @@ static BOOL compare_figure(IDXGISurface *surface, unsigned int x, unsigned int y
     figure.spans_size = 64;
     figure.spans = HeapAlloc(GetProcessHeap(), 0, figure.spans_size * sizeof(*figure.spans));
 
-    read_figure(&figure, rb.map_desc.pData, rb.map_desc.RowPitch, x, y, w, h, prev);
+    read_figure(&figure, rb.data, rb.pitch, x, y, w, h, prev);
 
     deserialize_figure(&ref_figure, (BYTE *)ref);
     span = w * h;
@@ -679,7 +682,7 @@ static BOOL compare_figure(IDXGISurface *surface, unsigned int x, unsigned int y
     if (diff > max_diff)
     {
         trace("diff %u > max_diff %u.\n", diff, max_diff);
-        read_figure(&figure, rb.map_desc.pData, rb.map_desc.RowPitch, x, y, w, h, prev);
+        read_figure(&figure, rb.data, rb.pitch, x, y, w, h, prev);
         serialize_figure(&figure);
     }
 




More information about the wine-cvs mailing list