[PATCH v3 3/3] d2d1: Add some tests for ID2D1Bitmap1::Map()/::Unmap().

Dmitry Timoshkov dmitry at baikal.ru
Fri May 27 04:22:57 CDT 2022


Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
---
 dlls/d2d1/tests/d2d1.c | 73 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)

diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index d5adb0c749c..e34d1070637 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -11388,6 +11388,78 @@ static void test_image_bounds(BOOL d3d11)
     release_test_context(&ctx);
 }
 
+static void test_bitmap_map(BOOL d3d11)
+{
+    struct d2d1_test_context ctx;
+    D2D1_SIZE_U size;
+    IDXGISurface *surface;
+    ID2D1Bitmap1 *bitmap;
+    D2D1_MAPPED_RECT mapped_rect;
+    D2D1_BITMAP_PROPERTIES1 bitmap_desc;
+    HRESULT hr;
+
+    if (!init_test_context(&ctx, d3d11))
+        return;
+
+    set_size_u(&size, 4, 4);
+    bitmap_desc.dpiX = 96.0f;
+    bitmap_desc.dpiY = 96.0f;
+    bitmap_desc.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM;
+    bitmap_desc.pixelFormat.alphaMode = D2D1_ALPHA_MODE_IGNORE;
+    bitmap_desc.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET;
+    bitmap_desc.colorContext = NULL;
+    hr = ID2D1DeviceContext_CreateBitmap(ctx.context, size, NULL, 0, &bitmap_desc, &bitmap);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+
+    hr = ID2D1Bitmap1_Map(bitmap, D2D1_MAP_OPTIONS_NONE, &mapped_rect);
+    ok(hr == E_INVALIDARG , "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);
+
+    hr = ID2D1Bitmap1_Map(bitmap, D2D1_MAP_OPTIONS_WRITE, &mapped_rect);
+    ok(hr == E_INVALIDARG , "Got unexpected hr %#lx.\n", hr);
+
+    ID2D1Bitmap1_Release(bitmap);
+
+    bitmap_desc.bitmapOptions = D2D1_BITMAP_OPTIONS_CANNOT_DRAW | D2D1_BITMAP_OPTIONS_CPU_READ;
+    hr = ID2D1DeviceContext_CreateBitmap(ctx.context, size, NULL, 0, &bitmap_desc, &bitmap);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+
+    hr = ID2D1Bitmap1_Map(bitmap, D2D1_MAP_OPTIONS_NONE, &mapped_rect);
+    ok(hr == E_INVALIDARG , "Got unexpected hr %#lx.\n", hr);
+
+    hr = ID2D1Bitmap1_Map(bitmap, D2D1_MAP_OPTIONS_READ, &mapped_rect);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+
+    hr = ID2D1Bitmap1_Map(bitmap, D2D1_MAP_OPTIONS_READ, &mapped_rect);
+    ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#lx.\n", hr);
+
+    hr = ID2D1Bitmap1_Map(bitmap, D2D1_MAP_OPTIONS_WRITE, &mapped_rect);
+    ok(hr == E_INVALIDARG , "Got unexpected hr %#lx.\n", hr);
+
+    hr = ID2D1Bitmap1_Unmap(bitmap);
+    ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+
+    hr = ID2D1Bitmap1_Unmap(bitmap);
+    ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#lx.\n", hr);
+
+    ID2D1Bitmap1_Release(bitmap);
+
+    surface = create_surface(ctx.device, DXGI_FORMAT_B8G8R8A8_UNORM);
+
+    bitmap_desc.bitmapOptions = D2D1_BITMAP_OPTIONS_CANNOT_DRAW | D2D1_BITMAP_OPTIONS_CPU_READ;
+    hr = ID2D1DeviceContext_CreateBitmapFromDxgiSurface(ctx.context, surface, &bitmap_desc, &bitmap);
+    todo_wine
+    ok(hr == E_INVALIDARG , "Got unexpected hr %#lx.\n", hr);
+    if (hr == S_OK)
+        ID2D1Bitmap1_Release(bitmap);
+
+    IDXGISurface_Release(surface);
+
+    release_test_context(&ctx);
+}
+
 START_TEST(d2d1)
 {
     HMODULE d2d1_dll = GetModuleHandleA("d2d1.dll");
@@ -11464,6 +11536,7 @@ START_TEST(d2d1)
     queue_test(test_effect_grayscale);
     queue_d3d10_test(test_stroke_contains_point);
     queue_test(test_image_bounds);
+    queue_test(test_bitmap_map);
 
     run_queued_tests();
 }
-- 
2.36.1




More information about the wine-devel mailing list