Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48054 Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/gdi32/tests/bitmap.c | 41 ++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 18 deletions(-)
diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c index 8fe160546c..dea7c3d9db 100644 --- a/dlls/gdi32/tests/bitmap.c +++ b/dlls/gdi32/tests/bitmap.c @@ -910,10 +910,15 @@ static void test_dibsections(void) ReleaseDC(0, hdc); }
+#define DATA_WIDTH 2 +#define DATA_HEIGHT 2 +#define MAX_PLANES 64 +#define MAX_BPP 64 + static void test_dib_formats(void) { BITMAPINFO *bi; - char data[256]; + char data[((DATA_WIDTH * MAX_BPP + 31) / 32) * 4 * DATA_HEIGHT * MAX_PLANES]; void *bits; int planes, bpp, compr, format; HBITMAP hdib, hbmp; @@ -928,9 +933,9 @@ static void test_dib_formats(void)
memset( data, 0xaa, sizeof(data) );
- for (bpp = 0; bpp <= 64; bpp++) + for (bpp = 0; bpp <= MAX_BPP; bpp++) { - for (planes = 0; planes <= 64; planes++) + for (planes = 0; planes <= MAX_PLANES; planes++) { for (compr = 0; compr < 8; compr++) { @@ -949,8 +954,8 @@ static void test_dib_formats(void)
memset( bi, 0, sizeof(bi->bmiHeader) ); bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bi->bmiHeader.biWidth = 2; - bi->bmiHeader.biHeight = 2; + bi->bmiHeader.biWidth = DATA_WIDTH; + bi->bmiHeader.biHeight = DATA_HEIGHT; bi->bmiHeader.biPlanes = planes; bi->bmiHeader.biBitCount = bpp; bi->bmiHeader.biCompression = compr; @@ -969,8 +974,8 @@ static void test_dib_formats(void) if (!planes) expect_ok = FALSE; memset( bi, 0, sizeof(bi->bmiHeader) ); bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bi->bmiHeader.biWidth = 2; - bi->bmiHeader.biHeight = 2; + bi->bmiHeader.biWidth = DATA_WIDTH; + bi->bmiHeader.biHeight = DATA_HEIGHT; bi->bmiHeader.biPlanes = planes; bi->bmiHeader.biBitCount = bpp; bi->bmiHeader.biCompression = compr; @@ -1027,8 +1032,8 @@ static void test_dib_formats(void) bpp, bi->bmiHeader.biBitCount );
bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bi->bmiHeader.biWidth = 2; - bi->bmiHeader.biHeight = 2; + bi->bmiHeader.biWidth = DATA_WIDTH; + bi->bmiHeader.biHeight = DATA_HEIGHT; bi->bmiHeader.biPlanes = planes; bi->bmiHeader.biBitCount = bpp; bi->bmiHeader.biCompression = compr; @@ -1067,8 +1072,8 @@ static void test_dib_formats(void)
memset( bi, 0, sizeof(bi->bmiHeader) ); bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bi->bmiHeader.biWidth = 2; - bi->bmiHeader.biHeight = 2; + bi->bmiHeader.biWidth = DATA_WIDTH; + bi->bmiHeader.biHeight = DATA_HEIGHT; bi->bmiHeader.biPlanes = 1; bi->bmiHeader.biBitCount = 16; bi->bmiHeader.biCompression = BI_BITFIELDS; @@ -1121,7 +1126,7 @@ static void test_dib_formats(void) ok( ret, "SetDIBits failed with bad bitfields\n" );
bi->bmiHeader.biWidth = -2; - bi->bmiHeader.biHeight = 2; + bi->bmiHeader.biHeight = DATA_HEIGHT; bi->bmiHeader.biBitCount = 32; bi->bmiHeader.biCompression = BI_RGB; hdib = CreateDIBSection(hdc, bi, DIB_RGB_COLORS, &bits, NULL, 0); @@ -1144,7 +1149,7 @@ static void test_dib_formats(void) ok( !ret || broken(ret), /* nt4 */ "GetDIBits succeeded with negative width\n" );
bi->bmiHeader.biWidth = 0; - bi->bmiHeader.biHeight = 2; + bi->bmiHeader.biHeight = DATA_HEIGHT; bi->bmiHeader.biBitCount = 32; bi->bmiHeader.biCompression = BI_RGB; hdib = CreateDIBSection(hdc, bi, DIB_RGB_COLORS, &bits, NULL, 0); @@ -1167,7 +1172,7 @@ static void test_dib_formats(void) ret = GetDIBits(hdc, hbmp, 0, 2, NULL, bi, DIB_RGB_COLORS); ok( !ret || broken(ret), /* nt4 */ "GetDIBits succeeded with zero width\n" );
- bi->bmiHeader.biWidth = 2; + bi->bmiHeader.biWidth = DATA_WIDTH; bi->bmiHeader.biHeight = 0; bi->bmiHeader.biBitCount = 32; bi->bmiHeader.biCompression = BI_RGB; @@ -1193,8 +1198,8 @@ static void test_dib_formats(void)
/* some functions accept DIB_PAL_COLORS+1, but not beyond */
- bi->bmiHeader.biWidth = 2; - bi->bmiHeader.biHeight = 2; + bi->bmiHeader.biWidth = DATA_WIDTH; + bi->bmiHeader.biHeight = DATA_HEIGHT; bi->bmiHeader.biBitCount = 1; bi->bmiHeader.biCompression = BI_RGB; hdib = CreateDIBSection(hdc, bi, DIB_PAL_COLORS+1, &bits, NULL, 0); @@ -1217,8 +1222,8 @@ static void test_dib_formats(void) ret = GetDIBits(hdc, hbmp, 0, 0, NULL, bi, DIB_PAL_COLORS+1); ok( !ret, "GetDIBits succeeded with DIB_PAL_COLORS+1\n" );
- bi->bmiHeader.biWidth = 2; - bi->bmiHeader.biHeight = 2; + bi->bmiHeader.biWidth = DATA_WIDTH; + bi->bmiHeader.biHeight = DATA_HEIGHT; bi->bmiHeader.biBitCount = 1; bi->bmiHeader.biCompression = BI_RGB; hdib = CreateDIBSection(hdc, bi, DIB_PAL_COLORS+2, &bits, NULL, 0);
Jeff Smith whydoubt@gmail.com wrote:
+#define DATA_WIDTH 2 +#define DATA_HEIGHT 2 +#define MAX_PLANES 64 +#define MAX_BPP 64
static void test_dib_formats(void) { BITMAPINFO *bi;
- char data[256];
- char data[((DATA_WIDTH * MAX_BPP + 31) / 32) * 4 * DATA_HEIGHT * MAX_PLANES];
This makes the test absolutely unreadable. Just adding a comment around char data[2544]; /* enough to hold DIB test data */ would be enough IMO.
On Fri, 22 Nov 2019, Jeff Smith wrote: [...]
+#define DATA_WIDTH 2 +#define DATA_HEIGHT 2 +#define MAX_PLANES 64 +#define MAX_BPP 64
static void test_dib_formats(void) { BITMAPINFO *bi;
- char data[256];
- char data[((DATA_WIDTH * MAX_BPP + 31) / 32) * 4 * DATA_HEIGHT * MAX_PLANES];
If not using DATA_WIDTH & co, I use the literals here at least. (probably won't help with the readability complaint but I'm not sure I agree with it)
[...]
@@ -1121,7 +1126,7 @@ static void test_dib_formats(void) ok( ret, "SetDIBits failed with bad bitfields\n" );
bi->bmiHeader.biWidth = -2;
Shouldn't that be -DATA_WIDTH?