[PATCH 1/4] d2d1: Use bitmap options to check if mapping is supported.

Nikolay Sivov wine at gitlab.winehq.org
Tue May 31 06:15:36 CDT 2022


From: Nikolay Sivov <nsivov at codeweavers.com>

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/d2d1/bitmap.c     | 3 +++
 dlls/d2d1/tests/d2d1.c | 8 ++++++++
 2 files changed, 11 insertions(+)

diff --git a/dlls/d2d1/bitmap.c b/dlls/d2d1/bitmap.c
index 6a02279b91b..1c6383ae4a9 100644
--- a/dlls/d2d1/bitmap.c
+++ b/dlls/d2d1/bitmap.c
@@ -257,6 +257,9 @@ static HRESULT STDMETHODCALLTYPE d2d_bitmap_Map(ID2D1Bitmap1 *iface, D2D1_MAP_OP
 
     TRACE("iface %p, options %#x, mapped_rect %p.\n", iface, options, mapped_rect);
 
+    if (!(bitmap->options & D2D1_BITMAP_OPTIONS_CPU_READ))
+        return E_INVALIDARG;
+
     if (bitmap->mapped_resource.pData)
         return D2DERR_WRONG_STATE;
 
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index 807a7be5ae6..9706b02528b 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -11804,6 +11804,14 @@ static void test_bitmap_map(BOOL d3d11)
     ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
     if (SUCCEEDED(hr)) ID2D1Bitmap1_Release(bitmap);
 
+    /* Create without D2D1_BITMAP_OPTIONS_CPU_READ, surface supports CPU reads. */
+    bitmap_desc.bitmapOptions = D2D1_BITMAP_OPTIONS_CANNOT_DRAW;
+    hr = ID2D1DeviceContext_CreateBitmapFromDxgiSurface(ctx.context, surface, &bitmap_desc, &bitmap);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+    hr = ID2D1Bitmap1_Map(bitmap, D2D1_MAP_OPTIONS_READ, &mapped_rect);
+    ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
+    ID2D1Bitmap1_Release(bitmap);
+
     ID3D11Texture2D_Release(texture);
     IDXGISurface_Release(surface);
 
-- 
GitLab


https://gitlab.winehq.org/wine/wine/-/merge_requests/161



More information about the wine-devel mailing list