Nikolay Sivov : d2d1: Allow creating zero-sized bitmaps.

Alexandre Julliard julliard at winehq.org
Mon Oct 1 21:19:04 CDT 2018


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Sat Sep 29 02:50:04 2018 +0330

d2d1: Allow creating zero-sized bitmaps.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/d2d1/bitmap.c     |  2 ++
 dlls/d2d1/tests/d2d1.c | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/dlls/d2d1/bitmap.c b/dlls/d2d1/bitmap.c
index 8551462..efb3204 100644
--- a/dlls/d2d1/bitmap.c
+++ b/dlls/d2d1/bitmap.c
@@ -317,6 +317,8 @@ HRESULT d2d_bitmap_create(struct d2d_device_context *context, D2D1_SIZE_U size,
 
     texture_desc.Width = size.width;
     texture_desc.Height = size.height;
+    if (!texture_desc.Width || !texture_desc.Height)
+        texture_desc.Width = texture_desc.Height = 1;
     texture_desc.MipLevels = 1;
     texture_desc.ArraySize = 1;
     texture_desc.Format = desc->pixelFormat.format;
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index 4eb1422..03d2153 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -819,6 +819,8 @@ static void check_bitmap_surface_(unsigned int line, ID2D1Bitmap *bitmap, BOOL h
         ok_(__FILE__, line)(!desc.MiscFlags, "Unexpected misc flags %#x.\n", desc.MiscFlags);
 
         pixel_size = ID2D1Bitmap_GetPixelSize(bitmap);
+        if (!pixel_size.width || !pixel_size.height)
+            pixel_size.width = pixel_size.height = 1;
         ok_(__FILE__, line)(desc.Width == pixel_size.width, "Got width %u, expected %u.\n",
                 desc.Width, pixel_size.width);
         ok_(__FILE__, line)(desc.Height == pixel_size.height, "Got height %u, expected %u.\n",
@@ -6889,6 +6891,25 @@ static void check_rt_bitmap_surface_(unsigned int line, ID2D1RenderTarget *rt, B
 
     ID2D1Bitmap_Release(bitmap);
 
+    /* Zero sized bitmaps. */
+    set_size_u(&size, 0, 0);
+    hr = ID2D1RenderTarget_CreateBitmap(rt, size, NULL, 0, &bitmap_desc, &bitmap);
+    ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to create bitmap, hr %#x.\n", hr);
+    check_bitmap_surface_(line, bitmap, has_surface, options);
+    ID2D1Bitmap_Release(bitmap);
+
+    set_size_u(&size, 2, 0);
+    hr = ID2D1RenderTarget_CreateBitmap(rt, size, NULL, 0, &bitmap_desc, &bitmap);
+    ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to create bitmap, hr %#x.\n", hr);
+    check_bitmap_surface_(line, bitmap, has_surface, options);
+    ID2D1Bitmap_Release(bitmap);
+
+    set_size_u(&size, 0, 2);
+    hr = ID2D1RenderTarget_CreateBitmap(rt, size, NULL, 0, &bitmap_desc, &bitmap);
+    ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to create bitmap, hr %#x.\n", hr);
+    check_bitmap_surface_(line, bitmap, has_surface, options);
+    ID2D1Bitmap_Release(bitmap);
+
     /* WIC bitmap. */
     CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
 




More information about the wine-cvs mailing list