[PATCH 3/5] d2d1: Allow creating zero-sized bitmaps.
Nikolay Sivov
nsivov at codeweavers.com
Fri Sep 28 03:57:58 CDT 2018
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/d2d1/bitmap.c | 12 ++++++++++--
dlls/d2d1/tests/d2d1.c | 24 +++++++++++++++++++++++-
2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/dlls/d2d1/bitmap.c b/dlls/d2d1/bitmap.c
index 85514627ca..fde348fa1c 100644
--- a/dlls/d2d1/bitmap.c
+++ b/dlls/d2d1/bitmap.c
@@ -315,8 +315,16 @@ HRESULT d2d_bitmap_create(struct d2d_device_context *context, D2D1_SIZE_U size,
return D2DERR_UNSUPPORTED_PIXEL_FORMAT;
}
- texture_desc.Width = size.width;
- texture_desc.Height = size.height;
+ if (size.width == 0 || size.height == 0)
+ {
+ texture_desc.Width = 1;
+ texture_desc.Height = 1;
+ }
+ else
+ {
+ texture_desc.Width = size.width;
+ texture_desc.Height = size.height;
+ }
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 dcd8c30688..80660b00f9 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -827,7 +827,10 @@ static void check_bitmap_surface_(unsigned int line, ID2D1Bitmap *bitmap, BOOL h
ok_(__FILE__, line)(desc.MiscFlags == 0, "Unexpected misc flags %#x.\n", desc.MiscFlags);
pixel_size = ID2D1Bitmap_GetPixelSize(bitmap);
- ok_(__FILE__, line)(desc.Width == pixel_size.width && desc.Height == pixel_size.height,
+ if (pixel_size.width == 0 || pixel_size.height == 0)
+ ok_(__FILE__, line)(desc.Width == 1 && desc.Height == 1, "Expected dummy 1x1 texture.\n");
+ else
+ ok_(__FILE__, line)(desc.Width == pixel_size.width && desc.Height == pixel_size.height,
"Mismatching texture size.\n");
ID3D10Texture2D_Release(texture);
@@ -6890,6 +6893,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);
--
2.19.0
More information about the wine-devel
mailing list