On Tue, 14 Sept 2021 at 04:15, Ziqing Hui zhui@codeweavers.com wrote:
- const struct effect_2d_affine_test
- {
const DWORD *img_data;
unsigned int img_width;
unsigned int img_height;
D2D1_MATRIX_3X2_F *matrix;
D2D_RECT_F bounds;
const char *figure;
- }
- effect_2d_affine_tests[] =
- {
{image_4x4, 4, 4, &rotate, {-6.0f, -3.0f, 2.0f, 4.0f}, "AQ8B7wEA"},
{image_4x4, 4, 4, &scale, {-2.0f, -3.0f, 1.0f, 9.0f}, "AQ8BDwEPAQ8BDwEPAQ8BDwF/"},
{image_4x4, 4, 4, &skew, {-7.0f, -3.0f, 3.0f, 7.0f}, "AQ8BAQ4BAQ4BzwEA"},
{image_16x16, 16, 16, &rotate, {-14.0f, -3.0f, 10.0f, 21.0f},
"AQ8BAQ4CAQ0DAQwEAQsFAQoGAQkHAQgIAQcIAQEGBwEBBwYBAQgFAQEJBAEBCgMBAQsCAQEM"},
{image_16x16, 16, 16, &scale, {-2.0f, -3.0f, 10.0f, 39.0f},
"AQkGCgYKBgoGCgYKBgoGCgYKBgoGCgYKBgoGCgYKBgoG"},
{image_16x16, 16, 16, &skew, {-19.0f, -3.0f, 15.0f, 31.0f},
"AQ8BAQ4CAQ0DAQwEAQsFAQoGAQkHAQgIAQcJAQYKAQULAQQMAQMNAQINAQIMAQMA"},
- };
...
ID2D1DeviceContext_BeginDraw(context);
ID2D1DeviceContext_Clear(context, 0);
ID2D1DeviceContext_DrawImage(context, output, NULL, NULL, 0, 0);
hr = ID2D1DeviceContext_EndDraw(context, NULL, NULL);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
match = compare_figure(&ctx, 0, 0, 16, 16, 0xff652e89, 0, test->figure);
In a certain sense that works, but we're only testing the part of the image intersecting with the top-left corner. It doesn't seem much more complicated to draw the image in the centre of the render target, and then use the bounds in compare_figure. E.g.:
ID2D1DeviceContext_DrawImage(..., 320, 240); ... x = 320.0f + output_bounds.left - 2.0f; y = 240.0f + output_bounds.top - 2.0f; w = (output_bounds.right - output_bounds.left) + 4.0f; h = (output_bounds.bottom - output_bounds.top) + 4.0f; match = compare_figure(&ctx, x, y, w, h, ...);