d2d1: Allow creating zero-sized bitmaps.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2018-09-29 02:32:04 +03:30 committed by Alexandre Julliard
parent 9775ed22aa
commit cc8d53affe
2 changed files with 23 additions and 0 deletions

View file

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

View file

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