From wine-devel Thu Feb 11 08:39:45 2021 From: Ralf Habacker Date: Thu, 11 Feb 2021 08:39:45 +0000 To: wine-devel Subject: [PATCH v9] gdi32/tests: Add tests for the advanced graphics mode Message-Id: <20210211083944.32228-1-ralf.habacker () freenet ! de> X-MARC-Message: https://marc.info/?l=wine-devel&m=161303288427889 The tests are designed to support an automated mode and an interactive mode. In automated mode, only tests where the angle used is a multiple of pi/4 are performed to increase the chance of matching images created on Windows. In interactive test mode (enabled by environment variable WINETEST_INTERACTIVE=value) there are several options available like dumping images to a file and limiting the performed tests and more. See the defines for WI_XXX in the source for specific values. Signed-off-by: Ralf Habacker --- - only add passing tests to automated mode - extend interactive test to support several options by using different values for WINETEST_INTERACTIVE dlls/gdi32/tests/dib.c | 457 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 457 insertions(+) diff --git a/dlls/gdi32/tests/dib.c b/dlls/gdi32/tests/dib.c index bdc3d9ed55b..abbd57ebee3 100644 --- a/dlls/gdi32/tests/dib.c +++ b/dlls/gdi32/tests/dib.c @@ -3529,11 +3529,468 @@ static void test_simple_graphics(void) DeleteDC(mem_dc); } +/* + * prelimary tests for the advanced graphics mode + */ + +/* supported modes for winetest_interactive */ +#define WI_IN_WORK 2 +#define WI_TODO 4 +#define WI_TEST_SHEAR 8 +#define WI_DRAW_ORIGIN 16 + +typedef struct { + const char *name; + double shear_x; + double angle; + const char *sha1; +} ref_hash_table_entry; + +typedef struct { + HDC dc; + BITMAPINFO *bmi; + BYTE *bits; + HBITMAP dib; + char test_name[1024]; + char save_path[MAX_PATH]; + char hash_name[1024]; + RECT bounds; + double angle; + double shear_x; +} test_data; + +/* generated on Windows 10 */ +static const ref_hash_table_entry ref_hash_table[] = { + { "LineTo", 0.000000, 0.000000, "e674c29670f7c4ce7284d775f42f5c9ba0652083" }, + { "Rectangle", 0.000000, 0.000000, "65257f012efd9648f6fc8008b2999e43ae77af2b" }, + { "Ellipse", 0.000000, 0.000000, "ca37209937b559c15e8503bf4ba6448290e63b5d" }, + { "Arc", 0.000000, 0.000000, "2f74a49d5f6e5d3a2f0f529b264b7d4d8f1d3906" }, + { "ArcTo", 0.000000, 0.000000, "104debc781c9785e6fa6e8a8e6893ae66c82376f" }, + { "Chord", 0.000000, 0.000000, "46e53f09a64e8ac4639216e624dfc038c43af941" }, + { "Pie", 0.000000, 0.000000, "46e53f09a64e8ac4639216e624dfc038c43af941" }, + { "FillRect", 0.000000, 0.000000, "51a1a9138502836010bb92a3ab2f1ac7c3272d37" }, + { "LineTo", 0.000000, 45.000000, "5cf7ec231cda517f919adcc30e836fb499d7a58b" }, + { "Rectangle", 0.000000, 45.000000, "e3fbac45b4d6eea230260f75db5a95faea87a4de" }, + { "Ellipse", 0.000000, 45.000000, "df3807e66cc3259cd327242278e65d4dfcb842cb" }, + { "Arc", 0.000000, 45.000000, "91c69166219983536e92ae66b64d3ebfcc784c4a" }, + { "ArcTo", 0.000000, 45.000000, "292c5ced6d6d7a17c6d93745b814bde9909929c3" }, + { "Chord", 0.000000, 45.000000, "b8cc5bfd303b75f0c7f22de5d7d9cc643630bc22" }, + { "Pie", 0.000000, 45.000000, "b8cc5bfd303b75f0c7f22de5d7d9cc643630bc22" }, + { "FillRect", 0.000000, 45.000000, "b8b4193c5308b87d3bd7d0b0a606fc118faa7418" }, + { "LineTo", 0.000000, 90.000000, "f94c76a61d71522fd526345b849940eb4a24d5a8" }, + { "Rectangle", 0.000000, 90.000000, "0befe6682e2e62cc14e5769d978aafed046e9a91" }, + { "Ellipse", 0.000000, 90.000000, "f0f89443304b99ac1a36cfd566bb18813f94f033" }, + { "Arc", 0.000000, 90.000000, "6d031451619a13f442dbf8a0093d516c50dc28f1" }, + { "ArcTo", 0.000000, 90.000000, "112af48cdd1fda6193977feb6b09e2cdf71a991b" }, + { "Chord", 0.000000, 90.000000, "3eb24f3fd584e27ed6a65b230e57e5ad7a723807" }, + { "Pie", 0.000000, 90.000000, "3eb24f3fd584e27ed6a65b230e57e5ad7a723807" }, + { "FillRect", 0.000000, 90.000000, "1c6d602d2f5c576ca63e414f376b1f98d3e73c22" }, + { "LineTo", 0.000000, 135.000000, "4185a5e31b487d1fa4addf9e85cb3afdddf1f411" }, + { "Rectangle", 0.000000, 135.000000, "e6d267c9381c7224cfc1129d337037d05deed893" }, + { "Ellipse", 0.000000, 135.000000, "11390f300830f51d0f3d3bd1df14eaf9d0cfa22b" }, + { "Arc", 0.000000, 135.000000, "c4899580184bb5f44f3a42e53371c5a761721808" }, + { "ArcTo", 0.000000, 135.000000, "d7fca10055537b7e91cb3530bfcba68429724cf3" }, + { "Chord", 0.000000, 135.000000, "2aa9e839c01925940bd7be5a4516bafda29cbac2" }, + { "Pie", 0.000000, 135.000000, "2aa9e839c01925940bd7be5a4516bafda29cbac2" }, + { "FillRect", 0.000000, 135.000000, "ab2b90e0acf7be930c263bcc38439e7d8e1853e4" }, + { "LineTo", 0.000000, 180.000000, "642a6efcbe41eac72a83b7bb5dae85cca067e1b0" }, + { "Rectangle", 0.000000, 180.000000, "c56b334e2d26303d98841d6a5efbd9f2afcf9557" }, + { "Ellipse", 0.000000, 180.000000, "fcd0d550e279fa6256868c905d41b70cc409bc9a" }, + { "Arc", 0.000000, 180.000000, "709a158ecb98c64dd62e3d9159b6146f8a56547a" }, + { "ArcTo", 0.000000, 180.000000, "99b688edc533cbb4d5f4ee7ea7db28a664884fd1" }, + { "Chord", 0.000000, 180.000000, "c526b9f9b5b9e0d1728e17611bdfbcd7a798ac85" }, + { "Pie", 0.000000, 180.000000, "c526b9f9b5b9e0d1728e17611bdfbcd7a798ac85" }, + { "FillRect", 0.000000, 180.000000, "ec15fe24cb23c461c56b8bf10a59cfbc89795d8a" }, + { "LineTo", 0.100000, 0.000000, "4e7a16ba484ba5c78b9f1c1e32525bd38e3d49c5" }, + { "Rectangle", 0.100000, 0.000000, "fc1c86fce1303a91ca862fb88af42b49e3ac3fa3" }, + { "Ellipse", 0.100000, 0.000000, "640318d1930ace3f8ab19f171b480548274d820a" }, + { "Arc", 0.100000, 0.000000, "0dfdb84da63e75b9c034e36839226ada6556e7b6" }, + { "ArcTo", 0.100000, 0.000000, "8d7f19d5877782e03fa58926253fdea63915eddf" }, + { "Chord", 0.100000, 0.000000, "b876bfc4509f4af13b1cfc16197ffaeea973a79e" }, + { "Pie", 0.100000, 0.000000, "b876bfc4509f4af13b1cfc16197ffaeea973a79e" }, + { "FillRect", 0.100000, 0.000000, "5ef4bf8112202ece0f7576b07d1c4a3129f32135" }, + { "LineTo", 0.100000, 45.000000, "1b8c0146c0ffd60759b5b7e49ceb100acaee2807" }, + { "Rectangle", 0.100000, 45.000000, "a4082461ea272fafa74a0d61e1c0f0e4f44f3bed" }, + { "Ellipse", 0.100000, 45.000000, "d00d738c63a7dc1387f5fc1533dc8fa3ff84ad0d" }, + { "Arc", 0.100000, 45.000000, "d83593fc89bc1f3bfe0b5d6c41965d576a12086c" }, + { "ArcTo", 0.100000, 45.000000, "74c23882f591c1d5fa5075f8a5caf2f0fd4576df" }, + { "Chord", 0.100000, 45.000000, "b804febbfa2f2ad2ce89842ddf2b633d81b52ebb" }, + { "Pie", 0.100000, 45.000000, "b804febbfa2f2ad2ce89842ddf2b633d81b52ebb" }, + { "FillRect", 0.100000, 45.000000, "08bb3dafae55f4c5ceb2b93f937191fc422d1a1d" }, + { "LineTo", 0.100000, 90.000000, "af0dcbec76e70a1c444e9eb58141c6ad85cce4dc" }, + { "Rectangle", 0.100000, 90.000000, "20e9bf8b42c3e323545dd61f48464a599b62efa6" }, + { "Ellipse", 0.100000, 90.000000, "e4e2356fbc6ee00319331c16e7a04fc8dc1a0e0f" }, + { "Arc", 0.100000, 90.000000, "9d8695e4617190e1006c4c0cad42cff972c848bb" }, + { "ArcTo", 0.100000, 90.000000, "6c8f92d238ccff672b736cd4f6e4984b2b4f8652" }, + { "Chord", 0.100000, 90.000000, "ca7a058ce4e5089ab4d05fc2ef9b307163fa44e2" }, + { "Pie", 0.100000, 90.000000, "ca7a058ce4e5089ab4d05fc2ef9b307163fa44e2" }, + { "FillRect", 0.100000, 90.000000, "d7d875f906444c4dd1665403df69f21dd8d910a5" }, + { "LineTo", 0.100000, 135.000000, "4185a5e31b487d1fa4addf9e85cb3afdddf1f411" }, + { "Rectangle", 0.100000, 135.000000, "fcbb94b32e6e0bcc03fcfca96c3111a0ca1b604b" }, + { "Ellipse", 0.100000, 135.000000, "38b7ac20c01d0a568ce57cba446d29197504877f" }, + { "Arc", 0.100000, 135.000000, "1056a409be4e664bf92057d322356585236dc3a2" }, + { "ArcTo", 0.100000, 135.000000, "436a31f6531ffaa15ba2ce3a418a1308e2adeee6" }, + { "Chord", 0.100000, 135.000000, "cbfb50dbf763c002aea9f357ede4406b380ccbf8" }, + { "Pie", 0.100000, 135.000000, "cbfb50dbf763c002aea9f357ede4406b380ccbf8" }, + { "FillRect", 0.100000, 135.000000, "f785f417c8846f8c6cbe7a4b8e8981be460f9b43" }, + { "LineTo", 0.100000, 180.000000, "b46c6bbffa9be0966f88eb97b3ae36a5c05fcd2c" }, + { "Rectangle", 0.100000, 180.000000, "9b91f448bd6483ca537b36d552ca0f4ee6444323" }, + { "Ellipse", 0.100000, 180.000000, "bf98c494a6f4bf08de0164ef4bd69aea83a72e65" }, + { "Arc", 0.100000, 180.000000, "169a0f7dec2f39e26244c508c306a3025be76c48" }, + { "ArcTo", 0.100000, 180.000000, "cc4c49379e748988d308dc2d0e044687db40ceff" }, + { "Chord", 0.100000, 180.000000, "1e045d5f25dd8a8a28097cc14f489789cb675649" }, + { "Pie", 0.100000, 180.000000, "1e045d5f25dd8a8a28097cc14f489789cb675649" }, + { "FillRect", 0.100000, 180.000000, "a6425e9d6a4cb8865a1a6744756db115a8df7a60" }, + /* interactive */ + { "LineTo", 0.000000, 30.000000, "e924a56173619fd0e38b50be820dba48f116374d" }, + { "Rectangle", 0.000000, 30.000000, "bafe8d7c41760b7534a30a19a625faba710ff8d0" }, + { "Ellipse", 0.000000, 30.000000, "99ff17f0625225706d99375c56f55dcbe24b6561" }, + { "Arc", 0.000000, 30.000000, "cf3aaf981fe3e658d2a7a7b6a6b42e300dad021a" }, + { "ArcTo", 0.000000, 30.000000, "a9944ad6103360348bdbdf8990db45ca96329829" }, + { "Chord", 0.000000, 30.000000, "29c5b5f2d953bbcd9ea6e6ef64fff8ad51385948" }, + { "Pie", 0.000000, 30.000000, "29c5b5f2d953bbcd9ea6e6ef64fff8ad51385948" }, + { "FillRect", 0.000000, 30.000000, "f2657bef13fff18207a820beac55ebd8de3a84d1" }, + { "LineTo", 0.000000, 60.000000, "e1fd793e4ef0b1eedb7b74fd1491089a2082c1f5" }, + { "Rectangle", 0.000000, 60.000000, "0f1cbb0a4d37b112d79d0fee92ce764ad1e39120" }, + { "Ellipse", 0.000000, 60.000000, "be27c3aa242b2bbd15ac8ad72f908069dc5a858d" }, + { "Arc", 0.000000, 60.000000, "325900ab2b828963d46c344c03e64a8b2f93acac" }, + { "ArcTo", 0.000000, 60.000000, "f2c94ae1af6b9a1fe90e00aef2bf55b473cef166" }, + { "Chord", 0.000000, 60.000000, "6dedfe6cd50f94316f2ac73c2c3ad32f0029f98a" }, + { "Pie", 0.000000, 60.000000, "6dedfe6cd50f94316f2ac73c2c3ad32f0029f98a" }, + { "FillRect", 0.000000, 60.000000, "b99d69f300f83c9599f171dc15ec69de085b431b" }, + { "LineTo", 0.000000, 120.000000, "d7eaf53e553c7a759736215f0cdbef3da71e52a4" }, + { "Rectangle", 0.000000, 120.000000, "a2f2f46894be75a44cd7282658709575bec0520a" }, + { "Ellipse", 0.000000, 120.000000, "a6952c2af22792d4e2d0a64e425593c357417a45" }, + { "Arc", 0.000000, 120.000000, "70842847715dc94bcd03e7f645bbcee88b0093c9" }, + { "ArcTo", 0.000000, 120.000000, "88ee7a30ffc16a784127aeacab65f619b35aab20" }, + { "Chord", 0.000000, 120.000000, "a48b6826d14024effcc6ecae1459de13d414fd16" }, + { "Pie", 0.000000, 120.000000, "a48b6826d14024effcc6ecae1459de13d414fd16" }, + { "FillRect", 0.000000, 120.000000, "42ca59eb65dcfc0138c7cc7b52426432838ba135" }, + { "LineTo", 0.000000, 150.000000, "4edbf0288de1e9fd2ba50a528f1996f5a58d3635" }, + { "Rectangle", 0.000000, 150.000000, "3bdac2e224469c3e211539d866209a6a1579e22a" }, + { "Ellipse", 0.000000, 150.000000, "82e94a7f8e8d887b6512cecaa4991f3a31ff73f3" }, + { "Arc", 0.000000, 150.000000, "1caa2ce5e6579561ae0386ce305d5f8f6dedac15" }, + { "ArcTo", 0.000000, 150.000000, "aa5ab0a751b34d8055dcf48f9158be96bd12b013" }, + { "Chord", 0.000000, 150.000000, "5a9898f517042b959ba52c8940541e2beb1bfbde" }, + { "Pie", 0.000000, 150.000000, "5a9898f517042b959ba52c8940541e2beb1bfbde" }, + { "FillRect", 0.000000, 150.000000, "c2a12e8a44715dc61392b0131284c74112207fb5" }, + { "LineTo", 0.100000, 30.000000, "27fe75214400eebb40c6e4ed0a2855ba36842830" }, + { "Rectangle", 0.100000, 30.000000, "67937f085d02a8a988429d5ca02bec36c6e9ae1a" }, + { "Ellipse", 0.100000, 30.000000, "6f2513ccada32f5a33ff3265ca24d3031a9d7dc3" }, + { "Arc", 0.100000, 30.000000, "32908793f9094f0a429b1fef45b8878efb4bc9f1" }, + { "ArcTo", 0.100000, 30.000000, "c1717316af84e5e59afc709efaf539a36302008e" }, + { "Chord", 0.100000, 30.000000, "f659defa3ceff47eee38789b3f17e466a721f13e" }, + { "Pie", 0.100000, 30.000000, "f659defa3ceff47eee38789b3f17e466a721f13e" }, + { "FillRect", 0.100000, 30.000000, "ac02de9d488be58d1a8919044f5ad8dae527220d" }, + { "LineTo", 0.100000, 60.000000, "7ae5f40fb519df6ac6c63a30890c08fbc0b97790" }, + { "Rectangle", 0.100000, 60.000000, "09121fa4f04e430cebeb548a8261a65681dd6127" }, + { "Ellipse", 0.100000, 60.000000, "ed1c41dc2af0dce03efd5b9f0da0315362bf243b" }, + { "Arc", 0.100000, 60.000000, "5d598913cd9ee159fec82d9735ebadcf2b1504a5" }, + { "ArcTo", 0.100000, 60.000000, "c635cbaac39b7000d8352912ecf3a846ec885438" }, + { "Chord", 0.100000, 60.000000, "6565943c444c2e672d3332133d077367a43303cd" }, + { "Pie", 0.100000, 60.000000, "6565943c444c2e672d3332133d077367a43303cd" }, + { "FillRect", 0.100000, 60.000000, "e1b55ebccddc51c4407c5c5b3fd39e93de849a0b" }, + { "LineTo", 0.100000, 120.000000, "1f97e0a18ff8bf2bdf6c5b701b475645851b443f" }, + { "Rectangle", 0.100000, 120.000000, "b87a6993146e289ec2f8b96a605704c3505b2c10" }, + { "Ellipse", 0.100000, 120.000000, "6cc143a8d1e1570d0530d49c624e9b66754009c3" }, + { "Arc", 0.100000, 120.000000, "ad0d72dfd05e840cf5dea27de9c58b69cb478aa6" }, + { "ArcTo", 0.100000, 120.000000, "9e358a932cf5eb56ef7128bc4894161f73e4de73" }, + { "Chord", 0.100000, 120.000000, "f46090e5b5982d0a26f6de683c8f8f1ebbc0947d" }, + { "Pie", 0.100000, 120.000000, "f46090e5b5982d0a26f6de683c8f8f1ebbc0947d" }, + { "FillRect", 0.100000, 120.000000, "e630db6ba66e5ad796421396a01f7fb765009cb0" }, + { "LineTo", 0.100000, 150.000000, "e22710ace132637da45baeea9d3d1fac50cc2b98" }, + { "Rectangle", 0.100000, 150.000000, "2153bfead354f3fedde95bf42f3ed8758c2093ee" }, + { "Ellipse", 0.100000, 150.000000, "84428b95368808f9dd48b6222c24503b7181da4a" }, + { "Arc", 0.100000, 150.000000, "b7fd257af933372af335f526a762ad83133b4da9" }, + { "ArcTo", 0.100000, 150.000000, "898efc1dd5b7bf3439edbde59d91bde84b76ac1e" }, + { "Chord", 0.100000, 150.000000, "d3fac4ae6451c8fcf79a8f97a9d5fd04f3090b46" }, + { "Pie", 0.100000, 150.000000, "d3fac4ae6451c8fcf79a8f97a9d5fd04f3090b46" }, + { "FillRect", 0.100000, 150.000000, "f030a552be29bd961e315a02380f16ec2974883c" }, + { NULL, 0.0, 0.0, NULL }, +}; + +static double radians ( double d ) +{ + return d * M_PI / 180; +} + +static BOOL save_bitmap_to_file( HBITMAP handle_bitmap, LPSTR file_name ) +{ + HDC dc; + int bits; + WORD bit_count; + DWORD palette_size = 0, bm_bits_size = 0, dib_size = 0, written = 0; + BITMAP bitmap; + BITMAPFILEHEADER bitmap_file_header; + BITMAPINFOHEADER bi; + LPBITMAPINFOHEADER lpbi; + HANDLE fh, handle_dib, handle_pal, handle_old_pal = NULL; + + dc = CreateDCA( "DISPLAY", NULL, NULL, NULL) ; + bits = GetDeviceCaps( dc, BITSPIXEL ) * GetDeviceCaps( dc, PLANES ); + DeleteDC( dc) ; + if (bits <= 1) + bit_count = 1; + else if (bits <= 4) + bit_count = 4; + else if (bits <= 8) + bit_count = 8; + else + bit_count = 24; + GetObjectA( handle_bitmap, sizeof(bitmap), (LPSTR)&bitmap) ; + bi.biSize = sizeof( BITMAPINFOHEADER ); + bi.biWidth = bitmap.bmWidth; + bi.biHeight = -bitmap.bmHeight; + bi.biPlanes = 1; + bi.biBitCount = bit_count; + bi.biCompression = BI_RGB; + bi.biSizeImage = 0; + bi.biXPelsPerMeter = 0; + bi.biYPelsPerMeter = 0; + bi.biClrImportant = 0; + bi.biClrUsed = 256; + bm_bits_size = ((bitmap.bmWidth * bit_count + 31) & ~31) / 8 * bitmap.bmHeight; + handle_dib = GlobalAlloc( GHND, bm_bits_size + palette_size + sizeof(BITMAPINFOHEADER) ); + lpbi = (LPBITMAPINFOHEADER)GlobalLock( handle_dib ); + *lpbi = bi; + + handle_pal = GetStockObject( DEFAULT_PALETTE ); + if ( handle_pal ) + { + dc = GetDC( NULL ); + handle_old_pal = SelectPalette( dc, (HPALETTE)handle_pal, FALSE ); + RealizePalette( dc ); + } + + GetDIBits( dc, handle_bitmap, 0, (UINT)bitmap.bmHeight, (LPSTR)lpbi + sizeof(BITMAPINFOHEADER) + + palette_size, (BITMAPINFO *)lpbi, DIB_RGB_COLORS ); + + if ( handle_old_pal ) + { + SelectPalette( dc, (HPALETTE)handle_old_pal, TRUE ); + RealizePalette (dc ); + ReleaseDC( NULL, dc ); + } + + fh = CreateFileA( file_name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL ); + + if ( fh == INVALID_HANDLE_VALUE ) + return FALSE; + + bitmap_file_header.bfType = 0x4D42; /* "BM" */ + dib_size = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + palette_size + bm_bits_size; + bitmap_file_header.bfSize = dib_size; + bitmap_file_header.bfReserved1 = 0; + bitmap_file_header.bfReserved2 = 0; + bitmap_file_header.bfOffBits = (DWORD)sizeof(BITMAPFILEHEADER) + (DWORD)sizeof(BITMAPINFOHEADER) + palette_size; + + WriteFile( fh, (LPSTR)&bitmap_file_header, sizeof(BITMAPFILEHEADER), &written, NULL ); + WriteFile( fh, (LPSTR)lpbi, dib_size, &written, NULL ); + + GlobalUnlock( handle_dib ); + GlobalFree( handle_dib ); + CloseHandle( fh ); + return TRUE; +} + +static void set_transform( HDC dc, RECT *bounds, double angle, double shear_x ) +{ + XFORM xf; + double r = radians( angle ); + xf.eM11 = cos( r ) + sin( r ) * shear_x; + xf.eM22 = cos( r ); + xf.eM12 = -sin( r ); + xf.eM21 = sin( r ) + cos( r ) * shear_x; + xf.eDx = ( bounds->right - bounds->left ) / 4; + xf.eDy = ( bounds->bottom - bounds->top ) / 4; + SetWorldTransform( dc, &xf ); +} + +static void init( test_data *td, const char *test_name ) +{ + sprintf( td->test_name, "%s", test_name ); + sprintf( td->save_path, "%s-%3.1f-%2.1f.bmp", td->test_name, td->shear_x, td->angle ); + sprintf( td->hash_name, "\"%s\", %3.1f, %2.1f", td->test_name, td->shear_x, td->angle ); + reset_bits( td->dc, td->bmi, td->bits ); + + /* draw origin */ + if ( winetest_interactive & WI_DRAW_ORIGIN ) { + MoveToEx( td->dc, -5, 0, NULL ); + LineTo( td->dc, 5, 0 ); + MoveToEx( td->dc, 0, 5, NULL ); + LineTo( td->dc, 0, -5 ); + } +} + +static const char *find_ref_hash( test_data *td ) +{ + const ref_hash_table_entry *p = ref_hash_table; + for( ; p->name != NULL; p++ ) { + if ( strcmp( p->name, td->test_name ) != 0 + || p->shear_x != td->shear_x + || p->angle != td->angle ) + continue; + return p->sha1; + } + return NULL; +} + +static void check_hash( test_data *td ) +{ + const char *ref_hash; + char *dib_hash; + + ref_hash = find_ref_hash( td ); + dib_hash = hash_dib( td->dc, td->bmi, td->bits ); + + if ( ref_hash == NULL ) + skip( "{ \"%s\", %lf, %lf, \"%s\" },\n", td->test_name, td->shear_x, td->angle, dib_hash ); + else if( strcmp( ref_hash, dib_hash ) != 0 ) + ok( FALSE, "%s: expected hash %s got %s\n", td->hash_name, ref_hash, dib_hash ); + + if ( winetest_interactive ) { + trace( "image saved as '%s'\n", td->save_path ); + save_bitmap_to_file( td->dib, td->save_path ); + } + HeapFree( GetProcessHeap(), 0, dib_hash ); +} + +static void test_gdi_advanced( test_data *td, double angle, double shear_x ) +{ + char bmibuf[sizeof( BITMAPINFO ) + 256 * sizeof( RGBQUAD )]; + HBITMAP orig_bm; + HPALETTE default_palette, old_hpal; + RECT r; + + td->bmi = ( BITMAPINFO * )bmibuf; + td->dc = CreateCompatibleDC( NULL ); + td->angle = angle; + td->shear_x = shear_x; + + SetGraphicsMode( td->dc, GM_ADVANCED ); + set_transform( td->dc, &td->bounds, td->angle, td->shear_x ); + + memset( td->bmi, 0, sizeof( bmibuf )); + td->bmi->bmiHeader.biSize = sizeof( td->bmi->bmiHeader ); + td->bmi->bmiHeader.biHeight = td->bounds.right; + td->bmi->bmiHeader.biWidth = td->bounds.bottom; + td->bmi->bmiHeader.biBitCount = 32; + td->bmi->bmiHeader.biPlanes = 1; + td->bmi->bmiHeader.biCompression = BI_RGB; + + td->dib = CreateDIBSection( 0, td->bmi, DIB_RGB_COLORS, ( void** )&( td->bits ), NULL, 0 ); + orig_bm = SelectObject( td->dc, td->dib ); + + default_palette = create_default_palette( 8 ); + old_hpal = SelectPalette( td->dc, default_palette, FALSE ); + + current_bounds = &td->bounds; + SetBoundsRect( td->dc, &td->bounds, DCB_SET ); + + SetRect( &r, 0, 0, 128, 128 ); + + init( td, "LineTo" ); + MoveToEx( td->dc, r.left, r.top, NULL ); + LineTo( td->dc, r.right, r.bottom ); + check_hash( td ); + + if ( winetest_interactive & WI_IN_WORK ) { + init( td, "Rectangle" ); + ok( Rectangle( td->dc, r.left, r.top, r.right, r.bottom ), td->test_name ); + check_hash( td ); + + init( td, "Ellipse" ); + ok( Ellipse( td->dc, r.left, r.top, r.right, r.bottom ), td->test_name ); + check_hash( td ); + + init( td, "Arc" ); + ok( Arc( td->dc, r.left, r.top, r.right, r.bottom, r.left+10, r.top, r.right-10, r.bottom ), td->test_name ); + check_hash( td ); + + init( td, "ArcTo" ); + ok( ArcTo( td->dc, r.left, r.top, r.right, r.bottom, r.left+10, r.top, r.right-10, r.bottom ), td->test_name ); + check_hash( td ); + + init( td, "Chord" ); + ok( Chord( td->dc, r.left, r.top, r.right, r.bottom, r.left+10, r.top, r.right-10, r.bottom ), td->test_name ); + check_hash( td ); + + init( td, "Pie" ); + ok( Pie( td->dc, r.left, r.top, r.right, r.bottom, r.left+10, r.top, r.right-10, r.bottom ), td->test_name ); + check_hash( td ); + + } + + if ( winetest_interactive & WI_TODO ) { + init( td, "FillRect" ); + ok( FillRect( td->dc, &r, GetStockObject( WHITE_BRUSH )), td->test_name ); + check_hash( td ); + } + + SelectObject( td->dc, orig_bm ); + DeleteObject( td->dib ); + SelectPalette( td->dc, old_hpal, FALSE ); + DeleteDC( td->dc ); +} + +static void test_advanced_graphics( void ) +{ + const char *scope = "advanced graphics mode:"; + test_data _test_data; + test_data *td = &_test_data; + int save = winetest_mute_threshold; + winetest_mute_threshold = 256; + + td->bounds.left = 0; + td->bounds.top = 0; + td->bounds.right = 256; + td->bounds.bottom = 256; + + if ( winetest_interactive ) + trace( "%s %s\n", scope, "Use the following command to see differences 'compare -metric AE -fuzz 5% -compose Src '" ); + else + trace( "%s %s\n", scope, "Use environment variable WINETEST_INTERACTIVE=x to get images and run more tests. See source for values" ); + + trace( "%s %s\n", scope, "angle is multiple of pi/4" ); + test_gdi_advanced( td, 0, 0.0 ); + test_gdi_advanced( td, 45, 0.0 ); + test_gdi_advanced( td, 90, 0.0 ); + test_gdi_advanced( td, 135, 0.0 ); + test_gdi_advanced( td, 180, 0.0 ); + + + if ( winetest_interactive ) { + trace( "%s %s\n", scope, "angle is not a multiple of pi/4" ); + test_gdi_advanced( td, 30, 0.0 ); + test_gdi_advanced( td, 60, 0.0 ); + test_gdi_advanced( td, 120, 0.0 ); + test_gdi_advanced( td, 150, 0.0 ); + } + + if ( winetest_interactive & WI_TEST_SHEAR ) { + trace( "%s %s\n", scope, "with shear, angle is multiple of pi/4" ); + test_gdi_advanced( td, 0, 0.1 ); + test_gdi_advanced( td, 45, 0.1 ); + test_gdi_advanced( td, 90, 0.1 ); + test_gdi_advanced( td, 135, 0.1 ); + test_gdi_advanced( td, 180, 0.1 ); + + trace( "%s %s\n", scope, "with shear, angle is not a multiple of pi/4" ); + test_gdi_advanced( td, 30, 0.1 ); + test_gdi_advanced( td, 60, 0.1 ); + test_gdi_advanced( td, 120, 0.1 ); + test_gdi_advanced( td, 150, 0.1 ); + } + winetest_mute_threshold = save; +} + START_TEST(dib) { CryptAcquireContextW(&crypt_prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); test_simple_graphics(); + test_advanced_graphics(); CryptReleaseContext(crypt_prov, 0); } -- 2.26.2