[GDI32_WINETEST] Sync everything except dib.c with Wine Staging 3.3. CORE-14434
[reactos.git] / modules / rostests / winetests / gdi32 / path.c
1 /*
2 * Unit test suite for paths
3 *
4 * Copyright 2007 Laurent Vromman
5 * Copyright 2007 Misha Koshelev
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22 #include <stdarg.h>
23 #include <stdio.h>
24 #include <assert.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "wingdi.h"
28
29 #include "wine/test.h"
30
31 #include "winuser.h"
32 #include "winerror.h"
33
34 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
35
36 static void test_path_state(void)
37 {
38 BYTE buffer[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)];
39 BITMAPINFO *bi = (BITMAPINFO *)buffer;
40 HDC hdc;
41 HRGN rgn;
42 HBITMAP orig, dib;
43 void *bits;
44 BOOL ret;
45
46 hdc = CreateCompatibleDC( 0 );
47 memset( buffer, 0, sizeof(buffer) );
48 bi->bmiHeader.biSize = sizeof(bi->bmiHeader);
49 bi->bmiHeader.biHeight = 256;
50 bi->bmiHeader.biWidth = 256;
51 bi->bmiHeader.biBitCount = 32;
52 bi->bmiHeader.biPlanes = 1;
53 bi->bmiHeader.biCompression = BI_RGB;
54 dib = CreateDIBSection( 0, bi, DIB_RGB_COLORS, (void**)&bits, NULL, 0 );
55 orig = SelectObject( hdc, dib );
56
57 BeginPath( hdc );
58 LineTo( hdc, 100, 100 );
59 ret = WidenPath( hdc );
60 ok( !ret, "WidenPath succeeded\n" );
61
62 /* selecting another bitmap doesn't affect the path */
63 SelectObject( hdc, orig );
64 ret = WidenPath( hdc );
65 ok( !ret, "WidenPath succeeded\n" );
66
67 SelectObject( hdc, dib );
68 ret = WidenPath( hdc );
69 ok( !ret, "WidenPath succeeded\n" );
70
71 ret = EndPath( hdc );
72 ok( ret, "EndPath failed error %u\n", GetLastError() );
73 ret = WidenPath( hdc );
74 ok( ret, "WidenPath failed error %u\n", GetLastError() );
75
76 SelectObject( hdc, orig );
77 ret = WidenPath( hdc );
78 ok( ret, "WidenPath failed error %u\n", GetLastError() );
79
80 BeginPath( hdc );
81 LineTo( hdc, 100, 100 );
82 ret = WidenPath( hdc );
83 ok( !ret, "WidenPath succeeded\n" );
84 SaveDC( hdc );
85 SelectObject( hdc, dib );
86 ret = EndPath( hdc );
87 ok( ret, "EndPath failed error %u\n", GetLastError() );
88 ret = WidenPath( hdc );
89 ok( ret, "WidenPath failed error %u\n", GetLastError() );
90
91 /* path should be open again after RestoreDC */
92 RestoreDC( hdc, -1 );
93 ret = WidenPath( hdc );
94 ok( !ret, "WidenPath succeeded\n" );
95 ret = EndPath( hdc );
96 ok( ret, "EndPath failed error %u\n", GetLastError() );
97
98 SaveDC( hdc );
99 BeginPath( hdc );
100 RestoreDC( hdc, -1 );
101 ret = WidenPath( hdc );
102 ok( ret, "WidenPath failed error %u\n", GetLastError() );
103
104 /* test all functions with no path at all */
105 AbortPath( hdc );
106 SetLastError( 0xdeadbeef );
107 ret = WidenPath( hdc );
108 ok( !ret, "WidenPath succeeded\n" );
109 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
110 "wrong error %u\n", GetLastError() );
111
112 SetLastError( 0xdeadbeef );
113 ret = FlattenPath( hdc );
114 ok( !ret, "FlattenPath succeeded\n" );
115 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
116 "wrong error %u\n", GetLastError() );
117
118 SetLastError( 0xdeadbeef );
119 ret = StrokePath( hdc );
120 ok( !ret, "StrokePath succeeded\n" );
121 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
122 "wrong error %u\n", GetLastError() );
123
124 SetLastError( 0xdeadbeef );
125 ret = FillPath( hdc );
126 ok( !ret, "FillPath succeeded\n" );
127 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
128 "wrong error %u\n", GetLastError() );
129
130 SetLastError( 0xdeadbeef );
131 ret = StrokeAndFillPath( hdc );
132 ok( !ret, "StrokeAndFillPath succeeded\n" );
133 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
134 "wrong error %u\n", GetLastError() );
135
136 SetLastError( 0xdeadbeef );
137 ret = SelectClipPath( hdc, RGN_OR );
138 ok( !ret, "SelectClipPath succeeded\n" );
139 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
140 "wrong error %u\n", GetLastError() );
141
142 SetLastError( 0xdeadbeef );
143 rgn = PathToRegion( hdc );
144 ok( !rgn, "PathToRegion succeeded\n" );
145 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
146 "wrong error %u\n", GetLastError() );
147
148 SetLastError( 0xdeadbeef );
149 ret = EndPath( hdc );
150 ok( !ret, "SelectClipPath succeeded\n" );
151 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
152 "wrong error %u\n", GetLastError() );
153
154 SetLastError( 0xdeadbeef );
155 ret = CloseFigure( hdc );
156 ok( !ret, "CloseFigure succeeded\n" );
157 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
158 "wrong error %u\n", GetLastError() );
159
160 /* test all functions with an open path */
161 AbortPath( hdc );
162 BeginPath( hdc );
163 SetLastError( 0xdeadbeef );
164 ret = WidenPath( hdc );
165 ok( !ret, "WidenPath succeeded\n" );
166 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
167 "wrong error %u\n", GetLastError() );
168
169 AbortPath( hdc );
170 BeginPath( hdc );
171 SetLastError( 0xdeadbeef );
172 ret = FlattenPath( hdc );
173 ok( !ret, "FlattenPath succeeded\n" );
174 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
175 "wrong error %u\n", GetLastError() );
176
177 AbortPath( hdc );
178 BeginPath( hdc );
179 SetLastError( 0xdeadbeef );
180 ret = StrokePath( hdc );
181 ok( !ret, "StrokePath succeeded\n" );
182 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
183 "wrong error %u\n", GetLastError() );
184
185 AbortPath( hdc );
186 BeginPath( hdc );
187 SetLastError( 0xdeadbeef );
188 ret = FillPath( hdc );
189 ok( !ret, "FillPath succeeded\n" );
190 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
191 "wrong error %u\n", GetLastError() );
192
193 AbortPath( hdc );
194 BeginPath( hdc );
195 SetLastError( 0xdeadbeef );
196 ret = StrokeAndFillPath( hdc );
197 ok( !ret, "StrokeAndFillPath succeeded\n" );
198 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
199 "wrong error %u\n", GetLastError() );
200
201 AbortPath( hdc );
202 BeginPath( hdc );
203 Rectangle( hdc, 1, 1, 10, 10 ); /* region needs some contents */
204 SetLastError( 0xdeadbeef );
205 ret = SelectClipPath( hdc, RGN_OR );
206 ok( !ret, "SelectClipPath succeeded\n" );
207 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
208 "wrong error %u\n", GetLastError() );
209
210 AbortPath( hdc );
211 BeginPath( hdc );
212 Rectangle( hdc, 1, 1, 10, 10 ); /* region needs some contents */
213 SetLastError( 0xdeadbeef );
214 rgn = PathToRegion( hdc );
215 ok( !rgn, "PathToRegion succeeded\n" );
216 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
217 "wrong error %u\n", GetLastError() );
218
219 AbortPath( hdc );
220 BeginPath( hdc );
221 ret = CloseFigure( hdc );
222 ok( ret, "CloseFigure failed\n" );
223
224 /* test all functions with a closed path */
225 AbortPath( hdc );
226 BeginPath( hdc );
227 EndPath( hdc );
228 ret = WidenPath( hdc );
229 ok( ret, "WidenPath failed\n" );
230 ok( GetPath( hdc, NULL, NULL, 0 ) != -1, "path deleted\n" );
231
232 AbortPath( hdc );
233 BeginPath( hdc );
234 EndPath( hdc );
235 ret = FlattenPath( hdc );
236 ok( ret, "FlattenPath failed\n" );
237 ok( GetPath( hdc, NULL, NULL, 0 ) != -1, "path deleted\n" );
238
239 AbortPath( hdc );
240 BeginPath( hdc );
241 EndPath( hdc );
242 ret = StrokePath( hdc );
243 ok( ret, "StrokePath failed\n" );
244 ok( GetPath( hdc, NULL, NULL, 0 ) == -1, "path not deleted\n" );
245
246 BeginPath( hdc );
247 EndPath( hdc );
248 ret = FillPath( hdc );
249 ok( ret, "FillPath failed\n" );
250 ok( GetPath( hdc, NULL, NULL, 0 ) == -1, "path not deleted\n" );
251
252 BeginPath( hdc );
253 EndPath( hdc );
254 ret = StrokeAndFillPath( hdc );
255 ok( ret, "StrokeAndFillPath failed\n" );
256 ok( GetPath( hdc, NULL, NULL, 0 ) == -1, "path not deleted\n" );
257
258 BeginPath( hdc );
259 Rectangle( hdc, 1, 1, 10, 10 ); /* region needs some contents */
260 EndPath( hdc );
261 ret = SelectClipPath( hdc, RGN_OR );
262 ok( ret, "SelectClipPath failed\n" );
263 ok( GetPath( hdc, NULL, NULL, 0 ) == -1, "path not deleted\n" );
264
265 BeginPath( hdc );
266 EndPath( hdc );
267 SetLastError( 0xdeadbeef );
268 ret = SelectClipPath( hdc, RGN_OR );
269 ok( !ret, "SelectClipPath succeeded on empty path\n" );
270 ok( GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError() );
271 ok( GetPath( hdc, NULL, NULL, 0 ) == -1, "path not deleted\n" );
272
273 BeginPath( hdc );
274 Rectangle( hdc, 1, 1, 10, 10 ); /* region needs some contents */
275 EndPath( hdc );
276 rgn = PathToRegion( hdc );
277 ok( rgn != 0, "PathToRegion failed\n" );
278 DeleteObject( rgn );
279 ok( GetPath( hdc, NULL, NULL, 0 ) == -1, "path not deleted\n" );
280
281 BeginPath( hdc );
282 EndPath( hdc );
283 SetLastError( 0xdeadbeef );
284 rgn = PathToRegion( hdc );
285 ok( !rgn, "PathToRegion succeeded on empty path\n" );
286 ok( GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError() );
287 DeleteObject( rgn );
288 ok( GetPath( hdc, NULL, NULL, 0 ) == -1, "path not deleted\n" );
289
290 BeginPath( hdc );
291 EndPath( hdc );
292 SetLastError( 0xdeadbeef );
293 ret = CloseFigure( hdc );
294 ok( !ret, "CloseFigure succeeded\n" );
295 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
296 "wrong error %u\n", GetLastError() );
297
298 AbortPath( hdc );
299 BeginPath( hdc );
300 EndPath( hdc );
301 SetLastError( 0xdeadbeef );
302 ret = EndPath( hdc );
303 ok( !ret, "EndPath succeeded\n" );
304 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
305 "wrong error %u\n", GetLastError() );
306
307 DeleteDC( hdc );
308 DeleteObject( dib );
309 }
310
311 static void test_widenpath(void)
312 {
313 HDC hdc = GetDC(0);
314 HPEN greenPen, narrowPen;
315 POINT pnt[6];
316 INT nSize;
317 BOOL ret;
318
319 /* Create a pen to be used in WidenPath */
320 greenPen = CreatePen(PS_SOLID, 10, RGB(0,0,0));
321 SelectObject(hdc, greenPen);
322
323 /* Prepare a path */
324 pnt[0].x = 100;
325 pnt[0].y = 0;
326 pnt[1].x = 200;
327 pnt[1].y = 0;
328 pnt[2].x = 300;
329 pnt[2].y = 100;
330 pnt[3].x = 300;
331 pnt[3].y = 200;
332 pnt[4].x = 200;
333 pnt[4].y = 300;
334 pnt[5].x = 100;
335 pnt[5].y = 300;
336
337 /* Set a polyline path */
338 BeginPath(hdc);
339 Polyline(hdc, pnt, 6);
340 EndPath(hdc);
341
342 /* Widen the polyline path */
343 ok(WidenPath(hdc), "WidenPath fails while widening a poyline path.\n");
344
345 /* Test if WidenPath seems to have done his job */
346 nSize = GetPath(hdc, NULL, NULL, 0);
347 ok(nSize != -1, "GetPath fails after calling WidenPath.\n");
348 ok(nSize > 6, "Path number of points is too low. Should be more than 6 but is %d\n", nSize);
349
350 AbortPath(hdc);
351
352 /* Test WidenPath with an open path (last error only set on Win2k and later) */
353 SetLastError(0xdeadbeef);
354 BeginPath(hdc);
355 ret = WidenPath(hdc);
356 ok(ret == FALSE && (GetLastError() == ERROR_CAN_NOT_COMPLETE || GetLastError() == 0xdeadbeef),
357 "WidenPath fails while widening an open path. Return value is %d, should be %d. Error is %u\n", ret, FALSE, GetLastError());
358
359 AbortPath(hdc);
360
361 /* Test when the pen width is equal to 1. The path should change too */
362 narrowPen = CreatePen(PS_SOLID, 1, RGB(0,0,0));
363 SelectObject(hdc, narrowPen);
364 BeginPath(hdc);
365 Polyline(hdc, pnt, 6);
366 EndPath(hdc);
367 ret = WidenPath(hdc);
368 ok(ret == TRUE, "WidenPath failed: %d\n", GetLastError());
369 nSize = GetPath(hdc, NULL, NULL, 0);
370 ok(nSize > 6, "WidenPath should compute a widened path with a 1px wide pen. Path length is %d, should be more than 6\n", nSize);
371
372 ReleaseDC(0, hdc);
373 return;
374 }
375
376 /*
377 * Tests for GDI drawing functions in paths
378 */
379
380 typedef struct
381 {
382 int x, y;
383 BYTE type;
384 } path_test_t;
385
386 /* Helper function to verify that the current path in the given DC matches the expected path.
387 *
388 * We use a "smart" matching algorithm that allows us to detect partial improvements
389 * in conformance. Specifically, two running indices are kept, one through the actual
390 * path and one through the expected path. The actual path index increases unless there is
391 * no match and the todo field of the appropriate path_test_t element is 2. Similarly,
392 * if the wine_entries_preceding field of the appropriate path_test_t element is non-zero,
393 * the expected path index does not increase for that many elements as long as there
394 * is no match. This allows us to todo_wine extra path elements that are present only
395 * on wine but not on native and vice versa.
396 *
397 * Note that if expected_size is zero and the WINETEST_DEBUG environment variable is
398 * greater than 2, the trace() output is a C path_test_t array structure, useful for making
399 * new tests that use this function.
400 */
401 static void ok_path(HDC hdc, const char *path_name, const path_test_t *expected, int expected_size)
402 {
403 static const char *type_string[8] = { "Unknown (0)", "PT_CLOSEFIGURE", "PT_LINETO",
404 "PT_LINETO | PT_CLOSEFIGURE", "PT_BEZIERTO",
405 "PT_BEZIERTO | PT_CLOSEFIGURE", "PT_MOVETO", "PT_MOVETO | PT_CLOSEFIGURE"};
406 POINT *pnt;
407 BYTE *types;
408 int size, idx;
409
410 /* Get the path */
411 assert(hdc != 0);
412 size = GetPath(hdc, NULL, NULL, 0);
413 ok(size > 0, "GetPath returned size %d, last error %d\n", size, GetLastError());
414 if (size <= 0) return;
415
416 pnt = HeapAlloc(GetProcessHeap(), 0, size*sizeof(POINT));
417 assert(pnt != 0);
418 types = HeapAlloc(GetProcessHeap(), 0, size*sizeof(BYTE));
419 assert(types != 0);
420 size = GetPath(hdc, pnt, types, size);
421 assert(size > 0);
422
423 ok( size == expected_size, "%s: Path size %d does not match expected size %d\n",
424 path_name, size, expected_size);
425
426 for (idx = 0; idx < min( size, expected_size ); idx++)
427 {
428 /* We allow a few pixels fudge in matching X and Y coordinates to account for imprecision in
429 * floating point to integer conversion */
430 static const int fudge = 2;
431
432 ok( types[idx] == expected[idx].type, "%s: Expected #%d: %s (%d,%d) but got %s (%d,%d)\n",
433 path_name, idx, type_string[expected[idx].type], expected[idx].x, expected[idx].y,
434 type_string[types[idx]], pnt[idx].x, pnt[idx].y);
435
436 if (types[idx] == expected[idx].type)
437 ok( (pnt[idx].x >= expected[idx].x - fudge && pnt[idx].x <= expected[idx].x + fudge) &&
438 (pnt[idx].y >= expected[idx].y - fudge && pnt[idx].y <= expected[idx].y + fudge),
439 "%s: Expected #%d: %s position (%d,%d) but got (%d,%d)\n", path_name, idx,
440 type_string[expected[idx].type], expected[idx].x, expected[idx].y, pnt[idx].x, pnt[idx].y);
441 }
442
443 if (winetest_debug > 2)
444 {
445 printf("static const path_test_t %s[] =\n{\n", path_name);
446 for (idx = 0; idx < size; idx++)
447 printf(" {%d, %d, %s}, /* %d */\n", pnt[idx].x, pnt[idx].y, type_string[types[idx]], idx);
448 printf("};\n" );
449 }
450
451 HeapFree(GetProcessHeap(), 0, types);
452 HeapFree(GetProcessHeap(), 0, pnt);
453 }
454
455 static const path_test_t arcto_path[] =
456 {
457 {0, 0, PT_MOVETO}, /* 0 */
458 {229, 215, PT_LINETO}, /* 1 */
459 {248, 205, PT_BEZIERTO}, /* 2 */
460 {273, 200, PT_BEZIERTO}, /* 3 */
461 {300, 200, PT_BEZIERTO}, /* 4 */
462 {355, 200, PT_BEZIERTO}, /* 5 */
463 {399, 222, PT_BEZIERTO}, /* 6 */
464 {399, 250, PT_BEZIERTO}, /* 7 */
465 {399, 263, PT_BEZIERTO}, /* 8 */
466 {389, 275, PT_BEZIERTO}, /* 9 */
467 {370, 285, PT_BEZIERTO}, /* 10 */
468 {363, 277, PT_LINETO}, /* 11 */
469 {380, 270, PT_BEZIERTO}, /* 12 */
470 {389, 260, PT_BEZIERTO}, /* 13 */
471 {389, 250, PT_BEZIERTO}, /* 14 */
472 {389, 228, PT_BEZIERTO}, /* 15 */
473 {349, 210, PT_BEZIERTO}, /* 16 */
474 {300, 210, PT_BEZIERTO}, /* 17 */
475 {276, 210, PT_BEZIERTO}, /* 18 */
476 {253, 214, PT_BEZIERTO}, /* 19 */
477 {236, 222, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 20 */
478 };
479
480 static void test_arcto(void)
481 {
482 HDC hdc = GetDC(0);
483
484 BeginPath(hdc);
485 SetArcDirection(hdc, AD_CLOCKWISE);
486 if (!ArcTo(hdc, 200, 200, 400, 300, 200, 200, 400, 300) &&
487 GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
488 {
489 /* ArcTo is only available on Win2k and later */
490 win_skip("ArcTo is not available\n");
491 goto done;
492 }
493 SetArcDirection(hdc, AD_COUNTERCLOCKWISE);
494 ArcTo(hdc, 210, 210, 390, 290, 390, 290, 210, 210);
495 CloseFigure(hdc);
496 EndPath(hdc);
497
498 ok_path(hdc, "arcto_path", arcto_path, sizeof(arcto_path)/sizeof(path_test_t));
499 done:
500 ReleaseDC(0, hdc);
501 }
502
503 static const path_test_t anglearc_path[] =
504 {
505 {0, 0, PT_MOVETO}, /* 0 */
506 {371, 229, PT_LINETO}, /* 1 */
507 {352, 211, PT_BEZIERTO}, /* 2 */
508 {327, 200, PT_BEZIERTO}, /* 3 */
509 {300, 200, PT_BEZIERTO}, /* 4 */
510 {245, 200, PT_BEZIERTO}, /* 5 */
511 {200, 245, PT_BEZIERTO}, /* 6 */
512 {200, 300, PT_BEZIERTO}, /* 7 */
513 {200, 300, PT_BEZIERTO}, /* 8 */
514 {200, 300, PT_BEZIERTO}, /* 9 */
515 {200, 300, PT_BEZIERTO}, /* 10 */
516 {231, 260, PT_LINETO}, /* 11 */
517 {245, 235, PT_BEZIERTO}, /* 12 */
518 {271, 220, PT_BEZIERTO}, /* 13 */
519 {300, 220, PT_BEZIERTO}, /* 14 */
520 {344, 220, PT_BEZIERTO}, /* 15 */
521 {380, 256, PT_BEZIERTO}, /* 16 */
522 {380, 300, PT_BEZIERTO}, /* 17 */
523 {380, 314, PT_BEZIERTO}, /* 18 */
524 {376, 328, PT_BEZIERTO}, /* 19 */
525 {369, 340, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 20 */
526 };
527
528 static void test_anglearc(void)
529 {
530 HDC hdc = GetDC(0);
531 BeginPath(hdc);
532 if (!AngleArc(hdc, 300, 300, 100, 45.0, 135.0) &&
533 GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
534 {
535 /* AngleArc is only available on Win2k and later */
536 win_skip("AngleArc is not available\n");
537 goto done;
538 }
539 AngleArc(hdc, 300, 300, 80, 150.0, -180.0);
540 CloseFigure(hdc);
541 EndPath(hdc);
542
543 ok_path(hdc, "anglearc_path", anglearc_path, sizeof(anglearc_path)/sizeof(path_test_t));
544 done:
545 ReleaseDC(0, hdc);
546 }
547
548 static const path_test_t polydraw_path[] =
549 {
550 {-20, -20, PT_MOVETO}, /* 0 */
551 {10, 10, PT_LINETO}, /* 1 */
552 {10, 15, PT_LINETO | PT_CLOSEFIGURE}, /* 2 */
553 {-20, -20, PT_MOVETO}, /* 3 */
554 {-10, -10, PT_LINETO}, /* 4 */
555 {100, 100, PT_MOVETO}, /* 5 */
556 {95, 95, PT_LINETO}, /* 6 */
557 {10, 10, PT_LINETO}, /* 7 */
558 {10, 15, PT_LINETO | PT_CLOSEFIGURE}, /* 8 */
559 {100, 100, PT_MOVETO}, /* 9 */
560 {15, 15, PT_LINETO}, /* 10 */
561 {25, 25, PT_MOVETO}, /* 11 */
562 {25, 30, PT_LINETO}, /* 12 */
563 {100, 100, PT_MOVETO}, /* 13 */
564 {30, 30, PT_BEZIERTO}, /* 14 */
565 {30, 35, PT_BEZIERTO}, /* 15 */
566 {35, 35, PT_BEZIERTO}, /* 16 */
567 {35, 40, PT_LINETO}, /* 17 */
568 {40, 40, PT_MOVETO}, /* 18 */
569 {40, 45, PT_LINETO}, /* 19 */
570 {35, 40, PT_MOVETO}, /* 20 */
571 {45, 50, PT_LINETO}, /* 21 */
572 {35, 40, PT_MOVETO}, /* 22 */
573 {50, 55, PT_LINETO}, /* 23 */
574 {45, 50, PT_LINETO}, /* 24 */
575 {35, 40, PT_MOVETO}, /* 25 */
576 {60, 60, PT_LINETO}, /* 26 */
577 {60, 65, PT_MOVETO}, /* 27 */
578 {65, 65, PT_LINETO}, /* 28 */
579 {75, 75, PT_MOVETO}, /* 29 */
580 {80, 80, PT_LINETO | PT_CLOSEFIGURE}, /* 30 */
581 };
582
583 static POINT polydraw_pts[] = {
584 {10, 10}, {10, 15},
585 {15, 15}, {15, 20}, {20, 20}, {20, 25},
586 {25, 25}, {25, 30},
587 {30, 30}, {30, 35}, {35, 35}, {35, 40},
588 {40, 40}, {40, 45}, {45, 45},
589 {45, 50}, {50, 50},
590 {50, 55}, {45, 50}, {55, 60},
591 {60, 60}, {60, 65}, {65, 65},
592 {70, 70}, {75, 70}, {75, 75}, {80, 80}};
593
594 static BYTE polydraw_tps[] =
595 {PT_LINETO, PT_CLOSEFIGURE | PT_LINETO, /* 2 */
596 PT_LINETO, PT_BEZIERTO, PT_LINETO, PT_LINETO, /* 6 */
597 PT_MOVETO, PT_LINETO, /* 8 */
598 PT_BEZIERTO, PT_BEZIERTO, PT_BEZIERTO, PT_LINETO, /* 12 */
599 PT_MOVETO, PT_LINETO, PT_CLOSEFIGURE, /* 15 */
600 PT_LINETO, PT_MOVETO | PT_CLOSEFIGURE, /* 17 */
601 PT_LINETO, PT_LINETO, PT_MOVETO | PT_CLOSEFIGURE, /* 20 */
602 PT_LINETO, PT_MOVETO | PT_LINETO, PT_LINETO, /* 23 */
603 PT_MOVETO, PT_MOVETO, PT_MOVETO, PT_LINETO | PT_CLOSEFIGURE}; /* 27 */
604
605 static void test_polydraw(void)
606 {
607 BOOL retb;
608 POINT pos;
609 HDC hdc = GetDC(0);
610
611 MoveToEx( hdc, -20, -20, NULL );
612
613 BeginPath(hdc);
614 GetCurrentPositionEx( hdc, &pos );
615 ok( pos.x == -20 && pos.y == -20, "wrong pos %d,%d\n", pos.x, pos.y );
616
617 /* closefigure with no previous moveto */
618 if (!(retb = PolyDraw(hdc, polydraw_pts, polydraw_tps, 2)) &&
619 GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
620 {
621 /* PolyDraw is only available on Win2k and later */
622 win_skip("PolyDraw is not available\n");
623 goto done;
624 }
625 expect(TRUE, retb);
626 GetCurrentPositionEx( hdc, &pos );
627 ok( pos.x == 10 && pos.y == 15, "wrong pos %d,%d\n", pos.x, pos.y );
628 LineTo(hdc, -10, -10);
629 GetCurrentPositionEx( hdc, &pos );
630 ok( pos.x == -10 && pos.y == -10, "wrong pos %d,%d\n", pos.x, pos.y );
631
632 MoveToEx(hdc, 100, 100, NULL);
633 GetCurrentPositionEx( hdc, &pos );
634 ok( pos.x == 100 && pos.y == 100, "wrong pos %d,%d\n", pos.x, pos.y );
635 LineTo(hdc, 95, 95);
636 GetCurrentPositionEx( hdc, &pos );
637 ok( pos.x == 95 && pos.y == 95, "wrong pos %d,%d\n", pos.x, pos.y );
638 /* closefigure with previous moveto */
639 retb = PolyDraw(hdc, polydraw_pts, polydraw_tps, 2);
640 expect(TRUE, retb);
641 GetCurrentPositionEx( hdc, &pos );
642 ok( pos.x == 10 && pos.y == 15, "wrong pos %d,%d\n", pos.x, pos.y );
643 /* bad bezier points */
644 retb = PolyDraw(hdc, &(polydraw_pts[2]), &(polydraw_tps[2]), 4);
645 expect(FALSE, retb);
646 GetCurrentPositionEx( hdc, &pos );
647 ok( pos.x == 10 && pos.y == 15, "wrong pos %d,%d\n", pos.x, pos.y );
648 retb = PolyDraw(hdc, &(polydraw_pts[6]), &(polydraw_tps[6]), 4);
649 expect(FALSE, retb);
650 GetCurrentPositionEx( hdc, &pos );
651 ok( pos.x == 10 && pos.y == 15, "wrong pos %d,%d\n", pos.x, pos.y );
652 /* good bezier points */
653 retb = PolyDraw(hdc, &(polydraw_pts[8]), &(polydraw_tps[8]), 4);
654 expect(TRUE, retb);
655 GetCurrentPositionEx( hdc, &pos );
656 ok( pos.x == 35 && pos.y == 40, "wrong pos %d,%d\n", pos.x, pos.y );
657 /* does lineto or bezierto take precedence? */
658 retb = PolyDraw(hdc, &(polydraw_pts[12]), &(polydraw_tps[12]), 4);
659 expect(FALSE, retb);
660 GetCurrentPositionEx( hdc, &pos );
661 ok( pos.x == 35 && pos.y == 40, "wrong pos %d,%d\n", pos.x, pos.y );
662 /* bad point type, has already moved cursor position */
663 retb = PolyDraw(hdc, &(polydraw_pts[15]), &(polydraw_tps[15]), 4);
664 expect(FALSE, retb);
665 GetCurrentPositionEx( hdc, &pos );
666 ok( pos.x == 35 && pos.y == 40, "wrong pos %d,%d\n", pos.x, pos.y );
667 /* bad point type, cursor position is moved, but back to its original spot */
668 retb = PolyDraw(hdc, &(polydraw_pts[17]), &(polydraw_tps[17]), 4);
669 expect(FALSE, retb);
670 GetCurrentPositionEx( hdc, &pos );
671 ok( pos.x == 35 && pos.y == 40, "wrong pos %d,%d\n", pos.x, pos.y );
672 /* does lineto or moveto take precedence? */
673 retb = PolyDraw(hdc, &(polydraw_pts[20]), &(polydraw_tps[20]), 3);
674 expect(TRUE, retb);
675 GetCurrentPositionEx( hdc, &pos );
676 ok( pos.x == 65 && pos.y == 65, "wrong pos %d,%d\n", pos.x, pos.y );
677 /* consecutive movetos */
678 retb = PolyDraw(hdc, &(polydraw_pts[23]), &(polydraw_tps[23]), 4);
679 expect(TRUE, retb);
680 GetCurrentPositionEx( hdc, &pos );
681 ok( pos.x == 80 && pos.y == 80, "wrong pos %d,%d\n", pos.x, pos.y );
682
683 EndPath(hdc);
684 ok_path(hdc, "polydraw_path", polydraw_path, sizeof(polydraw_path)/sizeof(path_test_t));
685 GetCurrentPositionEx( hdc, &pos );
686 ok( pos.x == 80 && pos.y == 80, "wrong pos %d,%d\n", pos.x, pos.y );
687 done:
688 ReleaseDC(0, hdc);
689 }
690
691 static void test_closefigure(void) {
692 int nSize, nSizeWitness;
693 POINT pos;
694 HDC hdc = GetDC(0);
695
696 MoveToEx( hdc, 100, 100, NULL );
697 GetCurrentPositionEx( hdc, &pos );
698 ok( pos.x == 100 && pos.y == 100, "wrong pos %d,%d\n", pos.x, pos.y );
699
700 BeginPath(hdc);
701 GetCurrentPositionEx( hdc, &pos );
702 ok( pos.x == 100 && pos.y == 100, "wrong pos %d,%d\n", pos.x, pos.y );
703 MoveToEx(hdc, 95, 95, NULL);
704 GetCurrentPositionEx( hdc, &pos );
705 ok( pos.x == 95 && pos.y == 95, "wrong pos %d,%d\n", pos.x, pos.y );
706 LineTo(hdc, 95, 0);
707 GetCurrentPositionEx( hdc, &pos );
708 ok( pos.x == 95 && pos.y == 0, "wrong pos %d,%d\n", pos.x, pos.y );
709 LineTo(hdc, 0, 95);
710 GetCurrentPositionEx( hdc, &pos );
711 ok( pos.x == 0 && pos.y == 95, "wrong pos %d,%d\n", pos.x, pos.y );
712
713 CloseFigure(hdc);
714 GetCurrentPositionEx( hdc, &pos );
715 ok( pos.x == 0 && pos.y == 95, "wrong pos %d,%d\n", pos.x, pos.y );
716 EndPath(hdc);
717 GetCurrentPositionEx( hdc, &pos );
718 ok( pos.x == 0 && pos.y == 95, "wrong pos %d,%d\n", pos.x, pos.y );
719 nSize = GetPath(hdc, NULL, NULL, 0);
720
721 AbortPath(hdc);
722
723 BeginPath(hdc);
724 MoveToEx(hdc, 95, 95, NULL);
725 LineTo(hdc, 95, 0);
726 LineTo(hdc, 0, 95);
727
728 EndPath(hdc);
729 nSizeWitness = GetPath(hdc, NULL, NULL, 0);
730
731 /* This test shows CloseFigure does not have to add a point at the end of the path */
732 ok(nSize == nSizeWitness, "Wrong number of points, no point should be added by CloseFigure\n");
733
734 ReleaseDC(0, hdc);
735 }
736
737 static void WINAPI linedda_callback(INT x, INT y, LPARAM lparam)
738 {
739 POINT **pt = (POINT**)lparam;
740 ok((*pt)->x == x && (*pt)->y == y, "point mismatch expect(%d,%d) got(%d,%d)\n",
741 (*pt)->x, (*pt)->y, x, y);
742
743 (*pt)++;
744 return;
745 }
746
747 static void test_linedda(void)
748 {
749 const POINT *pt;
750 static const POINT array_10_20_20_40[] = {{10,20},{10,21},{11,22},{11,23},
751 {12,24},{12,25},{13,26},{13,27},
752 {14,28},{14,29},{15,30},{15,31},
753 {16,32},{16,33},{17,34},{17,35},
754 {18,36},{18,37},{19,38},{19,39},
755 {-1,-1}};
756 static const POINT array_10_20_20_43[] = {{10,20},{10,21},{11,22},{11,23},
757 {12,24},{12,25},{13,26},{13,27},
758 {13,28},{14,29},{14,30},{15,31},
759 {15,32},{16,33},{16,34},{17,35},
760 {17,36},{17,37},{18,38},{18,39},
761 {19,40},{19,41},{20,42},{-1,-1}};
762
763 static const POINT array_10_20_10_20[] = {{-1,-1}};
764 static const POINT array_10_20_11_27[] = {{10,20},{10,21},{10,22},{10,23},
765 {11,24},{11,25},{11,26},{-1,-1}};
766
767 static const POINT array_20_43_10_20[] = {{20,43},{20,42},{19,41},{19,40},
768 {18,39},{18,38},{17,37},{17,36},
769 {17,35},{16,34},{16,33},{15,32},
770 {15,31},{14,30},{14,29},{13,28},
771 {13,27},{13,26},{12,25},{12,24},
772 {11,23},{11,22},{10,21},{-1,-1}};
773
774 static const POINT array_20_20_10_43[] = {{20,20},{20,21},{19,22},{19,23},
775 {18,24},{18,25},{17,26},{17,27},
776 {17,28},{16,29},{16,30},{15,31},
777 {15,32},{14,33},{14,34},{13,35},
778 {13,36},{13,37},{12,38},{12,39},
779 {11,40},{11,41},{10,42},{-1,-1}};
780
781 static const POINT array_20_20_43_10[] = {{20,20},{21,20},{22,19},{23,19},
782 {24,18},{25,18},{26,17},{27,17},
783 {28,17},{29,16},{30,16},{31,15},
784 {32,15},{33,14},{34,14},{35,13},
785 {36,13},{37,13},{38,12},{39,12},
786 {40,11},{41,11},{42,10},{-1,-1}};
787
788
789 pt = array_10_20_20_40;
790 LineDDA(10, 20, 20, 40, linedda_callback, (LPARAM)&pt);
791 ok(pt->x == -1 && pt->y == -1, "didn't find terminator\n");
792
793 pt = array_10_20_20_43;
794 LineDDA(10, 20, 20, 43, linedda_callback, (LPARAM)&pt);
795 ok(pt->x == -1 && pt->y == -1, "didn't find terminator\n");
796
797 pt = array_10_20_10_20;
798 LineDDA(10, 20, 10, 20, linedda_callback, (LPARAM)&pt);
799 ok(pt->x == -1 && pt->y == -1, "didn't find terminator\n");
800
801 pt = array_10_20_11_27;
802 LineDDA(10, 20, 11, 27, linedda_callback, (LPARAM)&pt);
803 ok(pt->x == -1 && pt->y == -1, "didn't find terminator\n");
804
805 pt = array_20_43_10_20;
806 LineDDA(20, 43, 10, 20, linedda_callback, (LPARAM)&pt);
807 ok(pt->x == -1 && pt->y == -1, "didn't find terminator\n");
808
809 pt = array_20_20_10_43;
810 LineDDA(20, 20, 10, 43, linedda_callback, (LPARAM)&pt);
811 ok(pt->x == -1 && pt->y == -1, "didn't find terminator\n");
812
813 pt = array_20_20_43_10;
814 LineDDA(20, 20, 43, 10, linedda_callback, (LPARAM)&pt);
815 ok(pt->x == -1 && pt->y == -1, "didn't find terminator\n");
816 }
817
818 static const path_test_t rectangle_path[] =
819 {
820 {39, 20, PT_MOVETO}, /* 0 */
821 {20, 20, PT_LINETO}, /* 1 */
822 {20, 39, PT_LINETO}, /* 2 */
823 {39, 39, PT_LINETO | PT_CLOSEFIGURE}, /* 3 */
824 {54, 35, PT_MOVETO}, /* 4 */
825 {30, 35, PT_LINETO}, /* 5 */
826 {30, 49, PT_LINETO}, /* 6 */
827 {54, 49, PT_LINETO | PT_CLOSEFIGURE}, /* 7 */
828 {59, 45, PT_MOVETO}, /* 8 */
829 {35, 45, PT_LINETO}, /* 9 */
830 {35, 59, PT_LINETO}, /* 10 */
831 {59, 59, PT_LINETO | PT_CLOSEFIGURE}, /* 11 */
832 {80, 80, PT_MOVETO}, /* 12 */
833 {80, 80, PT_LINETO}, /* 13 */
834 {80, 80, PT_LINETO}, /* 14 */
835 {80, 80, PT_LINETO | PT_CLOSEFIGURE}, /* 15 */
836 {39, 39, PT_MOVETO}, /* 16 */
837 {20, 39, PT_LINETO}, /* 17 */
838 {20, 20, PT_LINETO}, /* 18 */
839 {39, 20, PT_LINETO | PT_CLOSEFIGURE}, /* 19 */
840 {54, 49, PT_MOVETO}, /* 20 */
841 {30, 49, PT_LINETO}, /* 21 */
842 {30, 35, PT_LINETO}, /* 22 */
843 {54, 35, PT_LINETO | PT_CLOSEFIGURE}, /* 23 */
844 {59, 59, PT_MOVETO}, /* 24 */
845 {35, 59, PT_LINETO}, /* 25 */
846 {35, 45, PT_LINETO}, /* 26 */
847 {59, 45, PT_LINETO | PT_CLOSEFIGURE}, /* 27 */
848 {80, 80, PT_MOVETO}, /* 28 */
849 {80, 80, PT_LINETO}, /* 29 */
850 {80, 80, PT_LINETO}, /* 30 */
851 {80, 80, PT_LINETO | PT_CLOSEFIGURE}, /* 31 */
852 {-41, 40, PT_MOVETO}, /* 32 */
853 {-80, 40, PT_LINETO}, /* 33 */
854 {-80, 79, PT_LINETO}, /* 34 */
855 {-41, 79, PT_LINETO | PT_CLOSEFIGURE}, /* 35 */
856 {-61, 70, PT_MOVETO}, /* 36 */
857 {-110, 70, PT_LINETO}, /* 37 */
858 {-110, 99, PT_LINETO}, /* 38 */
859 {-61, 99, PT_LINETO | PT_CLOSEFIGURE}, /* 39 */
860 {119, -120, PT_MOVETO}, /* 40 */
861 {60, -120, PT_LINETO}, /* 41 */
862 {60, -61, PT_LINETO}, /* 42 */
863 {119, -61, PT_LINETO | PT_CLOSEFIGURE}, /* 43 */
864 {164, -150, PT_MOVETO}, /* 44 */
865 {90, -150, PT_LINETO}, /* 45 */
866 {90, -106, PT_LINETO}, /* 46 */
867 {164, -106, PT_LINETO | PT_CLOSEFIGURE}, /* 47 */
868 {-4, -6, PT_MOVETO}, /* 48 */
869 {-6, -6, PT_LINETO}, /* 49 */
870 {-6, -4, PT_LINETO}, /* 50 */
871 {-4, -4, PT_LINETO | PT_CLOSEFIGURE}, /* 51 */
872 {40, 20, PT_MOVETO}, /* 52 */
873 {20, 20, PT_LINETO}, /* 53 */
874 {20, 40, PT_LINETO}, /* 54 */
875 {40, 40, PT_LINETO | PT_CLOSEFIGURE}, /* 55 */
876 {55, 35, PT_MOVETO}, /* 56 */
877 {30, 35, PT_LINETO}, /* 57 */
878 {30, 50, PT_LINETO}, /* 58 */
879 {55, 50, PT_LINETO | PT_CLOSEFIGURE}, /* 59 */
880 {60, 45, PT_MOVETO}, /* 60 */
881 {35, 45, PT_LINETO}, /* 61 */
882 {35, 60, PT_LINETO}, /* 62 */
883 {60, 60, PT_LINETO | PT_CLOSEFIGURE}, /* 63 */
884 {70, 70, PT_MOVETO}, /* 64 */
885 {50, 70, PT_LINETO}, /* 65 */
886 {50, 70, PT_LINETO}, /* 66 */
887 {70, 70, PT_LINETO | PT_CLOSEFIGURE}, /* 67 */
888 {75, 75, PT_MOVETO}, /* 68 */
889 {75, 75, PT_LINETO}, /* 69 */
890 {75, 85, PT_LINETO}, /* 70 */
891 {75, 85, PT_LINETO | PT_CLOSEFIGURE}, /* 71 */
892 {81, 80, PT_MOVETO}, /* 72 */
893 {80, 80, PT_LINETO}, /* 73 */
894 {80, 81, PT_LINETO}, /* 74 */
895 {81, 81, PT_LINETO | PT_CLOSEFIGURE}, /* 75 */
896 {40, 40, PT_MOVETO}, /* 76 */
897 {20, 40, PT_LINETO}, /* 77 */
898 {20, 20, PT_LINETO}, /* 78 */
899 {40, 20, PT_LINETO | PT_CLOSEFIGURE}, /* 79 */
900 {55, 50, PT_MOVETO}, /* 80 */
901 {30, 50, PT_LINETO}, /* 81 */
902 {30, 35, PT_LINETO}, /* 82 */
903 {55, 35, PT_LINETO | PT_CLOSEFIGURE}, /* 83 */
904 {60, 60, PT_MOVETO}, /* 84 */
905 {35, 60, PT_LINETO}, /* 85 */
906 {35, 45, PT_LINETO}, /* 86 */
907 {60, 45, PT_LINETO | PT_CLOSEFIGURE}, /* 87 */
908 {70, 70, PT_MOVETO}, /* 88 */
909 {50, 70, PT_LINETO}, /* 89 */
910 {50, 70, PT_LINETO}, /* 90 */
911 {70, 70, PT_LINETO | PT_CLOSEFIGURE}, /* 91 */
912 {75, 85, PT_MOVETO}, /* 92 */
913 {75, 85, PT_LINETO}, /* 93 */
914 {75, 75, PT_LINETO}, /* 94 */
915 {75, 75, PT_LINETO | PT_CLOSEFIGURE}, /* 95 */
916 {81, 81, PT_MOVETO}, /* 96 */
917 {80, 81, PT_LINETO}, /* 97 */
918 {80, 80, PT_LINETO}, /* 98 */
919 {81, 80, PT_LINETO | PT_CLOSEFIGURE}, /* 99 */
920 };
921
922 static void test_rectangle(void)
923 {
924 HDC hdc = GetDC( 0 );
925
926 BeginPath( hdc );
927 Rectangle( hdc, 20, 20, 40, 40 );
928 Rectangle( hdc, 30, 50, 55, 35 );
929 Rectangle( hdc, 60, 60, 35, 45 );
930 Rectangle( hdc, 70, 70, 50, 70 );
931 Rectangle( hdc, 75, 75, 75, 85 );
932 Rectangle( hdc, 80, 80, 81, 81 );
933 SetArcDirection( hdc, AD_CLOCKWISE );
934 Rectangle( hdc, 20, 20, 40, 40 );
935 Rectangle( hdc, 30, 50, 55, 35 );
936 Rectangle( hdc, 60, 60, 35, 45 );
937 Rectangle( hdc, 70, 70, 50, 70 );
938 Rectangle( hdc, 75, 75, 75, 85 );
939 Rectangle( hdc, 80, 80, 81, 81 );
940 SetArcDirection( hdc, AD_COUNTERCLOCKWISE );
941 SetMapMode( hdc, MM_ANISOTROPIC );
942 SetViewportExtEx( hdc, -2, 2, NULL );
943 Rectangle( hdc, 20, 20, 40, 40 );
944 Rectangle( hdc, 30, 50, 55, 35 );
945 SetViewportExtEx( hdc, 3, -3, NULL );
946 Rectangle( hdc, 20, 20, 40, 40 );
947 Rectangle( hdc, 30, 50, 55, 35 );
948 SetWindowExtEx( hdc, -20, 20, NULL );
949 Rectangle( hdc, 20, 20, 40, 40 );
950 Rectangle( hdc, 24, 22, 21, 20 );
951 SetMapMode( hdc, MM_TEXT );
952 SetGraphicsMode( hdc, GM_ADVANCED );
953 Rectangle( hdc, 20, 20, 40, 40 );
954 Rectangle( hdc, 30, 50, 55, 35 );
955 Rectangle( hdc, 60, 60, 35, 45 );
956 Rectangle( hdc, 70, 70, 50, 70 );
957 Rectangle( hdc, 75, 75, 75, 85 );
958 Rectangle( hdc, 80, 80, 81, 81 );
959 SetArcDirection( hdc, AD_CLOCKWISE );
960 Rectangle( hdc, 20, 20, 40, 40 );
961 Rectangle( hdc, 30, 50, 55, 35 );
962 Rectangle( hdc, 60, 60, 35, 45 );
963 Rectangle( hdc, 70, 70, 50, 70 );
964 Rectangle( hdc, 75, 75, 75, 85 );
965 Rectangle( hdc, 80, 80, 81, 81 );
966 SetArcDirection( hdc, AD_COUNTERCLOCKWISE );
967 EndPath( hdc );
968 SetMapMode( hdc, MM_TEXT );
969 ok_path( hdc, "rectangle_path", rectangle_path, sizeof(rectangle_path)/sizeof(path_test_t) );
970 ReleaseDC( 0, hdc );
971 }
972
973 static const path_test_t roundrect_path[] =
974 {
975 {39, 25, PT_MOVETO}, /* 0 */
976 {39, 22, PT_BEZIERTO}, /* 1 */
977 {37, 20, PT_BEZIERTO}, /* 2 */
978 {34, 20, PT_BEZIERTO}, /* 3 */
979 {25, 20, PT_LINETO}, /* 4 */
980 {22, 20, PT_BEZIERTO}, /* 5 */
981 {20, 22, PT_BEZIERTO}, /* 6 */
982 {20, 25, PT_BEZIERTO}, /* 7 */
983 {20, 34, PT_LINETO}, /* 8 */
984 {20, 37, PT_BEZIERTO}, /* 9 */
985 {22, 39, PT_BEZIERTO}, /* 10 */
986 {25, 39, PT_BEZIERTO}, /* 11 */
987 {34, 39, PT_LINETO}, /* 12 */
988 {37, 39, PT_BEZIERTO}, /* 13 */
989 {39, 37, PT_BEZIERTO}, /* 14 */
990 {39, 34, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 15 */
991 {54, 42, PT_MOVETO}, /* 16 */
992 {54, 38, PT_BEZIERTO}, /* 17 */
993 {49, 35, PT_BEZIERTO}, /* 18 */
994 {42, 35, PT_BEZIERTO}, /* 19 */
995 {42, 35, PT_LINETO}, /* 20 */
996 {35, 35, PT_BEZIERTO}, /* 21 */
997 {30, 38, PT_BEZIERTO}, /* 22 */
998 {30, 42, PT_BEZIERTO}, /* 23 */
999 {30, 42, PT_LINETO}, /* 24 */
1000 {30, 46, PT_BEZIERTO}, /* 25 */
1001 {35, 49, PT_BEZIERTO}, /* 26 */
1002 {42, 49, PT_BEZIERTO}, /* 27 */
1003 {42, 49, PT_LINETO}, /* 28 */
1004 {49, 49, PT_BEZIERTO}, /* 29 */
1005 {54, 46, PT_BEZIERTO}, /* 30 */
1006 {54, 42, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 31 */
1007 {59, 46, PT_MOVETO}, /* 32 */
1008 {59, 45, PT_BEZIERTO}, /* 33 */
1009 {58, 45, PT_BEZIERTO}, /* 34 */
1010 {57, 45, PT_BEZIERTO}, /* 35 */
1011 {37, 45, PT_LINETO}, /* 36 */
1012 {36, 45, PT_BEZIERTO}, /* 37 */
1013 {35, 45, PT_BEZIERTO}, /* 38 */
1014 {35, 46, PT_BEZIERTO}, /* 39 */
1015 {35, 58, PT_LINETO}, /* 40 */
1016 {35, 59, PT_BEZIERTO}, /* 41 */
1017 {36, 59, PT_BEZIERTO}, /* 42 */
1018 {37, 59, PT_BEZIERTO}, /* 43 */
1019 {57, 59, PT_LINETO}, /* 44 */
1020 {58, 59, PT_BEZIERTO}, /* 45 */
1021 {59, 59, PT_BEZIERTO}, /* 46 */
1022 {59, 58, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 47 */
1023 {80, 80, PT_MOVETO}, /* 48 */
1024 {80, 80, PT_BEZIERTO}, /* 49 */
1025 {80, 80, PT_BEZIERTO}, /* 50 */
1026 {80, 80, PT_BEZIERTO}, /* 51 */
1027 {80, 80, PT_LINETO}, /* 52 */
1028 {80, 80, PT_BEZIERTO}, /* 53 */
1029 {80, 80, PT_BEZIERTO}, /* 54 */
1030 {80, 80, PT_BEZIERTO}, /* 55 */
1031 {80, 80, PT_LINETO}, /* 56 */
1032 {80, 80, PT_BEZIERTO}, /* 57 */
1033 {80, 80, PT_BEZIERTO}, /* 58 */
1034 {80, 80, PT_BEZIERTO}, /* 59 */
1035 {80, 80, PT_LINETO}, /* 60 */
1036 {80, 80, PT_BEZIERTO}, /* 61 */
1037 {80, 80, PT_BEZIERTO}, /* 62 */
1038 {80, 80, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 63 */
1039 {94, 85, PT_MOVETO}, /* 64 */
1040 {90, 85, PT_LINETO}, /* 65 */
1041 {90, 89, PT_LINETO}, /* 66 */
1042 {94, 89, PT_LINETO | PT_CLOSEFIGURE}, /* 67 */
1043 {39, 34, PT_MOVETO}, /* 68 */
1044 {39, 37, PT_BEZIERTO}, /* 69 */
1045 {37, 39, PT_BEZIERTO}, /* 70 */
1046 {34, 39, PT_BEZIERTO}, /* 71 */
1047 {25, 39, PT_LINETO}, /* 72 */
1048 {22, 39, PT_BEZIERTO}, /* 73 */
1049 {20, 37, PT_BEZIERTO}, /* 74 */
1050 {20, 34, PT_BEZIERTO}, /* 75 */
1051 {20, 25, PT_LINETO}, /* 76 */
1052 {20, 22, PT_BEZIERTO}, /* 77 */
1053 {22, 20, PT_BEZIERTO}, /* 78 */
1054 {25, 20, PT_BEZIERTO}, /* 79 */
1055 {34, 20, PT_LINETO}, /* 80 */
1056 {37, 20, PT_BEZIERTO}, /* 81 */
1057 {39, 22, PT_BEZIERTO}, /* 82 */
1058 {39, 25, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 83 */
1059 {54, 42, PT_MOVETO}, /* 84 */
1060 {54, 46, PT_BEZIERTO}, /* 85 */
1061 {49, 49, PT_BEZIERTO}, /* 86 */
1062 {42, 49, PT_BEZIERTO}, /* 87 */
1063 {42, 49, PT_LINETO}, /* 88 */
1064 {35, 49, PT_BEZIERTO}, /* 89 */
1065 {30, 46, PT_BEZIERTO}, /* 90 */
1066 {30, 42, PT_BEZIERTO}, /* 91 */
1067 {30, 42, PT_LINETO}, /* 92 */
1068 {30, 38, PT_BEZIERTO}, /* 93 */
1069 {35, 35, PT_BEZIERTO}, /* 94 */
1070 {42, 35, PT_BEZIERTO}, /* 95 */
1071 {42, 35, PT_LINETO}, /* 96 */
1072 {49, 35, PT_BEZIERTO}, /* 97 */
1073 {54, 38, PT_BEZIERTO}, /* 98 */
1074 {54, 42, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 99 */
1075 {-41, 52, PT_MOVETO}, /* 100 */
1076 {-41, 45, PT_BEZIERTO}, /* 101 */
1077 {-47, 40, PT_BEZIERTO}, /* 102 */
1078 {-56, 40, PT_BEZIERTO}, /* 103 */
1079 {-65, 40, PT_LINETO}, /* 104 */
1080 {-73, 40, PT_BEZIERTO}, /* 105 */
1081 {-80, 45, PT_BEZIERTO}, /* 106 */
1082 {-80, 52, PT_BEZIERTO}, /* 107 */
1083 {-80, 67, PT_LINETO}, /* 108 */
1084 {-80, 74, PT_BEZIERTO}, /* 109 */
1085 {-73, 79, PT_BEZIERTO}, /* 110 */
1086 {-65, 79, PT_BEZIERTO}, /* 111 */
1087 {-56, 79, PT_LINETO}, /* 112 */
1088 {-47, 79, PT_BEZIERTO}, /* 113 */
1089 {-41, 74, PT_BEZIERTO}, /* 114 */
1090 {-41, 67, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 115 */
1091 {-61, 79, PT_MOVETO}, /* 116 */
1092 {-61, 74, PT_BEZIERTO}, /* 117 */
1093 {-64, 70, PT_BEZIERTO}, /* 118 */
1094 {-68, 70, PT_BEZIERTO}, /* 119 */
1095 {-103, 70, PT_LINETO}, /* 120 */
1096 {-107, 70, PT_BEZIERTO}, /* 121 */
1097 {-110, 74, PT_BEZIERTO}, /* 122 */
1098 {-110, 79, PT_BEZIERTO}, /* 123 */
1099 {-110, 90, PT_LINETO}, /* 124 */
1100 {-110, 95, PT_BEZIERTO}, /* 125 */
1101 {-107, 99, PT_BEZIERTO}, /* 126 */
1102 {-103, 99, PT_BEZIERTO}, /* 127 */
1103 {-68, 99, PT_LINETO}, /* 128 */
1104 {-64, 99, PT_BEZIERTO}, /* 129 */
1105 {-61, 95, PT_BEZIERTO}, /* 130 */
1106 {-61, 90, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 131 */
1107 {119, -102, PT_MOVETO}, /* 132 */
1108 {119, -112, PT_BEZIERTO}, /* 133 */
1109 {109, -120, PT_BEZIERTO}, /* 134 */
1110 {97, -120, PT_BEZIERTO}, /* 135 */
1111 {82, -120, PT_LINETO}, /* 136 */
1112 {70, -120, PT_BEZIERTO}, /* 137 */
1113 {60, -112, PT_BEZIERTO}, /* 138 */
1114 {60, -102, PT_BEZIERTO}, /* 139 */
1115 {60, -79, PT_LINETO}, /* 140 */
1116 {60, -69, PT_BEZIERTO}, /* 141 */
1117 {70, -61, PT_BEZIERTO}, /* 142 */
1118 {82, -61, PT_BEZIERTO}, /* 143 */
1119 {97, -61, PT_LINETO}, /* 144 */
1120 {109, -61, PT_BEZIERTO}, /* 145 */
1121 {119, -69, PT_BEZIERTO}, /* 146 */
1122 {119, -79, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 147 */
1123 {164, -144, PT_MOVETO}, /* 148 */
1124 {164, -147, PT_BEZIERTO}, /* 149 */
1125 {162, -150, PT_BEZIERTO}, /* 150 */
1126 {160, -150, PT_BEZIERTO}, /* 151 */
1127 {94, -150, PT_LINETO}, /* 152 */
1128 {92, -150, PT_BEZIERTO}, /* 153 */
1129 {90, -147, PT_BEZIERTO}, /* 154 */
1130 {90, -144, PT_BEZIERTO}, /* 155 */
1131 {90, -112, PT_LINETO}, /* 156 */
1132 {90, -109, PT_BEZIERTO}, /* 157 */
1133 {92, -106, PT_BEZIERTO}, /* 158 */
1134 {94, -106, PT_BEZIERTO}, /* 159 */
1135 {160, -106, PT_LINETO}, /* 160 */
1136 {162, -106, PT_BEZIERTO}, /* 161 */
1137 {164, -109, PT_BEZIERTO}, /* 162 */
1138 {164, -112, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 163 */
1139 {-4, -6, PT_MOVETO}, /* 164 */
1140 {-4, -6, PT_BEZIERTO}, /* 165 */
1141 {-4, -6, PT_BEZIERTO}, /* 166 */
1142 {-4, -6, PT_BEZIERTO}, /* 167 */
1143 {-6, -6, PT_LINETO}, /* 168 */
1144 {-6, -6, PT_BEZIERTO}, /* 169 */
1145 {-6, -6, PT_BEZIERTO}, /* 170 */
1146 {-6, -6, PT_BEZIERTO}, /* 171 */
1147 {-6, -4, PT_LINETO}, /* 172 */
1148 {-6, -4, PT_BEZIERTO}, /* 173 */
1149 {-6, -4, PT_BEZIERTO}, /* 174 */
1150 {-6, -4, PT_BEZIERTO}, /* 175 */
1151 {-4, -4, PT_LINETO}, /* 176 */
1152 {-4, -4, PT_BEZIERTO}, /* 177 */
1153 {-4, -4, PT_BEZIERTO}, /* 178 */
1154 {-4, -4, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 179 */
1155 {40, 25, PT_MOVETO}, /* 180 */
1156 {40, 22, PT_BEZIERTO}, /* 181 */
1157 {38, 20, PT_BEZIERTO}, /* 182 */
1158 {35, 20, PT_BEZIERTO}, /* 183 */
1159 {25, 20, PT_LINETO}, /* 184 */
1160 {22, 20, PT_BEZIERTO}, /* 185 */
1161 {20, 22, PT_BEZIERTO}, /* 186 */
1162 {20, 25, PT_BEZIERTO}, /* 187 */
1163 {20, 35, PT_LINETO}, /* 188 */
1164 {20, 38, PT_BEZIERTO}, /* 189 */
1165 {22, 40, PT_BEZIERTO}, /* 190 */
1166 {25, 40, PT_BEZIERTO}, /* 191 */
1167 {35, 40, PT_LINETO}, /* 192 */
1168 {38, 40, PT_BEZIERTO}, /* 193 */
1169 {40, 38, PT_BEZIERTO}, /* 194 */
1170 {40, 35, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 195 */
1171 {55, 43, PT_MOVETO}, /* 196 */
1172 {55, 38, PT_BEZIERTO}, /* 197 */
1173 {49, 35, PT_BEZIERTO}, /* 198 */
1174 {43, 35, PT_BEZIERTO}, /* 199 */
1175 {43, 35, PT_LINETO}, /* 200 */
1176 {36, 35, PT_BEZIERTO}, /* 201 */
1177 {30, 38, PT_BEZIERTO}, /* 202 */
1178 {30, 43, PT_BEZIERTO}, /* 203 */
1179 {30, 43, PT_LINETO}, /* 204 */
1180 {30, 47, PT_BEZIERTO}, /* 205 */
1181 {36, 50, PT_BEZIERTO}, /* 206 */
1182 {43, 50, PT_BEZIERTO}, /* 207 */
1183 {43, 50, PT_LINETO}, /* 208 */
1184 {49, 50, PT_BEZIERTO}, /* 209 */
1185 {55, 47, PT_BEZIERTO}, /* 210 */
1186 {55, 43, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 211 */
1187 {60, 46, PT_MOVETO}, /* 212 */
1188 {60, 46, PT_BEZIERTO}, /* 213 */
1189 {59, 45, PT_BEZIERTO}, /* 214 */
1190 {58, 45, PT_BEZIERTO}, /* 215 */
1191 {38, 45, PT_LINETO}, /* 216 */
1192 {36, 45, PT_BEZIERTO}, /* 217 */
1193 {35, 46, PT_BEZIERTO}, /* 218 */
1194 {35, 46, PT_BEZIERTO}, /* 219 */
1195 {35, 59, PT_LINETO}, /* 220 */
1196 {35, 60, PT_BEZIERTO}, /* 221 */
1197 {36, 60, PT_BEZIERTO}, /* 222 */
1198 {38, 60, PT_BEZIERTO}, /* 223 */
1199 {58, 60, PT_LINETO}, /* 224 */
1200 {59, 60, PT_BEZIERTO}, /* 225 */
1201 {60, 60, PT_BEZIERTO}, /* 226 */
1202 {60, 59, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 227 */
1203 {70, 70, PT_MOVETO}, /* 228 */
1204 {70, 70, PT_BEZIERTO}, /* 229 */
1205 {70, 70, PT_BEZIERTO}, /* 230 */
1206 {70, 70, PT_BEZIERTO}, /* 231 */
1207 {50, 70, PT_LINETO}, /* 232 */
1208 {50, 70, PT_BEZIERTO}, /* 233 */
1209 {50, 70, PT_BEZIERTO}, /* 234 */
1210 {50, 70, PT_BEZIERTO}, /* 235 */
1211 {50, 70, PT_LINETO}, /* 236 */
1212 {50, 70, PT_BEZIERTO}, /* 237 */
1213 {50, 70, PT_BEZIERTO}, /* 238 */
1214 {50, 70, PT_BEZIERTO}, /* 239 */
1215 {70, 70, PT_LINETO}, /* 240 */
1216 {70, 70, PT_BEZIERTO}, /* 241 */
1217 {70, 70, PT_BEZIERTO}, /* 242 */
1218 {70, 70, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 243 */
1219 {75, 75, PT_MOVETO}, /* 244 */
1220 {75, 75, PT_BEZIERTO}, /* 245 */
1221 {75, 75, PT_BEZIERTO}, /* 246 */
1222 {75, 75, PT_BEZIERTO}, /* 247 */
1223 {75, 75, PT_LINETO}, /* 248 */
1224 {75, 75, PT_BEZIERTO}, /* 249 */
1225 {75, 75, PT_BEZIERTO}, /* 250 */
1226 {75, 75, PT_BEZIERTO}, /* 251 */
1227 {75, 85, PT_LINETO}, /* 252 */
1228 {75, 85, PT_BEZIERTO}, /* 253 */
1229 {75, 85, PT_BEZIERTO}, /* 254 */
1230 {75, 85, PT_BEZIERTO}, /* 255 */
1231 {75, 85, PT_LINETO}, /* 256 */
1232 {75, 85, PT_BEZIERTO}, /* 257 */
1233 {75, 85, PT_BEZIERTO}, /* 258 */
1234 {75, 85, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 259 */
1235 {81, 81, PT_MOVETO}, /* 260 */
1236 {81, 80, PT_BEZIERTO}, /* 261 */
1237 {81, 80, PT_BEZIERTO}, /* 262 */
1238 {81, 80, PT_BEZIERTO}, /* 263 */
1239 {81, 80, PT_LINETO}, /* 264 */
1240 {80, 80, PT_BEZIERTO}, /* 265 */
1241 {80, 80, PT_BEZIERTO}, /* 266 */
1242 {80, 81, PT_BEZIERTO}, /* 267 */
1243 {80, 81, PT_LINETO}, /* 268 */
1244 {80, 81, PT_BEZIERTO}, /* 269 */
1245 {80, 81, PT_BEZIERTO}, /* 270 */
1246 {81, 81, PT_BEZIERTO}, /* 271 */
1247 {81, 81, PT_LINETO}, /* 272 */
1248 {81, 81, PT_BEZIERTO}, /* 273 */
1249 {81, 81, PT_BEZIERTO}, /* 274 */
1250 {81, 81, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 275 */
1251 {95, 85, PT_MOVETO}, /* 276 */
1252 {90, 85, PT_LINETO}, /* 277 */
1253 {90, 90, PT_LINETO}, /* 278 */
1254 {95, 90, PT_LINETO | PT_CLOSEFIGURE}, /* 279 */
1255 {40, 35, PT_MOVETO}, /* 280 */
1256 {40, 38, PT_BEZIERTO}, /* 281 */
1257 {38, 40, PT_BEZIERTO}, /* 282 */
1258 {35, 40, PT_BEZIERTO}, /* 283 */
1259 {25, 40, PT_LINETO}, /* 284 */
1260 {22, 40, PT_BEZIERTO}, /* 285 */
1261 {20, 38, PT_BEZIERTO}, /* 286 */
1262 {20, 35, PT_BEZIERTO}, /* 287 */
1263 {20, 25, PT_LINETO}, /* 288 */
1264 {20, 22, PT_BEZIERTO}, /* 289 */
1265 {22, 20, PT_BEZIERTO}, /* 290 */
1266 {25, 20, PT_BEZIERTO}, /* 291 */
1267 {35, 20, PT_LINETO}, /* 292 */
1268 {38, 20, PT_BEZIERTO}, /* 293 */
1269 {40, 22, PT_BEZIERTO}, /* 294 */
1270 {40, 25, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 295 */
1271 {55, 43, PT_MOVETO}, /* 296 */
1272 {55, 47, PT_BEZIERTO}, /* 297 */
1273 {49, 50, PT_BEZIERTO}, /* 298 */
1274 {43, 50, PT_BEZIERTO}, /* 299 */
1275 {43, 50, PT_LINETO}, /* 300 */
1276 {36, 50, PT_BEZIERTO}, /* 301 */
1277 {30, 47, PT_BEZIERTO}, /* 302 */
1278 {30, 43, PT_BEZIERTO}, /* 303 */
1279 {30, 43, PT_LINETO}, /* 304 */
1280 {30, 38, PT_BEZIERTO}, /* 305 */
1281 {36, 35, PT_BEZIERTO}, /* 306 */
1282 {43, 35, PT_BEZIERTO}, /* 307 */
1283 {43, 35, PT_LINETO}, /* 308 */
1284 {49, 35, PT_BEZIERTO}, /* 309 */
1285 {55, 38, PT_BEZIERTO}, /* 310 */
1286 {55, 43, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 311 */
1287 };
1288
1289 static void test_roundrect(void)
1290 {
1291 HDC hdc = GetDC( 0 );
1292
1293 BeginPath( hdc );
1294 RoundRect( hdc, 20, 20, 40, 40, 10, 10 );
1295 RoundRect( hdc, 30, 50, 55, 35, -30, -30 );
1296 RoundRect( hdc, 60, 60, 35, 45, 5, 2 );
1297 RoundRect( hdc, 70, 70, 50, 70, 3, 5 );
1298 RoundRect( hdc, 75, 75, 75, 85, 6, 4 );
1299 RoundRect( hdc, 80, 80, 81, 81, 8, 9 );
1300 RoundRect( hdc, 90, 90, 95, 85, 0, 7 );
1301 SetArcDirection( hdc, AD_CLOCKWISE );
1302 RoundRect( hdc, 20, 20, 40, 40, 10, 10 );
1303 RoundRect( hdc, 30, 50, 55, 35, -30, -30 );
1304 SetArcDirection( hdc, AD_COUNTERCLOCKWISE );
1305 SetMapMode( hdc, MM_ANISOTROPIC );
1306 SetViewportExtEx( hdc, -2, 2, NULL );
1307 RoundRect( hdc, 20, 20, 40, 40, 15, 12 );
1308 RoundRect( hdc, 30, 50, 55, 35, 7, 9 );
1309 SetViewportExtEx( hdc, 3, -3, NULL );
1310 RoundRect( hdc, 20, 20, 40, 40, 15, 12 );
1311 RoundRect( hdc, 30, 50, 55, 35, 3, 4 );
1312 SetWindowExtEx( hdc, -20, 20, NULL );
1313 RoundRect( hdc, 20, 20, 40, 40, 2, 1 );
1314 RoundRect( hdc, 24, 22, 21, 20, 4, 4 );
1315 SetMapMode( hdc, MM_TEXT );
1316 SetGraphicsMode( hdc, GM_ADVANCED );
1317 RoundRect( hdc, 20, 20, 40, 40, 10, 10 );
1318 RoundRect( hdc, 30, 50, 55, 35, -30, -30 );
1319 RoundRect( hdc, 60, 60, 35, 45, 5, 2 );
1320 RoundRect( hdc, 70, 70, 50, 70, 3, 5 );
1321 RoundRect( hdc, 75, 75, 75, 85, 6, 4 );
1322 RoundRect( hdc, 80, 80, 81, 81, 8, 9 );
1323 RoundRect( hdc, 90, 90, 95, 85, 0, 7 );
1324 SetArcDirection( hdc, AD_CLOCKWISE );
1325 RoundRect( hdc, 20, 20, 40, 40, 10, 10 );
1326 RoundRect( hdc, 30, 50, 55, 35, -30, -30 );
1327 SetArcDirection( hdc, AD_COUNTERCLOCKWISE );
1328 EndPath( hdc );
1329 SetMapMode( hdc, MM_TEXT );
1330 ok_path( hdc, "roundrect_path", roundrect_path, sizeof(roundrect_path)/sizeof(path_test_t) );
1331 ReleaseDC( 0, hdc );
1332 }
1333
1334 static const path_test_t ellipse_path[] =
1335 {
1336 {39, 30, PT_MOVETO}, /* 0 */
1337 {39, 24, PT_BEZIERTO}, /* 1 */
1338 {35, 20, PT_BEZIERTO}, /* 2 */
1339 {30, 20, PT_BEZIERTO}, /* 3 */
1340 {24, 20, PT_BEZIERTO}, /* 4 */
1341 {20, 24, PT_BEZIERTO}, /* 5 */
1342 {20, 30, PT_BEZIERTO}, /* 6 */
1343 {20, 35, PT_BEZIERTO}, /* 7 */
1344 {24, 39, PT_BEZIERTO}, /* 8 */
1345 {30, 39, PT_BEZIERTO}, /* 9 */
1346 {35, 39, PT_BEZIERTO}, /* 10 */
1347 {39, 35, PT_BEZIERTO}, /* 11 */
1348 {39, 30, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 12 */
1349 {54, 42, PT_MOVETO}, /* 13 */
1350 {54, 38, PT_BEZIERTO}, /* 14 */
1351 {49, 35, PT_BEZIERTO}, /* 15 */
1352 {42, 35, PT_BEZIERTO}, /* 16 */
1353 {35, 35, PT_BEZIERTO}, /* 17 */
1354 {30, 38, PT_BEZIERTO}, /* 18 */
1355 {30, 42, PT_BEZIERTO}, /* 19 */
1356 {30, 46, PT_BEZIERTO}, /* 20 */
1357 {35, 49, PT_BEZIERTO}, /* 21 */
1358 {42, 49, PT_BEZIERTO}, /* 22 */
1359 {49, 49, PT_BEZIERTO}, /* 23 */
1360 {54, 46, PT_BEZIERTO}, /* 24 */
1361 {54, 42, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 25 */
1362 {59, 52, PT_MOVETO}, /* 26 */
1363 {59, 48, PT_BEZIERTO}, /* 27 */
1364 {54, 45, PT_BEZIERTO}, /* 28 */
1365 {47, 45, PT_BEZIERTO}, /* 29 */
1366 {40, 45, PT_BEZIERTO}, /* 30 */
1367 {35, 48, PT_BEZIERTO}, /* 31 */
1368 {35, 52, PT_BEZIERTO}, /* 32 */
1369 {35, 56, PT_BEZIERTO}, /* 33 */
1370 {40, 59, PT_BEZIERTO}, /* 34 */
1371 {47, 59, PT_BEZIERTO}, /* 35 */
1372 {54, 59, PT_BEZIERTO}, /* 36 */
1373 {59, 56, PT_BEZIERTO}, /* 37 */
1374 {59, 52, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 38 */
1375 {80, 80, PT_MOVETO}, /* 39 */
1376 {80, 80, PT_BEZIERTO}, /* 40 */
1377 {80, 80, PT_BEZIERTO}, /* 41 */
1378 {80, 80, PT_BEZIERTO}, /* 42 */
1379 {80, 80, PT_BEZIERTO}, /* 43 */
1380 {80, 80, PT_BEZIERTO}, /* 44 */
1381 {80, 80, PT_BEZIERTO}, /* 45 */
1382 {80, 80, PT_BEZIERTO}, /* 46 */
1383 {80, 80, PT_BEZIERTO}, /* 47 */
1384 {80, 80, PT_BEZIERTO}, /* 48 */
1385 {80, 80, PT_BEZIERTO}, /* 49 */
1386 {80, 80, PT_BEZIERTO}, /* 50 */
1387 {80, 80, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 51 */
1388 {39, 30, PT_MOVETO}, /* 52 */
1389 {39, 35, PT_BEZIERTO}, /* 53 */
1390 {35, 39, PT_BEZIERTO}, /* 54 */
1391 {30, 39, PT_BEZIERTO}, /* 55 */
1392 {24, 39, PT_BEZIERTO}, /* 56 */
1393 {20, 35, PT_BEZIERTO}, /* 57 */
1394 {20, 30, PT_BEZIERTO}, /* 58 */
1395 {20, 24, PT_BEZIERTO}, /* 59 */
1396 {24, 20, PT_BEZIERTO}, /* 60 */
1397 {30, 20, PT_BEZIERTO}, /* 61 */
1398 {35, 20, PT_BEZIERTO}, /* 62 */
1399 {39, 24, PT_BEZIERTO}, /* 63 */
1400 {39, 30, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 64 */
1401 {54, 42, PT_MOVETO}, /* 65 */
1402 {54, 46, PT_BEZIERTO}, /* 66 */
1403 {49, 49, PT_BEZIERTO}, /* 67 */
1404 {42, 49, PT_BEZIERTO}, /* 68 */
1405 {35, 49, PT_BEZIERTO}, /* 69 */
1406 {30, 46, PT_BEZIERTO}, /* 70 */
1407 {30, 42, PT_BEZIERTO}, /* 71 */
1408 {30, 38, PT_BEZIERTO}, /* 72 */
1409 {35, 35, PT_BEZIERTO}, /* 73 */
1410 {42, 35, PT_BEZIERTO}, /* 74 */
1411 {49, 35, PT_BEZIERTO}, /* 75 */
1412 {54, 38, PT_BEZIERTO}, /* 76 */
1413 {54, 42, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 77 */
1414 {59, 52, PT_MOVETO}, /* 78 */
1415 {59, 56, PT_BEZIERTO}, /* 79 */
1416 {54, 59, PT_BEZIERTO}, /* 80 */
1417 {47, 59, PT_BEZIERTO}, /* 81 */
1418 {40, 59, PT_BEZIERTO}, /* 82 */
1419 {35, 56, PT_BEZIERTO}, /* 83 */
1420 {35, 52, PT_BEZIERTO}, /* 84 */
1421 {35, 48, PT_BEZIERTO}, /* 85 */
1422 {40, 45, PT_BEZIERTO}, /* 86 */
1423 {47, 45, PT_BEZIERTO}, /* 87 */
1424 {54, 45, PT_BEZIERTO}, /* 88 */
1425 {59, 48, PT_BEZIERTO}, /* 89 */
1426 {59, 52, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 90 */
1427 {80, 80, PT_MOVETO}, /* 91 */
1428 {80, 80, PT_BEZIERTO}, /* 92 */
1429 {80, 80, PT_BEZIERTO}, /* 93 */
1430 {80, 80, PT_BEZIERTO}, /* 94 */
1431 {80, 80, PT_BEZIERTO}, /* 95 */
1432 {80, 80, PT_BEZIERTO}, /* 96 */
1433 {80, 80, PT_BEZIERTO}, /* 97 */
1434 {80, 80, PT_BEZIERTO}, /* 98 */
1435 {80, 80, PT_BEZIERTO}, /* 99 */
1436 {80, 80, PT_BEZIERTO}, /* 100 */
1437 {80, 80, PT_BEZIERTO}, /* 101 */
1438 {80, 80, PT_BEZIERTO}, /* 102 */
1439 {80, 80, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 103 */
1440 {-41, 60, PT_MOVETO}, /* 104 */
1441 {-41, 49, PT_BEZIERTO}, /* 105 */
1442 {-50, 40, PT_BEZIERTO}, /* 106 */
1443 {-60, 40, PT_BEZIERTO}, /* 107 */
1444 {-71, 40, PT_BEZIERTO}, /* 108 */
1445 {-80, 49, PT_BEZIERTO}, /* 109 */
1446 {-80, 60, PT_BEZIERTO}, /* 110 */
1447 {-80, 70, PT_BEZIERTO}, /* 111 */
1448 {-71, 79, PT_BEZIERTO}, /* 112 */
1449 {-60, 79, PT_BEZIERTO}, /* 113 */
1450 {-50, 79, PT_BEZIERTO}, /* 114 */
1451 {-41, 70, PT_BEZIERTO}, /* 115 */
1452 {-41, 60, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 116 */
1453 {-61, 85, PT_MOVETO}, /* 117 */
1454 {-61, 77, PT_BEZIERTO}, /* 118 */
1455 {-72, 70, PT_BEZIERTO}, /* 119 */
1456 {-85, 70, PT_BEZIERTO}, /* 120 */
1457 {-99, 70, PT_BEZIERTO}, /* 121 */
1458 {-110, 77, PT_BEZIERTO}, /* 122 */
1459 {-110, 85, PT_BEZIERTO}, /* 123 */
1460 {-110, 93, PT_BEZIERTO}, /* 124 */
1461 {-99, 99, PT_BEZIERTO}, /* 125 */
1462 {-85, 99, PT_BEZIERTO}, /* 126 */
1463 {-72, 99, PT_BEZIERTO}, /* 127 */
1464 {-61, 93, PT_BEZIERTO}, /* 128 */
1465 {-61, 85, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 129 */
1466 {119, -90, PT_MOVETO}, /* 130 */
1467 {119, -107, PT_BEZIERTO}, /* 131 */
1468 {106, -120, PT_BEZIERTO}, /* 132 */
1469 {90, -120, PT_BEZIERTO}, /* 133 */
1470 {73, -120, PT_BEZIERTO}, /* 134 */
1471 {60, -107, PT_BEZIERTO}, /* 135 */
1472 {60, -90, PT_BEZIERTO}, /* 136 */
1473 {60, -74, PT_BEZIERTO}, /* 137 */
1474 {73, -61, PT_BEZIERTO}, /* 138 */
1475 {90, -61, PT_BEZIERTO}, /* 139 */
1476 {106, -61, PT_BEZIERTO}, /* 140 */
1477 {119, -74, PT_BEZIERTO}, /* 141 */
1478 {119, -90, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 142 */
1479 {164, -128, PT_MOVETO}, /* 143 */
1480 {164, -140, PT_BEZIERTO}, /* 144 */
1481 {147, -150, PT_BEZIERTO}, /* 145 */
1482 {127, -150, PT_BEZIERTO}, /* 146 */
1483 {107, -150, PT_BEZIERTO}, /* 147 */
1484 {90, -140, PT_BEZIERTO}, /* 148 */
1485 {90, -128, PT_BEZIERTO}, /* 149 */
1486 {90, -116, PT_BEZIERTO}, /* 150 */
1487 {107, -106, PT_BEZIERTO}, /* 151 */
1488 {127, -106, PT_BEZIERTO}, /* 152 */
1489 {147, -106, PT_BEZIERTO}, /* 153 */
1490 {164, -116, PT_BEZIERTO}, /* 154 */
1491 {164, -128, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 155 */
1492 {-4, -5, PT_MOVETO}, /* 156 */
1493 {-4, -5, PT_BEZIERTO}, /* 157 */
1494 {-4, -6, PT_BEZIERTO}, /* 158 */
1495 {-5, -6, PT_BEZIERTO}, /* 159 */
1496 {-6, -6, PT_BEZIERTO}, /* 160 */
1497 {-6, -5, PT_BEZIERTO}, /* 161 */
1498 {-6, -5, PT_BEZIERTO}, /* 162 */
1499 {-6, -4, PT_BEZIERTO}, /* 163 */
1500 {-6, -4, PT_BEZIERTO}, /* 164 */
1501 {-5, -4, PT_BEZIERTO}, /* 165 */
1502 {-4, -4, PT_BEZIERTO}, /* 166 */
1503 {-4, -4, PT_BEZIERTO}, /* 167 */
1504 {-4, -5, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 168 */
1505 {40, 30, PT_MOVETO}, /* 169 */
1506 {40, 25, PT_BEZIERTO}, /* 170 */
1507 {36, 20, PT_BEZIERTO}, /* 171 */
1508 {30, 20, PT_BEZIERTO}, /* 172 */
1509 {24, 20, PT_BEZIERTO}, /* 173 */
1510 {20, 25, PT_BEZIERTO}, /* 174 */
1511 {20, 30, PT_BEZIERTO}, /* 175 */
1512 {20, 36, PT_BEZIERTO}, /* 176 */
1513 {24, 40, PT_BEZIERTO}, /* 177 */
1514 {30, 40, PT_BEZIERTO}, /* 178 */
1515 {36, 40, PT_BEZIERTO}, /* 179 */
1516 {40, 36, PT_BEZIERTO}, /* 180 */
1517 {40, 30, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 181 */
1518 {55, 43, PT_MOVETO}, /* 182 */
1519 {55, 38, PT_BEZIERTO}, /* 183 */
1520 {49, 35, PT_BEZIERTO}, /* 184 */
1521 {43, 35, PT_BEZIERTO}, /* 185 */
1522 {36, 35, PT_BEZIERTO}, /* 186 */
1523 {30, 38, PT_BEZIERTO}, /* 187 */
1524 {30, 43, PT_BEZIERTO}, /* 188 */
1525 {30, 47, PT_BEZIERTO}, /* 189 */
1526 {36, 50, PT_BEZIERTO}, /* 190 */
1527 {43, 50, PT_BEZIERTO}, /* 191 */
1528 {49, 50, PT_BEZIERTO}, /* 192 */
1529 {55, 47, PT_BEZIERTO}, /* 193 */
1530 {55, 43, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 194 */
1531 {60, 53, PT_MOVETO}, /* 195 */
1532 {60, 48, PT_BEZIERTO}, /* 196 */
1533 {54, 45, PT_BEZIERTO}, /* 197 */
1534 {48, 45, PT_BEZIERTO}, /* 198 */
1535 {41, 45, PT_BEZIERTO}, /* 199 */
1536 {35, 48, PT_BEZIERTO}, /* 200 */
1537 {35, 53, PT_BEZIERTO}, /* 201 */
1538 {35, 57, PT_BEZIERTO}, /* 202 */
1539 {41, 60, PT_BEZIERTO}, /* 203 */
1540 {48, 60, PT_BEZIERTO}, /* 204 */
1541 {54, 60, PT_BEZIERTO}, /* 205 */
1542 {60, 57, PT_BEZIERTO}, /* 206 */
1543 {60, 53, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 207 */
1544 {70, 70, PT_MOVETO}, /* 208 */
1545 {70, 70, PT_BEZIERTO}, /* 209 */
1546 {66, 70, PT_BEZIERTO}, /* 210 */
1547 {60, 70, PT_BEZIERTO}, /* 211 */
1548 {54, 70, PT_BEZIERTO}, /* 212 */
1549 {50, 70, PT_BEZIERTO}, /* 213 */
1550 {50, 70, PT_BEZIERTO}, /* 214 */
1551 {50, 70, PT_BEZIERTO}, /* 215 */
1552 {54, 70, PT_BEZIERTO}, /* 216 */
1553 {60, 70, PT_BEZIERTO}, /* 217 */
1554 {66, 70, PT_BEZIERTO}, /* 218 */
1555 {70, 70, PT_BEZIERTO}, /* 219 */
1556 {70, 70, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 220 */
1557 {75, 80, PT_MOVETO}, /* 221 */
1558 {75, 77, PT_BEZIERTO}, /* 222 */
1559 {75, 75, PT_BEZIERTO}, /* 223 */
1560 {75, 75, PT_BEZIERTO}, /* 224 */
1561 {75, 75, PT_BEZIERTO}, /* 225 */
1562 {75, 77, PT_BEZIERTO}, /* 226 */
1563 {75, 80, PT_BEZIERTO}, /* 227 */
1564 {75, 83, PT_BEZIERTO}, /* 228 */
1565 {75, 85, PT_BEZIERTO}, /* 229 */
1566 {75, 85, PT_BEZIERTO}, /* 230 */
1567 {75, 85, PT_BEZIERTO}, /* 231 */
1568 {75, 83, PT_BEZIERTO}, /* 232 */
1569 {75, 80, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 233 */
1570 {81, 81, PT_MOVETO}, /* 234 */
1571 {81, 80, PT_BEZIERTO}, /* 235 */
1572 {81, 80, PT_BEZIERTO}, /* 236 */
1573 {81, 80, PT_BEZIERTO}, /* 237 */
1574 {80, 80, PT_BEZIERTO}, /* 238 */
1575 {80, 80, PT_BEZIERTO}, /* 239 */
1576 {80, 81, PT_BEZIERTO}, /* 240 */
1577 {80, 81, PT_BEZIERTO}, /* 241 */
1578 {80, 81, PT_BEZIERTO}, /* 242 */
1579 {81, 81, PT_BEZIERTO}, /* 243 */
1580 {81, 81, PT_BEZIERTO}, /* 244 */
1581 {81, 81, PT_BEZIERTO}, /* 245 */
1582 {81, 81, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 246 */
1583 {40, 30, PT_MOVETO}, /* 247 */
1584 {40, 36, PT_BEZIERTO}, /* 248 */
1585 {36, 40, PT_BEZIERTO}, /* 249 */
1586 {30, 40, PT_BEZIERTO}, /* 250 */
1587 {24, 40, PT_BEZIERTO}, /* 251 */
1588 {20, 36, PT_BEZIERTO}, /* 252 */
1589 {20, 30, PT_BEZIERTO}, /* 253 */
1590 {20, 24, PT_BEZIERTO}, /* 254 */
1591 {24, 20, PT_BEZIERTO}, /* 255 */
1592 {30, 20, PT_BEZIERTO}, /* 256 */
1593 {36, 20, PT_BEZIERTO}, /* 257 */
1594 {40, 24, PT_BEZIERTO}, /* 258 */
1595 {40, 30, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 259 */
1596 {55, 43, PT_MOVETO}, /* 260 */
1597 {55, 47, PT_BEZIERTO}, /* 261 */
1598 {49, 50, PT_BEZIERTO}, /* 262 */
1599 {43, 50, PT_BEZIERTO}, /* 263 */
1600 {36, 50, PT_BEZIERTO}, /* 264 */
1601 {30, 47, PT_BEZIERTO}, /* 265 */
1602 {30, 43, PT_BEZIERTO}, /* 266 */
1603 {30, 38, PT_BEZIERTO}, /* 267 */
1604 {36, 35, PT_BEZIERTO}, /* 268 */
1605 {43, 35, PT_BEZIERTO}, /* 269 */
1606 {49, 35, PT_BEZIERTO}, /* 270 */
1607 {55, 38, PT_BEZIERTO}, /* 271 */
1608 {55, 43, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 272 */
1609 {60, 53, PT_MOVETO}, /* 273 */
1610 {60, 57, PT_BEZIERTO}, /* 274 */
1611 {54, 60, PT_BEZIERTO}, /* 275 */
1612 {48, 60, PT_BEZIERTO}, /* 276 */
1613 {41, 60, PT_BEZIERTO}, /* 277 */
1614 {35, 57, PT_BEZIERTO}, /* 278 */
1615 {35, 53, PT_BEZIERTO}, /* 279 */
1616 {35, 48, PT_BEZIERTO}, /* 280 */
1617 {41, 45, PT_BEZIERTO}, /* 281 */
1618 {48, 45, PT_BEZIERTO}, /* 282 */
1619 {54, 45, PT_BEZIERTO}, /* 283 */
1620 {60, 48, PT_BEZIERTO}, /* 284 */
1621 {60, 53, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 285 */
1622 {70, 70, PT_MOVETO}, /* 286 */
1623 {70, 70, PT_BEZIERTO}, /* 287 */
1624 {66, 70, PT_BEZIERTO}, /* 288 */
1625 {60, 70, PT_BEZIERTO}, /* 289 */
1626 {54, 70, PT_BEZIERTO}, /* 290 */
1627 {50, 70, PT_BEZIERTO}, /* 291 */
1628 {50, 70, PT_BEZIERTO}, /* 292 */
1629 {50, 70, PT_BEZIERTO}, /* 293 */
1630 {54, 70, PT_BEZIERTO}, /* 294 */
1631 {60, 70, PT_BEZIERTO}, /* 295 */
1632 {66, 70, PT_BEZIERTO}, /* 296 */
1633 {70, 70, PT_BEZIERTO}, /* 297 */
1634 {70, 70, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 298 */
1635 {75, 80, PT_MOVETO}, /* 299 */
1636 {75, 83, PT_BEZIERTO}, /* 300 */
1637 {75, 85, PT_BEZIERTO}, /* 301 */
1638 {75, 85, PT_BEZIERTO}, /* 302 */
1639 {75, 85, PT_BEZIERTO}, /* 303 */
1640 {75, 83, PT_BEZIERTO}, /* 304 */
1641 {75, 80, PT_BEZIERTO}, /* 305 */
1642 {75, 77, PT_BEZIERTO}, /* 306 */
1643 {75, 75, PT_BEZIERTO}, /* 307 */
1644 {75, 75, PT_BEZIERTO}, /* 308 */
1645 {75, 75, PT_BEZIERTO}, /* 309 */
1646 {75, 77, PT_BEZIERTO}, /* 310 */
1647 {75, 80, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 311 */
1648 {81, 81, PT_MOVETO}, /* 312 */
1649 {81, 81, PT_BEZIERTO}, /* 313 */
1650 {81, 81, PT_BEZIERTO}, /* 314 */
1651 {81, 81, PT_BEZIERTO}, /* 315 */
1652 {80, 81, PT_BEZIERTO}, /* 316 */
1653 {80, 81, PT_BEZIERTO}, /* 317 */
1654 {80, 81, PT_BEZIERTO}, /* 318 */
1655 {80, 80, PT_BEZIERTO}, /* 319 */
1656 {80, 80, PT_BEZIERTO}, /* 320 */
1657 {81, 80, PT_BEZIERTO}, /* 321 */
1658 {81, 80, PT_BEZIERTO}, /* 322 */
1659 {81, 80, PT_BEZIERTO}, /* 323 */
1660 {81, 81, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 324 */
1661 };
1662
1663 static void test_ellipse(void)
1664 {
1665 HDC hdc = GetDC( 0 );
1666
1667 BeginPath( hdc );
1668 Ellipse( hdc, 20, 20, 40, 40 );
1669 Ellipse( hdc, 30, 50, 55, 35 );
1670 Ellipse( hdc, 60, 60, 35, 45 );
1671 Ellipse( hdc, 70, 70, 50, 70 );
1672 Ellipse( hdc, 75, 75, 75, 85 );
1673 Ellipse( hdc, 80, 80, 81, 81 );
1674 SetArcDirection( hdc, AD_CLOCKWISE );
1675 Ellipse( hdc, 20, 20, 40, 40 );
1676 Ellipse( hdc, 30, 50, 55, 35 );
1677 Ellipse( hdc, 60, 60, 35, 45 );
1678 Ellipse( hdc, 70, 70, 50, 70 );
1679 Ellipse( hdc, 75, 75, 75, 85 );
1680 Ellipse( hdc, 80, 80, 81, 81 );
1681 SetArcDirection( hdc, AD_COUNTERCLOCKWISE );
1682 SetMapMode( hdc, MM_ANISOTROPIC );
1683 SetViewportExtEx( hdc, -2, 2, NULL );
1684 Ellipse( hdc, 20, 20, 40, 40 );
1685 Ellipse( hdc, 30, 50, 55, 35 );
1686 SetViewportExtEx( hdc, 3, -3, NULL );
1687 Ellipse( hdc, 20, 20, 40, 40 );
1688 Ellipse( hdc, 30, 50, 55, 35 );
1689 SetWindowExtEx( hdc, -20, 20, NULL );
1690 Ellipse( hdc, 20, 20, 40, 40 );
1691 Ellipse( hdc, 24, 22, 21, 20 );
1692 SetMapMode( hdc, MM_TEXT );
1693 SetGraphicsMode( hdc, GM_ADVANCED );
1694 Ellipse( hdc, 20, 20, 40, 40 );
1695 Ellipse( hdc, 30, 50, 55, 35 );
1696 Ellipse( hdc, 60, 60, 35, 45 );
1697 Ellipse( hdc, 70, 70, 50, 70 );
1698 Ellipse( hdc, 75, 75, 75, 85 );
1699 Ellipse( hdc, 80, 80, 81, 81 );
1700 SetArcDirection( hdc, AD_CLOCKWISE );
1701 Ellipse( hdc, 20, 20, 40, 40 );
1702 Ellipse( hdc, 30, 50, 55, 35 );
1703 Ellipse( hdc, 60, 60, 35, 45 );
1704 Ellipse( hdc, 70, 70, 50, 70 );
1705 Ellipse( hdc, 75, 75, 75, 85 );
1706 Ellipse( hdc, 80, 80, 81, 81 );
1707 SetArcDirection( hdc, AD_COUNTERCLOCKWISE );
1708 EndPath( hdc );
1709 SetMapMode( hdc, MM_TEXT );
1710 ok_path( hdc, "ellipse_path", ellipse_path, sizeof(ellipse_path)/sizeof(path_test_t) );
1711 }
1712
1713 static const path_test_t all_funcs_path[] =
1714 {
1715 {0, 0, PT_MOVETO}, /* 0 */
1716 {50, 150, PT_LINETO}, /* 1 */
1717 {50, 50, PT_MOVETO}, /* 2 */
1718 {150, 150, PT_LINETO}, /* 3 */
1719 {150, 50, PT_LINETO}, /* 4 */
1720 {50, 50, PT_LINETO}, /* 5 */
1721 {37, 13, PT_LINETO}, /* 6 */
1722 {24, 13, PT_BEZIERTO}, /* 7 */
1723 {14, 23, PT_BEZIERTO}, /* 8 */
1724 {14, 36, PT_BEZIERTO}, /* 9 */
1725 {14, 49, PT_BEZIERTO}, /* 10 */
1726 {24, 59, PT_BEZIERTO}, /* 11 */
1727 {37, 59, PT_BEZIERTO}, /* 12 */
1728 {37, 59, PT_BEZIERTO}, /* 13 */
1729 {37, 59, PT_BEZIERTO}, /* 14 */
1730 {37, 59, PT_BEZIERTO}, /* 15 */
1731 {10, 10, PT_MOVETO}, /* 16 */
1732 {20, 10, PT_LINETO}, /* 17 */
1733 {10, 20, PT_LINETO}, /* 18 */
1734 {20, 20, PT_LINETO}, /* 19 */
1735 {36, 27, PT_MOVETO}, /* 20 */
1736 {37, 26, PT_BEZIERTO}, /* 21 */
1737 {38, 25, PT_BEZIERTO}, /* 22 */
1738 {38, 25, PT_BEZIERTO}, /* 23 */
1739 {38, 23, PT_BEZIERTO}, /* 24 */
1740 {34, 21, PT_BEZIERTO}, /* 25 */
1741 {30, 21, PT_BEZIERTO}, /* 26 */
1742 {27, 21, PT_BEZIERTO}, /* 27 */
1743 {25, 21, PT_BEZIERTO}, /* 28 */
1744 {24, 22, PT_BEZIERTO}, /* 29 */
1745 {37, 59, PT_MOVETO}, /* 30 */
1746 {10, 10, PT_LINETO}, /* 31 */
1747 {20, 10, PT_LINETO}, /* 32 */
1748 {10, 20, PT_LINETO}, /* 33 */
1749 {20, 20, PT_LINETO}, /* 34 */
1750 {34, 26, PT_LINETO}, /* 35 */
1751 {35, 25, PT_BEZIERTO}, /* 36 */
1752 {36, 25, PT_BEZIERTO}, /* 37 */
1753 {36, 25, PT_BEZIERTO}, /* 38 */
1754 {36, 24, PT_BEZIERTO}, /* 39 */
1755 {33, 23, PT_BEZIERTO}, /* 40 */
1756 {30, 23, PT_BEZIERTO}, /* 41 */
1757 {28, 23, PT_BEZIERTO}, /* 42 */
1758 {26, 23, PT_BEZIERTO}, /* 43 */
1759 {25, 23, PT_BEZIERTO}, /* 44 */
1760 {10, 10, PT_MOVETO}, /* 45 */
1761 {20, 10, PT_LINETO}, /* 46 */
1762 {10, 20, PT_LINETO}, /* 47 */
1763 {20, 20, PT_LINETO}, /* 48 */
1764 {30, 30, PT_MOVETO}, /* 49 */
1765 {40, 20, PT_LINETO}, /* 50 */
1766 {20, 30, PT_LINETO}, /* 51 */
1767 {30, 40, PT_LINETO}, /* 52 */
1768 {10, 50, PT_LINETO}, /* 53 */
1769 {45, 45, PT_MOVETO}, /* 54 */
1770 {45, 45, PT_BEZIERTO}, /* 55 */
1771 {44, 46, PT_BEZIERTO}, /* 56 */
1772 {43, 47, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 57 */
1773 {10, 10, PT_MOVETO}, /* 58 */
1774 {20, 10, PT_LINETO}, /* 59 */
1775 {10, 20, PT_BEZIERTO}, /* 60 */
1776 {20, 20, PT_BEZIERTO}, /* 61 */
1777 {30, 30, PT_BEZIERTO}, /* 62 */
1778 {40, 20, PT_LINETO}, /* 63 */
1779 {20, 30, PT_LINETO | PT_CLOSEFIGURE}, /* 64 */
1780 {30, 40, PT_MOVETO}, /* 65 */
1781 {10, 50, PT_LINETO}, /* 66 */
1782 {55, 55, PT_MOVETO}, /* 67 */
1783 {54, 55, PT_BEZIERTO}, /* 68 */
1784 {54, 56, PT_BEZIERTO}, /* 69 */
1785 {54, 56, PT_BEZIERTO}, /* 70 */
1786 {58, 61, PT_LINETO | PT_CLOSEFIGURE}, /* 71 */
1787 {10, 10, PT_MOVETO}, /* 72 */
1788 {20, 10, PT_LINETO}, /* 73 */
1789 {10, 20, PT_LINETO}, /* 74 */
1790 {20, 20, PT_LINETO}, /* 75 */
1791 {30, 30, PT_LINETO}, /* 76 */
1792 {40, 20, PT_LINETO}, /* 77 */
1793 {20, 30, PT_LINETO}, /* 78 */
1794 {30, 40, PT_LINETO}, /* 79 */
1795 {10, 50, PT_LINETO | PT_CLOSEFIGURE}, /* 80 */
1796 {43, 49, PT_MOVETO}, /* 81 */
1797 {43, 40, PT_BEZIERTO}, /* 82 */
1798 {38, 33, PT_BEZIERTO}, /* 83 */
1799 {33, 33, PT_BEZIERTO}, /* 84 */
1800 {27, 33, PT_BEZIERTO}, /* 85 */
1801 {22, 40, PT_BEZIERTO}, /* 86 */
1802 {22, 49, PT_BEZIERTO}, /* 87 */
1803 {22, 58, PT_BEZIERTO}, /* 88 */
1804 {27, 65, PT_BEZIERTO}, /* 89 */
1805 {33, 65, PT_BEZIERTO}, /* 90 */
1806 {38, 65, PT_BEZIERTO}, /* 91 */
1807 {43, 58, PT_BEZIERTO}, /* 92 */
1808 {43, 49, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 93 */
1809 {79, 70, PT_MOVETO}, /* 94 */
1810 {60, 70, PT_LINETO}, /* 95 */
1811 {60, 89, PT_LINETO}, /* 96 */
1812 {79, 89, PT_LINETO | PT_CLOSEFIGURE}, /* 97 */
1813 {199, 122, PT_MOVETO}, /* 98 */
1814 {199, 110, PT_BEZIERTO}, /* 99 */
1815 {191, 100, PT_BEZIERTO}, /* 100 */
1816 {182, 100, PT_BEZIERTO}, /* 101 */
1817 {117, 100, PT_LINETO}, /* 102 */
1818 {108, 100, PT_BEZIERTO}, /* 103 */
1819 {100, 110, PT_BEZIERTO}, /* 104 */
1820 {100, 122, PT_BEZIERTO}, /* 105 */
1821 {100, 177, PT_LINETO}, /* 106 */
1822 {100, 189, PT_BEZIERTO}, /* 107 */
1823 {108, 199, PT_BEZIERTO}, /* 108 */
1824 {117, 199, PT_BEZIERTO}, /* 109 */
1825 {182, 199, PT_LINETO}, /* 110 */
1826 {191, 199, PT_BEZIERTO}, /* 111 */
1827 {199, 189, PT_BEZIERTO}, /* 112 */
1828 {199, 177, PT_BEZIERTO | PT_CLOSEFIGURE}, /* 113 */
1829 {10, 10, PT_MOVETO}, /* 114 */
1830 {20, 10, PT_BEZIERTO}, /* 115 */
1831 {10, 20, PT_BEZIERTO}, /* 116 */
1832 {20, 20, PT_BEZIERTO}, /* 117 */
1833 {30, 30, PT_BEZIERTO}, /* 118 */
1834 {40, 20, PT_BEZIERTO}, /* 119 */
1835 {20, 30, PT_BEZIERTO}, /* 120 */
1836 {10, 10, PT_MOVETO}, /* 121 */
1837 {20, 10, PT_LINETO}, /* 122 */
1838 {10, 20, PT_LINETO}, /* 123 */
1839 {20, 20, PT_LINETO | PT_CLOSEFIGURE}, /* 124 */
1840 {30, 30, PT_MOVETO}, /* 125 */
1841 {40, 20, PT_LINETO}, /* 126 */
1842 {20, 30, PT_LINETO}, /* 127 */
1843 {30, 40, PT_LINETO}, /* 128 */
1844 {10, 50, PT_LINETO | PT_CLOSEFIGURE}, /* 129 */
1845 {10, 50, PT_MOVETO}, /* 130 */
1846 {10, 10, PT_BEZIERTO}, /* 131 */
1847 {20, 10, PT_BEZIERTO}, /* 132 */
1848 {10, 20, PT_BEZIERTO}, /* 133 */
1849 {20, 20, PT_BEZIERTO}, /* 134 */
1850 {30, 30, PT_BEZIERTO}, /* 135 */
1851 {40, 20, PT_BEZIERTO}, /* 136 */
1852 {20, 30, PT_BEZIERTO}, /* 137 */
1853 {30, 40, PT_BEZIERTO}, /* 138 */
1854 {10, 50, PT_BEZIERTO}, /* 139 */
1855 {150, 150, PT_LINETO}, /* 140 */
1856 };
1857
1858 /* run once through all functions that support paths */
1859 static void test_all_functions(void)
1860 {
1861 POINT pts[9] = {{10, 10}, {20, 10}, {10, 20}, {20, 20}, {30, 30}, {40, 20},
1862 {20, 30}, {30, 40}, {10, 50}};
1863 DWORD counts[5] = {4, 5, 0, 1, 2};
1864 BYTE types[9] = { PT_MOVETO, PT_LINETO, PT_BEZIERTO, PT_BEZIERTO, PT_BEZIERTO, PT_LINETO,
1865 PT_LINETO | PT_CLOSEFIGURE, PT_MOVETO, PT_LINETO };
1866 HDC hdc = GetDC( 0 );
1867
1868 BeginPath( hdc );
1869 LineTo( hdc, 50, 150 );
1870 MoveToEx( hdc, 50, 50, NULL );
1871 LineTo( hdc, 150, 150 );
1872 LineTo( hdc, 150, 50 );
1873 LineTo( hdc, 50, 50 );
1874 AngleArc( hdc, 37, 36, 23, 90, 180 );
1875 Polyline( hdc, pts, 4 );
1876 Arc( hdc, 21, 21, 39, 29, 39, 29, 21, 21 );
1877 PolylineTo( hdc, pts, 4 );
1878 ArcTo( hdc, 23, 23, 37, 27, 37, 27, 23, 23 );
1879 PolyPolyline( hdc, pts, counts, 2 );
1880 Chord( hdc, 42, 43, 57, 66, 39, 29, 21, 21 );
1881 PolyDraw( hdc, pts, types, 9 );
1882 Pie( hdc, 52, 54, 65, 68, 39, 29, 21, 21 );
1883 Polygon( hdc, pts, 9 );
1884 Ellipse( hdc, 22, 33, 44, 66 );
1885 Rectangle( hdc, 60, 70, 80, 90 );
1886 RoundRect( hdc, 100, 100, 200, 200, 35, 45 );
1887 PolyBezier( hdc, pts, 7 );
1888 PolyPolygon( hdc, pts, (int *)counts, 2 );
1889 PolyBezierTo( hdc, pts, 9 );
1890 LineTo( hdc, 150, 150 );
1891 /* FIXME: ExtTextOut */
1892 EndPath( hdc );
1893 ok_path( hdc, "all_funcs_path", all_funcs_path, sizeof(all_funcs_path)/sizeof(path_test_t) );
1894 ReleaseDC( 0, hdc );
1895 }
1896
1897 START_TEST(path)
1898 {
1899 test_path_state();
1900 test_widenpath();
1901 test_arcto();
1902 test_anglearc();
1903 test_polydraw();
1904 test_closefigure();
1905 test_linedda();
1906 test_rectangle();
1907 test_roundrect();
1908 test_ellipse();
1909 test_all_functions();
1910 }