Nikolay Sivov : d2d1: Use bitmap options to check if mapping is supported.

Alexandre Julliard julliard at winehq.org
Tue May 31 15:57:59 CDT 2022


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Mon May 30 09:07:58 2022 +0300

d2d1: Use bitmap options to check if mapping is supported.

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);
 




More information about the wine-cvs mailing list