ReactOS  0.4.15-dev-1201-gb2cf5a4
graphicspath.c
Go to the documentation of this file.
1 /*
2  * Unit test suite for paths
3  *
4  * Copyright (C) 2007 Google (Evan Stade)
5  *
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.
10  *
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.
15  *
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
19  */
20 
21 #include "objbase.h"
22 #include "gdiplus.h"
23 #include "wine/test.h"
24 #include <math.h>
25 
26 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
27 #define expectf(expected, got) ok(fabs(expected - got) < 2.0, "Expected %.2f, got %.2f\n", expected, got)
28 #define POINT_TYPE_MAX_LEN (75)
29 
31 {
32  *name = '\0';
33 
35  case PathPointTypeStart:
36  strcat(name, "PathPointTypeStart");
37  break;
38  case PathPointTypeLine:
39  strcat(name, "PathPointTypeLine");
40  break;
42  strcat(name, "PathPointTypeBezier");
43  break;
44  default:
45  strcat(name, "Unknown type");
46  return;
47  }
48 
51  *name = '\0';
52  strcat(name, "Unknown type");
53  return;
54  }
55 
57  strcat(name, " | PathPointTypePathMarker");
59  strcat(name, " | PathPointTypeCloseSubpath");
60 }
61 
62 /* this helper structure and function modeled after gdi path.c test */
63 typedef struct
64 {
65  REAL X, Y;
66  BYTE type;
67 
68  /* How many extra entries before this one only on wine
69  * but not on native? */
71 
72  /* 0 - This entry matches on wine.
73  * 1 - This entry corresponds to a single entry on wine that does not match the native entry.
74  * 2 - This entry is currently skipped on wine but present on native. */
75  int todo;
76 } path_test_t;
77 
78 static void ok_path(GpPath* path, const path_test_t *expected, INT expected_size, BOOL todo_size)
79 {
80  BYTE * types;
81  INT size, idx = 0, eidx = 0, numskip;
82  GpPointF * points;
84 
85  if(GdipGetPointCount(path, &size) != Ok){
86  skip("Cannot perform path comparisons due to failure to retrieve path.\n");
87  return;
88  }
89 
90  todo_wine_if (todo_size)
91  ok(size == expected_size, "Path size %d does not match expected size %d\n",
92  size, expected_size);
93 
94  points = HeapAlloc(GetProcessHeap(), 0, size * sizeof(GpPointF));
96 
98  skip("Cannot perform path comparisons due to failure to retrieve path.\n");
99  goto end;
100  }
101 
102  numskip = expected_size ? expected[eidx].wine_only_entries_preceding : 0;
103  while (idx < size && eidx < expected_size){
104  /* We allow a few pixels fudge in matching X and Y coordinates to account for imprecision in
105  * floating point to integer conversion */
106  BOOL match = (types[idx] == expected[eidx].type) &&
107  fabs(points[idx].X - expected[eidx].X) <= 2.0 &&
108  fabs(points[idx].Y - expected[eidx].Y) <= 2.0;
109 
110  stringify_point_type(expected[eidx].type, ename);
112 
113  todo_wine_if (expected[eidx].todo || numskip)
114  ok(match, "Expected #%d: %s (%.1f,%.1f) but got %s (%.1f,%.1f)\n", eidx,
115  ename, expected[eidx].X, expected[eidx].Y,
116  name, points[idx].X, points[idx].Y);
117 
118  if (match || expected[eidx].todo != 2)
119  idx++;
120  if (match || !numskip--)
121  numskip = expected[++eidx].wine_only_entries_preceding;
122  }
123 
124 end:
127 }
128 
130 {
132  GpPath* path = NULL;
133 
135  expect(Ok, status);
136  ok(path != NULL, "Expected path to be initialized\n");
137 
140 
142  expect(Ok, status);
143 }
144 
145 static void test_getpathdata(void)
146 {
147  GpPath *path;
150  INT count;
151 
153  expect(Ok, status);
154  status = GdipAddPathLine(path, 5.0, 5.0, 100.0, 50.0);
155  expect(Ok, status);
156 
158  expect(Ok, status);
159  expect(2, count);
160 
161  data.Count = count;
162  data.Types = GdipAlloc(sizeof(BYTE) * count);
163  data.Points = GdipAlloc(sizeof(PointF) * count);
164 
166  expect(Ok, status);
167  expect((data.Points[0].X == 5.0) && (data.Points[0].Y == 5.0) &&
168  (data.Points[1].X == 100.0) && (data.Points[1].Y == 50.0), TRUE);
169  expect((data.Types[0] == PathPointTypeStart) && (data.Types[1] == PathPointTypeLine), TRUE);
170 
171  GdipFree(data.Points);
172  GdipFree(data.Types);
174 }
175 
177  {0.0, 50.0, PathPointTypeStart, 0, 0}, /*0*/
178  {5.0, 45.0, PathPointTypeLine, 0, 0}, /*1*/
179  {0.0, 40.0, PathPointTypeLine, 0, 0}, /*2*/
180  {15.0, 35.0, PathPointTypeLine, 0, 0}, /*3*/
181  {0.0, 30.0, PathPointTypeLine, 0, 0}, /*4*/
182  {25.0, 25.0, PathPointTypeLine | PathPointTypeCloseSubpath, 0, 0}, /*5*/
183  {0.0, 20.0, PathPointTypeStart, 0, 0}, /*6*/
184  {35.0, 15.0, PathPointTypeLine, 0, 0}, /*7*/
185  {0.0, 10.0, PathPointTypeLine, 0, 0} /*8*/
186  };
187 
188 static void test_line2(void)
189 {
191  GpPath* path;
192  int i;
193  GpPointF line2_points[9];
194 
195  for(i = 0; i < 9; i ++){
196  line2_points[i].X = i * 5.0 * (REAL)(i % 2);
197  line2_points[i].Y = 50.0 - i * 5.0;
198  }
199 
201  status = GdipAddPathLine2(path, line2_points, 3);
202  expect(Ok, status);
203  status = GdipAddPathLine2(path, &(line2_points[3]), 3);
204  expect(Ok, status);
206  expect(Ok, status);
207  status = GdipAddPathLine2(path, &(line2_points[6]), 3);
208  expect(Ok, status);
209 
211 
213 }
214 
215 static path_test_t arc_path[] = {
216  {600.0, 450.0, PathPointTypeStart, 0, 0}, /*0*/
217  {600.0, 643.3, PathPointTypeBezier, 0, 0}, /*1*/
218  {488.1, 800.0, PathPointTypeBezier, 0, 0}, /*2*/
219  {350.0, 800.0, PathPointTypeBezier, 0, 0}, /*3*/
220  {600.0, 450.0, PathPointTypeLine, 0, 0}, /*4*/
221  {600.0, 643.3, PathPointTypeBezier, 0, 0}, /*5*/
222  {488.1, 800.0, PathPointTypeBezier, 0, 0}, /*6*/
223  {350.0, 800.0, PathPointTypeBezier, 0, 0}, /*7*/
224  {329.8, 800.0, PathPointTypeBezier, 0, 0}, /*8*/
225  {309.7, 796.6, PathPointTypeBezier, 0, 0}, /*9*/
226  {290.1, 789.8, PathPointTypeBezier, 0, 0}, /*10*/
227  {409.9, 110.2, PathPointTypeLine, 0, 0}, /*11*/
228  {544.0, 156.5, PathPointTypeBezier, 0, 0}, /*12*/
229  {625.8, 346.2, PathPointTypeBezier, 0, 0}, /*13*/
230  {592.7, 533.9, PathPointTypeBezier, 0, 0}, /*14*/
231  {592.5, 535.3, PathPointTypeBezier, 0, 0}, /*15*/
232  {592.2, 536.7, PathPointTypeBezier, 0, 0}, /*16*/
233  {592.0, 538.1, PathPointTypeBezier, 0, 0}, /*17*/
234  {409.9, 789.8, PathPointTypeLine, 0, 0}, /*18*/
235  {544.0, 743.5, PathPointTypeBezier, 0, 0}, /*19*/
236  {625.8, 553.8, PathPointTypeBezier, 0, 0}, /*20*/
237  {592.7, 366.1, PathPointTypeBezier, 0, 0}, /*21*/
238  {592.5, 364.7, PathPointTypeBezier, 0, 0}, /*22*/
239  {592.2, 363.3, PathPointTypeBezier, 0, 0}, /*23*/
240  {592.0, 361.9, PathPointTypeBezier, 0, 0}, /*24*/
241  {540.4, 676.9, PathPointTypeLine, 0, 0}, /*25*/
242  {629.9, 529.7, PathPointTypeBezier, 0, 0}, /*26*/
243  {617.2, 308.8, PathPointTypeBezier, 0, 0}, /*27*/
244  {512.1, 183.5, PathPointTypeBezier, 0, 0}, /*28*/
245  {406.9, 58.2, PathPointTypeBezier, 0, 0}, /*29*/
246  {249.1, 75.9, PathPointTypeBezier, 0, 0}, /*30*/
247  {159.6, 223.1, PathPointTypeBezier, 0, 0}, /*31*/
248  {70.1, 370.3, PathPointTypeBezier, 0, 0}, /*32*/
249  {82.8, 591.2, PathPointTypeBezier, 0, 0}, /*33*/
250  {187.9, 716.5, PathPointTypeBezier, 0, 0}, /*34*/
251  {293.1, 841.8, PathPointTypeBezier, 0, 0}, /*35*/
252  {450.9, 824.1, PathPointTypeBezier, 0, 0}, /*36*/
253  {540.4, 676.9, PathPointTypeBezier | PathPointTypeCloseSubpath, 0, 1} /*37*/
254  };
255 
256 static void test_arc(void)
257 {
259  GpPath* path;
260 
262  /* Exactly 90 degrees */
263  status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 90.0);
264  expect(Ok, status);
265  /* Over 90 degrees */
266  status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0);
267  expect(Ok, status);
268  /* Negative start angle */
269  status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, -80.0, 100.0);
270  expect(Ok, status);
271  /* Negative sweep angle */
272  status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 80.0, -100.0);
273  expect(Ok, status);
274  /* More than a full revolution */
275  status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 50.0, -400.0);
276  expect(Ok, status);
277  /* 0 sweep angle */
278  status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 50.0, 0.0);
279  expect(Ok, status);
280 
282 
284 }
285 
286 static void test_worldbounds(void)
287 {
289  GpPath *path;
290  GpPen *pen;
291  GpMatrix *matrix;
292  GpRectF bounds;
293  GpPointF line2_points[10];
294  int i;
295 
296  for(i = 0; i < 10; i ++){
297  line2_points[i].X = 200.0 + i * 50.0 * (i % 2);
298  line2_points[i].Y = 200.0 + i * 50.0 * !(i % 2);
299  }
300  GdipCreatePen1((ARGB)0xdeadbeef, 20.0, UnitWorld, &pen);
302  GdipCreateMatrix2(1.5, 0.0, 1.0, 1.2, 10.4, 10.2, &matrix);
303 
305  GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0);
306  GdipAddPathLine2(path, &(line2_points[0]), 10);
308  expect(Ok, status);
310 
311  expectf(200.0, bounds.X);
312  expectf(200.0, bounds.Y);
313  expectf(450.0, bounds.Width);
314  expectf(600.0, bounds.Height);
315 
317  GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0);
318  GdipAddPathLine2(path, &(line2_points[0]), 10);
320  expect(Ok, status);
322 
323  expectf(510.4, bounds.X);
324  expectf(250.2, bounds.Y);
325  expectf(1275.0, bounds.Width);
326  expectf(720.0, bounds.Height);
327 
329  GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0);
330  GdipAddPathLine2(path, &(line2_points[0]), 10);
331  status = GdipGetPathWorldBounds(path, &bounds, NULL, pen);
332  expect(Ok, status);
334 
335  expectf(100.0, bounds.X);
336  expectf(100.0, bounds.Y);
337  expectf(650.0, bounds.Width);
338  expectf(800.0, bounds.Height);
339 
341  GdipAddPathLine2(path, &(line2_points[0]), 2);
342  status = GdipGetPathWorldBounds(path, &bounds, NULL, pen);
343  expect(Ok, status);
345 
346  expectf(156.0, bounds.X);
347  expectf(156.0, bounds.Y);
348  expectf(138.0, bounds.Width);
349  expectf(88.0, bounds.Height);
350 
351  line2_points[2].X = 2 * line2_points[1].X - line2_points[0].X;
352  line2_points[2].Y = 2 * line2_points[1].Y - line2_points[0].Y;
353 
355  GdipAddPathLine2(path, &(line2_points[0]), 3);
356  status = GdipGetPathWorldBounds(path, &bounds, NULL, pen);
357  expect(Ok, status);
359 
360  expectf(100.0, bounds.X);
361  expectf(100.0, bounds.Y);
362  expectf(300.0, bounds.Width);
363  expectf(200.0, bounds.Height);
364 
366  GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 45.0, 20.0);
367  status = GdipGetPathWorldBounds(path, &bounds, NULL, pen);
368  expect(Ok, status);
370 
371  expectf(386.7, bounds.X);
372  expectf(553.4, bounds.Y);
373  expectf(266.8, bounds.Width);
374  expectf(289.6, bounds.Height);
375 
377  status = GdipGetPathWorldBounds(path, &bounds, matrix, pen);
378  expect(Ok, status);
380 
381  expectf(0.0, bounds.X);
382  expectf(0.0, bounds.Y);
383  expectf(0.0, bounds.Width);
384  expectf(0.0, bounds.Height);
385 
387  GdipAddPathLine2(path, &(line2_points[0]), 2);
388  status = GdipGetPathWorldBounds(path, &bounds, matrix, pen);
389  expect(Ok, status);
391 
392  todo_wine{
393  expectf(427.9, bounds.X);
394  expectf(167.7, bounds.Y);
395  expectf(239.9, bounds.Width);
396  expectf(164.9, bounds.Height);
397  }
398 
400  GdipCreateMatrix2(0.9, -0.5, -0.5, -1.2, 10.4, 10.2, &matrix);
402  GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0);
403  GdipAddPathLine2(path, &(line2_points[0]), 10);
405  expect(Ok, status);
408 
409  expectf(-209.6, bounds.X);
410  expectf(-1274.8, bounds.Y);
411  expectf(705.0, bounds.Width);
412  expectf(945.0, bounds.Height);
413 
414  GdipDeletePen(pen);
415 }
416 
418  {600.00, 450.00, PathPointTypeStart, 0, 0}, /*0*/
419  {600.00, 643.30, PathPointTypeBezier, 0, 0}, /*1*/
420  {488.07, 800.00, PathPointTypeBezier, 0, 0}, /*2*/
421  {350.00, 800.00, PathPointTypeBezier, 0, 0}, /*3*/
422  {319.61, 797.40, PathPointTypeStart, 0, 0}, /*4*/
423  {182.56, 773.90, PathPointTypeBezier, 0, 0}, /*5*/
424  {85.07, 599.31, PathPointTypeBezier, 0, 0}, /*6*/
425  {101.85, 407.45, PathPointTypeBezier, 0, 0}, /*7*/
426  {102.54, 399.66, PathPointTypeBezier, 0, 0}, /*8*/
427  {103.40, 391.91, PathPointTypeBezier, 0, 0}, /*9*/
428  {104.46, 384.21, PathPointTypeBezier, 0, 0}, /*10*/
429  {409.92, 110.20, PathPointTypeLine, 0, 0}, /*11*/
430  {543.96, 156.53, PathPointTypeBezier, 0, 0}, /*12*/
431  {625.80, 346.22, PathPointTypeBezier, 0, 0}, /*13*/
432  {592.71, 533.88, PathPointTypeBezier, 0, 0}, /*14*/
433  {592.47, 535.28, PathPointTypeBezier, 0, 0}, /*15*/
434  {592.22, 536.67, PathPointTypeBezier, 0, 0}, /*16*/
435  {591.96, 538.06, PathPointTypeBezier, 0, 0}, /*17*/
436  {319.61, 797.40, PathPointTypeLine, 0, 0}, /*18*/
437  {182.56, 773.90, PathPointTypeBezier, 0, 0}, /*19*/
438  {85.07, 599.31, PathPointTypeBezier, 0, 0}, /*20*/
439  {101.85, 407.45, PathPointTypeBezier, 0, 0}, /*21*/
440  {102.54, 399.66, PathPointTypeBezier, 0, 0}, /*22*/
441  {103.40, 391.91, PathPointTypeBezier, 0, 0}, /*23*/
442  {104.46, 384.21, PathPointTypeBezier, 0, 0} /*24*/
443  };
444 
445 static void test_pathpath(void)
446 {
448  GpPath* path1, *path2;
449 
451  GdipAddPathArc(path2, 100.0, 100.0, 500.0, 700.0, 95.0, 100.0);
452 
454  GdipAddPathArc(path1, 100.0, 100.0, 500.0, 700.0, 0.0, 90.0);
456  expect(Ok, status);
457  GdipAddPathArc(path1, 100.0, 100.0, 500.0, 700.0, -80.0, 100.0);
459  expect(Ok, status);
460 
462 
465 }
466 
468  {30.00, 125.25, PathPointTypeStart, 0, 0}, /*0*/
469  {30.00, 139.20, PathPointTypeBezier, 0, 0}, /*1*/
470  {25.52, 150.50, PathPointTypeBezier, 0, 0}, /*2*/
471  {20.00, 150.50, PathPointTypeBezier, 0, 0}, /*3*/
472  {14.48, 150.50, PathPointTypeBezier, 0, 0}, /*4*/
473  {10.00, 139.20, PathPointTypeBezier, 0, 0}, /*5*/
474  {10.00, 125.25, PathPointTypeBezier, 0, 0}, /*6*/
475  {10.00, 111.30, PathPointTypeBezier, 0, 0}, /*7*/
476  {14.48, 100.00, PathPointTypeBezier, 0, 0}, /*8*/
477  {20.00, 100.00, PathPointTypeBezier, 0, 0}, /*9*/
478  {25.52, 100.00, PathPointTypeBezier, 0, 0}, /*10*/
479  {30.00, 111.30, PathPointTypeBezier, 0, 0}, /*11*/
480  {30.00, 125.25, PathPointTypeBezier | PathPointTypeCloseSubpath, 0, 0}, /*12*/
481  {7.00, 11.00, PathPointTypeStart, 0, 0}, /*13*/
482  {13.00, 17.00, PathPointTypeLine, 0, 0}, /*14*/
483  {5.00, 195.00, PathPointTypeStart, 0, 0}, /*15*/
484  {5.00, 192.24, PathPointTypeBezier, 0, 0}, /*16*/
485  {6.12, 190.00, PathPointTypeBezier, 0, 0}, /*17*/
486  {7.50, 190.00, PathPointTypeBezier, 0, 0}, /*18*/
487  {8.88, 190.00, PathPointTypeBezier, 0, 0}, /*19*/
488  {10.00, 192.24, PathPointTypeBezier, 0, 0}, /*20*/
489  {10.00, 195.00, PathPointTypeBezier, 0, 0}, /*21*/
490  {10.00, 197.76, PathPointTypeBezier, 0, 0}, /*22*/
491  {8.88, 200.00, PathPointTypeBezier, 0, 0}, /*23*/
492  {7.50, 200.00, PathPointTypeBezier, 0, 0}, /*24*/
493  {6.12, 200.00, PathPointTypeBezier, 0, 0}, /*25*/
494  {5.00, 197.76, PathPointTypeBezier, 0, 0}, /*26*/
495  {5.00, 195.00, PathPointTypeBezier | PathPointTypeCloseSubpath, 0, 0}, /*27*/
496  {10.00, 300.50, PathPointTypeStart, 0, 0}, /*28*/
497  {10.00, 300.78, PathPointTypeBezier, 0, 0}, /*29*/
498  {10.00, 301.00, PathPointTypeBezier, 0, 0}, /*30*/
499  {10.00, 301.00, PathPointTypeBezier, 0, 0}, /*31*/
500  {10.00, 301.00, PathPointTypeBezier, 0, 0}, /*32*/
501  {10.00, 300.78, PathPointTypeBezier, 0, 0}, /*33*/
502  {10.00, 300.50, PathPointTypeBezier, 0, 0}, /*34*/
503  {10.00, 300.22, PathPointTypeBezier, 0, 0}, /*35*/
504  {10.00, 300.00, PathPointTypeBezier, 0, 0}, /*36*/
505  {10.00, 300.00, PathPointTypeBezier, 0, 0}, /*37*/
506  {10.00, 300.00, PathPointTypeBezier, 0, 0}, /*38*/
507  {10.00, 300.22, PathPointTypeBezier, 0, 0}, /*39*/
508  {10.00, 300.50, PathPointTypeBezier | PathPointTypeCloseSubpath, 0, 0} /*40*/
509  };
510 
511 static void test_ellipse(void)
512 {
514  GpPath *path;
515  GpPointF points[2];
516 
517  points[0].X = 7.0;
518  points[0].Y = 11.0;
519  points[1].X = 13.0;
520  points[1].Y = 17.0;
521 
523  status = GdipAddPathEllipse(path, 10.0, 100.0, 20.0, 50.5);
524  expect(Ok, status);
526  status = GdipAddPathEllipse(path, 10.0, 200.0, -5.0, -10.0);
527  expect(Ok, status);
529  status = GdipAddPathEllipse(path, 10.0, 300.0, 0.0, 1.0);
530  expect(Ok, status);
531 
533 
535 }
536 
538  {5.00, 5.00, PathPointTypeStart, 0, 0}, /*0*/
539  {6.00, 8.00, PathPointTypeLine, 0, 0}, /*1*/
540  {409.92, 110.20, PathPointTypeLine, 0, 0}, /*2*/
541  {543.96, 156.53, PathPointTypeBezier, 0, 0}, /*3*/
542  {625.80, 346.22, PathPointTypeBezier, 0, 0}, /*4*/
543  {592.71, 533.88, PathPointTypeBezier, 0, 0}, /*5*/
544  {592.47, 535.28, PathPointTypeBezier, 0, 0}, /*6*/
545  {592.22, 536.67, PathPointTypeBezier, 0, 0}, /*7*/
546  {591.96, 538.06, PathPointTypeBezier, 0, 0}, /*8*/
547  {15.00, 15.00, PathPointTypeLine, 0, 0}, /*9*/
548  {26.00, 28.00, PathPointTypeLine | PathPointTypeCloseSubpath, 0, 0}, /*10*/
549  {35.00, 35.00, PathPointTypeStart, 0, 0}, /*11*/
550  {36.00, 38.00, PathPointTypeLine, 0, 0} /*12*/
551  };
552 
553 static void test_linei(void)
554 {
556  GpPath *path;
557 
559  status = GdipAddPathLineI(path, 5.0, 5.0, 6.0, 8.0);
560  expect(Ok, status);
561  GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, -80.0, 100.0);
562  status = GdipAddPathLineI(path, 15.0, 15.0, 26.0, 28.0);
563  expect(Ok, status);
565  status = GdipAddPathLineI(path, 35.0, 35.0, 36.0, 38.0);
566  expect(Ok, status);
567 
569 
571 }
572 
573 static path_test_t poly_path[] = {
574  {5.00, 5.00, PathPointTypeStart, 0, 0}, /*1*/
575  {6.00, 8.00, PathPointTypeLine, 0, 0}, /*2*/
576  {0.00, 0.00, PathPointTypeStart, 0, 0}, /*3*/
577  {10.00, 10.00, PathPointTypeLine, 0, 0}, /*4*/
578  {10.00, 20.00, PathPointTypeLine, 0, 0}, /*5*/
579  {30.00, 10.00, PathPointTypeLine, 0, 0}, /*6*/
580  {20.00, 0.00, PathPointTypeLine | PathPointTypeCloseSubpath, 0, 0}, /*7*/
581  };
582 
583 static void test_polygon(void)
584 {
586  GpPath *path;
587  GpPointF points[5];
588 
589  points[0].X = 0.0;
590  points[0].Y = 0.0;
591  points[1].X = 10.0;
592  points[1].Y = 10.0;
593  points[2].X = 10.0;
594  points[2].Y = 20.0;
595  points[3].X = 30.0;
596  points[3].Y = 10.0;
597  points[4].X = 20.0;
598  points[4].Y = 0.0;
599 
601 
602  /* NULL args */
607  /* Polygon should have 3 points at least */
610 
611  /* to test how it prolongs not empty path */
612  status = GdipAddPathLine(path, 5.0, 5.0, 6.0, 8.0);
613  expect(Ok, status);
615  expect(Ok, status);
616  /* check resulting path */
618 
620 }
621 
622 static path_test_t rect_path[] = {
623  {5.0, 5.0, PathPointTypeStart, 0, 0}, /*0*/
624  {105.0, 5.0, PathPointTypeLine, 0, 0}, /*1*/
625  {105.0, 55.0, PathPointTypeLine, 0, 0}, /*2*/
626  {5.0, 55.0, PathPointTypeLine | PathPointTypeCloseSubpath, 0, 0}, /*3*/
627 
628  {100.0, 50.0, PathPointTypeStart, 0, 0}, /*4*/
629  {220.0, 50.0, PathPointTypeLine, 0, 0}, /*5*/
630  {220.0, 80.0, PathPointTypeLine, 0, 0}, /*6*/
631  {100.0, 80.0, PathPointTypeLine | PathPointTypeCloseSubpath, 0, 0} /*7*/
632  };
633 
634 static void test_rect(void)
635 {
637  GpPath *path;
638  GpRectF rects[2];
639 
641  status = GdipAddPathRectangle(path, 5.0, 5.0, 100.0, 50.0);
642  expect(Ok, status);
643  status = GdipAddPathRectangle(path, 100.0, 50.0, 120.0, 30.0);
644  expect(Ok, status);
645 
647 
649 
651 
652  rects[0].X = 5.0;
653  rects[0].Y = 5.0;
654  rects[0].Width = 100.0;
655  rects[0].Height = 50.0;
656  rects[1].X = 100.0;
657  rects[1].Y = 50.0;
658  rects[1].Width = 120.0;
659  rects[1].Height = 30.0;
660 
662  expect(Ok, status);
663 
665 
667 }
668 
669 static void test_lastpoint(void)
670 {
672  GpPath *path;
673  GpPointF ptf;
674 
676  status = GdipAddPathRectangle(path, 5.0, 5.0, 100.0, 50.0);
677  expect(Ok, status);
678 
679  /* invalid args */
686 
688  expect(Ok, status);
689  expect(TRUE, (ptf.X == 5.0) && (ptf.Y == 55.0));
690 
692 }
693 
695  {0.0, 0.0, PathPointTypeStart, 0, 0}, /*0*/
696  {3.3, 3.3, PathPointTypeBezier, 0, 0}, /*1*/
697  {6.7, 3.3, PathPointTypeBezier, 0, 0}, /*2*/
698  {10.0, 10.0, PathPointTypeBezier, 0, 0}, /*3*/
699  {13.3, 16.7, PathPointTypeBezier, 0, 0}, /*4*/
700  {3.3, 20.0, PathPointTypeBezier, 0, 0}, /*5*/
701  {10.0, 20.0, PathPointTypeBezier, 0, 0}, /*6*/
702  {16.7, 20.0, PathPointTypeBezier, 0, 0}, /*7*/
703  {23.3, 13.3, PathPointTypeBezier, 0, 0}, /*8*/
704  {30.0, 10.0, PathPointTypeBezier, 0, 0} /*9*/
705  };
707  {100.0,120.0,PathPointTypeStart, 0, 0}, /*0*/
708  {123.0,10.0, PathPointTypeLine, 0, 0}, /*1*/
709  {0.0, 0.0, PathPointTypeLine, 0, 0}, /*2*/
710  {3.3, 3.3, PathPointTypeBezier, 0, 0}, /*3*/
711  {6.7, 3.3, PathPointTypeBezier, 0, 0}, /*4*/
712  {10.0, 10.0, PathPointTypeBezier, 0, 0}, /*5*/
713  {13.3, 16.7, PathPointTypeBezier, 0, 0}, /*6*/
714  {3.3, 20.0, PathPointTypeBezier, 0, 0}, /*7*/
715  {10.0, 20.0, PathPointTypeBezier, 0, 0}, /*8*/
716  {16.7, 20.0, PathPointTypeBezier, 0, 0}, /*9*/
717  {23.3, 13.3, PathPointTypeBezier, 0, 0}, /*10*/
718  {30.0, 10.0, PathPointTypeBezier, 0, 0} /*11*/
719  };
721  {10.0, 10.0, PathPointTypeStart, 0, 0}, /*0*/
722  {13.3, 16.7, PathPointTypeBezier, 0, 1}, /*1*/
723  {3.3, 20.0, PathPointTypeBezier, 0, 0}, /*2*/
724  {10.0, 20.0, PathPointTypeBezier, 0, 0}, /*3*/
725  {16.7, 20.0, PathPointTypeBezier, 0, 0}, /*4*/
726  {23.3, 13.3, PathPointTypeBezier, 0, 0}, /*5*/
727  {30.0, 10.0, PathPointTypeBezier, 0, 0} /*6*/
728  };
729 static void test_addcurve(void)
730 {
732  GpPath *path;
733  GpPointF points[4];
734 
735  points[0].X = 0.0;
736  points[0].Y = 0.0;
737  points[1].X = 10.0;
738  points[1].Y = 10.0;
739  points[2].X = 10.0;
740  points[2].Y = 20.0;
741  points[3].X = 30.0;
742  points[3].Y = 10.0;
743 
745 
746  /* NULL args */
747  status = GdipAddPathCurve2(NULL, NULL, 0, 0.0);
749  status = GdipAddPathCurve2(path, NULL, 0, 0.0);
751  status = GdipAddPathCurve2(path, points, -1, 0.0);
753  status = GdipAddPathCurve2(path, points, 1, 1.0);
755 
756  /* add to empty path */
757  status = GdipAddPathCurve2(path, points, 4, 1.0);
758  expect(Ok, status);
761 
762  /* add to notempty path and opened figure */
764  GdipAddPathLine(path, 100.0, 120.0, 123.0, 10.0);
765  status = GdipAddPathCurve2(path, points, 4, 1.0);
766  expect(Ok, status);
768 
769  /* NULL args */
771  status = GdipAddPathCurve3(NULL, NULL, 0, 0, 0, 0.0);
773  status = GdipAddPathCurve3(path, NULL, 0, 0, 0, 0.0);
775  /* wrong count, offset.. */
776  status = GdipAddPathCurve3(path, points, 0, 0, 0, 0.0);
778  status = GdipAddPathCurve3(path, points, 4, 0, 0, 0.0);
780  status = GdipAddPathCurve3(path, points, 4, 0, 4, 0.0);
782  status = GdipAddPathCurve3(path, points, 4, 1, 3, 0.0);
784  status = GdipAddPathCurve3(path, points, 4, 1, 0, 0.0);
786  status = GdipAddPathCurve3(path, points, 4, 3, 1, 0.0);
788 
789  /* use all points */
790  status = GdipAddPathCurve3(path, points, 4, 0, 3, 1.0);
791  expect(Ok, status);
794 
795  status = GdipAddPathCurve3(path, points, 4, 1, 2, 1.0);
796  expect(Ok, status);
798 
800 }
801 
803  {0.0, 0.0, PathPointTypeStart, 0, 0}, /*0*/
804  {-6.7, 0.0, PathPointTypeBezier, 0, 0}, /*1*/
805  {6.7, 3.3, PathPointTypeBezier, 0, 0}, /*2*/
806  {10.0, 10.0, PathPointTypeBezier, 0, 0}, /*3*/
807  {13.3, 16.7, PathPointTypeBezier, 0, 0}, /*4*/
808  {3.3, 20.0, PathPointTypeBezier, 0, 0}, /*5*/
809  {10.0, 20.0, PathPointTypeBezier, 0, 0}, /*6*/
810  {16.7, 20.0, PathPointTypeBezier, 0, 0}, /*7*/
811  {33.3, 16.7, PathPointTypeBezier, 0, 0}, /*8*/
812  {30.0, 10.0, PathPointTypeBezier, 0, 0}, /*9*/
813  {26.7, 3.3, PathPointTypeBezier, 0, 0}, /*10*/
814  {6.7, 0.0, PathPointTypeBezier, 0, 0}, /*11*/
815  {0.0, 0.0, PathPointTypeBezier | PathPointTypeCloseSubpath, 0, 0} /*12*/
816  };
817 static void test_addclosedcurve(void)
818 {
820  GpPath *path;
821  GpPointF points[4];
822 
823  points[0].X = 0.0;
824  points[0].Y = 0.0;
825  points[1].X = 10.0;
826  points[1].Y = 10.0;
827  points[2].X = 10.0;
828  points[2].Y = 20.0;
829  points[3].X = 30.0;
830  points[3].Y = 10.0;
831 
833 
834  /* NULL args */
843 
844  /* add to empty path */
846  expect(Ok, status);
849 }
850 
852  {0.0, 20.0, PathPointTypeStart, 0, 0}, /*0*/
853  {25.0, 25.0, PathPointTypeLine, 0, 0}, /*1*/
854  {0.0, 30.0, PathPointTypeLine, 0, 0}, /*2*/
855  {15.0, 35.0, PathPointTypeStart, 0, 0}, /*3*/
856  {0.0, 40.0, PathPointTypeLine, 0, 0}, /*4*/
857  {5.0, 45.0, PathPointTypeLine, 0, 0}, /*5*/
858  {0.0, 50.0, PathPointTypeLine | PathPointTypeCloseSubpath, 0, 0} /*6*/
859  };
860 
861 static void test_reverse(void)
862 {
864  GpPath *path;
865  GpPointF pts[7];
866  INT i;
867 
868  for(i = 0; i < 7; i++){
869  pts[i].X = i * 5.0 * (REAL)(i % 2);
870  pts[i].Y = 50.0 - i * 5.0;
871  }
872 
874 
875  /* NULL argument */
878 
879  /* empty path */
881  expect(Ok, status);
882 
883  GdipAddPathLine2(path, pts, 4);
885  GdipAddPathLine2(path, &(pts[4]), 3);
886 
888  expect(Ok, status);
890 
892 }
893 
895  {50.0, 25.0, PathPointTypeStart, 0, 0}, /*0*/
896  {97.2, 33.3, PathPointTypeLine, 0, 0}, /*1*/
897  {91.8, 40.9, PathPointTypeBezier,0, 0}, /*2*/
898  {79.4, 46.8, PathPointTypeBezier,0, 0}, /*3*/
899  {63.9, 49.0, PathPointTypeBezier | PathPointTypeCloseSubpath, 0, 0} /*4*/
900  };
902  {0.0, 30.0, PathPointTypeStart | PathPointTypeCloseSubpath, 0, 0} /*0*/
903  };
905  {30.0, 0.0, PathPointTypeStart | PathPointTypeCloseSubpath, 0, 0} /*0*/
906  };
907 static void test_addpie(void)
908 {
910  GpPath *path;
911 
913 
914  /* NULL argument */
915  status = GdipAddPathPie(NULL, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
917 
918  status = GdipAddPathPie(path, 0.0, 0.0, 100.0, 50.0, 10.0, 50.0);
919  expect(Ok, status);
922  expect(Ok, status);
923 
924  /* zero width base ellipse */
925  status = GdipAddPathPie(path, 0.0, 0.0, 0.0, 60.0, -90.0, 24.0);
929  expect(Ok, status);
930 
931  /* zero height base ellipse */
932  status = GdipAddPathPie(path, 0.0, 0.0, 60.0, 0.0 , -90.0, 24.0);
935 
937 }
938 
940  {100.0, 25.0,PathPointTypeStart, 0, 0}, /*0*/
941  {99.0, 30.0, PathPointTypeLine, 0, 0}, /*1*/
942  {96.0, 34.8, PathPointTypeLine, 0, 0}, /*2*/
943  {91.5, 39.0, PathPointTypeLine, 0, 0}, /*3*/
944  {85.5, 42.8, PathPointTypeLine, 0, 0}, /*4*/
945  {69.5, 48.0, PathPointTypeLine, 0, 1}, /*5*/
946  {50.0, 50.0, PathPointTypeLine, 0, 1}, /*6*/
947  {30.5, 48.0, PathPointTypeLine, 0, 1}, /*7*/
948  {14.8, 42.8, PathPointTypeLine, 0, 1}, /*8*/
949  {8.5, 39.0, PathPointTypeLine, 0, 1}, /*9*/
950  {4.0, 34.8, PathPointTypeLine, 0, 1}, /*10*/
951  {1.0, 30.0, PathPointTypeLine, 0, 1}, /*11*/
952  {0.0, 25.0, PathPointTypeLine, 0, 1}, /*12*/
953  {1.0, 20.0, PathPointTypeLine, 0, 1}, /*13*/
954  {4.0, 15.3, PathPointTypeLine, 0, 1}, /*14*/
955  {8.5, 11.0, PathPointTypeLine, 0, 1}, /*15*/
956  {14.8, 7.3, PathPointTypeLine, 0, 1}, /*16*/
957  {30.5, 2.0, PathPointTypeLine, 0, 1}, /*17*/
958  {50.0, 0.0, PathPointTypeLine, 0, 1}, /*18*/
959  {69.5, 2.0, PathPointTypeLine, 0, 1}, /*19*/
960  {85.5, 7.3, PathPointTypeLine, 0, 1}, /*20*/
961  {91.5, 11.0, PathPointTypeLine, 0, 1}, /*21*/
962  {96.0, 15.3, PathPointTypeLine, 0, 1}, /*22*/
963  {99.0, 20.0, PathPointTypeLine, 0, 1}, /*23*/
964  {100.0,25.0, PathPointTypeLine | PathPointTypeCloseSubpath, 0, 1} /*24*/
965  };
966 
968  {5.0, 10.0,PathPointTypeStart, 0, 0}, /*0*/
969  {50.0, 100.0, PathPointTypeLine, 0, 0} /*1*/
970  };
971 
973  {100.0, 25.0,PathPointTypeStart, 0, 0}, /*0*/
974  {99.0, 30.0, PathPointTypeLine, 0, 0}, /*1*/
975  {96.0, 34.8, PathPointTypeLine, 0, 0}, /*2*/
976  {91.5, 39.0, PathPointTypeLine, 0, 0}, /*3*/
977  {85.5, 42.8, PathPointTypeLine, 0, 0}, /*4*/
978  {69.5, 48.0, PathPointTypeLine, 0, 1}, /*5*/
979  {50.0, 50.0, PathPointTypeLine, 0, 1} /*6*/
980  };
981 
983  {100.0, 50.0,PathPointTypeStart, 0, 0}, /*0*/
984  {99.0, 60.0, PathPointTypeLine, 0, 0}, /*1*/
985  {96.0, 69.5, PathPointTypeLine, 0, 0}, /*2*/
986  {91.5, 78.0, PathPointTypeLine, 0, 0}, /*3*/
987  {85.5, 85.5, PathPointTypeLine, 0, 0}, /*4*/
988  {78.0, 91.5, PathPointTypeLine, 0, 0}, /*5*/
989  {69.5, 96.0, PathPointTypeLine, 0, 0}, /*6*/
990  {60.0, 99.0, PathPointTypeLine, 0, 0}, /*7*/
991  {50.0, 100.0,PathPointTypeLine, 0, 0} /*8*/
992  };
993 
994 static void test_flatten(void)
995 {
997  GpPath *path;
998  GpMatrix *m;
999 
1001  expect(Ok, status);
1003  expect(Ok, status);
1004 
1005  /* NULL arguments */
1006  status = GdipFlattenPath(NULL, NULL, 0.0);
1008  status = GdipFlattenPath(NULL, m, 0.0);
1010 
1011  /* flatten empty path */
1012  status = GdipFlattenPath(path, NULL, 1.0);
1013  expect(Ok, status);
1014 
1016  expect(Ok, status);
1017 
1018  status = GdipAddPathEllipse(path, 0.0, 0.0, 100.0, 50.0);
1019  expect(Ok, status);
1020 
1021  status = GdipFlattenPath(path, NULL, 1.0);
1022  expect(Ok, status);
1024 
1026  expect(Ok, status);
1027  status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 100.0);
1028  expect(Ok, status);
1029  status = GdipFlattenPath(path, NULL, 1.0);
1030  expect(Ok, status);
1032 
1034  expect(Ok, status);
1035  status = GdipAddPathArc(path, 0.0, 0.0, 100.0, 50.0, 0.0, 90.0);
1036  expect(Ok, status);
1037  status = GdipFlattenPath(path, NULL, 1.0);
1038  expect(Ok, status);
1040 
1041  /* easy case - quater of a full circle */
1043  expect(Ok, status);
1044  status = GdipAddPathArc(path, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
1045  expect(Ok, status);
1046  status = GdipFlattenPath(path, NULL, 1.0);
1047  expect(Ok, status);
1049 
1052 }
1053 
1055  {5.0, 5.0, PathPointTypeStart, 0, 0}, /*0*/
1056  {50.0, 5.0, PathPointTypeLine, 0, 0}, /*1*/
1057  {50.0, 15.0, PathPointTypeLine, 0, 0}, /*2*/
1058  {5.0, 15.0, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 0} /*3*/
1059  };
1060 
1062  {5.0, 0.0, PathPointTypeStart, 0, 0}, /*0*/
1063  {50.0, 0.0, PathPointTypeLine, 0, 0}, /*1*/
1064  {50.0, 20.0, PathPointTypeLine, 0, 0}, /*2*/
1065  {5.0, 20.0, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 0} /*3*/
1066  };
1067 
1069  {5.0, 0.0, PathPointTypeStart, 0, 0}, /*0*/
1070  {35.0, 0.0, PathPointTypeLine, 0, 0}, /*1*/
1071  {35.0, 10.0, PathPointTypeLine, 0, 0}, /*2*/
1072  {5.0, 10.0, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 0}, /*3*/
1073  {45.0, 0.0, PathPointTypeStart, 0, 0}, /*4*/
1074  {50.0, 0.0, PathPointTypeLine, 0, 0}, /*5*/
1075  {50.0, 10.0, PathPointTypeLine, 0, 0}, /*6*/
1076  {45.0, 10.0, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 0}, /*7*/
1077  };
1078 
1079 static void test_widen(void)
1080 {
1081  GpStatus status;
1082  GpPath *path;
1083  GpPen *pen;
1084  GpMatrix *m;
1085  INT count=-1;
1086 
1088  expect(Ok, status);
1089  status = GdipCreatePen1(0xffffffff, 10.0, UnitPixel, &pen);
1090  expect(Ok, status);
1092  expect(Ok, status);
1093 
1094  /* NULL arguments */
1095  status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 10.0);
1096  expect(Ok, status);
1097  status = GdipWidenPath(NULL, NULL, NULL, 0.0);
1099  status = GdipWidenPath(path, pen, m, 0.0);
1100  expect(Ok, status);
1101  status = GdipWidenPath(path, pen, NULL, 1.0);
1102  expect(Ok, status);
1103  status = GdipWidenPath(path, NULL, m, 1.0);
1105  status = GdipWidenPath(NULL, pen, m, 1.0);
1107 
1108  /* widen empty path */
1110  expect(Ok, status);
1111  status = GdipWidenPath(path, pen, m, 1.0);
1113 
1114  /* horizontal line */
1116  expect(Ok, status);
1117  status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 10.0);
1118  expect(Ok, status);
1119 
1120  status = GdipWidenPath(path, pen, m, 1.0);
1121  expect(Ok, status);
1123 
1124  /* horizontal 2x stretch */
1126  expect(Ok, status);
1127  status = GdipAddPathLine(path, 2.5, 10.0, 25.0, 10.0);
1128  expect(Ok, status);
1129 
1130  status = GdipScaleMatrix(m, 2.0, 1.0, MatrixOrderAppend);
1131  expect(Ok, status);
1132 
1133  status = GdipWidenPath(path, pen, m, 1.0);
1134  expect(Ok, status);
1136 
1137  /* vertical 2x stretch */
1139  expect(Ok, status);
1140  status = GdipAddPathLine(path, 5.0, 5.0, 50.0, 5.0);
1141  expect(Ok, status);
1142 
1143  status = GdipScaleMatrix(m, 0.5, 2.0, MatrixOrderAppend);
1144  expect(Ok, status);
1145 
1146  status = GdipWidenPath(path, pen, m, 1.0);
1147  expect(Ok, status);
1149 
1150  status = GdipScaleMatrix(m, 1.0, 0.5, MatrixOrderAppend);
1151  expect(Ok, status);
1152 
1153  /* dashed line */
1155  expect(Ok, status);
1156  status = GdipAddPathLine(path, 5.0, 5.0, 50.0, 5.0);
1157  expect(Ok, status);
1158 
1160  expect(Ok, status);
1161 
1162  status = GdipWidenPath(path, pen, m, 1.0);
1163  expect(Ok, status);
1165 
1167  expect(Ok, status);
1168 
1169  /* pen width in UnitWorld */
1170  GdipDeletePen(pen);
1171  status = GdipCreatePen1(0xffffffff, 10.0, UnitWorld, &pen);
1172  expect(Ok, status);
1173 
1175  expect(Ok, status);
1176  status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 10.0);
1177  expect(Ok, status);
1178 
1179  status = GdipWidenPath(path, pen, m, 1.0);
1180  expect(Ok, status);
1182 
1183  /* horizontal 2x stretch */
1185  expect(Ok, status);
1186  status = GdipAddPathLine(path, 2.5, 10.0, 25.0, 10.0);
1187  expect(Ok, status);
1188 
1189  status = GdipScaleMatrix(m, 2.0, 1.0, MatrixOrderAppend);
1190  expect(Ok, status);
1191 
1192  status = GdipWidenPath(path, pen, m, 1.0);
1193  expect(Ok, status);
1195 
1196  /* vertical 2x stretch */
1198  expect(Ok, status);
1199  status = GdipAddPathLine(path, 5.0, 5.0, 50.0, 5.0);
1200  expect(Ok, status);
1201 
1202  status = GdipScaleMatrix(m, 0.5, 2.0, MatrixOrderAppend);
1203  expect(Ok, status);
1204 
1205  status = GdipWidenPath(path, pen, m, 1.0);
1206  expect(Ok, status);
1208 
1209  status = GdipScaleMatrix(m, 1.0, 0.5, MatrixOrderAppend);
1210  expect(Ok, status);
1211 
1212  /* pen width in UnitInch */
1213  GdipDeletePen(pen);
1214  status = GdipCreatePen1(0xffffffff, 10.0, UnitWorld, &pen);
1215  expect(Ok, status);
1216 
1218  expect(Ok, status);
1219  status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 10.0);
1220  expect(Ok, status);
1221 
1222  status = GdipWidenPath(path, pen, m, 1.0);
1223  expect(Ok, status);
1225 
1226  /* pen width = 0 pixels - native fails to widen but can draw with this pen */
1227  GdipDeletePen(pen);
1228  status = GdipCreatePen1(0xffffffff, 0.0, UnitPixel, &pen);
1229  expect(Ok, status);
1230 
1232  expect(Ok, status);
1233  status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 10.0);
1234  expect(Ok, status);
1235 
1236  status = GdipWidenPath(path, pen, m, 1.0);
1237  expect(Ok, status);
1238 
1240  expect(Ok, status);
1241  todo_wine expect(0, count);
1242 
1244  GdipDeletePen(pen);
1246 }
1247 
1248 static void test_isvisible(void)
1249 {
1250  GpPath *path;
1251  GpGraphics *graphics = NULL;
1252  HDC hdc = GetDC(0);
1253  BOOL result;
1254  GpStatus status;
1255 
1256  status = GdipCreateFromHDC(hdc, &graphics);
1257  expect(Ok, status);
1259  expect(Ok, status);
1260 
1261  /* NULL */
1262  status = GdipIsVisiblePathPoint(NULL, 0.0, 0.0, NULL, NULL);
1264  status = GdipIsVisiblePathPoint(path, 0.0, 0.0, NULL, NULL);
1266  status = GdipIsVisiblePathPoint(path, 0.0, 0.0, NULL, NULL);
1268  status = GdipIsVisiblePathPoint(path, 0.0, 0.0, graphics, NULL);
1270 
1271  /* empty path */
1272  result = TRUE;
1273  status = GdipIsVisiblePathPoint(path, 0.0, 0.0, NULL, &result);
1274  expect(Ok, status);
1275  expect(FALSE, result);
1276  /* rect */
1277  status = GdipAddPathRectangle(path, 0.0, 0.0, 10.0, 10.0);
1278  expect(Ok, status);
1279  result = FALSE;
1280  status = GdipIsVisiblePathPoint(path, 0.0, 0.0, NULL, &result);
1281  expect(Ok, status);
1282  expect(TRUE, result);
1283  result = TRUE;
1284  status = GdipIsVisiblePathPoint(path, 11.0, 11.0, NULL, &result);
1285  expect(Ok, status);
1286  expect(FALSE, result);
1287  /* not affected by clipping */
1288  status = GdipSetClipRect(graphics, 5.0, 5.0, 5.0, 5.0, CombineModeReplace);
1289  expect(Ok, status);
1290  result = FALSE;
1291  status = GdipIsVisiblePathPoint(path, 0.0, 0.0, graphics, &result);
1292  expect(Ok, status);
1293  expect(TRUE, result);
1294 
1296  GdipDeleteGraphics(graphics);
1297  ReleaseDC(0, hdc);
1298 }
1299 
1300 static void test_empty_rect(void)
1301 {
1302  GpPath *path;
1303  GpStatus status;
1304  INT count;
1305  BOOL result;
1306 
1308  expect(Ok, status);
1309 
1310  status = GdipAddPathRectangle(path, 0.0, 0.0, -5.0, 5.0);
1311  expect(Ok, status);
1312 
1314  expect(Ok, status);
1315  expect(0, count);
1316 
1317  status = GdipIsVisiblePathPoint(path, -2.0, 2.0, NULL, &result);
1318  expect(Ok, status);
1319  expect(FALSE, result);
1320 
1321  status = GdipAddPathRectangle(path, 0.0, 0.0, 5.0, -5.0);
1322  expect(Ok, status);
1323 
1325  expect(Ok, status);
1326  expect(0, count);
1327 
1328  status = GdipAddPathRectangle(path, 0.0, 0.0, 0.0, 5.0);
1329  expect(Ok, status);
1330 
1332  expect(Ok, status);
1333  expect(0, count);
1334 
1335  status = GdipAddPathRectangle(path, 0.0, 0.0, 5.0, 0.0);
1336  expect(Ok, status);
1337 
1339  expect(Ok, status);
1340  expect(0, count);
1341 
1342  status = GdipAddPathRectangle(path, 0.0, 0.0, 5.0, 0.1);
1343  expect(Ok, status);
1344 
1346  expect(Ok, status);
1347  expect(4, count);
1348 
1350 }
1351 
1352 START_TEST(graphicspath)
1353 {
1356  HMODULE hmsvcrt;
1357  int (CDECL * _controlfp_s)(unsigned int *cur, unsigned int newval, unsigned int mask);
1358 
1359  /* Enable all FP exceptions except _EM_INEXACT, which gdi32 can trigger */
1360  hmsvcrt = LoadLibraryA("msvcrt");
1361  _controlfp_s = (void*)GetProcAddress(hmsvcrt, "_controlfp_s");
1362  if (_controlfp_s) _controlfp_s(0, 0, 0x0008001e);
1363 
1364  gdiplusStartupInput.GdiplusVersion = 1;
1365  gdiplusStartupInput.DebugEventCallback = NULL;
1366  gdiplusStartupInput.SuppressBackgroundThread = 0;
1367  gdiplusStartupInput.SuppressExternalCodecs = 0;
1368 
1370 
1372  test_getpathdata();
1373  test_line2();
1374  test_arc();
1375  test_worldbounds();
1376  test_pathpath();
1377  test_ellipse();
1378  test_linei();
1379  test_rect();
1380  test_polygon();
1381  test_lastpoint();
1382  test_addcurve();
1384  test_reverse();
1385  test_addpie();
1386  test_flatten();
1387  test_widen();
1388  test_isvisible();
1389  test_empty_rect();
1390 
1392 }
GpStatus WINGDIPAPI GdipGetPathData(GpPath *path, GpPathData *pathData)
static path_test_t widenline_dash_path[]
static path_test_t addpie_path2[]
Definition: graphicspath.c:901
static path_test_t flattenarc_path[]
Definition: graphicspath.c:972
static const WCHAR path2[]
Definition: path.c:29
static path_test_t flattenquater_path[]
Definition: graphicspath.c:982
static void test_isvisible(void)
GpStatus WINGDIPAPI GdipAddPathPolygon(GpPath *path, GDIPCONST GpPointF *points, INT count)
Definition: graphicspath.c:844
static path_test_t widenline_path[]
GpStatus WINGDIPAPI GdipCreateMatrix2(REAL m11, REAL m12, REAL m21, REAL m22, REAL dx, REAL dy, GpMatrix **matrix)
Definition: matrix.c:61
static void test_linei(void)
Definition: graphicspath.c:553
int wine_only_entries_preceding
Definition: graphicspath.c:70
static path_test_t addcurve_path2[]
Definition: graphicspath.c:706
static void test_arc(void)
Definition: graphicspath.c:256
#define Y(I)
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
GpStatus WINGDIPAPI GdipAddPathClosedCurve2(GpPath *path, GDIPCONST GpPointF *points, INT count, REAL tension)
Definition: graphicspath.c:362
static void test_addclosedcurve(void)
Definition: graphicspath.c:817
HDC WINAPI GetDC(_In_opt_ HWND)
static void test_reverse(void)
Definition: graphicspath.c:861
#define TRUE
Definition: types.h:120
Definition: match.c:28
GpStatus WINGDIPAPI GdipAddPathRectangles(GpPath *path, GDIPCONST GpRectF *rects, INT count)
GLsizei const GLchar ** path
Definition: glext.h:7234
GLuint GLenum matrix
Definition: glext.h:9407
static void test_addcurve(void)
Definition: graphicspath.c:729
GpStatus WINGDIPAPI GdipGetPathWorldBounds(GpPath *path, GpRectF *bounds, GDIPCONST GpMatrix *matrix, GDIPCONST GpPen *pen)
GpStatus WINGDIPAPI GdipTransformPath(GpPath *path, GpMatrix *matrix)
GLuint GLuint GLsizei count
Definition: gl.h:1545
static void test_addpie(void)
Definition: graphicspath.c:907
static path_test_t reverse_path[]
Definition: graphicspath.c:851
GpStatus WINGDIPAPI GdipCreateMatrix(GpMatrix **matrix)
Definition: matrix.c:140
static HDC
Definition: imagelist.c:92
GLsizei GLenum GLenum * types
Definition: glext.h:7753
BOOL todo
Definition: filedlg.c:313
static void test_ellipse(void)
Definition: graphicspath.c:511
void WINGDIPAPI GdipFree(void *ptr)
Definition: gdiplus.c:150
GpStatus WINGDIPAPI GdipSetClipRect(GpGraphics *graphics, REAL x, REAL y, REAL width, REAL height, CombineMode mode)
Definition: graphics.c:6473
GpStatus WINGDIPAPI GdipGetPathLastPoint(GpPath *path, GpPointF *lastPoint)
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define expectf(expected, got)
Definition: graphicspath.c:27
GLuint GLuint end
Definition: gl.h:1545
GpStatus WINGDIPAPI GdipFlattenPath(GpPath *path, GpMatrix *matrix, REAL flatness)
static void test_lastpoint(void)
Definition: graphicspath.c:669
#define GDIPCONST
Definition: gdiplusflat.h:24
int32_t INT
Definition: typedefs.h:58
static void test_polygon(void)
Definition: graphicspath.c:583
GpStatus WINGDIPAPI GdipDeletePath(GpPath *path)
const GLfloat * m
Definition: glext.h:10848
static void ok_path(GpPath *path, const path_test_t *expected, INT expected_size, BOOL todo_size)
Definition: graphicspath.c:78
uint32_t ULONG_PTR
Definition: typedefs.h:65
static path_test_t poly_path[]
Definition: graphicspath.c:573
GpStatus WINGDIPAPI GdipGetPathTypes(GpPath *path, BYTE *types, INT count)
GpStatus WINGDIPAPI GdipAddPathArc(GpPath *path, REAL x1, REAL y1, REAL x2, REAL y2, REAL startAngle, REAL sweepAngle)
Definition: graphicspath.c:195
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLenum GLint GLuint mask
Definition: glext.h:6028
static void test_empty_rect(void)
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2581
static path_test_t ellipse_path[]
Definition: graphicspath.c:467
static void test_widen(void)
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
static void test_getpathdata(void)
Definition: graphicspath.c:145
unsigned int idx
Definition: utils.c:41
smooth NULL
Definition: ftsmooth.c:416
GpStatus WINGDIPAPI GdipAddPathLine2(GpPath *path, GDIPCONST GpPointF *points, INT count)
Definition: graphicspath.c:623
static path_test_t flattenline_path[]
Definition: graphicspath.c:967
REAL Height
Definition: gdiplustypes.h:664
static path_test_t pathpath_path[]
Definition: graphicspath.c:417
PathPointType
Definition: gdiplusenums.h:82
GpStatus WINGDIPAPI GdipGetPathPoints(GpPath *path, GpPointF *points, INT count)
static const WCHAR path1[]
Definition: path.c:28
static path_test_t addpie_path[]
Definition: graphicspath.c:894
int CDECL _controlfp_s(unsigned int *cur, unsigned int newval, unsigned int mask)
Definition: cntrlfp.c:120
static path_test_t rect_path[]
Definition: graphicspath.c:622
GpStatus WINGDIPAPI GdipAddPathLineI(GpPath *path, INT x1, INT y1, INT x2, INT y2)
Definition: graphicspath.c:738
#define todo_wine_if(is_todo)
Definition: test.h:163
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
Definition: cmds.c:130
#define POINT_TYPE_MAX_LEN
Definition: graphicspath.c:28
REAL X
Definition: gdiplustypes.h:661
GpStatus WINGDIPAPI GdipGetPointCount(GpPath *path, INT *count)
static void test_pathpath(void)
Definition: graphicspath.c:445
void WINAPI GdiplusShutdown(ULONG_PTR)
Status WINAPI GdiplusStartup(ULONG_PTR *token, const struct GdiplusStartupInput *input, struct GdiplusStartupOutput *output)
Definition: gdiplus.c:81
REAL Y
Definition: gdiplustypes.h:649
GpStatus WINGDIPAPI GdipClosePathFigure(GpPath *path)
GpStatus WINGDIPAPI GdipAddPathRectangle(GpPath *path, REAL x, REAL y, REAL width, REAL height)
static path_test_t widenline_wide_path[]
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GpStatus WINGDIPAPI GdipAddPathPath(GpPath *path, GDIPCONST GpPath *addingPath, BOOL connect)
Definition: graphicspath.c:745
static path_test_t line2_path[]
Definition: graphicspath.c:176
GLsizei const GLfloat * points
Definition: glext.h:8112
GpStatus WINGDIPAPI GdipDeleteMatrix(GpMatrix *matrix)
Definition: matrix.c:160
START_TEST(graphicspath)
static path_test_t addclosedcurve_path[]
Definition: graphicspath.c:802
Status
Definition: gdiplustypes.h:24
GpStatus WINGDIPAPI GdipAddPathCurve2(GpPath *path, GDIPCONST GpPointF *points, INT count, REAL tension)
Definition: graphicspath.c:480
#define todo_wine
Definition: test.h:162
HDC hdc
Definition: main.c:9
GpStatus WINGDIPAPI GdipCreatePath(GpFillMode fill, GpPath **path)
GpStatus WINGDIPAPI GdipScaleMatrix(GpMatrix *matrix, REAL scaleX, REAL scaleY, GpMatrixOrder order)
Definition: matrix.c:289
REAL X
Definition: gdiplustypes.h:648
GpStatus WINGDIPAPI GdipSetPenEndCap(GpPen *pen, GpLineCap cap)
Definition: pen.c:671
unsigned char BYTE
Definition: xxhash.c:193
REAL Width
Definition: gdiplustypes.h:663
_Check_return_ _CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double x)
static void test_rect(void)
Definition: graphicspath.c:634
static void test_flatten(void)
Definition: graphicspath.c:994
Gdiplus::GdiplusStartupInput gdiplusStartupInput
Definition: winmain.cpp:33
ULONG_PTR gdiplusToken
Definition: winmain.cpp:34
#define CDECL
Definition: compat.h:29
static void test_line2(void)
Definition: graphicspath.c:188
#define ARRAY_SIZE(a)
Definition: main.h:24
GpStatus WINGDIPAPI GdipAddPathLine(GpPath *path, REAL x1, REAL y1, REAL x2, REAL y2)
Definition: graphicspath.c:704
#define ok(value,...)
Definition: atltest.h:57
static path_test_t arc_path[]
Definition: graphicspath.c:215
static path_test_t flattenellipse_path[]
Definition: graphicspath.c:939
GpStatus WINGDIPAPI GdipResetPath(GpPath *path)
GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics)
Definition: graphics.c:2395
GpStatus WINGDIPAPI GdipIsVisiblePathPoint(GpPath *path, REAL x, REAL y, GpGraphics *graphics, BOOL *result)
GpStatus WINGDIPAPI GdipWidenPath(GpPath *path, GpPen *pen, GpMatrix *matrix, REAL flatness)
#define expect(expected, got)
Definition: graphicspath.c:26
static void stringify_point_type(PathPointType type, char *name)
Definition: graphicspath.c:30
#define skip(...)
Definition: atltest.h:64
static void test_constructor_destructor(void)
Definition: graphicspath.c:129
static path_test_t linei_path[]
Definition: graphicspath.c:537
GpStatus WINGDIPAPI GdipAddPathCurve3(GpPath *path, GDIPCONST GpPointF *points, INT count, INT offset, INT nseg, REAL tension)
Definition: graphicspath.c:561
Definition: name.c:38
#define GetProcAddress(x, y)
Definition: compat.h:612
void *WINGDIPAPI GdipAlloc(SIZE_T size)
Definition: gdiplus.c:142
static path_test_t addcurve_path[]
Definition: graphicspath.c:694
GpStatus WINGDIPAPI GdipDeletePen(GpPen *pen)
Definition: pen.c:192
GpStatus WINGDIPAPI GdipAddPathPie(GpPath *path, REAL x, REAL y, REAL width, REAL height, REAL startAngle, REAL sweepAngle)
Definition: graphicspath.c:776
float REAL
Definition: types.h:41
REAL Y
Definition: gdiplustypes.h:662
GLuint64EXT * result
Definition: glext.h:11304
static SERVICE_STATUS status
Definition: service.c:31
GpStatus WINGDIPAPI GdipAddPathEllipse(GpPath *path, REAL x, REAL y, REAL width, REAL height)
Definition: graphicspath.c:583
GpStatus WINGDIPAPI GdipCreatePen1(ARGB color, REAL width, GpUnit unit, GpPen **pen)
Definition: pen.c:136
static path_test_t addpie_path3[]
Definition: graphicspath.c:904
#define HeapFree(x, y, z)
Definition: compat.h:594
static void test_worldbounds(void)
Definition: graphicspath.c:286
BOOL expected
Definition: store.c:2063
#define X(b, s)
GpStatus WINGDIPAPI GdipReversePath(GpPath *path)
GpStatus WINGDIPAPI GdipSetPenDashStyle(GpPen *pen, GpDashStyle dash)
Definition: pen.c:650
static path_test_t addcurve_path3[]
Definition: graphicspath.c:720
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
Definition: ps.c:97
DWORD ARGB