From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- 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 85514627ca6..efb320445fb 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 4eb14223c45..03d21532b81 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);