ReactOS  0.4.14-dev-50-g13bb5e2
brush.c
Go to the documentation of this file.
1 /*
2  * Unit test suite for brushes
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 <math.h>
22 
23 #include "objbase.h"
24 #include "gdiplus.h"
25 #include "wine/test.h"
26 
27 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
28 #define expectf(expected, got) ok(fabs(expected - got) < 0.0001, "Expected %.2f, got %.2f\n", expected, got)
29 
30 static HWND hwnd;
31 
32 static void test_constructor_destructor(void)
33 {
35  GpSolidFill *brush = NULL;
36 
37  status = GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
38  expect(Ok, status);
39  ok(brush != NULL, "Expected brush to be initialized\n");
40 
43 
44  status = GdipDeleteBrush((GpBrush*) brush);
45  expect(Ok, status);
46 }
47 
48 static void test_createHatchBrush(void)
49 {
51  GpHatch *brush;
52 
53  status = GdipCreateHatchBrush(HatchStyleMin, 1, 2, &brush);
54  expect(Ok, status);
55  ok(brush != NULL, "Expected the brush to be initialized.\n");
56 
57  GdipDeleteBrush((GpBrush *)brush);
58 
59  status = GdipCreateHatchBrush(HatchStyleMax, 1, 2, &brush);
60  expect(Ok, status);
61  ok(brush != NULL, "Expected the brush to be initialized.\n");
62 
63  GdipDeleteBrush((GpBrush *)brush);
64 
67 
68  status = GdipCreateHatchBrush((HatchStyle)(HatchStyleMin - 1), 1, 2, &brush);
70 
71  status = GdipCreateHatchBrush((HatchStyle)(HatchStyleMax + 1), 1, 2, &brush);
73 }
74 
76 {
78  GpLineGradient *brush;
79  GpRectF rect1 = { 1, 3, 1, 2 };
80  GpRectF rect2 = { 1, 3, -1, -2 };
81  GpRectF rect3 = { 1, 3, 0, 1 };
82  GpRectF rect4 = { 1, 3, 1, 0 };
83 
84  status = GdipCreateLineBrushFromRectWithAngle(&rect1, 10, 11, 0, TRUE, WrapModeTile, &brush);
85  expect(Ok, status);
86  GdipDeleteBrush((GpBrush *) brush);
87 
89  expect(Ok, status);
90  GdipDeleteBrush((GpBrush *) brush);
91 
93  expect(Ok, status);
94  GdipDeleteBrush((GpBrush *) brush);
95 
96  status = GdipCreateLineBrushFromRectWithAngle(&rect1, 10, 11, 405, TRUE, (WrapMode)(WrapModeClamp + 1), &brush);
97  expect(Ok, status);
98  GdipDeleteBrush((GpBrush *) brush);
99 
100  status = GdipCreateLineBrushFromRectWithAngle(&rect1, 10, 11, 45, FALSE, (WrapMode)(WrapModeClamp + 1), &brush);
101  expect(Ok, status);
102  GdipDeleteBrush((GpBrush *) brush);
103 
104  status = GdipCreateLineBrushFromRectWithAngle(&rect1, 10, 11, 90, TRUE, WrapModeTileFlipX, &brush);
105  expect(Ok, status);
106 
109 
110  status = GdipCreateLineBrushFromRectWithAngle(&rect3, 10, 11, 90, TRUE, WrapModeTileFlipXY, &brush);
112 
113  status = GdipCreateLineBrushFromRectWithAngle(&rect4, 10, 11, 90, TRUE, WrapModeTileFlipXY, &brush);
115 
118 
121 
122  status = GdipCreateLineBrushFromRectWithAngle(&rect3, 10, 11, 90, TRUE, WrapModeClamp, &brush);
124 
125  status = GdipCreateLineBrushFromRectWithAngle(&rect4, 10, 11, 90, TRUE, WrapModeClamp, &brush);
127 
128  status = GdipCreateLineBrushFromRectWithAngle(&rect1, 10, 11, 90, TRUE, WrapModeClamp, &brush);
130 
133 
134  GdipDeleteBrush((GpBrush *) brush);
135 }
136 
137 static void test_type(void)
138 {
140  GpBrushType bt;
141  GpSolidFill *brush = NULL;
142 
143  GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
144 
145  status = GdipGetBrushType((GpBrush*)brush, &bt);
146  expect(Ok, status);
148 
149  GdipDeleteBrush((GpBrush*) brush);
150 }
151 static GpPointF blendcount_ptf[] = {{0.0, 0.0},
152  {50.0, 50.0}};
153 static void test_gradientblendcount(void)
154 {
156  GpPathGradient *brush;
157  INT count;
158 
160  expect(Ok, status);
161 
168 
170  expect(Ok, status);
171  expect(1, count);
172 
173  GdipDeleteBrush((GpBrush*) brush);
174 }
175 
176 static GpPointF getblend_ptf[] = {{0.0, 0.0},
177  {50.0, 50.0}};
178 static void test_getblend(void)
179 {
181  GpPathGradient *brush;
182  REAL blends[4];
183  REAL pos[4];
184 
186  expect(Ok, status);
187 
188  /* check some invalid parameters combinations */
193  status = GdipGetPathGradientBlend(NULL, blends,NULL, -1);
199 
200  blends[0] = (REAL)0xdeadbeef;
201  pos[0] = (REAL)0xdeadbeef;
202  status = GdipGetPathGradientBlend(brush, blends, pos, 1);
203  expect(Ok, status);
204  expectf(1.0, blends[0]);
205  expectf((REAL)0xdeadbeef, pos[0]);
206 
207  GdipDeleteBrush((GpBrush*) brush);
208 }
209 
210 static GpPointF getbounds_ptf[] = {{0.0, 20.0},
211  {50.0, 50.0},
212  {21.0, 25.0},
213  {25.0, 46.0}};
214 static void test_getbounds(void)
215 {
217  GpPathGradient *brush;
218  GpRectF bounds;
219 
221  expect(Ok, status);
222 
227  status = GdipGetPathGradientRect(NULL, &bounds);
229 
230  status = GdipGetPathGradientRect(brush, &bounds);
231  expect(Ok, status);
232  expectf(0.0, bounds.X);
233  expectf(20.0, bounds.Y);
234  expectf(50.0, bounds.Width);
235  expectf(30.0, bounds.Height);
236 
237  GdipDeleteBrush((GpBrush*) brush);
238 }
239 
240 static void test_getgamma(void)
241 {
244  GpPointF start, end;
245  BOOL gamma;
246 
247  start.X = start.Y = 0.0;
248  end.X = end.Y = 100.0;
249 
250  status = GdipCreateLineBrush(&start, &end, (ARGB)0xdeadbeef, 0xdeadbeef, WrapModeTile, &line);
251  expect(Ok, status);
252 
253  /* NULL arguments */
260 
262 }
263 
264 static void test_transform(void)
265 {
269  GpGraphics *graphics = NULL;
270  GpBitmap *bitmap;
271  HDC hdc = GetDC(0);
272  GpMatrix *m, *m1;
273  BOOL res;
274  GpPointF start, end;
275  GpRectF rectf;
276  REAL elements[6];
277 
278  /* GpTexture */
279  status = GdipCreateMatrix2(2.0, 0.0, 0.0, 0.0, 0.0, 0.0, &m);
280  expect(Ok, status);
281 
282  status = GdipCreateFromHDC(hdc, &graphics);
283  expect(Ok, status);
284  status = GdipCreateBitmapFromGraphics(1, 1, graphics, &bitmap);
285  expect(Ok, status);
286 
288  expect(Ok, status);
289 
290  /* NULL */
295 
296  /* get default value - identity matrix */
298  expect(Ok, status);
300  expect(Ok, status);
301  expect(TRUE, res);
302  /* set and get then */
303  status = GdipCreateMatrix2(2.0, 0.0, 0.0, 2.0, 0.0, 0.0, &m1);
304  expect(Ok, status);
306  expect(Ok, status);
308  expect(Ok, status);
309  status = GdipIsMatrixEqual(m, m1, &res);
310  expect(Ok, status);
311  expect(TRUE, res);
312  /* reset */
314  expect(Ok, status);
316  expect(Ok, status);
318  expect(Ok, status);
319  expect(TRUE, res);
320 
322  expect(Ok, status);
323 
324  status = GdipDeleteMatrix(m1);
325  expect(Ok, status);
327  expect(Ok, status);
329  expect(Ok, status);
330  status = GdipDeleteGraphics(graphics);
331  expect(Ok, status);
332 
333 
334 
335  status = GdipCreateFromHWND(hwnd, &graphics);
336  expect(Ok, status);
337 
338  /* GpLineGradient */
339  /* create with vertical gradient line */
340  start.X = start.Y = end.X = 0.0;
341  end.Y = 100.0;
342 
343  status = GdipCreateLineBrush(&start, &end, (ARGB)0xffff0000, 0xff00ff00, WrapModeTile, &line);
344  expect(Ok, status);
345 
346  status = GdipCreateMatrix2(1.0, 0.0, 0.0, 1.0, 0.0, 0.0, &m);
347  expect(Ok, status);
348 
349  /* NULL arguments */
366 
367  /* initial transform */
369  expect(Ok, status);
370 
371  status = GdipGetMatrixElements(m, elements);
372  expect(Ok, status);
373  expectf(0.0, elements[0]);
374  expectf(1.0, elements[1]);
375  expectf(-1.0, elements[2]);
376  expectf(0.0, elements[3]);
377  expectf(50.0, elements[4]);
378  expectf(50.0, elements[5]);
379 
380  status = GdipGetLineRect(line, &rectf);
381  expect(Ok, status);
382  expectf(-50.0, rectf.X);
383  expectf(0.0, rectf.Y);
384  expectf(100.0, rectf.Width);
385  expectf(100.0, rectf.Height);
386 
387  status = GdipFillRectangle(graphics, (GpBrush*)line, 0, 0, 200, 200);
388  expect(Ok, status);
389 
390  /* manually set transform */
391  GdipSetMatrixElements(m, 2.0, 0.0, 0.0, 4.0, 0.0, 0.0);
392 
394  expect(Ok, status);
395 
397  expect(Ok, status);
398 
399  status = GdipGetMatrixElements(m, elements);
400  expect(Ok, status);
401  expectf(2.0, elements[0]);
402  expectf(0.0, elements[1]);
403  expectf(0.0, elements[2]);
404  expectf(4.0, elements[3]);
405  expectf(0.0, elements[4]);
406  expectf(0.0, elements[5]);
407 
408  status = GdipGetLineRect(line, &rectf);
409  expect(Ok, status);
410  expectf(-50.0, rectf.X);
411  expectf(0.0, rectf.Y);
412  expectf(100.0, rectf.Width);
413  expectf(100.0, rectf.Height);
414 
415  status = GdipFillRectangle(graphics, (GpBrush*)line, 200, 0, 200, 200);
416  expect(Ok, status);
417 
418  /* scale transform */
420  expect(Ok, status);
421 
423  expect(Ok, status);
424 
425  status = GdipGetMatrixElements(m, elements);
426  expect(Ok, status);
427  expectf(8.0, elements[0]);
428  expectf(0.0, elements[1]);
429  expectf(0.0, elements[2]);
430  expectf(2.0, elements[3]);
431  expectf(0.0, elements[4]);
432  expectf(0.0, elements[5]);
433 
434  status = GdipGetLineRect(line, &rectf);
435  expect(Ok, status);
436  expectf(-50.0, rectf.X);
437  expectf(0.0, rectf.Y);
438  expectf(100.0, rectf.Width);
439  expectf(100.0, rectf.Height);
440 
441  status = GdipFillRectangle(graphics, (GpBrush*)line, 400, 0, 200, 200);
442  expect(Ok, status);
443 
444  /* translate transform */
446  expect(Ok, status);
447 
449  expect(Ok, status);
450 
451  status = GdipGetMatrixElements(m, elements);
452  expect(Ok, status);
453  expectf(8.0, elements[0]);
454  expectf(0.0, elements[1]);
455  expectf(0.0, elements[2]);
456  expectf(2.0, elements[3]);
457  expectf(10.0, elements[4]);
458  expectf(-20.0, elements[5]);
459 
460  status = GdipGetLineRect(line, &rectf);
461  expect(Ok, status);
462  expectf(-50.0, rectf.X);
463  expectf(0.0, rectf.Y);
464  expectf(100.0, rectf.Width);
465  expectf(100.0, rectf.Height);
466 
467  status = GdipFillRectangle(graphics, (GpBrush*)line, 0, 200, 200, 200);
468  expect(Ok, status);
469 
470  /* multiply transform */
471  GdipSetMatrixElements(m, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
473  GdipScaleMatrix(m, 0.25, 0.5, MatrixOrderAppend);
474 
476  expect(Ok, status);
477 
478  /* NULL transform does nothing */
480  expect(Ok, status);
481 
483  expect(Ok, status);
484 
485  status = GdipGetMatrixElements(m, elements);
486  expect(Ok, status);
487  expectf(1.414214, elements[0]);
488  expectf(2.828427, elements[1]);
489  expectf(-0.353553, elements[2]);
490  expectf(0.707107, elements[3]);
491  expectf(5.303300, elements[4]);
492  expectf(-3.535534, elements[5]);
493 
494  status = GdipGetLineRect(line, &rectf);
495  expect(Ok, status);
496  expectf(-50.0, rectf.X);
497  expectf(0.0, rectf.Y);
498  expectf(100.0, rectf.Width);
499  expectf(100.0, rectf.Height);
500 
501  status = GdipFillRectangle(graphics, (GpBrush*)line, 200, 200, 200, 200);
502  expect(Ok, status);
503 
504  /* reset transform sets to identity */
506  expect(Ok, status);
507 
509  expect(Ok, status);
510 
511  status = GdipGetMatrixElements(m, elements);
512  expect(Ok, status);
513  expectf(1.0, elements[0]);
514  expectf(0.0, elements[1]);
515  expectf(0.0, elements[2]);
516  expectf(1.0, elements[3]);
517  expectf(0.0, elements[4]);
518  expectf(0.0, elements[5]);
519 
520  status = GdipGetLineRect(line, &rectf);
521  expect(Ok, status);
522  expectf(-50.0, rectf.X);
523  expectf(0.0, rectf.Y);
524  expectf(100.0, rectf.Width);
525  expectf(100.0, rectf.Height);
526 
527  status = GdipFillRectangle(graphics, (GpBrush*)line, 400, 200, 200, 200);
528  expect(Ok, status);
529 
531 
532  /* passing negative Width/Height to LinearGradientModeHorizontal */
533  rectf.X = rectf.Y = 10.0;
534  rectf.Width = rectf.Height = -100.0;
535  status = GdipCreateLineBrushFromRect(&rectf, (ARGB)0xffff0000, 0xff00ff00,
537  expect(Ok, status);
538  memset(&rectf, 0, sizeof(GpRectF));
539  status = GdipGetLineRect(line, &rectf);
540  expect(Ok, status);
541  expectf(10.0, rectf.X);
542  expectf(10.0, rectf.Y);
543  expectf(-100.0, rectf.Width);
544  expectf(-100.0, rectf.Height);
546  expect(Ok, status);
547  status = GdipGetMatrixElements(m, elements);
548  expect(Ok,status);
549  expectf(1.0, elements[0]);
550  expectf(0.0, elements[1]);
551  expectf(0.0, elements[2]);
552  expectf(1.0, elements[3]);
553  expectf(0.0, elements[4]);
554  expectf(0.0, elements[5]);
555  status = GdipFillRectangle(graphics, (GpBrush*)line, 0, 400, 200, 200);
556  expect(Ok, status);
558  expect(Ok,status);
559 
560  if(0){
561  /* enable to visually compare with Windows */
562  MSG msg;
563  while(GetMessageW(&msg, hwnd, 0, 0) > 0){
566  }
567  }
568 
570  GdipDeleteGraphics(graphics);
571  ReleaseDC(0, hdc);
572 }
573 
574 static void test_texturewrap(void)
575 {
578  GpGraphics *graphics = NULL;
579  GpBitmap *bitmap;
580  HDC hdc = GetDC(0);
582 
583  status = GdipCreateFromHDC(hdc, &graphics);
584  expect(Ok, status);
585  status = GdipCreateBitmapFromGraphics(1, 1, graphics, &bitmap);
586  expect(Ok, status);
587 
589  expect(Ok, status);
590 
591  /* NULL */
598 
599  /* get */
602  expect(Ok, status);
604  /* set, then get */
607  expect(Ok, status);
608  wrap = WrapModeTile;
610  expect(Ok, status);
612 
614  expect(Ok, status);
616  expect(Ok, status);
617  status = GdipDeleteGraphics(graphics);
618  expect(Ok, status);
619  ReleaseDC(0, hdc);
620 }
621 
622 static void test_gradientgetrect(void)
623 {
624  static const struct
625  {
627  GpRectF rect;
628  REAL transform[6];
629  }
630  create_from_rect[] =
631  {
632  { LinearGradientModeHorizontal, { 10.0f, 10.0f, -100.0f, -100.0f } },
633  { LinearGradientModeHorizontal, { 10.0f, 10.0f, 100.0f, 100.0f } },
634  { LinearGradientModeHorizontal, { 10.0f, -5.0f, 100.0f, 50.0f } },
635  { LinearGradientModeHorizontal, { -5.0f, 10.0f, 100.0f, 50.0f } },
636  { LinearGradientModeVertical, { 0.0f, 0.0f, 100.0f, 10.0f }, { 0.0f, 0.1f, -10.0f, -0.0f, 100.0f, 0.0f } },
637  { LinearGradientModeVertical, { 10.0f, -12.0f, 100.0f, 105.0f }, { 0.0f, 1.05f, -0.952f, 0.0f, 98.571f, -22.5f } },
638  };
639  static const struct
640  {
641  GpPointF pt1, pt2;
642  GpRectF rect;
643  REAL transform[6];
644  }
645  create_from_pt[] =
646  {
647  { { 1.0f, 1.0f }, { 100.0f, 100.0f }, { 1.0f, 1.0f, 99.0f, 99.0f }, { 1.0f, 1.0f, -1.0f, 1.0f, 50.50f, -50.50f } },
648  { { 0.0f, 0.0f }, { 0.0f, 10.0f }, { -5.0f, 0.0f, 10.0f, 10.0f }, { 0.0f, 1.0f, -1.0f, 0.0f, 5.0f, 5.0f } },
649  { { 0.0f, 0.0f }, { 10.0f, 0.0f }, { 0.0f, -5.0f, 10.0f, 10.0f }, { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f } },
650  /* Slope = -1 */
651  { { 0.0f, 0.0f }, { 20.0f, -20.0f }, { 0.0f, -20.0f, 20.0f, 20.0f }, { 1.0f, -1.0f, 1.0f, 1.0f, 10.0f, 10.0f } },
652  /* Slope = 1/100 */
653  { { 0.0f, 0.0f }, { 100.0f, 1.0f }, { 0.0f, 0.0f, 100.0f, 1.0f }, { 1.0f, 0.01f, -0.02f, 2.0f, 0.01f, -1.0f } },
654  { { 10.0f, 10.0f }, { -90.0f, 10.0f }, { -90.0f, -40.0f, 100.0f, 100.0f }, { -1.0f, 0.0f, 0.0f, -1.0f, -80.0f, 20.0f } },
655  };
656  static const struct
657  {
658  GpRectF rect;
659  REAL angle;
660  BOOL is_scalable;
661  REAL transform[6];
662  }
663  create_with_angle[] =
664  {
665  { { 10.0f, 10.0f, -100.0f, -100.0f }, 0.0f, TRUE },
666  { { 10.0f, 10.0f, -100.0f, -100.0f }, 0.0f, FALSE },
667  { { 10.0f, 10.0f, 100.0f, 100.0f }, 0.0f, FALSE },
668  { { 10.0f, 10.0f, 100.0f, 100.0f }, 0.0f, TRUE },
669  { { 10.0f, -5.0f, 100.0f, 50.0f }, 0.0f, FALSE },
670  { { 10.0f, -5.0f, 100.0f, 50.0f }, 0.0f, TRUE },
671  { { -5.0f, 10.0f, 100.0f, 50.0f }, 0.0f, FALSE },
672  { { -5.0f, 10.0f, 100.0f, 50.0f }, 0.0f, TRUE },
673  { { 0.0f, 0.0f, 100.0f, 10.0f }, -90.0f, TRUE, { 0.0f, -0.1f, 10.0f, 0.0f, 0.0f, 10.0f } },
674  { { 10.0f, -12.0f, 100.0f, 105.0f }, -90.0f, TRUE, { 0.0f, -1.05f, 0.952f, 0.0f, 21.429f, 103.5f } },
675  { { 0.0f, 0.0f, 100.0f, 10.0f }, -90.0f, FALSE, { 0.0f, -0.1f, 10.0f, -0.0f, 0.0f, 10.0f } },
676  { { 10.0f, -12.0f, 100.0f, 105.0f }, -90.0f, FALSE, { 0.0f, -1.05f, 0.952f, 0.0f, 21.429f, 103.5f } },
677  };
678  GpLineGradient *brush;
680  REAL elements[6];
682  unsigned int i;
683  ARGB colors[2];
684  GpRectF rectf;
685 
687  expect(Ok, status);
688 
689  for (i = 0; i < ARRAY_SIZE(create_from_pt); ++i)
690  {
691  status = GdipCreateLineBrush(&create_from_pt[i].pt1, &create_from_pt[i].pt2, 0x1, 0x2, WrapModeTile, &brush);
692  ok(status == Ok, "Failed to create a brush, %d.\n", status);
693 
694  memset(&rectf, 0, sizeof(rectf));
695  status = GdipGetLineRect(brush, &rectf);
696  ok(status == Ok, "Failed to get brush rect, %d.\n", status);
697  ok(!memcmp(&rectf, &create_from_pt[i].rect, sizeof(rectf)), "Unexpected brush rect.\n");
698 
700  ok(status == Ok, "Failed to get brush transform, %d.\n", status);
701 
703  ok(status == Ok, "Failed to get matrix elements, %d.\n", status);
704 
705 #define expectf2(expected, got) ok(fabs(expected - got) < 0.001, "%u: expected %.3f, got %.3f.\n", i, expected, got)
706  expectf2(create_from_pt[i].transform[0], elements[0]);
707  expectf2(create_from_pt[i].transform[1], elements[1]);
708  expectf2(create_from_pt[i].transform[2], elements[2]);
709  expectf2(create_from_pt[i].transform[3], elements[3]);
710  expectf2(create_from_pt[i].transform[4], elements[4]);
711  expectf2(create_from_pt[i].transform[5], elements[5]);
712 #undef expect2f
713 
714  status = GdipGetLineColors(brush, colors);
715  ok(status == Ok, "Failed to get line colors, %d.\n", status);
716  ok(colors[0] == 0x1 && colors[1] == 0x2, "Unexpected brush colors.\n");
717 
718  status = GdipDeleteBrush((GpBrush *)brush);
719  ok(status == Ok, "Failed to delete a brush, %d.\n", status);
720  }
721 
722  /* zero height rect */
723  rectf.X = rectf.Y = 10.0;
724  rectf.Width = 100.0;
725  rectf.Height = 0.0;
727  WrapModeTile, &brush);
729 
730  /* zero width rect */
731  rectf.X = rectf.Y = 10.0;
732  rectf.Width = 0.0;
733  rectf.Height = 100.0;
735  WrapModeTile, &brush);
737 
738  for (i = 0; i < ARRAY_SIZE(create_from_rect); ++i)
739  {
740  ARGB colors[2];
741  BOOL ret;
742 
743  status = GdipCreateLineBrushFromRect(&create_from_rect[i].rect, 0x1, 0x2, create_from_rect[i].mode,
744  WrapModeTile, &brush);
745  ok(status == Ok, "Failed to create a brush, %d.\n", status);
746 
747  memset(&rectf, 0, sizeof(rectf));
748  status = GdipGetLineRect(brush, &rectf);
749  ok(status == Ok, "Failed to get brush rect, %d.\n", status);
750  ok(!memcmp(&rectf, &create_from_rect[i].rect, sizeof(rectf)), "Unexpected brush rect.\n");
751 
753  ok(status == Ok, "Failed to get brush transform, %d.\n", status);
754 
755  if (create_from_rect[i].mode == LinearGradientModeHorizontal)
756  {
758  ok(status == Ok, "Unexpected ret value %d.\n", status);
759  }
760  else
761  {
763  ok(status == Ok, "Failed to get matrix elements, %d.\n", status);
764 
765 #define expectf2(expected, got) ok(fabs(expected - got) < 0.001, "%u: expected %.3f, got %.3f.\n", i, expected, got)
766  expectf2(create_from_rect[i].transform[0], elements[0]);
767  expectf2(create_from_rect[i].transform[1], elements[1]);
768  expectf2(create_from_rect[i].transform[2], elements[2]);
769  expectf2(create_from_rect[i].transform[3], elements[3]);
770  expectf2(create_from_rect[i].transform[4], elements[4]);
771  expectf2(create_from_rect[i].transform[5], elements[5]);
772 #undef expectf2
773  }
774 
775  status = GdipGetLineColors(brush, colors);
776  ok(status == Ok, "Failed to get line colors, %d.\n", status);
777  ok(colors[0] == 0x1 && colors[1] == 0x2, "Unexpected brush colors.\n");
778 
779  status = GdipDeleteBrush((GpBrush*)brush);
780  ok(status == Ok, "Failed to delete a brush, %d.\n", status);
781  }
782 
783  for (i = 0; i < ARRAY_SIZE(create_with_angle); ++i)
784  {
785  ARGB colors[2];
786  BOOL ret;
787 
788  status = GdipCreateLineBrushFromRectWithAngle(&create_with_angle[i].rect, 0x1, 0x2, create_with_angle[i].angle,
789  create_with_angle[i].is_scalable, WrapModeTile, &brush);
790  ok(status == Ok, "Failed to create a brush, %d.\n", status);
791 
792  memset(&rectf, 0, sizeof(rectf));
793  status = GdipGetLineRect(brush, &rectf);
794  ok(status == Ok, "Failed to get brush rect, %d.\n", status);
795  ok(!memcmp(&rectf, &create_with_angle[i].rect, sizeof(rectf)), "%u: unexpected brush rect {%f,%f,%f,%f}.\n",
796  i, rectf.X, rectf.Y, rectf.Width, rectf.Height);
797 
799  ok(status == Ok, "Failed to get brush transform, %d.\n", status);
800 
801  if (create_with_angle[i].angle == 0.0f)
802  {
804  ok(status == Ok, "Unexpected ret value %d.\n", status);
805  }
806  else
807  {
809  ok(status == Ok, "Failed to get matrix elements, %d.\n", status);
810 
811 #define expectf2(expected, got) ok(fabs(expected - got) < 0.001, "%u: expected %.3f, got %.3f.\n", i, expected, got)
812  expectf2(create_with_angle[i].transform[0], elements[0]);
813  expectf2(create_with_angle[i].transform[1], elements[1]);
814  expectf2(create_with_angle[i].transform[2], elements[2]);
815  expectf2(create_with_angle[i].transform[3], elements[3]);
816  expectf2(create_with_angle[i].transform[4], elements[4]);
817  expectf2(create_with_angle[i].transform[5], elements[5]);
818 #undef expectf2
819  }
820 
821  status = GdipGetLineColors(brush, colors);
822  ok(status == Ok, "Failed to get line colors, %d.\n", status);
823  ok(colors[0] == 0x1 && colors[1] == 0x2, "Unexpected brush colors.\n");
824 
825  status = GdipDeleteBrush((GpBrush*)brush);
826  ok(status == Ok, "Failed to delete a brush, %d.\n", status);
827  }
828 
830 }
831 
832 static void test_lineblend(void)
833 {
834  GpLineGradient *brush;
836  GpPointF pt1, pt2;
837  INT count=10;
838  int i;
839  const REAL factors[5] = {0.0f, 0.1f, 0.5f, 0.9f, 1.0f};
840  const REAL positions[5] = {0.0f, 0.2f, 0.5f, 0.8f, 1.0f};
841  const REAL two_positions[2] = {0.0f, 1.0f};
842  const ARGB colors[5] = {0xff0000ff, 0xff00ff00, 0xff00ffff, 0xffff0000, 0xffffffff};
843  REAL res_factors[6] = {0.3f, 0.0f, 0.0f, 0.0f, 0.0f};
844  REAL res_positions[6] = {0.3f, 0.0f, 0.0f, 0.0f, 0.0f};
845  ARGB res_colors[6] = {0xdeadbeef, 0, 0, 0, 0};
846 
847  pt1.X = pt1.Y = pt2.Y = pt2.X = 1.0;
848  status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush);
850 
851  pt1.X = pt1.Y = 1.0;
852  pt2.X = pt2.Y = 100.0;
853  status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush);
854  expect(Ok, status);
855 
858 
861 
863  expect(Ok, status);
864  expect(1, count);
865 
866  status = GdipGetLineBlend(NULL, res_factors, res_positions, 1);
868 
869  status = GdipGetLineBlend(brush, NULL, res_positions, 1);
871 
872  status = GdipGetLineBlend(brush, res_factors, NULL, 1);
874 
875  status = GdipGetLineBlend(brush, res_factors, res_positions, 0);
877 
878  status = GdipGetLineBlend(brush, res_factors, res_positions, -1);
880 
881  status = GdipGetLineBlend(brush, res_factors, res_positions, 1);
882  expect(Ok, status);
883 
884  status = GdipGetLineBlend(brush, res_factors, res_positions, 2);
885  expect(Ok, status);
886 
887  status = GdipSetLineBlend(NULL, factors, positions, 5);
889 
890  status = GdipSetLineBlend(brush, NULL, positions, 5);
892 
893  status = GdipSetLineBlend(brush, factors, NULL, 5);
895 
896  status = GdipSetLineBlend(brush, factors, positions, 0);
898 
899  status = GdipSetLineBlend(brush, factors, positions, -1);
901 
902  /* leave off the 0.0 position */
903  status = GdipSetLineBlend(brush, &factors[1], &positions[1], 4);
905 
906  /* leave off the 1.0 position */
907  status = GdipSetLineBlend(brush, factors, positions, 4);
909 
910  status = GdipSetLineBlend(brush, factors, positions, 5);
911  expect(Ok, status);
912 
914  expect(Ok, status);
915  expect(5, count);
916 
917  status = GdipGetLineBlend(brush, res_factors, res_positions, 4);
919 
920  status = GdipGetLineBlend(brush, res_factors, res_positions, 5);
921  expect(Ok, status);
922 
923  for (i=0; i<5; i++)
924  {
925  expectf(factors[i], res_factors[i]);
926  expectf(positions[i], res_positions[i]);
927  }
928 
929  status = GdipGetLineBlend(brush, res_factors, res_positions, 6);
930  expect(Ok, status);
931 
932  status = GdipSetLineBlend(brush, factors, positions, 1);
933  expect(Ok, status);
934 
936  expect(Ok, status);
937  expect(1, count);
938 
939  status = GdipGetLineBlend(brush, res_factors, res_positions, 1);
940  expect(Ok, status);
941 
944 
947 
949  expect(Ok, status);
950  expect(0, count);
951 
952  status = GdipGetLinePresetBlend(NULL, res_colors, res_positions, 1);
954 
955  status = GdipGetLinePresetBlend(brush, NULL, res_positions, 1);
957 
958  status = GdipGetLinePresetBlend(brush, res_colors, NULL, 1);
960 
961  status = GdipGetLinePresetBlend(brush, res_colors, res_positions, 0);
963 
964  status = GdipGetLinePresetBlend(brush, res_colors, res_positions, -1);
966 
967  status = GdipGetLinePresetBlend(brush, res_colors, res_positions, 1);
969 
970  status = GdipGetLinePresetBlend(brush, res_colors, res_positions, 2);
972 
973  status = GdipSetLinePresetBlend(NULL, colors, positions, 5);
975 
976  status = GdipSetLinePresetBlend(brush, NULL, positions, 5);
978 
979  status = GdipSetLinePresetBlend(brush, colors, NULL, 5);
981 
982  status = GdipSetLinePresetBlend(brush, colors, positions, 0);
984 
985  status = GdipSetLinePresetBlend(brush, colors, positions, -1);
987 
988  status = GdipSetLinePresetBlend(brush, colors, positions, 1);
990 
991  /* leave off the 0.0 position */
992  status = GdipSetLinePresetBlend(brush, &colors[1], &positions[1], 4);
994 
995  /* leave off the 1.0 position */
996  status = GdipSetLinePresetBlend(brush, colors, positions, 4);
998 
999  status = GdipSetLinePresetBlend(brush, colors, positions, 5);
1000  expect(Ok, status);
1001 
1003  expect(Ok, status);
1004  expect(5, count);
1005 
1006  status = GdipGetLinePresetBlend(brush, res_colors, res_positions, 4);
1008 
1009  status = GdipGetLinePresetBlend(brush, res_colors, res_positions, 5);
1010  expect(Ok, status);
1011 
1012  for (i=0; i<5; i++)
1013  {
1014  expect(colors[i], res_colors[i]);
1015  expectf(positions[i], res_positions[i]);
1016  }
1017 
1018  status = GdipGetLinePresetBlend(brush, res_colors, res_positions, 6);
1019  expect(Ok, status);
1020 
1021  status = GdipSetLinePresetBlend(brush, colors, two_positions, 2);
1022  expect(Ok, status);
1023 
1024  status = GdipDeleteBrush((GpBrush*)brush);
1025  expect(Ok, status);
1026 }
1027 
1028 static void test_linelinearblend(void)
1029 {
1030  GpLineGradient *brush;
1031  GpStatus status;
1032  GpPointF pt1, pt2;
1033  INT count=10;
1034  REAL res_factors[3] = {0.3f};
1035  REAL res_positions[3] = {0.3f};
1036 
1037  status = GdipSetLineLinearBlend(NULL, 0.6, 0.8);
1039 
1040  pt1.X = pt1.Y = 1.0;
1041  pt2.X = pt2.Y = 100.0;
1042  status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush);
1043  expect(Ok, status);
1044 
1045 
1046  status = GdipSetLineLinearBlend(brush, 0.6, 0.8);
1047  expect(Ok, status);
1048 
1049  status = GdipGetLineBlendCount(brush, &count);
1050  expect(Ok, status);
1051  expect(3, count);
1052 
1053  status = GdipGetLineBlend(brush, res_factors, res_positions, 3);
1054  expect(Ok, status);
1055  expectf(0.0, res_factors[0]);
1056  expectf(0.0, res_positions[0]);
1057  expectf(0.8, res_factors[1]);
1058  expectf(0.6, res_positions[1]);
1059  expectf(0.0, res_factors[2]);
1060  expectf(1.0, res_positions[2]);
1061 
1062 
1063  status = GdipSetLineLinearBlend(brush, 0.0, 0.8);
1064  expect(Ok, status);
1065 
1066  status = GdipGetLineBlendCount(brush, &count);
1067  expect(Ok, status);
1068  expect(2, count);
1069 
1070  status = GdipGetLineBlend(brush, res_factors, res_positions, 3);
1071  expect(Ok, status);
1072  expectf(0.8, res_factors[0]);
1073  expectf(0.0, res_positions[0]);
1074  expectf(0.0, res_factors[1]);
1075  expectf(1.0, res_positions[1]);
1076 
1077 
1078  status = GdipSetLineLinearBlend(brush, 1.0, 0.8);
1079  expect(Ok, status);
1080 
1081  status = GdipGetLineBlendCount(brush, &count);
1082  expect(Ok, status);
1083  expect(2, count);
1084 
1085  status = GdipGetLineBlend(brush, res_factors, res_positions, 3);
1086  expect(Ok, status);
1087  expectf(0.0, res_factors[0]);
1088  expectf(0.0, res_positions[0]);
1089  expectf(0.8, res_factors[1]);
1090  expectf(1.0, res_positions[1]);
1091 
1092  status = GdipDeleteBrush((GpBrush*)brush);
1093  expect(Ok, status);
1094 }
1095 
1097 {
1098  GpStatus status;
1099  GpPathGradient *grad;
1100  ARGB color[3];
1101  INT count;
1102 
1104  expect(Ok, status);
1105 
1106  count = 0;
1108  expect(Ok, status);
1109  expect(2, count);
1110 
1111  color[0] = color[1] = color[2] = 0xdeadbeef;
1112  count = 3;
1114  expect(Ok, status);
1115  expect(1, count);
1116  expect(0xffffffff, color[0]);
1117  expect(0xffffffff, color[1]);
1118  expect(0xdeadbeef, color[2]);
1119 
1120  color[0] = color[1] = color[2] = 0xdeadbeef;
1121  count = 2;
1123  expect(Ok, status);
1124  expect(1, count);
1125  expect(0xffffffff, color[0]);
1126  expect(0xffffffff, color[1]);
1127  expect(0xdeadbeef, color[2]);
1128 
1129  color[0] = color[1] = color[2] = 0xdeadbeef;
1130  count = 1;
1133  expect(1, count);
1134  expect(0xdeadbeef, color[0]);
1135  expect(0xdeadbeef, color[1]);
1136  expect(0xdeadbeef, color[2]);
1137 
1138  color[0] = color[1] = color[2] = 0xdeadbeef;
1139  count = 0;
1142  expect(0, count);
1143  expect(0xdeadbeef, color[0]);
1144  expect(0xdeadbeef, color[1]);
1145  expect(0xdeadbeef, color[2]);
1146 
1147  count = 3;
1150 
1151  count = 2;
1152 
1153  color[0] = 0x00ff0000;
1154  color[1] = 0x0000ff00;
1155 
1158 
1161 
1162  /* WinXP crashes on this test */
1163  if(0)
1164  {
1167  }
1168 
1170  expect(Ok, status);
1171  expect(2, count);
1172 
1175 
1178 
1179  count = 0;
1181  expect(Ok, status);
1182  expect(2, count);
1183 
1184  color[0] = color[1] = color[2] = 0xdeadbeef;
1185  count = 2;
1187  expect(Ok, status);
1188  expect(2, count);
1189  expect(0x00ff0000, color[0]);
1190  expect(0x0000ff00, color[1]);
1191  expect(0xdeadbeef, color[2]);
1192 
1193  count = 1;
1195  expect(Ok, status);
1196  expect(1, count);
1197 
1198  count = 0;
1200  expect(Ok, status);
1201  expect(2, count);
1202 
1203  /* If all colors are the same, count is set to 1. */
1204  color[0] = color[1] = 0;
1205  count = 2;
1207  expect(Ok, status);
1208  expect(2, count);
1209 
1210  color[0] = color[1] = color[2] = 0xdeadbeef;
1211  count = 2;
1213  expect(Ok, status);
1214  expect(1, count);
1215  expect(0x00000000, color[0]);
1216  expect(0x00000000, color[1]);
1217  expect(0xdeadbeef, color[2]);
1218 
1219  color[0] = color[1] = 0xff00ff00;
1220  count = 2;
1222  expect(Ok, status);
1223  expect(2, count);
1224 
1225  color[0] = color[1] = color[2] = 0xdeadbeef;
1226  count = 2;
1228  expect(Ok, status);
1229  expect(1, count);
1230  expect(0xff00ff00, color[0]);
1231  expect(0xff00ff00, color[1]);
1232  expect(0xdeadbeef, color[2]);
1233 
1234  count = 0;
1237  expect(0, count);
1238 
1239  GdipDeleteBrush((GpBrush*)grad);
1240 
1242  expect(Ok, status);
1243 
1244  color[0] = color[1] = color[2] = 0xdeadbeef;
1245  count = 3;
1247  expect(Ok, status);
1248  expect(1, count);
1249  expect(0xffffffff, color[0]);
1250  expect(0xffffffff, color[1]);
1251  expect(0xffffffff, color[2]);
1252 
1253  color[0] = color[1] = color[2] = 0xdeadbeef;
1254  count = 2;
1257  expect(2, count);
1258  expect(0xdeadbeef, color[0]);
1259  expect(0xdeadbeef, color[1]);
1260  expect(0xdeadbeef, color[2]);
1261 
1262  count = 0;
1264  expect(Ok, status);
1265  expect(3, count);
1266 
1267  GdipDeleteBrush((GpBrush*)grad);
1268 }
1269 
1270 static void test_pathgradientpath(void)
1271 {
1272  GpStatus status;
1273  GpPath *path=NULL;
1274  GpPathGradient *grad=NULL;
1275 
1277  expect(Ok, status);
1278 
1281 
1283  expect(Ok, status);
1284 
1287 
1290 
1292  expect(Ok, status);
1293 
1294  status = GdipDeleteBrush((GpBrush*)grad);
1295  expect(Ok, status);
1296 }
1297 
1299 {
1300  static const GpPointF path_points[] = {{0,0}, {3,0}, {0,4}};
1301  GpStatus status;
1302  GpPathGradient *grad;
1303  GpPointF point;
1304 
1305  status = GdipCreatePathGradient(path_points+1, 2, WrapModeClamp, &grad);
1306  expect(Ok, status);
1307 
1310 
1313 
1315  expect(Ok, status);
1316  expectf(1.5, point.X);
1317  expectf(2.0, point.Y);
1318 
1321 
1324 
1325  point.X = 10.0;
1326  point.Y = 15.0;
1328  expect(Ok, status);
1329 
1330  point.X = point.Y = -1;
1332  expect(Ok, status);
1333  expectf(10.0, point.X);
1334  expectf(15.0, point.Y);
1335 
1336  status = GdipDeleteBrush((GpBrush*)grad);
1337  expect(Ok, status);
1338 
1339  status = GdipCreatePathGradient(path_points, 3, WrapModeClamp, &grad);
1340  expect(Ok, status);
1341 
1343  expect(Ok, status);
1344  todo_wine expectf(1.0, point.X);
1345  todo_wine expectf(4.0/3.0, point.Y);
1346 
1347  status = GdipDeleteBrush((GpBrush*)grad);
1348  expect(Ok, status);
1349 }
1350 
1352 {
1353  static const GpPointF path_points[] = {{0,0}, {3,0}, {0,4}};
1354  GpStatus status;
1355  GpPathGradient *grad;
1356  INT count;
1357  int i;
1358  const REAL positions[5] = {0.0f, 0.2f, 0.5f, 0.8f, 1.0f};
1359  const REAL two_positions[2] = {0.0f, 1.0f};
1360  const ARGB colors[5] = {0xff0000ff, 0xff00ff00, 0xff00ffff, 0xffff0000, 0xffffffff};
1361  REAL res_positions[6] = {0.3f, 0.0f, 0.0f, 0.0f, 0.0f};
1362  ARGB res_colors[6] = {0xdeadbeef, 0, 0, 0, 0};
1363 
1364  status = GdipCreatePathGradient(path_points+1, 2, WrapModeClamp, &grad);
1365  expect(Ok, status);
1366 
1369 
1372 
1374  expect(Ok, status);
1375  expect(0, count);
1376 
1377  status = GdipGetPathGradientPresetBlend(NULL, res_colors, res_positions, 1);
1379 
1380  status = GdipGetPathGradientPresetBlend(grad, NULL, res_positions, 1);
1382 
1383  status = GdipGetPathGradientPresetBlend(grad, res_colors, NULL, 1);
1385 
1386  status = GdipGetPathGradientPresetBlend(grad, res_colors, res_positions, 0);
1388 
1389  status = GdipGetPathGradientPresetBlend(grad, res_colors, res_positions, -1);
1391 
1392  status = GdipGetPathGradientPresetBlend(grad, res_colors, res_positions, 1);
1394 
1395  status = GdipGetPathGradientPresetBlend(grad, res_colors, res_positions, 2);
1397 
1398  status = GdipSetPathGradientPresetBlend(NULL, colors, positions, 5);
1400 
1401  status = GdipSetPathGradientPresetBlend(grad, NULL, positions, 5);
1403 
1404  if (0)
1405  {
1406  /* crashes on windows xp */
1407  status = GdipSetPathGradientPresetBlend(grad, colors, NULL, 5);
1409  }
1410 
1411  status = GdipSetPathGradientPresetBlend(grad, colors, positions, 0);
1413 
1414  status = GdipSetPathGradientPresetBlend(grad, colors, positions, -1);
1416 
1417  status = GdipSetPathGradientPresetBlend(grad, colors, positions, 1);
1419 
1420  /* leave off the 0.0 position */
1421  status = GdipSetPathGradientPresetBlend(grad, &colors[1], &positions[1], 4);
1423 
1424  /* leave off the 1.0 position */
1425  status = GdipSetPathGradientPresetBlend(grad, colors, positions, 4);
1427 
1428  status = GdipSetPathGradientPresetBlend(grad, colors, positions, 5);
1429  expect(Ok, status);
1430 
1432  expect(Ok, status);
1433  expect(5, count);
1434 
1435  if (0)
1436  {
1437  /* Native GdipGetPathGradientPresetBlend seems to copy starting from
1438  * the end of each array and do no bounds checking. This is so braindead
1439  * I'm not going to copy it. */
1440 
1441  res_colors[0] = 0xdeadbeef;
1442  res_positions[0] = 0.3;
1443 
1444  status = GdipGetPathGradientPresetBlend(grad, &res_colors[1], &res_positions[1], 4);
1445  expect(Ok, status);
1446 
1447  expect(0xdeadbeef, res_colors[0]);
1448  expectf(0.3, res_positions[0]);
1449 
1450  for (i=1; i<5; i++)
1451  {
1452  expect(colors[i], res_colors[i]);
1453  expectf(positions[i], res_positions[i]);
1454  }
1455 
1456  status = GdipGetPathGradientPresetBlend(grad, res_colors, res_positions, 6);
1457  expect(Ok, status);
1458 
1459  for (i=0; i<5; i++)
1460  {
1461  expect(colors[i], res_colors[i+1]);
1462  expectf(positions[i], res_positions[i+1]);
1463  }
1464  }
1465 
1466  status = GdipGetPathGradientPresetBlend(grad, res_colors, res_positions, 5);
1467  expect(Ok, status);
1468 
1469  for (i=0; i<5; i++)
1470  {
1471  expect(colors[i], res_colors[i]);
1472  expectf(positions[i], res_positions[i]);
1473  }
1474 
1475  status = GdipGetPathGradientPresetBlend(grad, res_colors, res_positions, 0);
1477 
1478  status = GdipGetPathGradientPresetBlend(grad, res_colors, res_positions, -1);
1480 
1481  status = GdipGetPathGradientPresetBlend(grad, res_colors, res_positions, 1);
1483 
1484  status = GdipSetPathGradientPresetBlend(grad, colors, two_positions, 2);
1485  expect(Ok, status);
1486 
1487  status = GdipDeleteBrush((GpBrush*)grad);
1488  expect(Ok, status);
1489 }
1490 
1491 static void test_pathgradientblend(void)
1492 {
1493  static const GpPointF path_points[] = {{0,0}, {3,0}, {0,4}};
1494  GpPathGradient *brush;
1495  GpStatus status;
1496  INT count, i;
1497  const REAL factors[5] = {0.0f, 0.1f, 0.5f, 0.9f, 1.0f};
1498  const REAL positions[5] = {0.0f, 0.2f, 0.5f, 0.8f, 1.0f};
1499  REAL res_factors[6] = {0.3f, 0.0f, 0.0f, 0.0f, 0.0f};
1500  REAL res_positions[6] = {0.3f, 0.0f, 0.0f, 0.0f, 0.0f};
1501 
1502  status = GdipCreatePathGradient(path_points, 3, WrapModeClamp, &brush);
1503  expect(Ok, status);
1504 
1507 
1510 
1512  expect(Ok, status);
1513  expect(1, count);
1514 
1515  status = GdipGetPathGradientBlend(NULL, res_factors, res_positions, 1);
1517 
1518  status = GdipGetPathGradientBlend(brush, NULL, res_positions, 1);
1520 
1521  status = GdipGetPathGradientBlend(brush, res_factors, NULL, 1);
1523 
1524  status = GdipGetPathGradientBlend(brush, res_factors, res_positions, 0);
1526 
1527  status = GdipGetPathGradientBlend(brush, res_factors, res_positions, -1);
1529 
1530  status = GdipGetPathGradientBlend(brush, res_factors, res_positions, 1);
1531  expect(Ok, status);
1532 
1533  status = GdipGetPathGradientBlend(brush, res_factors, res_positions, 2);
1534  expect(Ok, status);
1535 
1536  status = GdipSetPathGradientBlend(NULL, factors, positions, 5);
1538 
1539  status = GdipSetPathGradientBlend(brush, NULL, positions, 5);
1541 
1542  status = GdipSetPathGradientBlend(brush, factors, NULL, 5);
1544 
1545  status = GdipSetPathGradientBlend(brush, factors, positions, 0);
1547 
1548  status = GdipSetPathGradientBlend(brush, factors, positions, -1);
1550 
1551  /* leave off the 0.0 position */
1552  status = GdipSetPathGradientBlend(brush, &factors[1], &positions[1], 4);
1554 
1555  /* leave off the 1.0 position */
1556  status = GdipSetPathGradientBlend(brush, factors, positions, 4);
1558 
1559  status = GdipSetPathGradientBlend(brush, factors, positions, 5);
1560  expect(Ok, status);
1561 
1563  expect(Ok, status);
1564  expect(5, count);
1565 
1566  status = GdipGetPathGradientBlend(brush, res_factors, res_positions, 4);
1568 
1569  status = GdipGetPathGradientBlend(brush, res_factors, res_positions, 5);
1570  expect(Ok, status);
1571 
1572  for (i=0; i<5; i++)
1573  {
1574  expectf(factors[i], res_factors[i]);
1575  expectf(positions[i], res_positions[i]);
1576  }
1577 
1578  status = GdipGetPathGradientBlend(brush, res_factors, res_positions, 6);
1579  expect(Ok, status);
1580 
1581  status = GdipSetPathGradientBlend(brush, factors, positions, 1);
1582  expect(Ok, status);
1583 
1585  expect(Ok, status);
1586  expect(1, count);
1587 
1588  status = GdipGetPathGradientBlend(brush, res_factors, res_positions, 1);
1589  expect(Ok, status);
1590 
1591  status = GdipDeleteBrush((GpBrush*)brush);
1592  expect(Ok, status);
1593 }
1594 
1595 static void test_getHatchStyle(void)
1596 {
1597  GpStatus status;
1598  GpHatch *brush;
1599  GpHatchStyle hatchStyle;
1600 
1601  GdipCreateHatchBrush(HatchStyleHorizontal, 11, 12, &brush);
1602 
1603  status = GdipGetHatchStyle(NULL, &hatchStyle);
1605 
1606  status = GdipGetHatchStyle(brush, NULL);
1608 
1609  status = GdipGetHatchStyle(brush, &hatchStyle);
1610  expect(Ok, status);
1611  expect(HatchStyleHorizontal, hatchStyle);
1612 
1613  GdipDeleteBrush((GpBrush *)brush);
1614 }
1615 
1617 {
1618  struct GdiplusStartupInput gdiplusStartupInput;
1620  HMODULE hmsvcrt;
1621  int (CDECL * _controlfp_s)(unsigned int *cur, unsigned int newval, unsigned int mask);
1622  WNDCLASSA class;
1623 
1624  /* Enable all FP exceptions except _EM_INEXACT, which gdi32 can trigger */
1625  hmsvcrt = LoadLibraryA("msvcrt");
1626  _controlfp_s = (void*)GetProcAddress(hmsvcrt, "_controlfp_s");
1627  if (_controlfp_s) _controlfp_s(0, 0, 0x0008001e);
1628 
1629  memset( &class, 0, sizeof(class) );
1630  class.lpszClassName = "gdiplus_test";
1631  class.style = CS_HREDRAW | CS_VREDRAW;
1632  class.lpfnWndProc = DefWindowProcA;
1633  class.hInstance = GetModuleHandleA(0);
1634  class.hIcon = LoadIconA(0, (LPCSTR)IDI_APPLICATION);
1635  class.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
1636  class.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
1637  RegisterClassA( &class );
1638  hwnd = CreateWindowA( "gdiplus_test", "graphics test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
1639  CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, 0, 0, GetModuleHandleA(0), 0 );
1640  ok(hwnd != NULL, "Expected window to be created\n");
1641 
1642  gdiplusStartupInput.GdiplusVersion = 1;
1643  gdiplusStartupInput.DebugEventCallback = NULL;
1644  gdiplusStartupInput.SuppressBackgroundThread = 0;
1645  gdiplusStartupInput.SuppressExternalCodecs = 0;
1646 
1647  GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
1648 
1652  test_type();
1654  test_getblend();
1655  test_getbounds();
1656  test_getgamma();
1657  test_transform();
1658  test_texturewrap();
1660  test_lineblend();
1668 
1671 }
static void test_gradientblendcount(void)
Definition: brush.c:153
GpStatus WINGDIPAPI GdipSetTextureTransform(GpTexture *texture, GDIPCONST GpMatrix *matrix)
Definition: brush.c:1939
RECT rect2
Definition: edittest.c:51
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static GpPointF getblend_ptf[]
Definition: brush.c:176
GpStatus WINGDIPAPI GdipSetMatrixElements(GpMatrix *matrix, REAL m11, REAL m12, REAL m21, REAL m22, REAL dx, REAL dy)
Definition: matrix.c:316
static void test_createHatchBrush(void)
Definition: brush.c:48
static void test_createLineBrushFromRectWithAngle(void)
Definition: brush.c:75
BOOL WINAPI TranslateMessage(_In_ const MSG *)
GpStatus WINGDIPAPI GdipScaleLineTransform(GpLineGradient *brush, REAL sx, REAL sy, GpMatrixOrder order)
Definition: brush.c:2141
HatchStyle
Definition: gdiplusenums.h:387
#define TRUE
Definition: types.h:120
GpStatus WINGDIPAPI GdipResetLineTransform(GpLineGradient *brush)
Definition: brush.c:2106
GpStatus WINGDIPAPI GdipCreateMatrix2(REAL m11, REAL m12, REAL m21, REAL m22, REAL dx, REAL dy, GpMatrix **matrix)
Definition: matrix.c:61
#define expect(expected, got)
Definition: brush.c:27
LinearGradientMode
Definition: gdiplusenums.h:222
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorCount(GpPathGradient *brush, INT *count)
Definition: brush.c:1244
GpStatus WINGDIPAPI GdipGetPathGradientBlendCount(GpPathGradient *brush, INT *count)
Definition: brush.c:1074
static GpPointF getbounds_ptf[]
Definition: brush.c:210
WrapMode
Definition: gdiplusenums.h:203
HDC WINAPI GetDC(_In_opt_ HWND)
GpStatus WINGDIPAPI GdipSetLineTransform(GpLineGradient *brush, GDIPCONST GpMatrix *matrix)
Definition: brush.c:2116
GpStatus WINGDIPAPI GdipGetLineColors(GpLineGradient *brush, ARGB *colors)
Definition: brush.c:1983
GpStatus WINGDIPAPI GdipGetMatrixElements(GDIPCONST GpMatrix *matrix, REAL *out)
Definition: matrix.c:172
GLuint GLuint GLsizei count
Definition: gl.h:1545
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
static void test_texturewrap(void)
Definition: brush.c:574
GpStatus WINGDIPAPI GdipCreateMatrix(GpMatrix **matrix)
Definition: matrix.c:140
static HDC
Definition: imagelist.c:92
GpStatus WINGDIPAPI GdipCreateTexture(GpImage *image, GpWrapMode wrapmode, GpTexture **texture)
Definition: brush.c:786
GpStatus WINGDIPAPI GdipSetTextureWrapMode(GpTexture *brush, GpWrapMode wrapmode)
Definition: brush.c:1957
#define CS_HREDRAW
Definition: winuser.h:648
GpStatus WINGDIPAPI GdipGetLineBlend(GpLineGradient *brush, REAL *factors, REAL *positions, INT count)
Definition: brush.c:1403
#define expectf(expected, got)
Definition: brush.c:28
#define IDI_APPLICATION
Definition: winuser.h:699
GLuint GLuint end
Definition: gl.h:1545
static void test_lineblend(void)
Definition: brush.c:832
GpStatus WINGDIPAPI GdipGetLineBlendCount(GpLineGradient *brush, INT *count)
Definition: brush.c:1420
GLfloat angle
Definition: glext.h:10853
GpStatus WINGDIPAPI GdipSetPathGradientSurroundColorsWithCount(GpPathGradient *grad, GDIPCONST ARGB *argb, INT *count)
Definition: brush.c:1793
GpStatus WINGDIPAPI GdipCreatePathGradient(GDIPCONST GpPointF *points, INT count, GpWrapMode wrap, GpPathGradient **grad)
Definition: brush.c:658
GpStatus WINGDIPAPI GdipGetPathGradientPath(GpPathGradient *grad, GpPath *path)
Definition: brush.c:1161
START_TEST(brush)
Definition: brush.c:364
BOOL WINAPI DestroyWindow(_In_ HWND)
GpStatus WINGDIPAPI GdipGetPathGradientPresetBlendCount(GpPathGradient *brush, INT *count)
Definition: brush.c:1643
#define COLOR_WINDOW
Definition: winuser.h:908
int32_t INT
Definition: typedefs.h:56
POINTL point
Definition: edittest.c:50
& rect
Definition: startmenu.cpp:1413
GpStatus WINGDIPAPI GdipDeletePath(GpPath *path)
HICON WINAPI LoadIconA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2029
const GLfloat * m
Definition: glext.h:10848
uint32_t ULONG_PTR
Definition: typedefs.h:63
GpStatus WINGDIPAPI GdipCreateLineBrush(GDIPCONST GpPointF *startpoint, GDIPCONST GpPointF *endpoint, ARGB startcolor, ARGB endcolor, GpWrapMode wrap, GpLineGradient **line)
Definition: brush.c:372
static void test_gradientsurroundcolorcount(void)
Definition: brush.c:1096
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
GpStatus WINGDIPAPI GdipIsMatrixEqual(GDIPCONST GpMatrix *matrix, GDIPCONST GpMatrix *matrix2, BOOL *result)
Definition: matrix.c:499
static void test_pathgradientpresetblend(void)
Definition: brush.c:1351
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
static void test_pathgradientblend(void)
Definition: brush.c:1491
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint color
Definition: glext.h:6243
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2581
GpStatus WINGDIPAPI GdipGetLinePresetBlendCount(GpLineGradient *brush, INT *count)
Definition: brush.c:2095
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
GpStatus WINGDIPAPI GdipGetLineRect(GpLineGradient *brush, GpRectF *rect)
Definition: brush.c:2191
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4216
static void test_getblend(void)
Definition: brush.c:178
#define CW_USEDEFAULT
Definition: winuser.h:225
GpStatus WINGDIPAPI GdipFillRectangle(GpGraphics *graphics, GpBrush *brush, REAL x, REAL y, REAL width, REAL height)
Definition: graphics.c:4537
GpStatus WINGDIPAPI GdipSetLineBlend(GpLineGradient *brush, GDIPCONST REAL *factors, GDIPCONST REAL *positions, INT count)
Definition: brush.c:1369
static void test_pathgradientpath(void)
Definition: brush.c:1270
smooth NULL
Definition: ftsmooth.c:416
GpStatus WINGDIPAPI GdipSetPathGradientPresetBlend(GpPathGradient *brush, GDIPCONST ARGB *blend, GDIPCONST REAL *pos, INT count)
Definition: brush.c:1581
Definition: parser.c:48
const char * LPCSTR
Definition: xmlstorage.h:183
REAL Height
Definition: gdiplustypes.h:264
GpStatus WINGDIPAPI GdipGetPathGradientCenterPoint(GpPathGradient *grad, GpPointF *point)
Definition: brush.c:1086
GpStatus WINGDIPAPI GdipMultiplyLineTransform(GpLineGradient *brush, GDIPCONST GpMatrix *matrix, GpMatrixOrder order)
Definition: brush.c:2152
#define expectf2(expected, got)
GpStatus WINGDIPAPI GdipCreateHatchBrush(GpHatchStyle hatchstyle, ARGB forecol, ARGB backcol, GpHatch **brush)
Definition: brush.c:276
GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
Definition: brush.c:994
int CDECL _controlfp_s(unsigned int *cur, unsigned int newval, unsigned int mask)
Definition: cntrlfp.c:120
DebugEventProc DebugEventCallback
Definition: gdiplusinit.h:35
Definition: uimain.c:88
#define CS_VREDRAW
Definition: winuser.h:653
static void test_type(void)
Definition: brush.c:137
GLfloat f
Definition: glext.h:7540
GpStatus WINGDIPAPI GdipCreateFromHWND(HWND hwnd, GpGraphics **graphics)
Definition: graphics.c:2529
BOOL SuppressBackgroundThread
Definition: gdiplusinit.h:36
GpStatus WINGDIPAPI GdipTranslateLineTransform(GpLineGradient *brush, REAL dx, REAL dy, GpMatrixOrder order)
Definition: brush.c:2166
GpStatus WINGDIPAPI GdipSetPathGradientBlend(GpPathGradient *brush, GDIPCONST REAL *blend, GDIPCONST REAL *pos, INT count)
Definition: brush.c:1514
GLenum GLuint texture
Definition: glext.h:6295
REAL X
Definition: gdiplustypes.h:261
GpStatus WINGDIPAPI GdipResetTextureTransform(GpTexture *brush)
Definition: brush.c:1345
static void test_linelinearblend(void)
Definition: brush.c:1028
void WINAPI GdiplusShutdown(ULONG_PTR)
Status WINAPI GdiplusStartup(ULONG_PTR *token, const struct GdiplusStartupInput *input, struct GdiplusStartupOutput *output)
Definition: gdiplus.c:81
GpStatus WINGDIPAPI GdipGetBrushType(GpBrush *brush, GpBrushType *type)
Definition: brush.c:950
REAL Y
Definition: gdiplustypes.h:249
GpStatus WINGDIPAPI GdipRotateMatrix(GpMatrix *matrix, REAL angle, GpMatrixOrder order)
Definition: matrix.c:258
static void test_gradientgetrect(void)
Definition: brush.c:622
GpStatus WINGDIPAPI GdipCreateLineBrushFromRect(GDIPCONST GpRectF *rect, ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap, GpLineGradient **line)
Definition: brush.c:436
static void test_constructor_destructor(void)
Definition: brush.c:32
static ULONG_PTR gdiplusToken
Definition: CImage.cpp:79
int ret
GpStatus WINGDIPAPI GdipDeleteMatrix(GpMatrix *matrix)
Definition: matrix.c:160
GpStatus WINGDIPAPI GdipGetTextureWrapMode(GpTexture *brush, GpWrapMode *wrapmode)
Definition: brush.c:1316
char line[200]
Definition: main.c:97
GpStatus WINGDIPAPI GdipGetHatchStyle(GpHatch *brush, GpHatchStyle *hatchstyle)
Definition: brush.c:983
static void test_transform(void)
Definition: brush.c:264
#define todo_wine
Definition: test.h:154
HDC hdc
Definition: main.c:9
GpStatus WINGDIPAPI GdipCreateBitmapFromGraphics(INT width, INT height, GpGraphics *target, GpBitmap **bitmap)
Definition: image.c:1542
GpStatus WINGDIPAPI GdipCreatePath(GpFillMode fill, GpPath **path)
GpStatus WINGDIPAPI GdipGetTextureTransform(GpTexture *brush, GpMatrix *matrix)
Definition: brush.c:1301
GpStatus WINGDIPAPI GdipScaleMatrix(GpMatrix *matrix, REAL scaleX, REAL scaleY, GpMatrixOrder order)
Definition: matrix.c:289
REAL X
Definition: gdiplustypes.h:248
GpStatus WINGDIPAPI GdipGetLineGammaCorrection(GpLineGradient *line, BOOL *usinggamma)
Definition: brush.c:1030
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static HWND hwnd
Definition: brush.c:30
GLenum mode
Definition: glext.h:6217
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2059
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
Status
Definition: gdiplustypes.h:24
REAL Width
Definition: gdiplustypes.h:263
static void test_pathgradientcenterpoint(void)
Definition: brush.c:1298
GpStatus WINGDIPAPI GdipGetLinePresetBlend(GpLineGradient *brush, ARGB *blend, REAL *positions, INT count)
Definition: brush.c:2077
GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorsWithCount(GpPathGradient *grad, ARGB *argb, INT *count)
Definition: brush.c:1221
#define CDECL
Definition: compat.h:21
GLuint start
Definition: gl.h:1545
#define ARRAY_SIZE(a)
Definition: main.h:24
GpStatus WINGDIPAPI GdipGetPathGradientPresetBlend(GpPathGradient *brush, ARGB *blend, REAL *pos, INT count)
Definition: brush.c:1616
#define ok(value,...)
Definition: atltest.h:57
GpStatus WINGDIPAPI GdipSetLineLinearBlend(GpLineGradient *brush, REAL focus, REAL scale)
Definition: brush.c:2010
Definition: services.c:325
GpStatus WINGDIPAPI GdipGetLineTransform(GpLineGradient *brush, GpMatrix *matrix)
Definition: brush.c:2129
static void test_getHatchStyle(void)
Definition: brush.c:1595
GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics)
Definition: graphics.c:2395
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
static void test_getbounds(void)
Definition: brush.c:214
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
Definition: winddi.h:3706
static void test_getgamma(void)
Definition: brush.c:240
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
GLuint res
Definition: glext.h:9613
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
GLuint GLenum GLenum transform
Definition: glext.h:9407
#define GetProcAddress(x, y)
Definition: compat.h:410
GpStatus WINGDIPAPI GdipGetPathGradientRect(GpPathGradient *brush, GpRectF *rect)
Definition: brush.c:1186
#define wrap(journal, var)
Definition: recovery.c:207
static HBITMAP bitmap
Definition: clipboard.c:1344
BrushType
Definition: gdiplusenums.h:36
GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
Definition: brush.c:757
float REAL
Definition: types.h:41
GpStatus WINGDIPAPI GdipSetLinePresetBlend(GpLineGradient *brush, GDIPCONST ARGB *blend, GDIPCONST REAL *positions, INT count)
Definition: brush.c:2042
GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF *rect, ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap, GpLineGradient **line)
Definition: brush.c:489
GpStatus WINGDIPAPI GdipIsMatrixIdentity(GDIPCONST GpMatrix *matrix, BOOL *result)
Definition: matrix.c:512
REAL Y
Definition: gdiplustypes.h:262
GpStatus WINGDIPAPI GdipGetPathGradientBlend(GpPathGradient *brush, REAL *blend, REAL *positions, INT count)
Definition: brush.c:1055
#define WS_VISIBLE
Definition: pedump.c:620
#define memset(x, y, z)
Definition: compat.h:39
static SERVICE_STATUS status
Definition: service.c:31
static GpPointF blendcount_ptf[]
Definition: brush.c:151
GpStatus WINGDIPAPI GdipSetPathGradientCenterPoint(GpPathGradient *grad, GpPointF *point)
Definition: brush.c:1668
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
Definition: ps.c:97
DWORD ARGB