4 * Copyright 2011 Huw Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "wine/test.h"
33 static HCRYPTPROV crypt_prov;
34 static DWORD (WINAPI *pSetLayout)(HDC hdc, DWORD layout);
36 static const DWORD rop3[256] =
38 0x000042, 0x010289, 0x020C89, 0x0300AA, 0x040C88, 0x0500A9, 0x060865, 0x0702C5,
39 0x080F08, 0x090245, 0x0A0329, 0x0B0B2A, 0x0C0324, 0x0D0B25, 0x0E08A5, 0x0F0001,
40 0x100C85, 0x1100A6, 0x120868, 0x1302C8, 0x140869, 0x1502C9, 0x165CCA, 0x171D54,
41 0x180D59, 0x191CC8, 0x1A06C5, 0x1B0768, 0x1C06CA, 0x1D0766, 0x1E01A5, 0x1F0385,
42 0x200F09, 0x210248, 0x220326, 0x230B24, 0x240D55, 0x251CC5, 0x2606C8, 0x271868,
43 0x280369, 0x2916CA, 0x2A0CC9, 0x2B1D58, 0x2C0784, 0x2D060A, 0x2E064A, 0x2F0E2A,
44 0x30032A, 0x310B28, 0x320688, 0x330008, 0x3406C4, 0x351864, 0x3601A8, 0x370388,
45 0x38078A, 0x390604, 0x3A0644, 0x3B0E24, 0x3C004A, 0x3D18A4, 0x3E1B24, 0x3F00EA,
46 0x400F0A, 0x410249, 0x420D5D, 0x431CC4, 0x440328, 0x450B29, 0x4606C6, 0x47076A,
47 0x480368, 0x4916C5, 0x4A0789, 0x4B0605, 0x4C0CC8, 0x4D1954, 0x4E0645, 0x4F0E25,
48 0x500325, 0x510B26, 0x5206C9, 0x530764, 0x5408A9, 0x550009, 0x5601A9, 0x570389,
49 0x580785, 0x590609, 0x5A0049, 0x5B18A9, 0x5C0649, 0x5D0E29, 0x5E1B29, 0x5F00E9,
50 0x600365, 0x6116C6, 0x620786, 0x630608, 0x640788, 0x650606, 0x660046, 0x6718A8,
51 0x6858A6, 0x690145, 0x6A01E9, 0x6B178A, 0x6C01E8, 0x6D1785, 0x6E1E28, 0x6F0C65,
52 0x700CC5, 0x711D5C, 0x720648, 0x730E28, 0x740646, 0x750E26, 0x761B28, 0x7700E6,
53 0x7801E5, 0x791786, 0x7A1E29, 0x7B0C68, 0x7C1E24, 0x7D0C69, 0x7E0955, 0x7F03C9,
54 0x8003E9, 0x810975, 0x820C49, 0x831E04, 0x840C48, 0x851E05, 0x8617A6, 0x8701C5,
55 0x8800C6, 0x891B08, 0x8A0E06, 0x8B0666, 0x8C0E08, 0x8D0668, 0x8E1D7C, 0x8F0CE5,
56 0x900C45, 0x911E08, 0x9217A9, 0x9301C4, 0x9417AA, 0x9501C9, 0x960169, 0x97588A,
57 0x981888, 0x990066, 0x9A0709, 0x9B07A8, 0x9C0704, 0x9D07A6, 0x9E16E6, 0x9F0345,
58 0xA000C9, 0xA11B05, 0xA20E09, 0xA30669, 0xA41885, 0xA50065, 0xA60706, 0xA707A5,
59 0xA803A9, 0xA90189, 0xAA0029, 0xAB0889, 0xAC0744, 0xAD06E9, 0xAE0B06, 0xAF0229,
60 0xB00E05, 0xB10665, 0xB21974, 0xB30CE8, 0xB4070A, 0xB507A9, 0xB616E9, 0xB70348,
61 0xB8074A, 0xB906E6, 0xBA0B09, 0xBB0226, 0xBC1CE4, 0xBD0D7D, 0xBE0269, 0xBF08C9,
62 0xC000CA, 0xC11B04, 0xC21884, 0xC3006A, 0xC40E04, 0xC50664, 0xC60708, 0xC707AA,
63 0xC803A8, 0xC90184, 0xCA0749, 0xCB06E4, 0xCC0020, 0xCD0888, 0xCE0B08, 0xCF0224,
64 0xD00E0A, 0xD1066A, 0xD20705, 0xD307A4, 0xD41D78, 0xD50CE9, 0xD616EA, 0xD70349,
65 0xD80745, 0xD906E8, 0xDA1CE9, 0xDB0D75, 0xDC0B04, 0xDD0228, 0xDE0268, 0xDF08C8,
66 0xE003A5, 0xE10185, 0xE20746, 0xE306EA, 0xE40748, 0xE506E5, 0xE61CE8, 0xE70D79,
67 0xE81D74, 0xE95CE6, 0xEA02E9, 0xEB0849, 0xEC02E8, 0xED0848, 0xEE0086, 0xEF0A08,
68 0xF00021, 0xF10885, 0xF20B05, 0xF3022A, 0xF40B0A, 0xF50225, 0xF60265, 0xF708C5,
69 0xF802E5, 0xF90845, 0xFA0089, 0xFB0A09, 0xFC008A, 0xFD0A0A, 0xFE02A9, 0xFF0062
72 static inline BOOL rop_uses_src(DWORD rop)
74 return (((rop & 0xcc0000) >> 2) != (rop & 0x330000));
77 static const char *sha1_graphics_a8r8g8b8[] =
79 "a3cadd34d95d3d5cc23344f69aab1c2e55935fcf",
80 "2426172d9e8fec27d9228088f382ef3c93717da9",
81 "9e8f27ca952cdba01dbf25d07c34e86a7820c012",
82 "664fac17803859a4015c6ae29e5538e314d5c827",
83 "17b2c177bdce5e94433574a928bda5c94a8cdfa5",
84 "fe6cc678fb13a3ead67839481bf22348adc69f52",
85 "d51bd330cec510cdccf5394328bd8e5411901e9e",
86 "df4aebf98d91f11be560dd232123b3ae327303d7",
87 "f2af53dd073a09b1031d0032d28da35c82adc566",
88 "eb5a963a6f7b25533ddfb8915e70865d037bd156",
89 "c387917268455017aa0b28bed73aa6554044bbb3",
90 "dcae44fee010dbf7a107797a503923fd8b1abe2e",
91 "6c530622a025d872a642e8f950867884d7b136cb",
92 "7c07d91b8f68fb31821701b3dcb96de018bf0c66",
93 "b2261353decda2712b83538ab434a49ce21f3172",
94 "35f731c0f6356b8f30651bb3cbe0d922c49deba5",
95 "9b9874c1c1d92afa554137e191d34ea33acc322f",
96 "c311dd74325e8cebfc8529a6d24a6fa4ecb7137e",
97 "d7398de15b2837a58a62a701ca1b3384625afec4",
98 "a78b28472bb7ff480ddedd06b9cf2daa775fa7ae",
99 "5246ef357e7317b9d141a3294d300c195da76cb7",
100 "87f6b6a19f021ca5912d285e14ce2ff9474d79f3",
101 "e2a8eef4aeda3a0f6c950075acba38f1f9e0814d",
102 "8b66f14d51ecdeea12bc993302bb9b7d3ec085a1",
103 "7da9dd3d40d44d92deb9883fb7110443c2d5769a",
104 "e358efb1c11172e40855de620bdb8a8e545cd790",
105 "9e0c2596c6ecb4f1bc97b18ec3ca493d37626608",
106 "58806549380c964e7a53ad54821d2eb86fa5b9ce",
107 "7fc30d3058c235ce39088de0a598b8c7fe7ca61f",
108 "52a6c769c227f2bb1949097c4c87fed5ee0cbcb1",
109 "8a010d4c5af51fcc34d51be3197878782bdf63e7",
110 "c84c2c33e22eb7e5c4a2faad3b3b99a359d77528",
111 "41bcc1f57c60bdec3c4d1e749084a12867f91224",
112 "94645300d6eb51020a7ef8261dee2941cd51b5df",
113 "c56f5bdc9cac4f0bc81c33295d9aed8eaf4cb1f2",
114 "21cdfde38ac7edbb241ec83d82f31286e90c4629",
115 "1fd2f4dcb62f8522171872e43fd4a35041d68100",
116 "39c31de73aafcfcadf0bf414da4495be9de54417",
117 "132949f59bfeb88dc2047e6eaecb8512aea3d9ab",
118 "f6a6d765bf23726329f96020ba8c5e3c0897aafa",
119 "e71d6bb9bd38eea5719f8ba57177997910e2d841",
120 "3d2ccbe51408232a04769546b1bdd74f84558a41",
121 "a1fe9aa885584a0f713d7c6f76c89830fbf28563",
122 "aaf62842bb98d8a2945c4f643baf50afaeea9307",
123 "287b2f2f2fb5a1d7ee4a29b43342103d78a7a8ab",
127 static const char *sha1_graphics_a8b8g8r8[] =
129 "a3cadd34d95d3d5cc23344f69aab1c2e55935fcf",
130 "e0bc877697093ed440e125154e247ca9d65e933c",
131 "c6d7faf5a502299f99d59eef3f7650bd63dbe108",
132 "9d8c05c3ebd786e7d052418e905a80a64bf7853d",
133 "3da12af0a810fd993fa3dbe23328a4fcd2b6c92a",
134 "b91c8f21cc4d7994abc551feff5b6927d267a9db",
135 "d49dd2c6a37e975b6dc3d201ccc217a788b30284",
136 "ca6753f9eb44529cf8c67cd6abcd4ed1ef758904",
137 "18c3ae944e0afb6c43c21cde093ddb22a27611e4",
138 "b753ebb39d90210cc717f57b53dd439f7de6b077",
139 "38c017dd1fff26b492a57e09f3ce2c4370faf225",
140 "94368cea5033b435454daa56d55546310675131e",
141 "bf57a6a37fb107d29ed3d45695919887abcb7902",
142 "3db0f8bcca3d94920aa57be6321202b8c3c08822",
143 "1f1fc165a4dae7ba118ddccb58a279bfe3876b0a",
144 "8e09abb108e137c99527ab4c9bd07d95b9254bbb",
145 "b0178632775d29bec2b16de7b9b8287115c40d0f",
146 "ca7e859647b9498b53fdd92543ad8aea98ff46f3",
147 "3369889a67d6c79a24ee15f7d14374f9995215e4",
148 "473a1fd07df800c87a5d3286b642ace10c61c6af",
149 "10cd25a0ed5cd8f978d7d68236f81d949b938e84",
150 "b8951d2b20518fd129e5113a5f429626893913bf",
151 "4851c5b7d5bc18590e787c0c218a592ef504e738",
152 "9aa506e3df33e0d5298755aa4144e10eb4b5adcf",
153 "abdf003699364fe45fab7dc61e67c606d0063b40",
154 "89abaadff4e68c738cf9251c51e3609564843381",
155 "f6aa3f907f620b9f3493f03cb3b4b292df3a9545",
156 "77d0ad32938147aa4038c1eced232b7b5a5f88f3",
157 "43d36e57b702ce56eb250bf53f1ecc4680990cfe",
158 "fd6e0ebb52710ebcdd8dd69931165c83c4930b41",
159 "71b9756fdfeedce1e6db201176d21a981b881662",
160 "5319528d9af750c172ae62ee85ddb2eaef73b193",
161 "b7ce8aa3c328eedaed7306234ed9bae67708e627",
162 "19b32a0daa91201725b5e13820c343d0a84ff698",
163 "abca6a80a99b05722d2d87ce2a8b94ef1ae549e1",
164 "2ba70994d0b4ce87fdf6fbc33ada11252178061e",
165 "7b4e1d47a03e2cec236d8fb6e2ae89d8ed078f79",
166 "89e90d6159d59886bbbf0c40a7cd01293c3cfda3",
167 "3a598f1eb35c1412b0c131e9d9e36a4aef9534d2",
168 "d01071c44259adc94b89978b7d51a058b6dad665",
169 "27ef47377e88f5ac5ad33b19eae27d56c456ac65",
170 "339908a568f384e1f384a3e1b0dd415779203b02",
171 "88fd743d00bd37d2ed722092146795b044d08a6e",
172 "118bf4c5bddc206ba737f7aa8b239940cd1aadc2",
173 "7cb51f6c5f1dae926601986c934533df5f8baa9f",
177 static const char *sha1_graphics_24[] =
179 "e993b15c9bd14fb45a15310450b7083c44e42665",
180 "edbd7bab3d957fbc85e89612197cf918f5f5af20",
181 "6a7efb3b6e0b49336df1bd2937ca09a11d976531",
182 "236eb5ca9da70ec7cc719cd2fd291bab14000257",
183 "f98023c7cd8c068f2d7a77ce3600004b90ea12d6",
184 "5c4cb9cea2226fc671bb4a11f8253343ee94bb4b",
185 "fd4be592483623dbc800fe28210a1f0daa71999b",
186 "788b8de98c47974fa9f232a6042ae4ca546ddb7d",
187 "a8772e6c44ba633fb384a7c4b50b435f1406107e",
188 "883bc8f305c602edca785e21cd00f488583fb13f",
189 "3bac4e80993f49dc3926e30524115fca9d7a8026",
190 "91369e35be29059a0665782541db4c8b324c6bb2",
191 "0fa8cf332a56bb6d7e14e85861fdd60f51d70501",
192 "593d694cdcc8349b3bfc8257041dbcb27e61da45",
193 "1036b91d93e31cd1d4740d0c8642e115e5a38188",
194 "1898073cdb35ca4d2b21bba933ac16a0b4297317",
195 "5068bff794553cf5a3145ae407c9a2984357844c",
196 "413a7989969c229dee4ab1798362f32f96cf0a10",
197 "0bb222e540b82720d4971e4a2fc626899af03e03",
198 "adc20832d8c43f1cf372d8392535492013cd2306",
199 "45649794dcbcabda487f66f7a80fc1bec79047a1",
200 "367c2dc1e91ff9ea0e984d6fb3000cfb4e0ae7e9",
201 "b4df692ac70a5f9f303270df4641ab014c6cbf46",
202 "8bc3128ba47891366fd7b02fde7ca19100e64b9f",
203 "e649e00efe7fea1eb8b17f7867fe089e5270c44b",
204 "a0bffbbfb0adf6f188479c88da04e25d76ab4822",
205 "92a1ab214dd8027c407814420449119466c92840",
206 "b58f19c1800344a2b8e017eb784705bdb2bd8450",
207 "5747a6d5c6ce79731c55e8cf33f7da3025cd35fd",
208 "955390669afed2369b15b32fa519f2f921cdf1a0",
209 "201906f7d763b930a98c97f8eeab417f2b65e723",
210 "5313357d50c40c05a3b3a83d0d2013a138c955a1",
211 "701c5af1d0c28294ce7d804b5697643c430d22a0",
212 "b0a959745b2db1d9f449e68e4479a4f36301879c",
213 "63f764b9bd2f4876ab1ee0f3c0eb55b5a7de5212",
214 "e171f6ec77bca91d6b8559911bce296c0bac469e",
215 "9725669042ef68acb408404d196496d10340bb5a",
216 "03d5eb8e3a6662e6dc183f88ee2f285065fc9c51",
217 "f4c312f9a37ddc54a27f6b1421dab1ce0cec0c27",
218 "0f79500eda467cd3cbc220abdd37b5dba695d654",
219 "84c43a3cbd7d8c1ac9a0e9b6f07620158079b278",
220 "7d479beeb6758c164566638b5c873c188d6a91e7",
221 "80086808fca03e757d812e31d1ae576bf90dac9d",
222 "1015e0217ea13eaa62c7666b8b81aafd75f8f610",
223 "93e1aec608e037af3bfb7bd32dde446abe4eea11",
227 static const char *sha1_graphics_r5g5b5[] =
229 "2a2ab8b3c019e70b788ade028b0e9e53ffc529ae",
230 "847005cf7371f511bcc837251cde07b1796f6113",
231 "a8f75743a930843ec14d516cd048b6e0468e5d89",
232 "d094f51ce9b9daa9c1d9594ea88be2a2db651459",
233 "cf3928e240c9149788e1635b115a4e5baea0dd8f",
234 "a9034a905daa91757b4f63345c0e40638cd53ca8",
235 "15ee915d989e49bb9bab5b834d8f355bd067cd8f",
236 "99474fecf11df7b7035c35be6b8b697be9889418",
237 "cbc2898717f97ebb07c0c7cc04abde936dc5b584",
238 "29c896b591fdf4ddd23e5c0da1818c37e4686d94",
239 "4b5b275d33c1ebfe5bdc61df2ad125e865b800fa",
240 "92df731fa1f89550d9d4f7ea36c13f2e57c4b02a",
241 "420e39ff3bdd04c4b6cc2c98e99cb7993c7a0de5",
242 "1fabf0fdd046857b1974e31c1c1764fa9d1a762f",
243 "449092689226a1172b6086ba1181d6b6d6499f26",
244 "1a92a60f190d33ef06d9decb56fd3fdd33f3af03",
245 "e61f5978c2e28c0c6d8f5eefe0f840c975586efc",
246 "897d16f4d6a6ddad685d23ed7828d4f676539b75",
247 "9d21bcfdeaf1ca5d47eb823bdefc24d7a95f4f56",
248 "6daaf945a955928c5c124c880522ca4634fb2343",
249 "12a288390d16e1efa99d4185301de48a4d433b14",
250 "ea92af2538b76f41a3a03eaa11ac395c9b6197c4",
251 "3a50ce21b3563a604b4fc9f247a30f5a981f1ba6",
252 "d7d97e28ed316f6596c737eb83baa5948d86b673",
253 "ecc2991277d7314f55b00e0f284ae3703aeef81e",
254 "656bf3b7121bcd620a0a3ad488f0d66604824577",
255 "d7d8493b5fa7a3a8323d6ac84245093a79f052c1",
256 "df5dafe96e528c2cc7fd11e4934e298f53cec34b",
257 "a49530722328ae88fd765792ac0c657efbcce75d",
258 "aa46aa2226e3121eaefa9d0836418e0b69262d69",
259 "333f3f2cf3ff15736d59f92a33c45323d3987d6d",
260 "a6fd83542c3826132e88d3f5e304d604c0056fad",
261 "a8d6a5285a927ba3a3be34b06a06c70a20d4c1b3",
262 "e428d213ad02651287894f093413949dcb369208",
263 "7df915bedcc5951a1b6f828490f7dbb93212e835",
264 "645dc251d205139282b17eb7bece1055fff3bcd0",
265 "c3d4a1425e17de9e05e3f6dfc6a24c26bfd5ee12",
266 "2a66dae03890ff791eabb982949435adb19af02b",
267 "24ac219478ba406f30794550690486b14cbac5e8",
268 "6c652ecce55e71fee16bc1c9b2c5ae4161bdd2ea",
269 "9b02173f424c098ea0f4cc5db9eb65f69263d127",
270 "a92942269911a88793b3460b6f2a2cd56e48eec1",
271 "aa4a0a4b7f2697aaf270c89874631974bd9d7183",
272 "585061e403d9cac1603a38af420efe87338f381a",
276 static const char *sha1_graphics_r4g4b4[] =
278 "2a2ab8b3c019e70b788ade028b0e9e53ffc529ae",
279 "cfa0ab83ee93283ad914c3748f0532da1697af1d",
280 "8bd18697d1ef27492805667a0bc956343ac08667",
281 "e8501c830321584474654f90e40eaf27dc21e6a8",
282 "d95ab10fcfb8447b41742e89f1ae8cd297a32fc4",
283 "821177710961d2cb5f7e7dfc0e06e767b6042753",
284 "667124365ffadeea1d8791bedda77a0c7b898de8",
285 "c9f23e684b600dea17575b4b17175fbd9106c3a9",
286 "7678876e50eae35d1eaa096aae25afaa0b864bf3",
287 "fb52b0c373a5f2a60b981604b120962942d2447a",
288 "5ab8dd07436681d762fa04ad7c6d71291c488924",
289 "0167981d9e1490a2ebd396ff7582f0943aa8e1b8",
290 "115a6bd382410a4a1d3c1fa71d8bf02536863e38",
291 "65c6d1228e3b6d63d42647f14217bc1658b70d9a",
292 "25fcb75aa687aac35b8f72640889fe92413e00c5",
293 "3bddf9d53e89560b083302b146cd33791b13d941",
294 "a81504498c7a7bb46340ce74476a42f70f2730b1",
295 "e61a4f2657a444d8c49f84fb944f9f847667bf2b",
296 "32b6e0aa79b7e96cd0ab2da167f6463c011023a8",
297 "1d283aa4d2b2114f7809fe59357d590c7c779aa7",
298 "29640e2ddd2d3016da14507c3ce9b2ce32f39bb4",
299 "57ebf8becac1524543da120e88e9cc57ecfdec49",
300 "d591232bbc2592462c819a9486750f64180518fd",
301 "0e183a4c30b3da345129cffe33fe0fc593d8666b",
302 "f14d9a4bd8a365b7c8f068a0dad481b6eb2b178b",
303 "8933450132bf949ba4bc28626968425b5ed2867d",
304 "9928a8f28a66c00069a124f7171b248817005763",
305 "e4a9dcc3e565cd3a6b7087dd1433f3898bb9cdb2",
306 "eca4f9b16b3bddfd0735fdd792e0ccaadfb9ba49",
307 "233e588cf660e2c9b552cf02065cf63fa6655864",
308 "0740ff74dcd259d9a644ba51ad77ff0d40348951",
309 "a3345acaf272f2e288626906e3056cd0ced70499",
310 "957a86fbe8a96dd068db65e4e624a52bcc84af46",
311 "13b0f240054dc57ba0e2dfde74048496304a2c7f",
312 "51ef267eb9c15487c9430f505e8a6c929eb2170c",
313 "1b593d8e031d3b37fecf6f1df5a8f96c8e8bfef8",
314 "75ae8c80af4356a1a5eebde6608fbc31e8a95372",
315 "b89ae8de2d975b8adb263ace66fd953d29165a8b",
316 "e901ab4b20bc87370609d7ba1f21aa08abd9eced",
317 "3cbf5fffdd73f9639f3eb34ec1ab3055bc8618fb",
318 "8e2e70ade90711c4ac01352aa0373fce36ff5dc0",
319 "8c40d6d8e0c696c31f04c896e492a2a38703d870",
320 "9af4907a8144458a73dbb7471784f8c3d9aeffcf",
321 "e4731b63d41f6b51e30752ea52d85c4a2938731b",
325 static const char *sha1_graphics_8[] =
327 "41728d7ff2bb425b5fc06521adeabf6cc73136f3",
328 "512246d4886ab889a090b167ba194577cb95272e",
329 "921e852d4564cb9e5ac15ff68b5207bebea871d1",
330 "9636b0ebefc443ea11949ccd28f6ca454277dd41",
331 "aa9050da55e6b6957c60b7d603fce539cb5c0048",
332 "e2b93aca15fb1233ac09a713dced1f4cd950b1e4",
333 "3e3a603fc26cc305aa27f88da7d2a3b0073877d8",
334 "390b2bf70daba36310683f46af9cd50b9a061396",
335 "82d21737e9a7247397a6c983a9b6d9a0452dd74d",
336 "2a8460af91675e01cbe9384eb6cd3eb2cb420960",
337 "1af53b1218ee9844fcda891b836d42f6b2f66bd5",
338 "da1cc34a9d9b779fc7849e03e214096026506464",
339 "5ba8f99ca034666effa556748c49a0f5a015125f",
340 "b67ba2f55659c75ac72c1112494461bb3086e1a4",
341 "73e2859ce849f756f954718ce3c90f02e31712b6",
342 "b1dff0f5dd233b44ee568878c5d3f8ae1d80c6d9",
343 "1f27dc1a1316fb7a4a78fe40fcd4bdae3aaad218",
344 "6e375e1485a1e45ac6ab10af49645d5fb2e76dff",
345 "cfc67c325c7cdf96d90af9b3cceb8d0504cbb3b0",
346 "7262364067e03c7fa498af1d59d228d6c63b460e",
347 "5241241a355a667ef0834049adf4218e8b3f16b8",
348 "db22d666690948eb966f75b796c72c7150a5c4b9",
349 "1f13ea0034db4b0ffa4ddcff9664fd892058f9cd",
350 "3caf512cfddfd463d0750cfe3cadb58548eb2ae8",
351 "4e5e7d5fd64818b2b3d3e793c88f603b699d2f0f",
352 "c4efce8f7ed2d380ea5dc6fe1ef8448a27827532",
353 "bdc0a354635b879871077c5b712570e469863c99",
354 "d599bf210423fe3adbb4f1de87d9360de97827d0",
355 "bae7c8b789e4e9b336c03c4daee3bce63fe039d9",
356 "cc01f17928f7780cefd423ea653b072eea723a1b",
357 "c005662a47f14c2f1b7c7fb3b0ef0fc390c6ea6a",
358 "675cde16a6ad2bcd8d7e72780b07a0ccd8d0393a",
359 "ea39ac62ca2f815a1d029340c6465994b6f03cb0",
360 "9a603513cd81acf70cf8b27b0d544e7f672e9d40",
361 "f4a334e69535de74ee5ed54be93a75120a66e54a",
362 "559fd1d15447745527c61fe43a94c6708bff3e39",
363 "995f77f2f53398399f09d1365cb4dfd105764e5c",
364 "c21851589a5f8a45ea5f9bb3e72f4f88d0a6697d",
365 "8c609921d4a3ed89a994a75482b27496bf103cf5",
366 "eb2ce16a6ae251f4965135ee776776b5fc02c42c",
367 "66493ee117719e172f327a426af601996025f28c",
368 "acead2745fec0b6c817fa601353bdf2d197b64f7",
369 "a6b858b2d125c159529d3f3ec45b31925a79acff",
370 "d83adc669c0dea0dc4812b93f998514b6f02d805",
371 "9e8ceb7c3cd68e043b6d875c8c84a1e394962412",
372 "9e996fc74eeef53f0a6c31aabb2edce6e103f189",
373 "7d1bfff706b0713e53209407889f83a0da26a81d",
374 "31e667c2dbb81dcf81d01cb88f794e88ddb90ff2",
378 static const char *sha1_graphics_4[] =
380 "fa867e2976a549ecd3b1fa67df54963232fcef8c",
381 "256d742b4da96b373b4fa5663d0ad3b5faab5c8e",
382 "d96d8f4232b930bccd53b903b5efaf8c0bdb16f4",
383 "9401799e6116c35e5f0e5bdca07ea25316757a72",
384 "482ae2b0ef1d64752b5ef11cc7f35a33eb55d07c",
385 "dcfb3e01100b41c0f75a1c5f84b6de6b90138281",
386 "2505598845fa026ea7187582461efbf06cb6904f",
387 "3981a19363beca8f28d32a5928ac296fd22a5296",
388 "01404024ebb2c266d17d734059524d874491650f",
389 "c87bbff3f83b8ec11bb03cfa9bc9ee5166c4c7ef",
390 "f35c5d62853be78c5d39fb2f45200dc262aa8e18",
391 "46e94a55f5f58a6b915078d8ffdc725f53aab516",
392 "665bbbc749a5ffeedc0d62aef0661a5ce845b017",
393 "1f26a01730f67d40ea711a50d9d801bac15a642e",
394 "3b53d24178cfacba53103a44dfd5d072b15a6781",
395 "c52cfd57f26037723d37192722fc3a217f280c9e",
396 "e34da6500cf2e424d980714d92737cf6c31a7bda",
397 "d17f4358ae529f920960ed89e535902ee13b0033",
398 "0f44e12ecd1ea7e39433890443626d4fc35204a4",
399 "eb38683e812fd13dca971ba8f4cfd2b6820d3524",
400 "73bbc83f88f1aaa6df0158b63e70bb3165163163",
401 "0dc2690a5c58a2907a8ab06693ebfab6698172eb",
402 "39c16648cf6c261be71a33cec41867f28e119b94",
403 "26ad5116562e7b58c76a26eaf521e2e40899e944",
404 "1bcc54eaf8e3c2b7c59ecccb23c240181d7ba8b8",
405 "4f827ca6927f15191588456f985bf29d2a3b3c24",
406 "e7de769c3d12ea9dd223bef4881c578823bec67e",
407 "6fb102d020e5554116feefc8482104f3ae2036d2",
408 "ae546ffd30b837afc7dfcb5c9ce4f01d15b35ddc",
409 "20c9eb3276c08fdce35755e349bec94b04929812",
410 "628d837163a25c6520f19c0602383176dbad528e",
411 "b5a12cff7100290ad43f5ed17a321b42de048893",
412 "b672afbeeafb44194a821f0def81a8892872937e",
413 "db0124045882b598feea192186cf7eb7a0387866",
414 "602d91471378fe24a2d0248bd8a92b624f099fea",
415 "e772873b87a0f55ea51a3da323f64bf8814c6703",
416 "bbf027f506cbb80d359bf4892fcb75f816f2e446",
417 "ed44bded6b17df7fe92b191fd810d1aafbd55f52",
418 "a49bcb1ace42d548254d9e96d22088b1fe2e75b4",
419 "3e411b004a5be84451860c6da6a4a1a482b77862",
420 "3b3d2f18fdc75e938ca43cc2d0b41fa67c1c5d36",
421 "7811c536a6527112b438a6413f3927f2c79086a7",
422 "46760975993f9881b7bbe94123173e6a683d3f25",
423 "df5feb905a31c288008cf5e82d73ac818a160d82",
427 static const char *sha1_graphics_1[] =
429 "23366004515f3bc46796ea505d748f8d0f97fbe1",
430 "ad674a4104c6a1eacaee8f20effdfe31775b4409",
431 "a7cc69f957d7b533a0a330859a143d701daac73c",
432 "a955bf088c5edb129289ce65caace48ec95632e4",
433 "5316d3c558c254479883133cf58cd07ab521d3f0",
434 "fcbfdb5d60716ea05f2d1896fae7a6e7a8249d35",
435 "2c140b39cc8d21358fded8959cd655f03d7f0f89",
436 "121423a38b4ac4743bd516e0a7e88a3863796313",
437 "7c17635c6c7f62dbf8fd4773d0c503358553d2c7",
438 "21d5d9e47bb07de2cf7bc99b7725390d03a6cde6",
439 "f69ee65ea25676429a28eea79b5b9cb9206b8d01",
440 "39ff81f77ef4ee772367ed1a63785987c060126e",
441 "4c686508a994ca4c7a0a73b8c0fe52423c180d9c",
442 "b0cc1f5e244ae0c0835a9866a46abdfcd56d1cb1",
443 "7ddf19df5bbdf4475b6ec1bc042425e382502864",
444 "144c9a846e5e37ac6efd5ed3a97ec231479e8fca",
445 "c5ffc59048bf786b5646ad6226cd8633965de9ef",
446 "40fadc2d24c713b04ff96f7dc26e70e85f26c55e",
447 "400a21caa01e015096ee1afcf1b54e7f8ec515bd",
448 "0ff4b49797e30e3555aab45219adf449a9a560ff",
449 "280327328ca940c212ce24fe72e0b00014072767",
450 "144c9a846e5e37ac6efd5ed3a97ec231479e8fca",
451 "b85463875f755b85f1464b1b6275912bcbad6c9f",
452 "816f200969feecc788b61dfeecf05b1790984401",
453 "a4964d8bbf80fe785f906bc0f7c5b113242a58fc",
454 "a5d204cc7342d40b765ca042f8668e22601c4ff9",
455 "adb2818f6d3845dd140bc0f9abdbaa89d2a8c3de",
456 "0a76e0121facb103857130bc6e12185ad77fc3fa",
457 "02aede714773d654d0fc2f640afaa133ec718ad5",
458 "13cc63972aee4f6ae27091a8af18de01f1d3a5da",
459 "3bb745ccb08402ce6fac6ee26fb8d7aad2dba27e",
460 "b26699f62661e16a1dc452d24c88ce363a1f2998",
461 "4d95c3d1e170f004c80aa8c52feafb8e0e90760e",
462 "c14832e69ec3585c15987b3d69d5007236fa9814",
463 "e44ea620b0c47125a34193537ab9d219a52ad028",
464 "d1e6091caa4482d3142df3b958606c41ebf4698e",
465 "07c1116d8286fb665a1005de220eadc3d5999aaf",
466 "4afb0649488f6e6f7d3a2b8bf438d82f2c88f4d1",
467 "f2fe295317e795a88edd0b2c52618b8cb0e7f2ce",
468 "ffc78c075d4be66806f6c59180772d5eed963dc0",
469 "c86eeaeed09871dee4b43722ba512d2d3af7f4d0",
470 "24b1a6241c81dbb950cfbe5da6798fd59eb36266",
471 "1007d3b531b4bc3553d4547bc88443fc1f497cf6",
472 "b71ca46be287598f716bb04fac0a52ad139c70db",
473 "6589e48498e30ab036fbfe94d73427b2b1238a69",
474 "4dce919117d2e41df9f5d4d0de14f97ae650046d",
475 "22c2e078f69d73b7a5cb3f7dcbb8fbaa007ef3ac",
476 "be36cda370650e6d5fb0570aeb8ced491d0c2b1c",
477 "4c34cb8e47f9ff4b4348aa2d40cce7cb54d65cb0",
478 "18f4497e43903e8df5b27da4ceebf62b15550a87",
479 "3fa3570a2ebd38042b90f24bd3496233bca5a23d",
480 "65c8811c609203fd424f5ed5f92ca2268a1dca54",
481 "a45b297d709e297584eb0f2985294ec0ab53d8ad",
482 "0d180c37bc26d83a1a11f66168757f3de2493243",
483 "d1d2ecf71a37d9eda58fa09454aa871971428ace",
484 "6672da4e016b6e9de0ca218f8307cce7d48d62c4",
485 "ee22f43ea867228c6ff937d39e1826e285a107e8",
486 "a2a928de9007d765da496abec8c21b23601f8c45",
487 "28ded40e72d4327b9413571476b167fb28a1f420",
491 static inline DWORD get_stride(BITMAPINFO *bmi)
493 return ((bmi->bmiHeader.biBitCount * bmi->bmiHeader.biWidth + 31) >> 3) & ~3;
496 static inline DWORD get_dib_size(BITMAPINFO *bmi)
498 return get_stride(bmi) * abs(bmi->bmiHeader.biHeight);
501 static char *hash_dib(BITMAPINFO *bmi, void *bits)
503 DWORD dib_size = get_dib_size(bmi);
507 DWORD hash_size = sizeof(hash_buf);
509 static const char *hex = "0123456789abcdef";
511 if(!crypt_prov) return NULL;
513 if(!CryptCreateHash(crypt_prov, CALG_SHA1, 0, 0, &hash)) return NULL;
515 CryptHashData(hash, bits, dib_size, 0);
517 CryptGetHashParam(hash, HP_HASHVAL, NULL, &hash_size, 0);
518 if(hash_size != sizeof(hash_buf)) return NULL;
520 CryptGetHashParam(hash, HP_HASHVAL, hash_buf, &hash_size, 0);
521 CryptDestroyHash(hash);
523 buf = HeapAlloc(GetProcessHeap(), 0, hash_size * 2 + 1);
525 for(i = 0; i < hash_size; i++)
527 buf[i * 2] = hex[hash_buf[i] >> 4];
528 buf[i * 2 + 1] = hex[hash_buf[i] & 0xf];
535 static void compare_hash_broken_todo(BITMAPINFO *bmi, BYTE *bits, const char ***sha1, const char *info, int num_broken, BOOL todo)
537 char *hash = hash_dib(bmi, bits);
543 skip("SHA1 hashing unavailable on this platform\n");
547 for(i = 0; i <= num_broken; i++)
549 if((*sha1)[i] == NULL)
551 ok((*sha1)[i] != NULL, "missing hash, got \"%s\",\n", hash);
556 ok_cond = !strcmp(hash, **sha1);
558 for(i = 1; i <= num_broken; i++)
559 ok_cond = ok_cond || broken( !strcmp(hash, (*sha1)[i]) );
562 todo_wine ok( ok_cond, "%d: %s: expected hash %s got %s\n",
563 bmi->bmiHeader.biBitCount, info, **sha1, hash );
565 ok( ok_cond, "%d: %s: expected hash %s got %s\n",
566 bmi->bmiHeader.biBitCount, info, **sha1, hash );
568 *sha1 += num_broken + 1;
570 HeapFree(GetProcessHeap(), 0, hash);
573 static void compare_hash(BITMAPINFO *bmi, BYTE *bits, const char ***sha1, const char *info)
575 compare_hash_broken_todo(bmi, bits, sha1, info, 0, FALSE);
578 static const RECT bias_check[] =
580 {100, 100, 200, 150},
581 {100, 100, 150, 200},
590 static const RECT hline_clips[] =
592 {120, 120, 140, 120}, /* unclipped */
593 {100, 122, 140, 122}, /* l edgecase */
594 { 99, 124, 140, 124}, /* l edgecase clipped */
595 {120, 126, 200, 126}, /* r edgecase */
596 {120, 128, 201, 128}, /* r edgecase clipped */
597 { 99, 130, 201, 130}, /* l and r clipped */
598 {120, 100, 140, 100}, /* t edgecase */
599 {120, 99, 140, 99}, /* t edgecase clipped */
600 {120, 199, 140, 199}, /* b edgecase */
601 {120, 200, 140, 200}, /* b edgecase clipped */
602 {120, 132, 310, 132}, /* inside two clip rects */
603 { 10, 134, 101, 134}, /* r end on l edgecase */
604 { 10, 136, 100, 136}, /* r end on l edgecase clipped */
605 {199, 138, 220, 138}, /* l end on r edgecase */
606 {200, 140, 220, 140} /* l end on r edgecase clipped */
609 static const RECT vline_clips[] =
611 {120, 120, 120, 140}, /* unclipped */
612 {100, 120, 100, 140}, /* l edgecase */
613 { 99, 120, 99, 140}, /* l edgecase clipped */
614 {199, 120, 199, 140}, /* r edgecase */
615 {200, 120, 200, 140}, /* r edgecase clipped */
616 {122, 99, 122, 201}, /* t and b clipped */
617 {124, 100, 124, 140}, /* t edgecase */
618 {126, 99, 126, 140}, /* t edgecase clipped */
619 {128, 120, 128, 200}, /* b edgecase */
620 {130, 120, 130, 201}, /* b edgecase clipped */
621 {132, 12, 132, 140}, /* inside two clip rects */
622 {134, 90, 134, 101}, /* b end on t edgecase */
623 {136, 90, 136, 100}, /* b end on t edgecase clipped */
624 {138, 199, 138, 220}, /* t end on b edgecase */
625 {140, 200, 140, 220} /* t end on b edgecase clipped */
628 static const RECT line_clips[] =
630 { 90, 110, 310, 120},
631 { 90, 120, 295, 130},
632 { 90, 190, 110, 240}, /* totally clipped, moving outcodes */
633 { 90, 130, 100, 135}, /* totally clipped, end pt on l edge */
634 { 90, 132, 101, 137}, /* end pt just inside l edge */
635 {200, 140, 210, 141}, /* totally clipped, start pt on r edge */
636 {199, 142, 210, 143} /* start pt just inside r edge */
639 static const RECT patblt_clips[] =
641 {120, 120, 140, 126}, /* unclipped */
642 {100, 130, 140, 136}, /* l edgecase */
643 { 99, 140, 140, 146}, /* l edgecase clipped */
644 {180, 130, 200, 136}, /* r edgecase */
645 {180, 140, 201, 146}, /* r edgecase clipped */
646 {120, 100, 130, 110}, /* t edgecase */
647 {140, 99, 150, 110}, /* t edgecase clipped */
648 {120, 180, 130, 200}, /* b edgecase */
649 {140, 180, 150, 201}, /* b edgecase */
650 {199, 150, 210, 156}, /* l edge on r edgecase */
651 {200, 160, 210, 166}, /* l edge on r edgecase clipped */
652 { 90, 150, 101, 156}, /* r edge on l edgecase */
653 { 90, 160, 100, 166}, /* r edge on l edgecase clipped */
654 {160, 90, 166, 101}, /* b edge on t edgecase */
655 {170, 90, 176, 101}, /* b edge on t edgecase clipped */
656 {160, 199, 166, 210}, /* t edge on b edgecase */
657 {170, 200, 176, 210}, /* t edge on b edgecase clipped */
660 static const RECT rectangles[] =
664 {120, 10, 120, 20}, /* zero width */
665 {120, 10, 130, 10}, /* zero height */
666 {120, 40, 121, 41}, /* 1 x 1 */
667 {130, 50, 132, 52}, /* 2 x 2 */
668 {140, 60, 143, 63}, /* 3 x 3 */
669 {150, 70, 154, 74}, /* 4 x 4 */
670 {120, 20, 121, 30}, /* width == 1 */
671 {130, 20, 132, 30}, /* width == 2 */
672 {140, 20, 143, 30}, /* width == 3 */
673 {200, 20, 210, 21}, /* height == 1 */
674 {200, 30, 210, 32}, /* height == 2 */
675 {200, 40, 210, 43} /* height == 3 */
678 static const BITMAPINFOHEADER dib_brush_header_8888 = {sizeof(BITMAPINFOHEADER), 16, -16, 1, 32, BI_RGB, 0, 0, 0, 0, 0};
679 static const BITMAPINFOHEADER dib_brush_header_24 = {sizeof(BITMAPINFOHEADER), 16, -16, 1, 24, BI_RGB, 0, 0, 0, 0, 0};
680 static const BITMAPINFOHEADER dib_brush_header_555 = {sizeof(BITMAPINFOHEADER), 16, -16, 1, 16, BI_RGB, 0, 0, 0, 0, 0};
681 static const BITMAPINFOHEADER dib_brush_header_8 = {sizeof(BITMAPINFOHEADER), 16, -16, 1, 8, BI_RGB, 0, 0, 0, 0, 0};
682 static const BITMAPINFOHEADER dib_brush_header_4 = {sizeof(BITMAPINFOHEADER), 16, -16, 1, 4, BI_RGB, 0, 0, 0, 0, 0};
683 static const BITMAPINFOHEADER dib_brush_header_1 = {sizeof(BITMAPINFOHEADER), 16, -16, 1, 1, BI_RGB, 0, 0, 0, 0, 0};
685 static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sha1)
687 DWORD dib_size = get_dib_size(bmi);
688 HPEN solid_pen, dashed_pen, orig_pen;
689 HBRUSH solid_brush, dib_brush, hatch_brush, orig_brush;
691 INT i, x, y, hatch_style;
694 BYTE dib_src_buf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)];
695 BYTE dib_brush_buf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD) + 16 * 16 * sizeof(DWORD)]; /* Enough for 16 x 16 at 32 bpp */
696 BITMAPINFO *src_bi = (BITMAPINFO*)dib_src_buf;
697 BITMAPINFO *brush_bi = (BITMAPINFO*)dib_brush_buf;
698 BYTE *brush_bits, *src_bits;
699 BOOL ret, dib_is_1bpp = (bmi->bmiHeader.biBitCount == 1);
701 memset(bits, 0xcc, dib_size);
702 compare_hash(bmi, bits, sha1, "empty");
704 src_dc = CreateCompatibleDC( 0 );
705 solid_pen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0xff));
706 orig_pen = SelectObject(hdc, solid_pen);
707 SetBrushOrgEx(hdc, 0, 0, NULL);
709 /* horizontal and vertical lines */
710 for(i = 1; i <= 16; i++)
713 MoveToEx(hdc, 10, i * 3, NULL);
714 LineTo(hdc, 100, i * 3); /* l -> r */
715 MoveToEx(hdc, 100, 50 + i * 3, NULL);
716 LineTo(hdc, 10, 50 + i * 3); /* r -> l */
717 MoveToEx(hdc, 120 + i * 3, 10, NULL);
718 LineTo(hdc, 120 + i * 3, 100); /* t -> b */
719 MoveToEx(hdc, 170 + i * 3, 100, NULL);
720 LineTo(hdc, 170 + i * 3, 10); /* b -> t */
722 compare_hash(bmi, bits, sha1, "h and v solid lines");
723 memset(bits, 0xcc, dib_size);
726 SetROP2(hdc, R2_COPYPEN);
727 for(i = 0; i < 16; i++)
729 double s = sin(M_PI * i / 8.0);
730 double c = cos(M_PI * i / 8.0);
732 MoveToEx(hdc, 200.5 + 10 * c, 200.5 + 10 * s, NULL);
733 LineTo(hdc, 200.5 + 100 * c, 200.5 + 100 * s);
735 compare_hash(bmi, bits, sha1, "diagonal solid lines");
736 memset(bits, 0xcc, dib_size);
738 for(i = 0; i < sizeof(bias_check) / sizeof(bias_check[0]); i++)
740 MoveToEx(hdc, bias_check[i].left, bias_check[i].top, NULL);
741 LineTo(hdc, bias_check[i].right, bias_check[i].bottom);
743 compare_hash(bmi, bits, sha1, "more diagonal solid lines");
744 memset(bits, 0xcc, dib_size);
746 /* solid brush PatBlt */
747 solid_brush = CreateSolidBrush(RGB(0x33, 0xaa, 0xff));
748 orig_brush = SelectObject(hdc, solid_brush);
750 for(i = 0, y = 10; i < 256; i++)
752 ret = PatBlt(hdc, 10, y, 100, 10, rop3[i]);
754 if(rop_uses_src(rop3[i]))
755 ok(ret == FALSE, "got TRUE for %x\n", rop3[i]);
758 ok(ret, "got FALSE for %x\n", rop3[i]);
763 compare_hash(bmi, bits, sha1, "solid patblt");
764 memset(bits, 0xcc, dib_size);
767 hrgn = CreateRectRgn(10, 10, 200, 20);
768 hrgn2 = CreateRectRgn(100, 100, 200, 200);
769 CombineRgn(hrgn, hrgn, hrgn2, RGN_OR);
770 SetRectRgn(hrgn2, 290, 100, 300, 200);
771 CombineRgn(hrgn, hrgn, hrgn2, RGN_OR);
772 ExtSelectClipRgn(hdc, hrgn, RGN_COPY);
775 for(i = 0; i < sizeof(hline_clips)/sizeof(hline_clips[0]); i++)
777 MoveToEx(hdc, hline_clips[i].left, hline_clips[i].top, NULL);
778 LineTo(hdc, hline_clips[i].right, hline_clips[i].bottom);
780 compare_hash(bmi, bits, sha1, "clipped solid hlines");
781 memset(bits, 0xcc, dib_size);
783 for(i = 0; i < sizeof(vline_clips)/sizeof(vline_clips[0]); i++)
785 MoveToEx(hdc, vline_clips[i].left, vline_clips[i].top, NULL);
786 LineTo(hdc, vline_clips[i].right, vline_clips[i].bottom);
788 compare_hash(bmi, bits, sha1, "clipped solid vlines");
789 memset(bits, 0xcc, dib_size);
791 for(i = 0; i < sizeof(line_clips)/sizeof(line_clips[0]); i++)
793 MoveToEx(hdc, line_clips[i].left, line_clips[i].top, NULL);
794 LineTo(hdc, line_clips[i].right, line_clips[i].bottom);
796 compare_hash(bmi, bits, sha1, "clipped solid diagonal lines");
797 memset(bits, 0xcc, dib_size);
800 for(i = 0; i < sizeof(patblt_clips) / sizeof(patblt_clips[0]); i++)
802 PatBlt(hdc, patblt_clips[i].left, patblt_clips[i].top,
803 patblt_clips[i].right - patblt_clips[i].left,
804 patblt_clips[i].bottom - patblt_clips[i].top, PATCOPY);
806 compare_hash(bmi, bits, sha1, "clipped patblt");
807 memset(bits, 0xcc, dib_size);
809 /* clipped dashed lines */
810 dashed_pen = CreatePen(PS_DASH, 1, RGB(0xff, 0, 0));
811 SelectObject(hdc, dashed_pen);
812 SetBkMode(hdc, TRANSPARENT);
813 SetBkColor(hdc, RGB(0, 0xff, 0));
815 for(i = 0; i < sizeof(hline_clips)/sizeof(hline_clips[0]); i++)
817 MoveToEx(hdc, hline_clips[i].left, hline_clips[i].top, NULL);
818 LineTo(hdc, hline_clips[i].right, hline_clips[i].bottom);
820 compare_hash(bmi, bits, sha1, "clipped dashed hlines");
821 memset(bits, 0xcc, dib_size);
823 for(i = 0; i < sizeof(hline_clips)/sizeof(hline_clips[0]); i++)
825 MoveToEx(hdc, hline_clips[i].right - 1, hline_clips[i].bottom, NULL);
826 LineTo(hdc, hline_clips[i].left - 1, hline_clips[i].top);
828 compare_hash(bmi, bits, sha1, "clipped dashed hlines r -> l");
829 memset(bits, 0xcc, dib_size);
831 for(i = 0; i < sizeof(vline_clips)/sizeof(vline_clips[0]); i++)
833 MoveToEx(hdc, vline_clips[i].left, vline_clips[i].top, NULL);
834 LineTo(hdc, vline_clips[i].right, vline_clips[i].bottom);
836 compare_hash(bmi, bits, sha1, "clipped dashed vlines");
837 memset(bits, 0xcc, dib_size);
839 for(i = 0; i < sizeof(vline_clips)/sizeof(vline_clips[0]); i++)
841 MoveToEx(hdc, vline_clips[i].right, vline_clips[i].bottom - 1, NULL);
842 LineTo(hdc, vline_clips[i].left, vline_clips[i].top - 1);
844 compare_hash(bmi, bits, sha1, "clipped dashed vlines b -> t");
845 memset(bits, 0xcc, dib_size);
847 for(i = 0; i < sizeof(line_clips)/sizeof(line_clips[0]); i++)
849 MoveToEx(hdc, line_clips[i].left, line_clips[i].top, NULL);
850 LineTo(hdc, line_clips[i].right, line_clips[i].bottom);
852 compare_hash(bmi, bits, sha1, "clipped dashed diagonal lines");
853 memset(bits, 0xcc, dib_size);
855 SetBkMode(hdc, OPAQUE);
857 for(i = 0; i < sizeof(line_clips)/sizeof(line_clips[0]); i++)
859 MoveToEx(hdc, line_clips[i].left, line_clips[i].top, NULL);
860 LineTo(hdc, line_clips[i].right, line_clips[i].bottom);
862 compare_hash(bmi, bits, sha1, "clipped opaque dashed diagonal lines");
863 memset(bits, 0xcc, dib_size);
865 ExtSelectClipRgn(hdc, NULL, RGN_COPY);
867 /* 8888 DIB pattern brush */
869 brush_bi->bmiHeader = dib_brush_header_8888;
870 brush_bits = (BYTE*)brush_bi + sizeof(BITMAPINFOHEADER);
871 memset(brush_bits, 0, 16 * 16 * sizeof(DWORD));
872 brush_bits[2] = 0xff;
873 brush_bits[6] = 0xff;
874 brush_bits[14] = 0xff;
875 brush_bits[65] = 0xff;
876 brush_bits[69] = 0xff;
877 brush_bits[72] = 0xff;
879 dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
881 SelectObject(hdc, dib_brush);
882 SetBrushOrgEx(hdc, 1, 1, NULL);
884 for(i = 0, y = 10; i < 256; i++)
886 if(!rop_uses_src(rop3[i]))
888 ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
889 ok(ret, "got FALSE for %x\n", rop3[i]);
893 compare_hash_broken_todo(bmi, bits, sha1, "top-down 8888 dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp);
894 memset(bits, 0xcc, dib_size);
896 SelectObject(hdc, orig_brush);
897 DeleteObject(dib_brush);
899 /* 8888 bottom-up DIB pattern brush */
901 brush_bi->bmiHeader.biHeight = -brush_bi->bmiHeader.biHeight;
903 dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
905 SelectObject(hdc, dib_brush);
907 /* This used to set the x origin to 100 as well, but
908 there's a Windows bug for 24 bpp where the brush's x offset
909 is incorrectly calculated for rops that involve both D and P */
910 SetBrushOrgEx(hdc, 4, 100, NULL);
912 for(i = 0, y = 10; i < 256; i++)
914 if(!rop_uses_src(rop3[i]))
916 ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
917 ok(ret, "got FALSE for %x\n", rop3[i]);
921 compare_hash_broken_todo(bmi, bits, sha1, "bottom-up 8888 dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp);
922 memset(bits, 0xcc, dib_size);
924 SelectObject(hdc, orig_brush);
925 DeleteObject(dib_brush);
927 /* 24 bpp dib pattern brush */
929 brush_bi->bmiHeader = dib_brush_header_24;
930 brush_bits = (BYTE*)brush_bi + sizeof(BITMAPINFOHEADER);
931 memset(brush_bits, 0, 16 * 16 * 3);
932 brush_bits[0] = brush_bits[3] = brush_bits[6] = brush_bits[8] = 0xff;
933 brush_bits[49] = brush_bits[52] = 0xff;
935 dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
937 SelectObject(hdc, dib_brush);
938 SetBrushOrgEx(hdc, 1, 1, NULL);
940 for(i = 0, y = 10; i < 256; i++)
942 if(!rop_uses_src(rop3[i]))
944 ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
945 ok(ret, "got FALSE for %x\n", rop3[i]);
949 compare_hash_broken_todo(bmi, bits, sha1, "top-down 24 bpp brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp);
950 memset(bits, 0xcc, dib_size);
952 SelectObject(hdc, orig_brush);
953 DeleteObject(dib_brush);
955 /* 555 dib pattern brush */
957 brush_bi->bmiHeader = dib_brush_header_555;
958 brush_bits = (BYTE*)brush_bi + sizeof(BITMAPINFOHEADER);
959 memset(brush_bits, 0, 16 * 16 * sizeof(WORD));
960 brush_bits[0] = brush_bits[1] = 0xff;
961 brush_bits[32] = brush_bits[34] = 0x7c;
963 dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
965 SelectObject(hdc, dib_brush);
966 SetBrushOrgEx(hdc, 1, 1, NULL);
968 for(i = 0, y = 10; i < 256; i++)
970 if(!rop_uses_src(rop3[i]))
972 ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
973 ok(ret, "got FALSE for %x\n", rop3[i]);
977 compare_hash_broken_todo(bmi, bits, sha1, "top-down 555 dib brush patblt", dib_is_1bpp ? 1 : 0, dib_is_1bpp);
978 memset(bits, 0xcc, dib_size);
980 SelectObject(hdc, orig_brush);
981 DeleteObject(dib_brush);
983 SetBrushOrgEx(hdc, 0, 0, NULL);
985 /* 8 bpp dib pattern brush */
987 brush_bi->bmiHeader = dib_brush_header_8;
988 brush_bi->bmiHeader.biClrUsed = 3;
989 memset(brush_bi->bmiColors, 0, brush_bi->bmiHeader.biClrUsed * sizeof(RGBQUAD));
990 brush_bi->bmiColors[0].rgbRed = 0xff;
991 brush_bi->bmiColors[1].rgbRed = 0xff;
992 brush_bi->bmiColors[1].rgbGreen = 0xff;
993 brush_bi->bmiColors[1].rgbBlue = 0xff;
995 brush_bits = (BYTE*)brush_bi + sizeof(BITMAPINFOHEADER) + brush_bi->bmiHeader.biClrUsed * sizeof(RGBQUAD);
996 memset(brush_bits, 0, 16 * 16 * sizeof(BYTE));
997 brush_bits[0] = brush_bits[1] = 1;
998 brush_bits[16] = brush_bits[17] = 2;
999 brush_bits[32] = brush_bits[33] = 6;
1001 dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
1003 SelectObject(hdc, dib_brush);
1004 SetBrushOrgEx(hdc, 1, 1, NULL);
1006 for(i = 0, y = 10; i < 256; i++)
1008 if(!rop_uses_src(rop3[i]))
1010 ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
1011 ok(ret, "got FALSE for %x\n", rop3[i]);
1015 compare_hash_broken_todo(bmi, bits, sha1, "top-down 8 bpp dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp);
1016 memset(bits, 0xcc, dib_size);
1018 SelectObject(hdc, orig_brush);
1019 DeleteObject(dib_brush);
1021 /* 4 bpp dib pattern brush */
1023 brush_bi->bmiHeader = dib_brush_header_4;
1024 dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
1026 SelectObject(hdc, dib_brush);
1027 SetBrushOrgEx(hdc, 1, 1, NULL);
1029 for(i = 0, y = 10; i < 256; i++)
1031 if(!rop_uses_src(rop3[i]))
1033 ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
1034 ok(ret, "got FALSE for %x\n", rop3[i]);
1038 compare_hash_broken_todo(bmi, bits, sha1, "top-down 4 bpp dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp);
1039 memset(bits, 0xcc, dib_size);
1041 SelectObject(hdc, orig_brush);
1042 DeleteObject(dib_brush);
1044 /* 1 bpp dib pattern brush */
1046 brush_bi->bmiHeader = dib_brush_header_1;
1047 brush_bi->bmiHeader.biClrUsed = 2;
1048 memset(brush_bits, 0, 16 * 4);
1049 brush_bits[0] = 0xf0;
1050 brush_bits[4] = 0xf0;
1051 brush_bits[8] = 0xf0;
1053 dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
1054 SelectObject(hdc, dib_brush);
1055 for(i = 0, y = 10; i < 256; i++)
1057 if(!rop_uses_src(rop3[i]))
1059 ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
1060 ok(ret, "got FALSE for %x\n", rop3[i]);
1065 compare_hash_broken_todo(bmi, bits, sha1, "top-down 1 bpp dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp);
1066 memset(bits, 0xcc, dib_size);
1068 SelectObject(hdc, orig_brush);
1069 SetBrushOrgEx(hdc, 0, 0, NULL);
1073 SelectObject(hdc, solid_pen);
1074 SelectObject(hdc, solid_brush);
1076 for(i = 0; i < sizeof(rectangles)/sizeof(rectangles[0]); i++)
1078 Rectangle(hdc, rectangles[i].left, rectangles[i].top, rectangles[i].right, rectangles[i].bottom);
1081 SelectObject(hdc, dashed_pen);
1082 for(i = 0; i < sizeof(rectangles)/sizeof(rectangles[0]); i++)
1084 Rectangle(hdc, rectangles[i].left, rectangles[i].top + 150, rectangles[i].right, rectangles[i].bottom + 150);
1087 compare_hash(bmi, bits, sha1, "rectangles");
1088 memset(bits, 0xcc, dib_size);
1089 SelectObject(hdc, solid_pen);
1093 PaintRgn(hdc, hrgn);
1094 compare_hash(bmi, bits, sha1, "PaintRgn");
1095 memset(bits, 0xcc, dib_size);
1097 /* RTL rectangles */
1101 win_skip("Don't have SetLayout\n");
1106 pSetLayout(hdc, LAYOUT_RTL);
1107 PaintRgn(hdc, hrgn);
1108 PatBlt(hdc, 10, 250, 10, 10, PATCOPY);
1109 Rectangle(hdc, 100, 250, 110, 260);
1110 compare_hash(bmi, bits, sha1, "rtl");
1111 memset(bits, 0xcc, dib_size);
1113 pSetLayout(hdc, LAYOUT_LTR);
1116 for(i = 0, y = 10; i < 256; i++)
1118 if(!rop_uses_src(rop3[i]))
1120 for(hatch_style = HS_HORIZONTAL; hatch_style <= HS_DIAGCROSS; hatch_style++)
1122 hatch_brush = CreateHatchBrush(hatch_style, RGB(0xff, 0, 0));
1123 SelectObject(hdc, hatch_brush);
1124 ret = PatBlt(hdc, 10 + i + 30 * hatch_style, y, 20, 20, rop3[i]);
1125 ok(ret, "got FALSE for %x\n", rop3[i]);
1126 SelectObject(hdc, orig_brush);
1127 DeleteObject(hatch_brush);
1133 compare_hash_broken_todo(bmi, bits, sha1, "hatch brushes", 1, FALSE); /* nt4 is different */
1134 memset(bits, 0xcc, dib_size);
1136 /* overlapping blits */
1138 orig_brush = SelectObject(hdc, solid_brush);
1140 Rectangle(hdc, 10, 10, 100, 100);
1141 Rectangle(hdc, 20, 15, 30, 40);
1142 Rectangle(hdc, 15, 15, 20, 20);
1143 Rectangle(hdc, 15, 20, 50, 45);
1144 BitBlt( hdc, 20, 20, 100, 100, hdc, 10, 10, SRCCOPY );
1145 compare_hash(bmi, bits, sha1, "overlapping BitBlt SRCCOPY +x, +y");
1146 memset(bits, 0xcc, dib_size);
1148 Rectangle(hdc, 10, 10, 100, 100);
1149 Rectangle(hdc, 20, 15, 30, 40);
1150 Rectangle(hdc, 15, 15, 20, 20);
1151 Rectangle(hdc, 15, 20, 50, 45);
1152 BitBlt( hdc, 10, 10, 100, 100, hdc, 20, 20, SRCCOPY );
1153 if (bmi->bmiHeader.biBitCount == 1) /* Windows gets this one wrong */
1154 compare_hash_broken_todo(bmi, bits, sha1, "overlapping BitBlt SRCCOPY -x, -y",1, FALSE);
1156 compare_hash(bmi, bits, sha1, "overlapping BitBlt SRCCOPY -x, -y");
1157 memset(bits, 0xcc, dib_size);
1159 Rectangle(hdc, 10, 10, 100, 100);
1160 Rectangle(hdc, 20, 15, 30, 40);
1161 Rectangle(hdc, 15, 15, 20, 20);
1162 Rectangle(hdc, 15, 20, 50, 45);
1163 BitBlt( hdc, 20, 10, 100, 100, hdc, 10, 20, SRCCOPY );
1164 compare_hash(bmi, bits, sha1, "overlapping BitBlt SRCCOPY +x, -y");
1165 memset(bits, 0xcc, dib_size);
1167 Rectangle(hdc, 10, 10, 100, 100);
1168 Rectangle(hdc, 20, 15, 30, 40);
1169 Rectangle(hdc, 15, 15, 20, 20);
1170 Rectangle(hdc, 15, 20, 50, 45);
1171 BitBlt( hdc, 10, 20, 100, 100, hdc, 20, 10, SRCCOPY );
1172 if (bmi->bmiHeader.biBitCount == 1) /* Windows gets this one wrong */
1173 compare_hash_broken_todo(bmi, bits, sha1, "overlapping BitBlt SRCCOPY -x, +y", 1, FALSE );
1175 compare_hash(bmi, bits, sha1, "overlapping BitBlt SRCCOPY -x, +y" );
1176 memset(bits, 0xcc, dib_size);
1178 Rectangle(hdc, 10, 10, 100, 100);
1179 Rectangle(hdc, 20, 15, 30, 40);
1180 Rectangle(hdc, 15, 15, 20, 20);
1181 Rectangle(hdc, 15, 20, 50, 45);
1182 BitBlt( hdc, 20, 20, 100, 100, hdc, 10, 10, PATPAINT );
1183 compare_hash(bmi, bits, sha1, "overlapping BitBlt PATPAINT +x, +y");
1184 memset(bits, 0xcc, dib_size);
1186 Rectangle(hdc, 10, 10, 100, 100);
1187 Rectangle(hdc, 20, 15, 30, 40);
1188 Rectangle(hdc, 15, 15, 20, 20);
1189 Rectangle(hdc, 15, 20, 50, 45);
1190 BitBlt( hdc, 10, 10, 100, 100, hdc, 20, 20, PATPAINT );
1191 compare_hash(bmi, bits, sha1, "overlapping BitBlt PATPAINT -x, -y");
1192 memset(bits, 0xcc, dib_size);
1194 Rectangle(hdc, 10, 10, 100, 100);
1195 Rectangle(hdc, 20, 15, 30, 40);
1196 Rectangle(hdc, 15, 15, 20, 20);
1197 Rectangle(hdc, 15, 20, 50, 45);
1198 BitBlt( hdc, 20, 10, 100, 100, hdc, 10, 20, PATPAINT );
1199 if (bmi->bmiHeader.biBitCount >= 24) /* Windows gets this one wrong */
1200 compare_hash_broken_todo(bmi, bits, sha1, "overlapping BitBlt PATPAINT +x, -y", 1, FALSE);
1202 compare_hash(bmi, bits, sha1, "overlapping BitBlt PATPAINT +x, -y");
1203 memset(bits, 0xcc, dib_size);
1205 Rectangle(hdc, 10, 10, 100, 100);
1206 Rectangle(hdc, 20, 15, 30, 40);
1207 Rectangle(hdc, 15, 15, 20, 20);
1208 Rectangle(hdc, 15, 20, 50, 45);
1209 BitBlt( hdc, 10, 20, 100, 100, hdc, 20, 10, PATPAINT );
1210 compare_hash(bmi, bits, sha1, "overlapping BitBlt PATPAINT -x, +y" );
1211 memset(bits, 0xcc, dib_size);
1213 /* blitting with 32-bpp BI_RGB source */
1215 memset( dib_src_buf, 0, sizeof(dib_src_buf) );
1216 src_bi->bmiHeader.biSize = sizeof(bmi->bmiHeader);
1217 src_bi->bmiHeader.biHeight = 256;
1218 src_bi->bmiHeader.biWidth = 256;
1219 src_bi->bmiHeader.biBitCount = 32;
1220 src_bi->bmiHeader.biPlanes = 1;
1221 src_bi->bmiHeader.biCompression = BI_RGB;
1222 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
1223 SelectObject( src_dc, bmp );
1224 for (y = 0; y < 256; y++)
1225 for (x = 0; x < 256; x++)
1227 BYTE a = (x + y) * 2;
1228 BYTE r = (BYTE)(y + 2 * x) * a / 255;
1229 BYTE g = (BYTE)(x + y / 3) * a / 255;
1230 BYTE b = (BYTE)(x / 3 + 2 * y) * a / 255;
1231 ((DWORD *)src_bits)[y * 256 + x] = (a << 24) | RGB( r, g, b );
1234 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
1235 if (bmi->bmiHeader.biBitCount == 8) /* broken on NT4 */
1236 compare_hash_broken_todo(bmi, bits, sha1, "BitBlt src 32-bpp SRCCOPY", 1, FALSE );
1238 compare_hash(bmi, bits, sha1, "BitBlt src 32-bpp SRCCOPY" );
1239 memset(bits, 0xcc, dib_size);
1241 /* blitting with 32-bpp r10g10b10 source */
1243 src_bi->bmiHeader.biBitCount = 32;
1244 src_bi->bmiHeader.biCompression = BI_BITFIELDS;
1245 ((DWORD *)src_bi->bmiColors)[0] = 0x3ff00000;
1246 ((DWORD *)src_bi->bmiColors)[1] = 0x000ffc00;
1247 ((DWORD *)src_bi->bmiColors)[2] = 0x000003ff;
1248 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
1249 SelectObject( src_dc, bmp );
1250 for (y = 0; y < 256; y++)
1251 for (x = 0; x < 256; x++)
1253 WORD r = (7 * x + 3 * y) % 1024;
1254 WORD g = (11 * x + y / 3) % 1024;
1255 WORD b = (x / 3 + 9 * y) % 1024;
1256 ((DWORD *)src_bits)[y * 256 + x] = r << 20 | g << 10 | b;
1259 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
1260 if (bmi->bmiHeader.biBitCount == 8) /* broken on NT4 */
1261 compare_hash_broken_todo(bmi, bits, sha1, "BitBlt src 32-bpp r10g10b10 SRCCOPY", 1, FALSE );
1263 compare_hash(bmi, bits, sha1, "BitBlt src 32-bpp r10g10b10 SRCCOPY" );
1264 memset(bits, 0xcc, dib_size);
1266 /* blitting with 32-bpp b6g6r6 source */
1268 src_bi->bmiHeader.biBitCount = 32;
1269 src_bi->bmiHeader.biCompression = BI_BITFIELDS;
1270 ((DWORD *)src_bi->bmiColors)[0] = 0x00003f;
1271 ((DWORD *)src_bi->bmiColors)[1] = 0x000fc0;
1272 ((DWORD *)src_bi->bmiColors)[2] = 0x03f000;
1273 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
1274 SelectObject( src_dc, bmp );
1275 for (y = 0; y < 256; y++)
1276 for (x = 0; x < 256; x++)
1278 BYTE r = (y + 2 * x) % 64;
1279 BYTE g = (x + y / 3) % 64;
1280 BYTE b = (x / 3 + 2 * y) % 64;
1281 ((DWORD *)src_bits)[y * 256 + x] = r | g << 6 | b << 12;
1284 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
1285 if (bmi->bmiHeader.biBitCount == 8) /* broken on NT4 */
1286 compare_hash_broken_todo(bmi, bits, sha1, "BitBlt src 32-bpp b6g6r6 SRCCOPY", 1, FALSE );
1288 compare_hash(bmi, bits, sha1, "BitBlt src 32-bpp b6g6r6 SRCCOPY" );
1289 memset(bits, 0xcc, dib_size);
1291 /* blitting with 24-bpp source */
1293 src_bi->bmiHeader.biBitCount = 24;
1294 src_bi->bmiHeader.biCompression = BI_RGB;
1295 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
1296 DeleteObject( SelectObject( src_dc, bmp ) );
1297 for (y = 0; y < 256; y++)
1298 for (x = 0; x < 256; x++)
1300 src_bits[(y * 256 + x) * 3 + 0] = x + 3 * y;
1301 src_bits[(y * 256 + x) * 3 + 1] = 2 * x + 7 * y;
1302 src_bits[(y * 256 + x) * 3 + 2] = 5 * x + 12 * y;
1305 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
1306 if (bmi->bmiHeader.biBitCount == 8) /* broken on NT4 */
1307 compare_hash_broken_todo(bmi, bits, sha1, "BitBlt src 24-bpp SRCCOPY", 1, FALSE );
1309 compare_hash(bmi, bits, sha1, "BitBlt src 24-bpp SRCCOPY" );
1310 memset(bits, 0xcc, dib_size);
1312 /* blitting with 16-bpp BI_RGB source */
1314 src_bi->bmiHeader.biBitCount = 16;
1315 src_bi->bmiHeader.biCompression = BI_RGB;
1316 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
1317 DeleteObject( SelectObject( src_dc, bmp ) );
1318 for (y = 0; y < 256; y++)
1319 for (x = 0; x < 256; x++)
1320 ((WORD *)src_bits)[y * 256 + x] = x | x << 4 | x << 8 | y << 3 | y << 7;
1322 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
1323 compare_hash(bmi, bits, sha1, "BitBlt src 16-bpp SRCCOPY" );
1324 memset(bits, 0xcc, dib_size);
1326 /* blitting with 16-bpp b4g4r4 source */
1328 src_bi->bmiHeader.biBitCount = 16;
1329 src_bi->bmiHeader.biCompression = BI_BITFIELDS;
1330 ((DWORD *)src_bi->bmiColors)[0] = 0x00000f;
1331 ((DWORD *)src_bi->bmiColors)[1] = 0x0000f0;
1332 ((DWORD *)src_bi->bmiColors)[2] = 0x000f00;
1333 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
1334 DeleteObject( SelectObject( src_dc, bmp ) );
1335 for (y = 0; y < 256; y++)
1336 for (x = 0; x < 256; x++)
1337 ((WORD *)src_bits)[y * 256 + x] = x | x << 4 | x << 8 | y << 3 | y << 7;
1339 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
1340 compare_hash(bmi, bits, sha1, "BitBlt src 16-bpp b4g4r4 SRCCOPY" );
1341 memset(bits, 0xcc, dib_size);
1343 /* blitting with 8-bpp source */
1345 src_bi->bmiHeader.biBitCount = 8;
1346 src_bi->bmiHeader.biCompression = BI_RGB;
1347 src_bi->bmiHeader.biClrUsed = 160;
1348 for (i = 0; i < 256; i++) ((DWORD *)src_bi->bmiColors)[i] = i | (i * 3) << 8 | (i / 2) << 16;
1349 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
1350 DeleteObject( SelectObject( src_dc, bmp ) );
1351 for (y = 0; y < 256; y++)
1352 for (x = 0; x < 256; x++)
1353 src_bits[y * 256 + x] = 3 * x + 5 * y;
1355 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
1356 compare_hash(bmi, bits, sha1, "BitBlt src 8-bpp SRCCOPY" );
1357 memset(bits, 0xcc, dib_size);
1359 /* blitting with 4-bpp source */
1361 src_bi->bmiHeader.biBitCount = 4;
1362 src_bi->bmiHeader.biClrUsed = 12;
1363 for (i = 0; i < 16; i++) ((DWORD *)src_bi->bmiColors)[i] = i | (i * 5) << 8 | (i * 19) << 16;
1364 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
1365 DeleteObject( SelectObject( src_dc, bmp ) );
1366 for (y = 0; y < 256; y++)
1367 for (x = 0; x < 256; x += 2)
1368 src_bits[(y * 256 + x) / 2] = 7 * x + 3 * y;
1370 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
1371 compare_hash(bmi, bits, sha1, "BitBlt src 4-bpp SRCCOPY" );
1372 memset(bits, 0xcc, dib_size);
1374 /* blitting with 1-bpp source */
1376 src_bi->bmiHeader.biBitCount = 1;
1377 src_bi->bmiHeader.biClrUsed = 0;
1378 for (i = 0; i < 2; i++) ((DWORD *)src_bi->bmiColors)[i] = (i + 37) | (i * 91) << 8 | (i * 53) << 16;
1379 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
1380 DeleteObject( SelectObject( src_dc, bmp ) );
1381 for (y = 0; y < 256; y++)
1382 for (x = 0; x < 256; x += 8)
1383 src_bits[(y * 256 + x) / 8] = 7 * x + 3 * y;
1385 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
1386 compare_hash(bmi, bits, sha1, "BitBlt src 1-bpp SRCCOPY" );
1387 memset(bits, 0xcc, dib_size);
1390 DeleteObject( bmp );
1391 SelectObject(hdc, orig_brush);
1392 SelectObject(hdc, orig_pen);
1394 DeleteObject(dib_brush);
1395 DeleteObject(dashed_pen);
1396 DeleteObject(solid_brush);
1397 DeleteObject(solid_pen);
1400 static void test_simple_graphics(void)
1402 char bmibuf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)];
1403 BITMAPINFO *bmi = (BITMAPINFO *)bmibuf;
1404 DWORD *bit_fields = (DWORD*)(bmibuf + sizeof(BITMAPINFOHEADER));
1407 HBITMAP dib, orig_bm;
1411 mem_dc = CreateCompatibleDC(NULL);
1415 memset(bmi, 0, sizeof(bmibuf));
1416 bmi->bmiHeader.biSize = sizeof(bmi->bmiHeader);
1417 bmi->bmiHeader.biHeight = 512;
1418 bmi->bmiHeader.biWidth = 512;
1419 bmi->bmiHeader.biBitCount = 32;
1420 bmi->bmiHeader.biPlanes = 1;
1421 bmi->bmiHeader.biCompression = BI_RGB;
1423 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
1424 ok(dib != NULL, "ret NULL\n");
1425 ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
1426 ok(ds.dsBitfields[0] == 0, "got %08x\n", ds.dsBitfields[0]);
1427 ok(ds.dsBitfields[1] == 0, "got %08x\n", ds.dsBitfields[1]);
1428 ok(ds.dsBitfields[2] == 0, "got %08x\n", ds.dsBitfields[2]);
1429 ok(ds.dsBmih.biCompression == BI_RGB ||
1430 broken(ds.dsBmih.biCompression == BI_BITFIELDS), /* nt4 sp1 and 2 */
1431 "got %x\n", ds.dsBmih.biCompression);
1433 orig_bm = SelectObject(mem_dc, dib);
1435 sha1 = sha1_graphics_a8r8g8b8;
1436 draw_graphics(mem_dc, bmi, bits, &sha1);
1438 SelectObject(mem_dc, orig_bm);
1441 /* a8r8g8b8 - bitfields. Should be the same as the regular 32 bit case.*/
1442 trace("8888 - bitfields\n");
1443 bmi->bmiHeader.biBitCount = 32;
1444 bmi->bmiHeader.biCompression = BI_BITFIELDS;
1445 bit_fields[0] = 0xff0000;
1446 bit_fields[1] = 0x00ff00;
1447 bit_fields[2] = 0x0000ff;
1449 dib = CreateDIBSection(mem_dc, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
1450 ok(dib != NULL, "ret NULL\n");
1451 ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
1452 ok(ds.dsBitfields[0] == 0xff0000, "got %08x\n", ds.dsBitfields[0]);
1453 ok(ds.dsBitfields[1] == 0x00ff00, "got %08x\n", ds.dsBitfields[1]);
1454 ok(ds.dsBitfields[2] == 0x0000ff, "got %08x\n", ds.dsBitfields[2]);
1455 ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %x\n", ds.dsBmih.biCompression);
1457 orig_bm = SelectObject(mem_dc, dib);
1459 sha1 = sha1_graphics_a8r8g8b8;
1460 draw_graphics(mem_dc, bmi, bits, &sha1);
1462 SelectObject(mem_dc, orig_bm);
1465 /* a8b8g8r8 - bitfields. */
1466 trace("a8b8g8r8 - bitfields\n");
1467 bmi->bmiHeader.biBitCount = 32;
1468 bmi->bmiHeader.biCompression = BI_BITFIELDS;
1469 bit_fields[0] = 0x0000ff;
1470 bit_fields[1] = 0x00ff00;
1471 bit_fields[2] = 0xff0000;
1473 dib = CreateDIBSection(mem_dc, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
1474 ok(dib != NULL, "ret NULL\n");
1475 ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
1476 ok(ds.dsBitfields[0] == 0x0000ff, "got %08x\n", ds.dsBitfields[0]);
1477 ok(ds.dsBitfields[1] == 0x00ff00, "got %08x\n", ds.dsBitfields[1]);
1478 ok(ds.dsBitfields[2] == 0xff0000, "got %08x\n", ds.dsBitfields[2]);
1479 ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %x\n", ds.dsBmih.biCompression);
1481 orig_bm = SelectObject(mem_dc, dib);
1483 sha1 = sha1_graphics_a8b8g8r8;
1484 draw_graphics(mem_dc, bmi, bits, &sha1);
1486 SelectObject(mem_dc, orig_bm);
1491 bmi->bmiHeader.biBitCount = 24;
1492 bmi->bmiHeader.biCompression = BI_RGB;
1494 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
1495 ok(dib != NULL, "ret NULL\n");
1496 orig_bm = SelectObject(mem_dc, dib);
1498 sha1 = sha1_graphics_24;
1499 draw_graphics(mem_dc, bmi, bits, &sha1);
1501 SelectObject(mem_dc, orig_bm);
1506 bmi->bmiHeader.biBitCount = 16;
1507 bmi->bmiHeader.biCompression = BI_RGB;
1509 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
1510 ok(dib != NULL, "ret NULL\n");
1511 ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
1512 ok(ds.dsBitfields[0] == 0x7c00, "got %08x\n", ds.dsBitfields[0]);
1513 ok(ds.dsBitfields[1] == 0x03e0, "got %08x\n", ds.dsBitfields[1]);
1514 ok(ds.dsBitfields[2] == 0x001f, "got %08x\n", ds.dsBitfields[2]);
1515 ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %x\n", ds.dsBmih.biCompression);
1517 orig_bm = SelectObject(mem_dc, dib);
1519 sha1 = sha1_graphics_r5g5b5;
1520 draw_graphics(mem_dc, bmi, bits, &sha1);
1522 SelectObject(mem_dc, orig_bm);
1527 bmi->bmiHeader.biBitCount = 16;
1528 bmi->bmiHeader.biCompression = BI_BITFIELDS;
1529 bit_fields[0] = 0x0f00;
1530 bit_fields[1] = 0x00f0;
1531 bit_fields[2] = 0x000f;
1532 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
1533 ok(dib != NULL, "ret NULL\n");
1534 ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
1535 ok(ds.dsBitfields[0] == 0x0f00, "got %08x\n", ds.dsBitfields[0]);
1536 ok(ds.dsBitfields[1] == 0x00f0, "got %08x\n", ds.dsBitfields[1]);
1537 ok(ds.dsBitfields[2] == 0x000f, "got %08x\n", ds.dsBitfields[2]);
1538 ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %x\n", ds.dsBmih.biCompression);
1540 orig_bm = SelectObject(mem_dc, dib);
1542 sha1 = sha1_graphics_r4g4b4;
1543 draw_graphics(mem_dc, bmi, bits, &sha1);
1545 SelectObject(mem_dc, orig_bm);
1550 bmi->bmiHeader.biBitCount = 8;
1551 bmi->bmiHeader.biCompression = BI_RGB;
1552 bmi->bmiHeader.biClrUsed = 5;
1553 bmi->bmiColors[0].rgbRed = 0xff;
1554 bmi->bmiColors[0].rgbGreen = 0xff;
1555 bmi->bmiColors[0].rgbBlue = 0xff;
1556 bmi->bmiColors[1].rgbRed = 0;
1557 bmi->bmiColors[1].rgbGreen = 0;
1558 bmi->bmiColors[1].rgbBlue = 0;
1559 bmi->bmiColors[2].rgbRed = 0xff;
1560 bmi->bmiColors[2].rgbGreen = 0;
1561 bmi->bmiColors[2].rgbBlue = 0;
1562 bmi->bmiColors[3].rgbRed = 0;
1563 bmi->bmiColors[3].rgbGreen = 0xff;
1564 bmi->bmiColors[3].rgbBlue = 0;
1565 bmi->bmiColors[4].rgbRed = 0;
1566 bmi->bmiColors[4].rgbGreen = 0;
1567 bmi->bmiColors[4].rgbBlue = 0xff;
1569 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
1570 ok(dib != NULL, "ret NULL\n");
1572 orig_bm = SelectObject(mem_dc, dib);
1574 sha1 = sha1_graphics_8;
1575 draw_graphics(mem_dc, bmi, bits, &sha1);
1577 SelectObject(mem_dc, orig_bm);
1582 bmi->bmiHeader.biBitCount = 4;
1584 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
1585 ok(dib != NULL, "ret NULL\n");
1587 orig_bm = SelectObject(mem_dc, dib);
1589 sha1 = sha1_graphics_4;
1590 draw_graphics(mem_dc, bmi, bits, &sha1);
1592 SelectObject(mem_dc, orig_bm);
1597 bmi->bmiHeader.biBitCount = 1;
1598 bmi->bmiHeader.biClrUsed = 2;
1600 bmi->bmiColors[0].rgbRed = 0x00;
1601 bmi->bmiColors[0].rgbGreen = 0x01;
1602 bmi->bmiColors[0].rgbBlue = 0xff;
1603 bmi->bmiColors[1].rgbRed = 0xff;
1604 bmi->bmiColors[1].rgbGreen = 0x00;
1605 bmi->bmiColors[1].rgbBlue = 0x00;
1607 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
1608 ok(dib != NULL, "ret NULL\n");
1610 orig_bm = SelectObject(mem_dc, dib);
1612 sha1 = sha1_graphics_1;
1613 draw_graphics(mem_dc, bmi, bits, &sha1);
1615 SelectObject(mem_dc, orig_bm);
1623 HMODULE mod = GetModuleHandleA("gdi32.dll");
1624 pSetLayout = (void *)GetProcAddress( mod, "SetLayout" );
1626 CryptAcquireContextW(&crypt_prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
1628 test_simple_graphics();
1630 CryptReleaseContext(crypt_prov, 0);