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

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
Nikolay Sivov 2022-05-30 09:07:58 +03:00 committed by Alexandre Julliard
parent f185a3acb9
commit 828a7aa071
2 changed files with 11 additions and 0 deletions

View file

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

View file

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