d3drm/tests: Clean up some magic values.

In BMP files with 24-bit depth, color components are stored in BGR
order. Due to magic values being used several places in tests to reduce
the components, some logical errors are hard to spot.

Give names to the magic values to make logical errors more apparent.
This commit is contained in:
Jeff Smith 2022-07-19 10:09:27 -05:00 committed by Alexandre Julliard
parent 236476417a
commit 77189a341f

View file

@ -6145,6 +6145,10 @@ static void test_create_device_3(void)
IDirect3DRM_Release(d3drm);
}
#define MOD_R 247
#define MOD_G 239
#define MOD_B 251
static char *create_bitmap(unsigned int w, unsigned int h, BOOL palettized)
{
unsigned int bpp = palettized ? 8 : 24;
@ -6205,9 +6209,9 @@ static char *create_bitmap(unsigned int w, unsigned int h, BOOL palettized)
}
else
{
buffer[i++] = j % 251;
buffer[i++] = j % 239;
buffer[i++] = j++ % 247;
buffer[i++] = j % MOD_B;
buffer[i++] = j % MOD_G;
buffer[i++] = j++ % MOD_R;
}
}
ret = WriteFile(file, buffer, size, &written, NULL);
@ -6253,11 +6257,11 @@ static void test_bitmap_data(unsigned int test_idx, const D3DRMIMAGE *img,
const unsigned char *ptr = &data[i * img->bytes_per_line + j * 4];
unsigned int idx = upside_down ? (h - 1 - i) * w + j : i * w + j;
if (ptr[0] != idx % 251 || ptr[1] != idx % 239 || ptr[2] != idx % 247 || ptr[3] != 0xff)
if (ptr[0] != idx % MOD_B || ptr[1] != idx % MOD_G || ptr[2] != idx % MOD_R || ptr[3] != 0xff)
{
ok(0, "Test %u: Got unexpected color 0x%02x%02x%02x%02x at position %u, %u, "
"expected 0x%02x%02x%02x%02x.\n", test_idx, ptr[0], ptr[1], ptr[2], ptr[3],
j, i, idx % 251, idx % 239, idx % 247, 0xff);
j, i, idx % MOD_B, idx % MOD_G, idx % MOD_R, 0xff);
return;
}
}
@ -6283,8 +6287,8 @@ static void test_bitmap_data(unsigned int test_idx, const D3DRMIMAGE *img,
for (i = 0; i < img->palette_size; ++i)
{
unsigned int idx = upside_down ? (h - 1) * w - i + (i % w) * 2 : i;
ok(img->palette[i].red == idx % 251
&& img->palette[i].green == idx % 239 && img->palette[i].blue == idx % 247,
ok(img->palette[i].red == idx % MOD_B
&& img->palette[i].green == idx % MOD_G && img->palette[i].blue == idx % MOD_R,
"Test %u: Got unexpected palette entry (%u) color 0x%02x%02x%02x.\n",
test_idx, i, img->palette[i].red, img->palette[i].green, img->palette[i].blue);
ok(img->palette[i].flags == D3DRMPALETTE_READONLY,