2 * Unit test suite for brushes
4 * Copyright (C) 2007 Google (Evan Stade)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
24 #define expectf(expected, got) ok(fabs(expected - got) < 0.0001, "Expected %.2f, got %.2f\n", expected, got)
28 static void test_constructor_destructor(void)
31 GpSolidFill
*brush
= NULL
;
33 status
= GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
35 ok(brush
!= NULL
, "Expected brush to be initialized\n");
37 status
= GdipDeleteBrush(NULL
);
38 expect(InvalidParameter
, status
);
40 status
= GdipDeleteBrush((GpBrush
*) brush
);
44 static void test_createHatchBrush(void)
49 status
= GdipCreateHatchBrush(HatchStyleMin
, 1, 2, &brush
);
51 ok(brush
!= NULL
, "Expected the brush to be initialized.\n");
53 GdipDeleteBrush((GpBrush
*)brush
);
55 status
= GdipCreateHatchBrush(HatchStyleMax
, 1, 2, &brush
);
57 ok(brush
!= NULL
, "Expected the brush to be initialized.\n");
59 GdipDeleteBrush((GpBrush
*)brush
);
61 status
= GdipCreateHatchBrush(HatchStyle05Percent
, 1, 2, NULL
);
62 expect(InvalidParameter
, status
);
64 status
= GdipCreateHatchBrush((HatchStyle
)(HatchStyleMin
- 1), 1, 2, &brush
);
65 expect(InvalidParameter
, status
);
67 status
= GdipCreateHatchBrush((HatchStyle
)(HatchStyleMax
+ 1), 1, 2, &brush
);
68 expect(InvalidParameter
, status
);
71 static void test_createLineBrushFromRectWithAngle(void)
74 GpLineGradient
*brush
;
75 GpRectF rect1
= { 1, 3, 1, 2 };
76 GpRectF rect2
= { 1, 3, -1, -2 };
77 GpRectF rect3
= { 1, 3, 0, 1 };
78 GpRectF rect4
= { 1, 3, 1, 0 };
80 status
= GdipCreateLineBrushFromRectWithAngle(&rect1
, 10, 11, 0, TRUE
, WrapModeTile
, &brush
);
82 GdipDeleteBrush((GpBrush
*) brush
);
84 status
= GdipCreateLineBrushFromRectWithAngle(&rect2
, 10, 11, 135, TRUE
, (WrapMode
)(WrapModeTile
- 1), &brush
);
86 GdipDeleteBrush((GpBrush
*) brush
);
88 status
= GdipCreateLineBrushFromRectWithAngle(&rect2
, 10, 11, -225, FALSE
, (WrapMode
)(WrapModeTile
- 1), &brush
);
90 GdipDeleteBrush((GpBrush
*) brush
);
92 status
= GdipCreateLineBrushFromRectWithAngle(&rect1
, 10, 11, 405, TRUE
, (WrapMode
)(WrapModeClamp
+ 1), &brush
);
94 GdipDeleteBrush((GpBrush
*) brush
);
96 status
= GdipCreateLineBrushFromRectWithAngle(&rect1
, 10, 11, 45, FALSE
, (WrapMode
)(WrapModeClamp
+ 1), &brush
);
98 GdipDeleteBrush((GpBrush
*) brush
);
100 status
= GdipCreateLineBrushFromRectWithAngle(&rect1
, 10, 11, 90, TRUE
, WrapModeTileFlipX
, &brush
);
103 status
= GdipCreateLineBrushFromRectWithAngle(NULL
, 10, 11, 90, TRUE
, WrapModeTile
, &brush
);
104 expect(InvalidParameter
, status
);
106 status
= GdipCreateLineBrushFromRectWithAngle(&rect3
, 10, 11, 90, TRUE
, WrapModeTileFlipXY
, &brush
);
107 expect(OutOfMemory
, status
);
109 status
= GdipCreateLineBrushFromRectWithAngle(&rect4
, 10, 11, 90, TRUE
, WrapModeTileFlipXY
, &brush
);
110 expect(OutOfMemory
, status
);
112 status
= GdipCreateLineBrushFromRectWithAngle(&rect3
, 10, 11, 90, TRUE
, WrapModeTileFlipXY
, NULL
);
113 expect(InvalidParameter
, status
);
115 status
= GdipCreateLineBrushFromRectWithAngle(&rect4
, 10, 11, 90, TRUE
, WrapModeTileFlipXY
, NULL
);
116 expect(InvalidParameter
, status
);
118 status
= GdipCreateLineBrushFromRectWithAngle(&rect3
, 10, 11, 90, TRUE
, WrapModeClamp
, &brush
);
119 expect(InvalidParameter
, status
);
121 status
= GdipCreateLineBrushFromRectWithAngle(&rect4
, 10, 11, 90, TRUE
, WrapModeClamp
, &brush
);
122 expect(InvalidParameter
, status
);
124 status
= GdipCreateLineBrushFromRectWithAngle(&rect1
, 10, 11, 90, TRUE
, WrapModeClamp
, &brush
);
125 expect(InvalidParameter
, status
);
127 status
= GdipCreateLineBrushFromRectWithAngle(&rect1
, 10, 11, 90, TRUE
, WrapModeTile
, NULL
);
128 expect(InvalidParameter
, status
);
130 GdipDeleteBrush((GpBrush
*) brush
);
133 static void test_type(void)
137 GpSolidFill
*brush
= NULL
;
139 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
141 status
= GdipGetBrushType((GpBrush
*)brush
, &bt
);
143 expect(BrushTypeSolidColor
, bt
);
145 GdipDeleteBrush((GpBrush
*) brush
);
147 static GpPointF blendcount_ptf
[] = {{0.0, 0.0},
149 static void test_gradientblendcount(void)
152 GpPathGradient
*brush
;
155 status
= GdipCreatePathGradient(blendcount_ptf
, 2, WrapModeClamp
, &brush
);
158 status
= GdipGetPathGradientBlendCount(NULL
, NULL
);
159 expect(InvalidParameter
, status
);
160 status
= GdipGetPathGradientBlendCount(NULL
, &count
);
161 expect(InvalidParameter
, status
);
162 status
= GdipGetPathGradientBlendCount(brush
, NULL
);
163 expect(InvalidParameter
, status
);
165 status
= GdipGetPathGradientBlendCount(brush
, &count
);
169 GdipDeleteBrush((GpBrush
*) brush
);
172 static GpPointF getblend_ptf
[] = {{0.0, 0.0},
174 static void test_getblend(void)
177 GpPathGradient
*brush
;
181 status
= GdipCreatePathGradient(getblend_ptf
, 2, WrapModeClamp
, &brush
);
184 /* check some invalid parameters combinations */
185 status
= GdipGetPathGradientBlend(NULL
, NULL
, NULL
, -1);
186 expect(InvalidParameter
, status
);
187 status
= GdipGetPathGradientBlend(brush
,NULL
, NULL
, -1);
188 expect(InvalidParameter
, status
);
189 status
= GdipGetPathGradientBlend(NULL
, blends
,NULL
, -1);
190 expect(InvalidParameter
, status
);
191 status
= GdipGetPathGradientBlend(NULL
, NULL
, pos
, -1);
192 expect(InvalidParameter
, status
);
193 status
= GdipGetPathGradientBlend(NULL
, NULL
, NULL
, 1);
194 expect(InvalidParameter
, status
);
196 blends
[0] = (REAL
)0xdeadbeef;
197 pos
[0] = (REAL
)0xdeadbeef;
198 status
= GdipGetPathGradientBlend(brush
, blends
, pos
, 1);
200 expectf(1.0, blends
[0]);
201 expectf((REAL
)0xdeadbeef, pos
[0]);
203 GdipDeleteBrush((GpBrush
*) brush
);
206 static GpPointF getbounds_ptf
[] = {{0.0, 20.0},
210 static void test_getbounds(void)
213 GpPathGradient
*brush
;
216 status
= GdipCreatePathGradient(getbounds_ptf
, 4, WrapModeClamp
, &brush
);
219 status
= GdipGetPathGradientRect(NULL
, NULL
);
220 expect(InvalidParameter
, status
);
221 status
= GdipGetPathGradientRect(brush
, NULL
);
222 expect(InvalidParameter
, status
);
223 status
= GdipGetPathGradientRect(NULL
, &bounds
);
224 expect(InvalidParameter
, status
);
226 status
= GdipGetPathGradientRect(brush
, &bounds
);
228 expectf(0.0, bounds
.X
);
229 expectf(20.0, bounds
.Y
);
230 expectf(50.0, bounds
.Width
);
231 expectf(30.0, bounds
.Height
);
233 GdipDeleteBrush((GpBrush
*) brush
);
236 static void test_getgamma(void)
239 GpLineGradient
*line
;
243 start
.X
= start
.Y
= 0.0;
244 end
.X
= end
.Y
= 100.0;
246 status
= GdipCreateLineBrush(&start
, &end
, (ARGB
)0xdeadbeef, 0xdeadbeef, WrapModeTile
, &line
);
250 status
= GdipGetLineGammaCorrection(NULL
, NULL
);
251 expect(InvalidParameter
, status
);
252 status
= GdipGetLineGammaCorrection(line
, NULL
);
253 expect(InvalidParameter
, status
);
254 status
= GdipGetLineGammaCorrection(NULL
, &gamma
);
255 expect(InvalidParameter
, status
);
257 GdipDeleteBrush((GpBrush
*)line
);
260 static void test_transform(void)
264 GpLineGradient
*line
;
265 GpGraphics
*graphics
= NULL
;
275 status
= GdipCreateMatrix2(2.0, 0.0, 0.0, 0.0, 0.0, 0.0, &m
);
278 status
= GdipCreateFromHDC(hdc
, &graphics
);
280 status
= GdipCreateBitmapFromGraphics(1, 1, graphics
, &bitmap
);
283 status
= GdipCreateTexture((GpImage
*)bitmap
, WrapModeTile
, &texture
);
287 status
= GdipGetTextureTransform(NULL
, NULL
);
288 expect(InvalidParameter
, status
);
289 status
= GdipGetTextureTransform(texture
, NULL
);
290 expect(InvalidParameter
, status
);
292 /* get default value - identity matrix */
293 status
= GdipGetTextureTransform(texture
, m
);
295 status
= GdipIsMatrixIdentity(m
, &res
);
298 /* set and get then */
299 status
= GdipCreateMatrix2(2.0, 0.0, 0.0, 2.0, 0.0, 0.0, &m1
);
301 status
= GdipSetTextureTransform(texture
, m1
);
303 status
= GdipGetTextureTransform(texture
, m
);
305 status
= GdipIsMatrixEqual(m
, m1
, &res
);
309 status
= GdipResetTextureTransform(texture
);
311 status
= GdipGetTextureTransform(texture
, m
);
313 status
= GdipIsMatrixIdentity(m
, &res
);
317 status
= GdipDeleteBrush((GpBrush
*)texture
);
320 status
= GdipDeleteMatrix(m1
);
322 status
= GdipDeleteMatrix(m
);
324 status
= GdipDisposeImage((GpImage
*)bitmap
);
326 status
= GdipDeleteGraphics(graphics
);
331 status
= GdipCreateFromHWND(hwnd
, &graphics
);
335 /* create with vertical gradient line */
336 start
.X
= start
.Y
= end
.X
= 0.0;
339 status
= GdipCreateLineBrush(&start
, &end
, (ARGB
)0xffff0000, 0xff00ff00, WrapModeTile
, &line
);
342 status
= GdipCreateMatrix2(1.0, 0.0, 0.0, 1.0, 0.0, 0.0, &m
);
346 status
= GdipResetLineTransform(NULL
);
347 expect(InvalidParameter
, status
);
348 status
= GdipSetLineTransform(NULL
, m
);
349 expect(InvalidParameter
, status
);
350 status
= GdipSetLineTransform(line
, NULL
);
351 expect(InvalidParameter
, status
);
352 status
= GdipGetLineTransform(NULL
, m
);
353 expect(InvalidParameter
, status
);
354 status
= GdipGetLineTransform(line
, NULL
);
355 expect(InvalidParameter
, status
);
356 status
= GdipScaleLineTransform(NULL
, 1, 1, MatrixOrderPrepend
);
357 expect(InvalidParameter
, status
);
358 status
= GdipMultiplyLineTransform(NULL
, m
, MatrixOrderPrepend
);
359 expect(InvalidParameter
, status
);
360 status
= GdipTranslateLineTransform(NULL
, 0, 0, MatrixOrderPrepend
);
361 expect(InvalidParameter
, status
);
363 /* initial transform */
364 status
= GdipGetLineTransform(line
, m
);
367 status
= GdipGetMatrixElements(m
, elements
);
369 expectf(0.0, elements
[0]);
370 expectf(1.0, elements
[1]);
371 expectf(-1.0, elements
[2]);
372 expectf(0.0, elements
[3]);
373 expectf(50.0, elements
[4]);
374 expectf(50.0, elements
[5]);
376 status
= GdipGetLineRect(line
, &rectf
);
378 expectf(-50.0, rectf
.X
);
379 expectf(0.0, rectf
.Y
);
380 expectf(100.0, rectf
.Width
);
381 expectf(100.0, rectf
.Height
);
383 status
= GdipFillRectangle(graphics
, (GpBrush
*)line
, 0, 0, 200, 200);
386 /* manually set transform */
387 GdipSetMatrixElements(m
, 2.0, 0.0, 0.0, 4.0, 0.0, 0.0);
389 status
= GdipSetLineTransform(line
, m
);
392 status
= GdipGetLineTransform(line
, m
);
395 status
= GdipGetMatrixElements(m
, elements
);
397 expectf(2.0, elements
[0]);
398 expectf(0.0, elements
[1]);
399 expectf(0.0, elements
[2]);
400 expectf(4.0, elements
[3]);
401 expectf(0.0, elements
[4]);
402 expectf(0.0, elements
[5]);
404 status
= GdipGetLineRect(line
, &rectf
);
406 expectf(-50.0, rectf
.X
);
407 expectf(0.0, rectf
.Y
);
408 expectf(100.0, rectf
.Width
);
409 expectf(100.0, rectf
.Height
);
411 status
= GdipFillRectangle(graphics
, (GpBrush
*)line
, 200, 0, 200, 200);
414 /* scale transform */
415 status
= GdipScaleLineTransform(line
, 4.0, 0.5, MatrixOrderAppend
);
418 status
= GdipGetLineTransform(line
, m
);
421 status
= GdipGetMatrixElements(m
, elements
);
423 expectf(8.0, elements
[0]);
424 expectf(0.0, elements
[1]);
425 expectf(0.0, elements
[2]);
426 expectf(2.0, elements
[3]);
427 expectf(0.0, elements
[4]);
428 expectf(0.0, elements
[5]);
430 status
= GdipGetLineRect(line
, &rectf
);
432 expectf(-50.0, rectf
.X
);
433 expectf(0.0, rectf
.Y
);
434 expectf(100.0, rectf
.Width
);
435 expectf(100.0, rectf
.Height
);
437 status
= GdipFillRectangle(graphics
, (GpBrush
*)line
, 400, 0, 200, 200);
440 /* translate transform */
441 status
= GdipTranslateLineTransform(line
, 10.0, -20.0, MatrixOrderAppend
);
444 status
= GdipGetLineTransform(line
, m
);
447 status
= GdipGetMatrixElements(m
, elements
);
449 expectf(8.0, elements
[0]);
450 expectf(0.0, elements
[1]);
451 expectf(0.0, elements
[2]);
452 expectf(2.0, elements
[3]);
453 expectf(10.0, elements
[4]);
454 expectf(-20.0, elements
[5]);
456 status
= GdipGetLineRect(line
, &rectf
);
458 expectf(-50.0, rectf
.X
);
459 expectf(0.0, rectf
.Y
);
460 expectf(100.0, rectf
.Width
);
461 expectf(100.0, rectf
.Height
);
463 status
= GdipFillRectangle(graphics
, (GpBrush
*)line
, 0, 200, 200, 200);
466 /* multiply transform */
467 GdipSetMatrixElements(m
, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
468 GdipRotateMatrix(m
, 45.0, MatrixOrderAppend
);
469 GdipScaleMatrix(m
, 0.25, 0.5, MatrixOrderAppend
);
471 status
= GdipMultiplyLineTransform(line
, m
, MatrixOrderAppend
);
474 /* NULL transform does nothing */
475 status
= GdipMultiplyLineTransform(line
, NULL
, MatrixOrderAppend
);
478 status
= GdipGetLineTransform(line
, m
);
481 status
= GdipGetMatrixElements(m
, elements
);
483 expectf(1.414214, elements
[0]);
484 expectf(2.828427, elements
[1]);
485 expectf(-0.353553, elements
[2]);
486 expectf(0.707107, elements
[3]);
487 expectf(5.303300, elements
[4]);
488 expectf(-3.535534, elements
[5]);
490 status
= GdipGetLineRect(line
, &rectf
);
492 expectf(-50.0, rectf
.X
);
493 expectf(0.0, rectf
.Y
);
494 expectf(100.0, rectf
.Width
);
495 expectf(100.0, rectf
.Height
);
497 status
= GdipFillRectangle(graphics
, (GpBrush
*)line
, 200, 200, 200, 200);
500 /* reset transform sets to identity */
501 status
= GdipResetLineTransform(line
);
504 status
= GdipGetLineTransform(line
, m
);
507 status
= GdipGetMatrixElements(m
, elements
);
509 expectf(1.0, elements
[0]);
510 expectf(0.0, elements
[1]);
511 expectf(0.0, elements
[2]);
512 expectf(1.0, elements
[3]);
513 expectf(0.0, elements
[4]);
514 expectf(0.0, elements
[5]);
516 status
= GdipGetLineRect(line
, &rectf
);
518 expectf(-50.0, rectf
.X
);
519 expectf(0.0, rectf
.Y
);
520 expectf(100.0, rectf
.Width
);
521 expectf(100.0, rectf
.Height
);
523 status
= GdipFillRectangle(graphics
, (GpBrush
*)line
, 400, 200, 200, 200);
526 GdipDeleteBrush((GpBrush
*)line
);
528 /* passing negative Width/Height to LinearGradientModeHorizontal */
529 rectf
.X
= rectf
.Y
= 10.0;
530 rectf
.Width
= rectf
.Height
= -100.0;
531 status
= GdipCreateLineBrushFromRect(&rectf
, (ARGB
)0xffff0000, 0xff00ff00,
532 LinearGradientModeHorizontal
, WrapModeTile
, &line
);
534 memset(&rectf
, 0, sizeof(GpRectF
));
535 status
= GdipGetLineRect(line
, &rectf
);
537 expectf(10.0, rectf
.X
);
538 expectf(10.0, rectf
.Y
);
539 expectf(-100.0, rectf
.Width
);
540 expectf(-100.0, rectf
.Height
);
541 status
= GdipGetLineTransform(line
, m
);
543 status
= GdipGetMatrixElements(m
, elements
);
545 expectf(1.0, elements
[0]);
546 expectf(0.0, elements
[1]);
547 expectf(0.0, elements
[2]);
548 expectf(1.0, elements
[3]);
549 expectf(0.0, elements
[4]);
550 expectf(0.0, elements
[5]);
551 status
= GdipFillRectangle(graphics
, (GpBrush
*)line
, 0, 400, 200, 200);
553 status
= GdipDeleteBrush((GpBrush
*)line
);
557 /* enable to visually compare with Windows */
559 while(GetMessageW(&msg
, hwnd
, 0, 0) > 0){
560 TranslateMessage(&msg
);
561 DispatchMessageW(&msg
);
566 GdipDeleteGraphics(graphics
);
570 static void test_texturewrap(void)
574 GpGraphics
*graphics
= NULL
;
579 status
= GdipCreateFromHDC(hdc
, &graphics
);
581 status
= GdipCreateBitmapFromGraphics(1, 1, graphics
, &bitmap
);
584 status
= GdipCreateTexture((GpImage
*)bitmap
, WrapModeTile
, &texture
);
588 status
= GdipGetTextureWrapMode(NULL
, NULL
);
589 expect(InvalidParameter
, status
);
590 status
= GdipGetTextureWrapMode(texture
, NULL
);
591 expect(InvalidParameter
, status
);
592 status
= GdipGetTextureWrapMode(NULL
, &wrap
);
593 expect(InvalidParameter
, status
);
596 wrap
= WrapModeClamp
;
597 status
= GdipGetTextureWrapMode(texture
, &wrap
);
599 expect(WrapModeTile
, wrap
);
601 wrap
= WrapModeClamp
;
602 status
= GdipSetTextureWrapMode(texture
, wrap
);
605 status
= GdipGetTextureWrapMode(texture
, &wrap
);
607 expect(WrapModeClamp
, wrap
);
609 status
= GdipDeleteBrush((GpBrush
*)texture
);
611 status
= GdipDisposeImage((GpImage
*)bitmap
);
613 status
= GdipDeleteGraphics(graphics
);
618 static void test_gradientgetrect(void)
620 GpLineGradient
*brush
;
627 status
= GdipCreateMatrix(&transform
);
631 pt2
.X
= pt2
.Y
= 100.0;
632 status
= GdipCreateLineBrush(&pt1
, &pt2
, 0, 0, WrapModeTile
, &brush
);
634 memset(&rectf
, 0, sizeof(GpRectF
));
635 status
= GdipGetLineRect(brush
, &rectf
);
637 expectf(1.0, rectf
.X
);
638 expectf(1.0, rectf
.Y
);
639 expectf(99.0, rectf
.Width
);
640 expectf(99.0, rectf
.Height
);
641 status
= GdipGetLineTransform(brush
, transform
);
643 status
= GdipGetMatrixElements(transform
, elements
);
645 expectf(1.0, elements
[0]);
646 expectf(1.0, elements
[1]);
647 expectf(-1.0, elements
[2]);
648 expectf(1.0, elements
[3]);
649 expectf(50.50, elements
[4]);
650 expectf(-50.50, elements
[5]);
651 status
= GdipDeleteBrush((GpBrush
*)brush
);
654 /* vertical gradient */
655 pt1
.X
= pt1
.Y
= pt2
.X
= 0.0;
657 status
= GdipCreateLineBrush(&pt1
, &pt2
, 0, 0, WrapModeTile
, &brush
);
659 memset(&rectf
, 0, sizeof(GpRectF
));
660 status
= GdipGetLineRect(brush
, &rectf
);
662 expectf(-5.0, rectf
.X
);
663 expectf(0.0, rectf
.Y
);
664 expectf(10.0, rectf
.Width
);
665 expectf(10.0, rectf
.Height
);
666 status
= GdipGetLineTransform(brush
, transform
);
668 status
= GdipGetMatrixElements(transform
, elements
);
670 expectf(0.0, elements
[0]);
671 expectf(1.0, elements
[1]);
672 expectf(-1.0, elements
[2]);
673 expectf(0.0, elements
[3]);
674 expectf(5.0, elements
[4]);
675 expectf(5.0, elements
[5]);
676 status
= GdipDeleteBrush((GpBrush
*)brush
);
679 /* horizontal gradient */
680 pt1
.X
= pt1
.Y
= pt2
.Y
= 0.0;
682 status
= GdipCreateLineBrush(&pt1
, &pt2
, 0, 0, WrapModeTile
, &brush
);
684 memset(&rectf
, 0, sizeof(GpRectF
));
685 status
= GdipGetLineRect(brush
, &rectf
);
687 expectf(0.0, rectf
.X
);
688 expectf(-5.0, rectf
.Y
);
689 expectf(10.0, rectf
.Width
);
690 expectf(10.0, rectf
.Height
);
691 status
= GdipGetLineTransform(brush
, transform
);
693 status
= GdipGetMatrixElements(transform
, elements
);
695 expectf(1.0, elements
[0]);
696 expectf(0.0, elements
[1]);
697 expectf(0.0, elements
[2]);
698 expectf(1.0, elements
[3]);
699 expectf(0.0, elements
[4]);
700 expectf(0.0, elements
[5]);
701 status
= GdipDeleteBrush((GpBrush
*)brush
);
708 status
= GdipCreateLineBrush(&pt1
, &pt2
, 0, 0, WrapModeTile
, &brush
);
710 memset(&rectf
, 0, sizeof(GpRectF
));
711 status
= GdipGetLineRect(brush
, &rectf
);
713 expectf(0.0, rectf
.X
);
714 expectf(-20.0, rectf
.Y
);
715 expectf(20.0, rectf
.Width
);
716 expectf(20.0, rectf
.Height
);
717 status
= GdipGetLineTransform(brush
, transform
);
719 status
= GdipGetMatrixElements(transform
, elements
);
721 expectf(1.0, elements
[0]);
722 expectf(-1.0, elements
[1]);
723 expectf(1.0, elements
[2]);
724 expectf(1.0, elements
[3]);
725 expectf(10.0, elements
[4]);
726 expectf(10.0, elements
[5]);
727 status
= GdipDeleteBrush((GpBrush
*)brush
);
734 status
= GdipCreateLineBrush(&pt1
, &pt2
, 0, 0, WrapModeTile
, &brush
);
736 memset(&rectf
, 0, sizeof(GpRectF
));
737 status
= GdipGetLineRect(brush
, &rectf
);
739 expectf(0.0, rectf
.X
);
740 expectf(0.0, rectf
.Y
);
741 expectf(100.0, rectf
.Width
);
742 expectf(1.0, rectf
.Height
);
743 status
= GdipGetLineTransform(brush
, transform
);
745 status
= GdipGetMatrixElements(transform
, elements
);
747 expectf(1.0, elements
[0]);
748 expectf(0.01, elements
[1]);
749 expectf(-0.02, elements
[2]);
750 /* expectf(2.0, elements[3]); */
751 expectf(0.01, elements
[4]);
752 /* expectf(-1.0, elements[5]); */
753 status
= GdipDeleteBrush((GpBrush
*)brush
);
756 /* zero height rect */
757 rectf
.X
= rectf
.Y
= 10.0;
760 status
= GdipCreateLineBrushFromRect(&rectf
, 0, 0, LinearGradientModeVertical
,
761 WrapModeTile
, &brush
);
762 expect(OutOfMemory
, status
);
764 /* zero width rect */
765 rectf
.X
= rectf
.Y
= 10.0;
767 rectf
.Height
= 100.0;
768 status
= GdipCreateLineBrushFromRect(&rectf
, 0, 0, LinearGradientModeHorizontal
,
769 WrapModeTile
, &brush
);
770 expect(OutOfMemory
, status
);
772 /* from rect with LinearGradientModeHorizontal */
773 rectf
.X
= rectf
.Y
= 10.0;
774 rectf
.Width
= rectf
.Height
= 100.0;
775 status
= GdipCreateLineBrushFromRect(&rectf
, 0, 0, LinearGradientModeHorizontal
,
776 WrapModeTile
, &brush
);
778 memset(&rectf
, 0, sizeof(GpRectF
));
779 status
= GdipGetLineRect(brush
, &rectf
);
781 expectf(10.0, rectf
.X
);
782 expectf(10.0, rectf
.Y
);
783 expectf(100.0, rectf
.Width
);
784 expectf(100.0, rectf
.Height
);
785 status
= GdipGetLineTransform(brush
, transform
);
787 status
= GdipGetMatrixElements(transform
, elements
);
789 expectf(1.0, elements
[0]);
790 expectf(0.0, elements
[1]);
791 expectf(0.0, elements
[2]);
792 expectf(1.0, elements
[3]);
793 expectf(0.0, elements
[4]);
794 expectf(0.0, elements
[5]);
795 status
= GdipDeleteBrush((GpBrush
*)brush
);
798 /* passing negative Width/Height to LinearGradientModeHorizontal */
799 rectf
.X
= rectf
.Y
= 10.0;
800 rectf
.Width
= rectf
.Height
= -100.0;
801 status
= GdipCreateLineBrushFromRect(&rectf
, 0, 0, LinearGradientModeHorizontal
,
802 WrapModeTile
, &brush
);
804 memset(&rectf
, 0, sizeof(GpRectF
));
805 status
= GdipGetLineRect(brush
, &rectf
);
807 expectf(10.0, rectf
.X
);
808 expectf(10.0, rectf
.Y
);
809 expectf(-100.0, rectf
.Width
);
810 expectf(-100.0, rectf
.Height
);
811 status
= GdipGetLineTransform(brush
, transform
);
813 status
= GdipGetMatrixElements(transform
, elements
);
815 expectf(1.0, elements
[0]);
816 expectf(0.0, elements
[1]);
817 expectf(0.0, elements
[2]);
818 expectf(1.0, elements
[3]);
819 expectf(0.0, elements
[4]);
820 expectf(0.0, elements
[5]);
821 status
= GdipDeleteBrush((GpBrush
*)brush
);
824 /* reverse gradient line as immediately previous */
829 status
= GdipCreateLineBrush(&pt1
, &pt2
, 0, 0, WrapModeTile
, &brush
);
831 memset(&rectf
, 0, sizeof(GpRectF
));
832 status
= GdipGetLineRect(brush
, &rectf
);
834 expectf(-90.0, rectf
.X
);
835 expectf(-40.0, rectf
.Y
);
836 expectf(100.0, rectf
.Width
);
837 expectf(100.0, rectf
.Height
);
838 status
= GdipGetLineTransform(brush
, transform
);
840 status
= GdipGetMatrixElements(transform
, elements
);
842 expectf(-1.0, elements
[0]);
843 expectf(0.0, elements
[1]);
844 expectf(0.0, elements
[2]);
845 expectf(-1.0, elements
[3]);
846 expectf(-80.0, elements
[4]);
847 expectf(20.0, elements
[5]);
848 status
= GdipDeleteBrush((GpBrush
*)brush
);
851 GdipDeleteMatrix(transform
);
854 static void test_lineblend(void)
856 GpLineGradient
*brush
;
861 const REAL factors
[5] = {0.0f
, 0.1f
, 0.5f
, 0.9f
, 1.0f
};
862 const REAL positions
[5] = {0.0f
, 0.2f
, 0.5f
, 0.8f
, 1.0f
};
863 const REAL two_positions
[2] = {0.0f
, 1.0f
};
864 const ARGB colors
[5] = {0xff0000ff, 0xff00ff00, 0xff00ffff, 0xffff0000, 0xffffffff};
865 REAL res_factors
[6] = {0.3f
, 0.0f
, 0.0f
, 0.0f
, 0.0f
};
866 REAL res_positions
[6] = {0.3f
, 0.0f
, 0.0f
, 0.0f
, 0.0f
};
867 ARGB res_colors
[6] = {0xdeadbeef, 0, 0, 0, 0};
869 pt1
.X
= pt1
.Y
= pt2
.Y
= pt2
.X
= 1.0;
870 status
= GdipCreateLineBrush(&pt1
, &pt2
, 0, 0, WrapModeTile
, &brush
);
871 expect(OutOfMemory
, status
);
874 pt2
.X
= pt2
.Y
= 100.0;
875 status
= GdipCreateLineBrush(&pt1
, &pt2
, 0, 0, WrapModeTile
, &brush
);
878 status
= GdipGetLineBlendCount(NULL
, &count
);
879 expect(InvalidParameter
, status
);
881 status
= GdipGetLineBlendCount(brush
, NULL
);
882 expect(InvalidParameter
, status
);
884 status
= GdipGetLineBlendCount(brush
, &count
);
888 status
= GdipGetLineBlend(NULL
, res_factors
, res_positions
, 1);
889 expect(InvalidParameter
, status
);
891 status
= GdipGetLineBlend(brush
, NULL
, res_positions
, 1);
892 expect(InvalidParameter
, status
);
894 status
= GdipGetLineBlend(brush
, res_factors
, NULL
, 1);
895 expect(InvalidParameter
, status
);
897 status
= GdipGetLineBlend(brush
, res_factors
, res_positions
, 0);
898 expect(InvalidParameter
, status
);
900 status
= GdipGetLineBlend(brush
, res_factors
, res_positions
, -1);
901 expect(InvalidParameter
, status
);
903 status
= GdipGetLineBlend(brush
, res_factors
, res_positions
, 1);
906 status
= GdipGetLineBlend(brush
, res_factors
, res_positions
, 2);
909 status
= GdipSetLineBlend(NULL
, factors
, positions
, 5);
910 expect(InvalidParameter
, status
);
912 status
= GdipSetLineBlend(brush
, NULL
, positions
, 5);
913 expect(InvalidParameter
, status
);
915 status
= GdipSetLineBlend(brush
, factors
, NULL
, 5);
916 expect(InvalidParameter
, status
);
918 status
= GdipSetLineBlend(brush
, factors
, positions
, 0);
919 expect(InvalidParameter
, status
);
921 status
= GdipSetLineBlend(brush
, factors
, positions
, -1);
922 expect(InvalidParameter
, status
);
924 /* leave off the 0.0 position */
925 status
= GdipSetLineBlend(brush
, &factors
[1], &positions
[1], 4);
926 expect(InvalidParameter
, status
);
928 /* leave off the 1.0 position */
929 status
= GdipSetLineBlend(brush
, factors
, positions
, 4);
930 expect(InvalidParameter
, status
);
932 status
= GdipSetLineBlend(brush
, factors
, positions
, 5);
935 status
= GdipGetLineBlendCount(brush
, &count
);
939 status
= GdipGetLineBlend(brush
, res_factors
, res_positions
, 4);
940 expect(InsufficientBuffer
, status
);
942 status
= GdipGetLineBlend(brush
, res_factors
, res_positions
, 5);
947 expectf(factors
[i
], res_factors
[i
]);
948 expectf(positions
[i
], res_positions
[i
]);
951 status
= GdipGetLineBlend(brush
, res_factors
, res_positions
, 6);
954 status
= GdipSetLineBlend(brush
, factors
, positions
, 1);
957 status
= GdipGetLineBlendCount(brush
, &count
);
961 status
= GdipGetLineBlend(brush
, res_factors
, res_positions
, 1);
964 status
= GdipGetLinePresetBlendCount(NULL
, &count
);
965 expect(InvalidParameter
, status
);
967 status
= GdipGetLinePresetBlendCount(brush
, NULL
);
968 expect(InvalidParameter
, status
);
970 status
= GdipGetLinePresetBlendCount(brush
, &count
);
974 status
= GdipGetLinePresetBlend(NULL
, res_colors
, res_positions
, 1);
975 expect(InvalidParameter
, status
);
977 status
= GdipGetLinePresetBlend(brush
, NULL
, res_positions
, 1);
978 expect(InvalidParameter
, status
);
980 status
= GdipGetLinePresetBlend(brush
, res_colors
, NULL
, 1);
981 expect(InvalidParameter
, status
);
983 status
= GdipGetLinePresetBlend(brush
, res_colors
, res_positions
, 0);
984 expect(InvalidParameter
, status
);
986 status
= GdipGetLinePresetBlend(brush
, res_colors
, res_positions
, -1);
987 expect(InvalidParameter
, status
);
989 status
= GdipGetLinePresetBlend(brush
, res_colors
, res_positions
, 1);
990 expect(InvalidParameter
, status
);
992 status
= GdipGetLinePresetBlend(brush
, res_colors
, res_positions
, 2);
993 expect(GenericError
, status
);
995 status
= GdipSetLinePresetBlend(NULL
, colors
, positions
, 5);
996 expect(InvalidParameter
, status
);
998 status
= GdipSetLinePresetBlend(brush
, NULL
, positions
, 5);
999 expect(InvalidParameter
, status
);
1001 status
= GdipSetLinePresetBlend(brush
, colors
, NULL
, 5);
1002 expect(InvalidParameter
, status
);
1004 status
= GdipSetLinePresetBlend(brush
, colors
, positions
, 0);
1005 expect(InvalidParameter
, status
);
1007 status
= GdipSetLinePresetBlend(brush
, colors
, positions
, -1);
1008 expect(InvalidParameter
, status
);
1010 status
= GdipSetLinePresetBlend(brush
, colors
, positions
, 1);
1011 expect(InvalidParameter
, status
);
1013 /* leave off the 0.0 position */
1014 status
= GdipSetLinePresetBlend(brush
, &colors
[1], &positions
[1], 4);
1015 expect(InvalidParameter
, status
);
1017 /* leave off the 1.0 position */
1018 status
= GdipSetLinePresetBlend(brush
, colors
, positions
, 4);
1019 expect(InvalidParameter
, status
);
1021 status
= GdipSetLinePresetBlend(brush
, colors
, positions
, 5);
1024 status
= GdipGetLinePresetBlendCount(brush
, &count
);
1028 status
= GdipGetLinePresetBlend(brush
, res_colors
, res_positions
, 4);
1029 expect(InsufficientBuffer
, status
);
1031 status
= GdipGetLinePresetBlend(brush
, res_colors
, res_positions
, 5);
1036 expect(colors
[i
], res_colors
[i
]);
1037 expectf(positions
[i
], res_positions
[i
]);
1040 status
= GdipGetLinePresetBlend(brush
, res_colors
, res_positions
, 6);
1043 status
= GdipSetLinePresetBlend(brush
, colors
, two_positions
, 2);
1046 status
= GdipDeleteBrush((GpBrush
*)brush
);
1050 static void test_linelinearblend(void)
1052 GpLineGradient
*brush
;
1056 REAL res_factors
[3] = {0.3f
};
1057 REAL res_positions
[3] = {0.3f
};
1059 status
= GdipSetLineLinearBlend(NULL
, 0.6, 0.8);
1060 expect(InvalidParameter
, status
);
1062 pt1
.X
= pt1
.Y
= 1.0;
1063 pt2
.X
= pt2
.Y
= 100.0;
1064 status
= GdipCreateLineBrush(&pt1
, &pt2
, 0, 0, WrapModeTile
, &brush
);
1068 status
= GdipSetLineLinearBlend(brush
, 0.6, 0.8);
1071 status
= GdipGetLineBlendCount(brush
, &count
);
1075 status
= GdipGetLineBlend(brush
, res_factors
, res_positions
, 3);
1077 expectf(0.0, res_factors
[0]);
1078 expectf(0.0, res_positions
[0]);
1079 expectf(0.8, res_factors
[1]);
1080 expectf(0.6, res_positions
[1]);
1081 expectf(0.0, res_factors
[2]);
1082 expectf(1.0, res_positions
[2]);
1085 status
= GdipSetLineLinearBlend(brush
, 0.0, 0.8);
1088 status
= GdipGetLineBlendCount(brush
, &count
);
1092 status
= GdipGetLineBlend(brush
, res_factors
, res_positions
, 3);
1094 expectf(0.8, res_factors
[0]);
1095 expectf(0.0, res_positions
[0]);
1096 expectf(0.0, res_factors
[1]);
1097 expectf(1.0, res_positions
[1]);
1100 status
= GdipSetLineLinearBlend(brush
, 1.0, 0.8);
1103 status
= GdipGetLineBlendCount(brush
, &count
);
1107 status
= GdipGetLineBlend(brush
, res_factors
, res_positions
, 3);
1109 expectf(0.0, res_factors
[0]);
1110 expectf(0.0, res_positions
[0]);
1111 expectf(0.8, res_factors
[1]);
1112 expectf(1.0, res_positions
[1]);
1114 status
= GdipDeleteBrush((GpBrush
*)brush
);
1118 static void test_gradientsurroundcolorcount(void)
1121 GpPathGradient
*grad
;
1125 status
= GdipCreatePathGradient(blendcount_ptf
, 2, WrapModeClamp
, &grad
);
1129 status
= GdipGetPathGradientSurroundColorCount(grad
, &count
);
1133 color
[0] = color
[1] = color
[2] = 0xdeadbeef;
1135 status
= GdipGetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1138 expect(0xffffffff, color
[0]);
1139 expect(0xffffffff, color
[1]);
1140 expect(0xdeadbeef, color
[2]);
1142 color
[0] = color
[1] = color
[2] = 0xdeadbeef;
1144 status
= GdipGetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1147 expect(0xffffffff, color
[0]);
1148 expect(0xffffffff, color
[1]);
1149 expect(0xdeadbeef, color
[2]);
1151 color
[0] = color
[1] = color
[2] = 0xdeadbeef;
1153 status
= GdipGetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1154 expect(InvalidParameter
, status
);
1156 expect(0xdeadbeef, color
[0]);
1157 expect(0xdeadbeef, color
[1]);
1158 expect(0xdeadbeef, color
[2]);
1160 color
[0] = color
[1] = color
[2] = 0xdeadbeef;
1162 status
= GdipGetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1163 expect(InvalidParameter
, status
);
1165 expect(0xdeadbeef, color
[0]);
1166 expect(0xdeadbeef, color
[1]);
1167 expect(0xdeadbeef, color
[2]);
1170 status
= GdipSetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1171 expect(InvalidParameter
, status
);
1175 color
[0] = 0x00ff0000;
1176 color
[1] = 0x0000ff00;
1178 status
= GdipSetPathGradientSurroundColorsWithCount(NULL
, color
, &count
);
1179 expect(InvalidParameter
, status
);
1181 status
= GdipSetPathGradientSurroundColorsWithCount(grad
, NULL
, &count
);
1182 expect(InvalidParameter
, status
);
1184 /* WinXP crashes on this test */
1187 status
= GdipSetPathGradientSurroundColorsWithCount(grad
, color
, NULL
);
1188 expect(InvalidParameter
, status
);
1191 status
= GdipSetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1195 status
= GdipGetPathGradientSurroundColorCount(NULL
, &count
);
1196 expect(InvalidParameter
, status
);
1198 status
= GdipGetPathGradientSurroundColorCount(grad
, NULL
);
1199 expect(InvalidParameter
, status
);
1202 status
= GdipGetPathGradientSurroundColorCount(grad
, &count
);
1206 color
[0] = color
[1] = color
[2] = 0xdeadbeef;
1208 status
= GdipGetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1211 expect(0x00ff0000, color
[0]);
1212 expect(0x0000ff00, color
[1]);
1213 expect(0xdeadbeef, color
[2]);
1216 status
= GdipSetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1221 status
= GdipGetPathGradientSurroundColorCount(grad
, &count
);
1225 /* If all colors are the same, count is set to 1. */
1226 color
[0] = color
[1] = 0;
1228 status
= GdipSetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1232 color
[0] = color
[1] = color
[2] = 0xdeadbeef;
1234 status
= GdipGetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1237 expect(0x00000000, color
[0]);
1238 expect(0x00000000, color
[1]);
1239 expect(0xdeadbeef, color
[2]);
1241 color
[0] = color
[1] = 0xff00ff00;
1243 status
= GdipSetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1247 color
[0] = color
[1] = color
[2] = 0xdeadbeef;
1249 status
= GdipGetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1252 expect(0xff00ff00, color
[0]);
1253 expect(0xff00ff00, color
[1]);
1254 expect(0xdeadbeef, color
[2]);
1257 status
= GdipSetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1258 expect(InvalidParameter
, status
);
1261 GdipDeleteBrush((GpBrush
*)grad
);
1263 status
= GdipCreatePathGradient(getbounds_ptf
, 3, WrapModeClamp
, &grad
);
1266 color
[0] = color
[1] = color
[2] = 0xdeadbeef;
1268 status
= GdipGetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1271 expect(0xffffffff, color
[0]);
1272 expect(0xffffffff, color
[1]);
1273 expect(0xffffffff, color
[2]);
1275 color
[0] = color
[1] = color
[2] = 0xdeadbeef;
1277 status
= GdipGetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1278 expect(InvalidParameter
, status
);
1280 expect(0xdeadbeef, color
[0]);
1281 expect(0xdeadbeef, color
[1]);
1282 expect(0xdeadbeef, color
[2]);
1285 status
= GdipGetPathGradientSurroundColorCount(grad
, &count
);
1289 GdipDeleteBrush((GpBrush
*)grad
);
1292 static void test_pathgradientpath(void)
1296 GpPathGradient
*grad
=NULL
;
1298 status
= GdipCreatePathGradient(blendcount_ptf
, 2, WrapModeClamp
, &grad
);
1301 status
= GdipGetPathGradientPath(grad
, NULL
);
1302 expect(NotImplemented
, status
);
1304 status
= GdipCreatePath(FillModeWinding
, &path
);
1307 status
= GdipGetPathGradientPath(NULL
, path
);
1308 expect(NotImplemented
, status
);
1310 status
= GdipGetPathGradientPath(grad
, path
);
1311 expect(NotImplemented
, status
);
1313 status
= GdipDeletePath(path
);
1316 status
= GdipDeleteBrush((GpBrush
*)grad
);
1320 static void test_pathgradientcenterpoint(void)
1322 static const GpPointF path_points
[] = {{0,0}, {3,0}, {0,4}};
1324 GpPathGradient
*grad
;
1327 status
= GdipCreatePathGradient(path_points
+1, 2, WrapModeClamp
, &grad
);
1330 status
= GdipGetPathGradientCenterPoint(NULL
, &point
);
1331 expect(InvalidParameter
, status
);
1333 status
= GdipGetPathGradientCenterPoint(grad
, NULL
);
1334 expect(InvalidParameter
, status
);
1336 status
= GdipGetPathGradientCenterPoint(grad
, &point
);
1338 expectf(1.5, point
.X
);
1339 expectf(2.0, point
.Y
);
1341 status
= GdipSetPathGradientCenterPoint(NULL
, &point
);
1342 expect(InvalidParameter
, status
);
1344 status
= GdipSetPathGradientCenterPoint(grad
, NULL
);
1345 expect(InvalidParameter
, status
);
1349 status
= GdipSetPathGradientCenterPoint(grad
, &point
);
1352 point
.X
= point
.Y
= -1;
1353 status
= GdipGetPathGradientCenterPoint(grad
, &point
);
1355 expectf(10.0, point
.X
);
1356 expectf(15.0, point
.Y
);
1358 status
= GdipDeleteBrush((GpBrush
*)grad
);
1361 status
= GdipCreatePathGradient(path_points
, 3, WrapModeClamp
, &grad
);
1364 status
= GdipGetPathGradientCenterPoint(grad
, &point
);
1366 todo_wine
expectf(1.0, point
.X
);
1367 todo_wine
expectf(4.0/3.0, point
.Y
);
1369 status
= GdipDeleteBrush((GpBrush
*)grad
);
1373 static void test_pathgradientpresetblend(void)
1375 static const GpPointF path_points
[] = {{0,0}, {3,0}, {0,4}};
1377 GpPathGradient
*grad
;
1380 const REAL positions
[5] = {0.0f
, 0.2f
, 0.5f
, 0.8f
, 1.0f
};
1381 const REAL two_positions
[2] = {0.0f
, 1.0f
};
1382 const ARGB colors
[5] = {0xff0000ff, 0xff00ff00, 0xff00ffff, 0xffff0000, 0xffffffff};
1383 REAL res_positions
[6] = {0.3f
, 0.0f
, 0.0f
, 0.0f
, 0.0f
};
1384 ARGB res_colors
[6] = {0xdeadbeef, 0, 0, 0, 0};
1386 status
= GdipCreatePathGradient(path_points
+1, 2, WrapModeClamp
, &grad
);
1389 status
= GdipGetPathGradientPresetBlendCount(NULL
, &count
);
1390 expect(InvalidParameter
, status
);
1392 status
= GdipGetPathGradientPresetBlendCount(grad
, NULL
);
1393 expect(InvalidParameter
, status
);
1395 status
= GdipGetPathGradientPresetBlendCount(grad
, &count
);
1399 status
= GdipGetPathGradientPresetBlend(NULL
, res_colors
, res_positions
, 1);
1400 expect(InvalidParameter
, status
);
1402 status
= GdipGetPathGradientPresetBlend(grad
, NULL
, res_positions
, 1);
1403 expect(InvalidParameter
, status
);
1405 status
= GdipGetPathGradientPresetBlend(grad
, res_colors
, NULL
, 1);
1406 expect(InvalidParameter
, status
);
1408 status
= GdipGetPathGradientPresetBlend(grad
, res_colors
, res_positions
, 0);
1409 expect(InvalidParameter
, status
);
1411 status
= GdipGetPathGradientPresetBlend(grad
, res_colors
, res_positions
, -1);
1412 expect(OutOfMemory
, status
);
1414 status
= GdipGetPathGradientPresetBlend(grad
, res_colors
, res_positions
, 1);
1415 expect(InvalidParameter
, status
);
1417 status
= GdipGetPathGradientPresetBlend(grad
, res_colors
, res_positions
, 2);
1418 expect(GenericError
, status
);
1420 status
= GdipSetPathGradientPresetBlend(NULL
, colors
, positions
, 5);
1421 expect(InvalidParameter
, status
);
1423 status
= GdipSetPathGradientPresetBlend(grad
, NULL
, positions
, 5);
1424 expect(InvalidParameter
, status
);
1428 /* crashes on windows xp */
1429 status
= GdipSetPathGradientPresetBlend(grad
, colors
, NULL
, 5);
1430 expect(InvalidParameter
, status
);
1433 status
= GdipSetPathGradientPresetBlend(grad
, colors
, positions
, 0);
1434 expect(InvalidParameter
, status
);
1436 status
= GdipSetPathGradientPresetBlend(grad
, colors
, positions
, -1);
1437 expect(InvalidParameter
, status
);
1439 status
= GdipSetPathGradientPresetBlend(grad
, colors
, positions
, 1);
1440 expect(InvalidParameter
, status
);
1442 /* leave off the 0.0 position */
1443 status
= GdipSetPathGradientPresetBlend(grad
, &colors
[1], &positions
[1], 4);
1444 expect(InvalidParameter
, status
);
1446 /* leave off the 1.0 position */
1447 status
= GdipSetPathGradientPresetBlend(grad
, colors
, positions
, 4);
1448 expect(InvalidParameter
, status
);
1450 status
= GdipSetPathGradientPresetBlend(grad
, colors
, positions
, 5);
1453 status
= GdipGetPathGradientPresetBlendCount(grad
, &count
);
1459 /* Native GdipGetPathGradientPresetBlend seems to copy starting from
1460 * the end of each array and do no bounds checking. This is so braindead
1461 * I'm not going to copy it. */
1463 res_colors
[0] = 0xdeadbeef;
1464 res_positions
[0] = 0.3;
1466 status
= GdipGetPathGradientPresetBlend(grad
, &res_colors
[1], &res_positions
[1], 4);
1469 expect(0xdeadbeef, res_colors
[0]);
1470 expectf(0.3, res_positions
[0]);
1474 expect(colors
[i
], res_colors
[i
]);
1475 expectf(positions
[i
], res_positions
[i
]);
1478 status
= GdipGetPathGradientPresetBlend(grad
, res_colors
, res_positions
, 6);
1483 expect(colors
[i
], res_colors
[i
+1]);
1484 expectf(positions
[i
], res_positions
[i
+1]);
1488 status
= GdipGetPathGradientPresetBlend(grad
, res_colors
, res_positions
, 5);
1493 expect(colors
[i
], res_colors
[i
]);
1494 expectf(positions
[i
], res_positions
[i
]);
1497 status
= GdipGetPathGradientPresetBlend(grad
, res_colors
, res_positions
, 0);
1498 expect(InvalidParameter
, status
);
1500 status
= GdipGetPathGradientPresetBlend(grad
, res_colors
, res_positions
, -1);
1501 expect(OutOfMemory
, status
);
1503 status
= GdipGetPathGradientPresetBlend(grad
, res_colors
, res_positions
, 1);
1504 expect(InvalidParameter
, status
);
1506 status
= GdipSetPathGradientPresetBlend(grad
, colors
, two_positions
, 2);
1509 status
= GdipDeleteBrush((GpBrush
*)grad
);
1513 static void test_pathgradientblend(void)
1515 static const GpPointF path_points
[] = {{0,0}, {3,0}, {0,4}};
1516 GpPathGradient
*brush
;
1519 const REAL factors
[5] = {0.0f
, 0.1f
, 0.5f
, 0.9f
, 1.0f
};
1520 const REAL positions
[5] = {0.0f
, 0.2f
, 0.5f
, 0.8f
, 1.0f
};
1521 REAL res_factors
[6] = {0.3f
, 0.0f
, 0.0f
, 0.0f
, 0.0f
};
1522 REAL res_positions
[6] = {0.3f
, 0.0f
, 0.0f
, 0.0f
, 0.0f
};
1524 status
= GdipCreatePathGradient(path_points
, 3, WrapModeClamp
, &brush
);
1527 status
= GdipGetPathGradientBlendCount(NULL
, &count
);
1528 expect(InvalidParameter
, status
);
1530 status
= GdipGetPathGradientBlendCount(brush
, NULL
);
1531 expect(InvalidParameter
, status
);
1533 status
= GdipGetPathGradientBlendCount(brush
, &count
);
1537 status
= GdipGetPathGradientBlend(NULL
, res_factors
, res_positions
, 1);
1538 expect(InvalidParameter
, status
);
1540 status
= GdipGetPathGradientBlend(brush
, NULL
, res_positions
, 1);
1541 expect(InvalidParameter
, status
);
1543 status
= GdipGetPathGradientBlend(brush
, res_factors
, NULL
, 1);
1544 expect(InvalidParameter
, status
);
1546 status
= GdipGetPathGradientBlend(brush
, res_factors
, res_positions
, 0);
1547 expect(InvalidParameter
, status
);
1549 status
= GdipGetPathGradientBlend(brush
, res_factors
, res_positions
, -1);
1550 expect(InvalidParameter
, status
);
1552 status
= GdipGetPathGradientBlend(brush
, res_factors
, res_positions
, 1);
1555 status
= GdipGetPathGradientBlend(brush
, res_factors
, res_positions
, 2);
1558 status
= GdipSetPathGradientBlend(NULL
, factors
, positions
, 5);
1559 expect(InvalidParameter
, status
);
1561 status
= GdipSetPathGradientBlend(brush
, NULL
, positions
, 5);
1562 expect(InvalidParameter
, status
);
1564 status
= GdipSetPathGradientBlend(brush
, factors
, NULL
, 5);
1565 expect(InvalidParameter
, status
);
1567 status
= GdipSetPathGradientBlend(brush
, factors
, positions
, 0);
1568 expect(InvalidParameter
, status
);
1570 status
= GdipSetPathGradientBlend(brush
, factors
, positions
, -1);
1571 expect(InvalidParameter
, status
);
1573 /* leave off the 0.0 position */
1574 status
= GdipSetPathGradientBlend(brush
, &factors
[1], &positions
[1], 4);
1575 expect(InvalidParameter
, status
);
1577 /* leave off the 1.0 position */
1578 status
= GdipSetPathGradientBlend(brush
, factors
, positions
, 4);
1579 expect(InvalidParameter
, status
);
1581 status
= GdipSetPathGradientBlend(brush
, factors
, positions
, 5);
1584 status
= GdipGetPathGradientBlendCount(brush
, &count
);
1588 status
= GdipGetPathGradientBlend(brush
, res_factors
, res_positions
, 4);
1589 expect(InsufficientBuffer
, status
);
1591 status
= GdipGetPathGradientBlend(brush
, res_factors
, res_positions
, 5);
1596 expectf(factors
[i
], res_factors
[i
]);
1597 expectf(positions
[i
], res_positions
[i
]);
1600 status
= GdipGetPathGradientBlend(brush
, res_factors
, res_positions
, 6);
1603 status
= GdipSetPathGradientBlend(brush
, factors
, positions
, 1);
1606 status
= GdipGetPathGradientBlendCount(brush
, &count
);
1610 status
= GdipGetPathGradientBlend(brush
, res_factors
, res_positions
, 1);
1613 status
= GdipDeleteBrush((GpBrush
*)brush
);
1617 static void test_getHatchStyle(void)
1621 GpHatchStyle hatchStyle
;
1623 GdipCreateHatchBrush(HatchStyleHorizontal
, 11, 12, &brush
);
1625 status
= GdipGetHatchStyle(NULL
, &hatchStyle
);
1626 expect(InvalidParameter
, status
);
1628 status
= GdipGetHatchStyle(brush
, NULL
);
1629 expect(InvalidParameter
, status
);
1631 status
= GdipGetHatchStyle(brush
, &hatchStyle
);
1633 expect(HatchStyleHorizontal
, hatchStyle
);
1635 GdipDeleteBrush((GpBrush
*)brush
);
1640 struct GdiplusStartupInput gdiplusStartupInput
;
1641 ULONG_PTR gdiplusToken
;
1643 int (CDECL
* _controlfp_s
)(unsigned int *cur
, unsigned int newval
, unsigned int mask
);
1646 /* Enable all FP exceptions except _EM_INEXACT, which gdi32 can trigger */
1647 hmsvcrt
= LoadLibraryA("msvcrt");
1648 _controlfp_s
= (void*)GetProcAddress(hmsvcrt
, "_controlfp_s");
1649 if (_controlfp_s
) _controlfp_s(0, 0, 0x0008001e);
1651 memset( &class, 0, sizeof(class) );
1652 class.lpszClassName
= "gdiplus_test";
1653 class.style
= CS_HREDRAW
| CS_VREDRAW
;
1654 class.lpfnWndProc
= DefWindowProcA
;
1655 class.hInstance
= GetModuleHandleA(0);
1656 class.hIcon
= LoadIconA(0, (LPCSTR
)IDI_APPLICATION
);
1657 class.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
1658 class.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
1659 RegisterClassA( &class );
1660 hwnd
= CreateWindowA( "gdiplus_test", "graphics test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
1661 CW_USEDEFAULT
, CW_USEDEFAULT
, 800, 600, 0, 0, GetModuleHandleA(0), 0 );
1662 ok(hwnd
!= NULL
, "Expected window to be created\n");
1664 gdiplusStartupInput
.GdiplusVersion
= 1;
1665 gdiplusStartupInput
.DebugEventCallback
= NULL
;
1666 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
1667 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
1669 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
1671 test_constructor_destructor();
1672 test_createHatchBrush();
1673 test_createLineBrushFromRectWithAngle();
1675 test_gradientblendcount();
1681 test_gradientgetrect();
1683 test_linelinearblend();
1684 test_gradientsurroundcolorcount();
1685 test_pathgradientpath();
1686 test_pathgradientcenterpoint();
1687 test_pathgradientpresetblend();
1688 test_pathgradientblend();
1689 test_getHatchStyle();
1691 GdiplusShutdown(gdiplusToken
);
1692 DestroyWindow(hwnd
);