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
25 #include "wine/test.h"
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)
32 static void test_constructor_destructor(void)
35 GpSolidFill
*brush
= NULL
;
37 status
= GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
39 ok(brush
!= NULL
, "Expected brush to be initialized\n");
41 status
= GdipDeleteBrush(NULL
);
42 expect(InvalidParameter
, status
);
44 status
= GdipDeleteBrush((GpBrush
*) brush
);
48 static void test_createHatchBrush(void)
53 status
= GdipCreateHatchBrush(HatchStyleMin
, 1, 2, &brush
);
55 ok(brush
!= NULL
, "Expected the brush to be initialized.\n");
57 GdipDeleteBrush((GpBrush
*)brush
);
59 status
= GdipCreateHatchBrush(HatchStyleMax
, 1, 2, &brush
);
61 ok(brush
!= NULL
, "Expected the brush to be initialized.\n");
63 GdipDeleteBrush((GpBrush
*)brush
);
65 status
= GdipCreateHatchBrush(HatchStyle05Percent
, 1, 2, NULL
);
66 expect(InvalidParameter
, status
);
68 status
= GdipCreateHatchBrush((HatchStyle
)(HatchStyleMin
- 1), 1, 2, &brush
);
69 expect(InvalidParameter
, status
);
71 status
= GdipCreateHatchBrush((HatchStyle
)(HatchStyleMax
+ 1), 1, 2, &brush
);
72 expect(InvalidParameter
, status
);
75 static void test_createLineBrushFromRectWithAngle(void)
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 };
84 status
= GdipCreateLineBrushFromRectWithAngle(&rect1
, 10, 11, 0, TRUE
, WrapModeTile
, &brush
);
86 GdipDeleteBrush((GpBrush
*) brush
);
88 status
= GdipCreateLineBrushFromRectWithAngle(&rect2
, 10, 11, 135, TRUE
, (WrapMode
)(WrapModeTile
- 1), &brush
);
90 GdipDeleteBrush((GpBrush
*) brush
);
92 status
= GdipCreateLineBrushFromRectWithAngle(&rect2
, 10, 11, -225, FALSE
, (WrapMode
)(WrapModeTile
- 1), &brush
);
94 GdipDeleteBrush((GpBrush
*) brush
);
96 status
= GdipCreateLineBrushFromRectWithAngle(&rect1
, 10, 11, 405, TRUE
, (WrapMode
)(WrapModeClamp
+ 1), &brush
);
98 GdipDeleteBrush((GpBrush
*) brush
);
100 status
= GdipCreateLineBrushFromRectWithAngle(&rect1
, 10, 11, 45, FALSE
, (WrapMode
)(WrapModeClamp
+ 1), &brush
);
102 GdipDeleteBrush((GpBrush
*) brush
);
104 status
= GdipCreateLineBrushFromRectWithAngle(&rect1
, 10, 11, 90, TRUE
, WrapModeTileFlipX
, &brush
);
107 status
= GdipCreateLineBrushFromRectWithAngle(NULL
, 10, 11, 90, TRUE
, WrapModeTile
, &brush
);
108 expect(InvalidParameter
, status
);
110 status
= GdipCreateLineBrushFromRectWithAngle(&rect3
, 10, 11, 90, TRUE
, WrapModeTileFlipXY
, &brush
);
111 expect(OutOfMemory
, status
);
113 status
= GdipCreateLineBrushFromRectWithAngle(&rect4
, 10, 11, 90, TRUE
, WrapModeTileFlipXY
, &brush
);
114 expect(OutOfMemory
, status
);
116 status
= GdipCreateLineBrushFromRectWithAngle(&rect3
, 10, 11, 90, TRUE
, WrapModeTileFlipXY
, NULL
);
117 expect(InvalidParameter
, status
);
119 status
= GdipCreateLineBrushFromRectWithAngle(&rect4
, 10, 11, 90, TRUE
, WrapModeTileFlipXY
, NULL
);
120 expect(InvalidParameter
, status
);
122 status
= GdipCreateLineBrushFromRectWithAngle(&rect3
, 10, 11, 90, TRUE
, WrapModeClamp
, &brush
);
123 expect(InvalidParameter
, status
);
125 status
= GdipCreateLineBrushFromRectWithAngle(&rect4
, 10, 11, 90, TRUE
, WrapModeClamp
, &brush
);
126 expect(InvalidParameter
, status
);
128 status
= GdipCreateLineBrushFromRectWithAngle(&rect1
, 10, 11, 90, TRUE
, WrapModeClamp
, &brush
);
129 expect(InvalidParameter
, status
);
131 status
= GdipCreateLineBrushFromRectWithAngle(&rect1
, 10, 11, 90, TRUE
, WrapModeTile
, NULL
);
132 expect(InvalidParameter
, status
);
134 GdipDeleteBrush((GpBrush
*) brush
);
137 static void test_type(void)
141 GpSolidFill
*brush
= NULL
;
143 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
145 status
= GdipGetBrushType((GpBrush
*)brush
, &bt
);
147 expect(BrushTypeSolidColor
, bt
);
149 GdipDeleteBrush((GpBrush
*) brush
);
151 static GpPointF blendcount_ptf
[] = {{0.0, 0.0},
153 static void test_gradientblendcount(void)
156 GpPathGradient
*brush
;
159 status
= GdipCreatePathGradient(blendcount_ptf
, 2, WrapModeClamp
, &brush
);
162 status
= GdipGetPathGradientBlendCount(NULL
, NULL
);
163 expect(InvalidParameter
, status
);
164 status
= GdipGetPathGradientBlendCount(NULL
, &count
);
165 expect(InvalidParameter
, status
);
166 status
= GdipGetPathGradientBlendCount(brush
, NULL
);
167 expect(InvalidParameter
, status
);
169 status
= GdipGetPathGradientBlendCount(brush
, &count
);
173 GdipDeleteBrush((GpBrush
*) brush
);
176 static GpPointF getblend_ptf
[] = {{0.0, 0.0},
178 static void test_getblend(void)
181 GpPathGradient
*brush
;
185 status
= GdipCreatePathGradient(getblend_ptf
, 2, WrapModeClamp
, &brush
);
188 /* check some invalid parameters combinations */
189 status
= GdipGetPathGradientBlend(NULL
, NULL
, NULL
, -1);
190 expect(InvalidParameter
, status
);
191 status
= GdipGetPathGradientBlend(brush
,NULL
, NULL
, -1);
192 expect(InvalidParameter
, status
);
193 status
= GdipGetPathGradientBlend(NULL
, blends
,NULL
, -1);
194 expect(InvalidParameter
, status
);
195 status
= GdipGetPathGradientBlend(NULL
, NULL
, pos
, -1);
196 expect(InvalidParameter
, status
);
197 status
= GdipGetPathGradientBlend(NULL
, NULL
, NULL
, 1);
198 expect(InvalidParameter
, status
);
200 blends
[0] = (REAL
)0xdeadbeef;
201 pos
[0] = (REAL
)0xdeadbeef;
202 status
= GdipGetPathGradientBlend(brush
, blends
, pos
, 1);
204 expectf(1.0, blends
[0]);
205 expectf((REAL
)0xdeadbeef, pos
[0]);
207 GdipDeleteBrush((GpBrush
*) brush
);
210 static GpPointF getbounds_ptf
[] = {{0.0, 20.0},
214 static void test_getbounds(void)
217 GpPathGradient
*brush
;
220 status
= GdipCreatePathGradient(getbounds_ptf
, 4, WrapModeClamp
, &brush
);
223 status
= GdipGetPathGradientRect(NULL
, NULL
);
224 expect(InvalidParameter
, status
);
225 status
= GdipGetPathGradientRect(brush
, NULL
);
226 expect(InvalidParameter
, status
);
227 status
= GdipGetPathGradientRect(NULL
, &bounds
);
228 expect(InvalidParameter
, status
);
230 status
= GdipGetPathGradientRect(brush
, &bounds
);
232 expectf(0.0, bounds
.X
);
233 expectf(20.0, bounds
.Y
);
234 expectf(50.0, bounds
.Width
);
235 expectf(30.0, bounds
.Height
);
237 GdipDeleteBrush((GpBrush
*) brush
);
240 static void test_getgamma(void)
243 GpLineGradient
*line
;
247 start
.X
= start
.Y
= 0.0;
248 end
.X
= end
.Y
= 100.0;
250 status
= GdipCreateLineBrush(&start
, &end
, (ARGB
)0xdeadbeef, 0xdeadbeef, WrapModeTile
, &line
);
254 status
= GdipGetLineGammaCorrection(NULL
, NULL
);
255 expect(InvalidParameter
, status
);
256 status
= GdipGetLineGammaCorrection(line
, NULL
);
257 expect(InvalidParameter
, status
);
258 status
= GdipGetLineGammaCorrection(NULL
, &gamma
);
259 expect(InvalidParameter
, status
);
261 GdipDeleteBrush((GpBrush
*)line
);
264 static void test_transform(void)
268 GpLineGradient
*line
;
269 GpGraphics
*graphics
= NULL
;
279 status
= GdipCreateMatrix2(2.0, 0.0, 0.0, 0.0, 0.0, 0.0, &m
);
282 status
= GdipCreateFromHDC(hdc
, &graphics
);
284 status
= GdipCreateBitmapFromGraphics(1, 1, graphics
, &bitmap
);
287 status
= GdipCreateTexture((GpImage
*)bitmap
, WrapModeTile
, &texture
);
291 status
= GdipGetTextureTransform(NULL
, NULL
);
292 expect(InvalidParameter
, status
);
293 status
= GdipGetTextureTransform(texture
, NULL
);
294 expect(InvalidParameter
, status
);
296 /* get default value - identity matrix */
297 status
= GdipGetTextureTransform(texture
, m
);
299 status
= GdipIsMatrixIdentity(m
, &res
);
302 /* set and get then */
303 status
= GdipCreateMatrix2(2.0, 0.0, 0.0, 2.0, 0.0, 0.0, &m1
);
305 status
= GdipSetTextureTransform(texture
, m1
);
307 status
= GdipGetTextureTransform(texture
, m
);
309 status
= GdipIsMatrixEqual(m
, m1
, &res
);
313 status
= GdipResetTextureTransform(texture
);
315 status
= GdipGetTextureTransform(texture
, m
);
317 status
= GdipIsMatrixIdentity(m
, &res
);
321 status
= GdipDeleteBrush((GpBrush
*)texture
);
324 status
= GdipDeleteMatrix(m1
);
326 status
= GdipDeleteMatrix(m
);
328 status
= GdipDisposeImage((GpImage
*)bitmap
);
330 status
= GdipDeleteGraphics(graphics
);
335 status
= GdipCreateFromHWND(hwnd
, &graphics
);
339 /* create with vertical gradient line */
340 start
.X
= start
.Y
= end
.X
= 0.0;
343 status
= GdipCreateLineBrush(&start
, &end
, (ARGB
)0xffff0000, 0xff00ff00, WrapModeTile
, &line
);
346 status
= GdipCreateMatrix2(1.0, 0.0, 0.0, 1.0, 0.0, 0.0, &m
);
350 status
= GdipResetLineTransform(NULL
);
351 expect(InvalidParameter
, status
);
352 status
= GdipSetLineTransform(NULL
, m
);
353 expect(InvalidParameter
, status
);
354 status
= GdipSetLineTransform(line
, NULL
);
355 expect(InvalidParameter
, status
);
356 status
= GdipGetLineTransform(NULL
, m
);
357 expect(InvalidParameter
, status
);
358 status
= GdipGetLineTransform(line
, NULL
);
359 expect(InvalidParameter
, status
);
360 status
= GdipScaleLineTransform(NULL
, 1, 1, MatrixOrderPrepend
);
361 expect(InvalidParameter
, status
);
362 status
= GdipMultiplyLineTransform(NULL
, m
, MatrixOrderPrepend
);
363 expect(InvalidParameter
, status
);
364 status
= GdipTranslateLineTransform(NULL
, 0, 0, MatrixOrderPrepend
);
365 expect(InvalidParameter
, status
);
367 /* initial transform */
368 status
= GdipGetLineTransform(line
, m
);
371 status
= GdipGetMatrixElements(m
, elements
);
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]);
380 status
= GdipGetLineRect(line
, &rectf
);
382 expectf(-50.0, rectf
.X
);
383 expectf(0.0, rectf
.Y
);
384 expectf(100.0, rectf
.Width
);
385 expectf(100.0, rectf
.Height
);
387 status
= GdipFillRectangle(graphics
, (GpBrush
*)line
, 0, 0, 200, 200);
390 /* manually set transform */
391 GdipSetMatrixElements(m
, 2.0, 0.0, 0.0, 4.0, 0.0, 0.0);
393 status
= GdipSetLineTransform(line
, m
);
396 status
= GdipGetLineTransform(line
, m
);
399 status
= GdipGetMatrixElements(m
, elements
);
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]);
408 status
= GdipGetLineRect(line
, &rectf
);
410 expectf(-50.0, rectf
.X
);
411 expectf(0.0, rectf
.Y
);
412 expectf(100.0, rectf
.Width
);
413 expectf(100.0, rectf
.Height
);
415 status
= GdipFillRectangle(graphics
, (GpBrush
*)line
, 200, 0, 200, 200);
418 /* scale transform */
419 status
= GdipScaleLineTransform(line
, 4.0, 0.5, MatrixOrderAppend
);
422 status
= GdipGetLineTransform(line
, m
);
425 status
= GdipGetMatrixElements(m
, elements
);
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]);
434 status
= GdipGetLineRect(line
, &rectf
);
436 expectf(-50.0, rectf
.X
);
437 expectf(0.0, rectf
.Y
);
438 expectf(100.0, rectf
.Width
);
439 expectf(100.0, rectf
.Height
);
441 status
= GdipFillRectangle(graphics
, (GpBrush
*)line
, 400, 0, 200, 200);
444 /* translate transform */
445 status
= GdipTranslateLineTransform(line
, 10.0, -20.0, MatrixOrderAppend
);
448 status
= GdipGetLineTransform(line
, m
);
451 status
= GdipGetMatrixElements(m
, elements
);
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]);
460 status
= GdipGetLineRect(line
, &rectf
);
462 expectf(-50.0, rectf
.X
);
463 expectf(0.0, rectf
.Y
);
464 expectf(100.0, rectf
.Width
);
465 expectf(100.0, rectf
.Height
);
467 status
= GdipFillRectangle(graphics
, (GpBrush
*)line
, 0, 200, 200, 200);
470 /* multiply transform */
471 GdipSetMatrixElements(m
, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
472 GdipRotateMatrix(m
, 45.0, MatrixOrderAppend
);
473 GdipScaleMatrix(m
, 0.25, 0.5, MatrixOrderAppend
);
475 status
= GdipMultiplyLineTransform(line
, m
, MatrixOrderAppend
);
478 /* NULL transform does nothing */
479 status
= GdipMultiplyLineTransform(line
, NULL
, MatrixOrderAppend
);
482 status
= GdipGetLineTransform(line
, m
);
485 status
= GdipGetMatrixElements(m
, elements
);
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]);
494 status
= GdipGetLineRect(line
, &rectf
);
496 expectf(-50.0, rectf
.X
);
497 expectf(0.0, rectf
.Y
);
498 expectf(100.0, rectf
.Width
);
499 expectf(100.0, rectf
.Height
);
501 status
= GdipFillRectangle(graphics
, (GpBrush
*)line
, 200, 200, 200, 200);
504 /* reset transform sets to identity */
505 status
= GdipResetLineTransform(line
);
508 status
= GdipGetLineTransform(line
, m
);
511 status
= GdipGetMatrixElements(m
, elements
);
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]);
520 status
= GdipGetLineRect(line
, &rectf
);
522 expectf(-50.0, rectf
.X
);
523 expectf(0.0, rectf
.Y
);
524 expectf(100.0, rectf
.Width
);
525 expectf(100.0, rectf
.Height
);
527 status
= GdipFillRectangle(graphics
, (GpBrush
*)line
, 400, 200, 200, 200);
530 GdipDeleteBrush((GpBrush
*)line
);
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,
536 LinearGradientModeHorizontal
, WrapModeTile
, &line
);
538 memset(&rectf
, 0, sizeof(GpRectF
));
539 status
= GdipGetLineRect(line
, &rectf
);
541 expectf(10.0, rectf
.X
);
542 expectf(10.0, rectf
.Y
);
543 expectf(-100.0, rectf
.Width
);
544 expectf(-100.0, rectf
.Height
);
545 status
= GdipGetLineTransform(line
, m
);
547 status
= GdipGetMatrixElements(m
, elements
);
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);
557 status
= GdipDeleteBrush((GpBrush
*)line
);
561 /* enable to visually compare with Windows */
563 while(GetMessageW(&msg
, hwnd
, 0, 0) > 0){
564 TranslateMessage(&msg
);
565 DispatchMessageW(&msg
);
570 GdipDeleteGraphics(graphics
);
574 static void test_texturewrap(void)
578 GpGraphics
*graphics
= NULL
;
583 status
= GdipCreateFromHDC(hdc
, &graphics
);
585 status
= GdipCreateBitmapFromGraphics(1, 1, graphics
, &bitmap
);
588 status
= GdipCreateTexture((GpImage
*)bitmap
, WrapModeTile
, &texture
);
592 status
= GdipGetTextureWrapMode(NULL
, NULL
);
593 expect(InvalidParameter
, status
);
594 status
= GdipGetTextureWrapMode(texture
, NULL
);
595 expect(InvalidParameter
, status
);
596 status
= GdipGetTextureWrapMode(NULL
, &wrap
);
597 expect(InvalidParameter
, status
);
600 wrap
= WrapModeClamp
;
601 status
= GdipGetTextureWrapMode(texture
, &wrap
);
603 expect(WrapModeTile
, wrap
);
605 wrap
= WrapModeClamp
;
606 status
= GdipSetTextureWrapMode(texture
, wrap
);
609 status
= GdipGetTextureWrapMode(texture
, &wrap
);
611 expect(WrapModeClamp
, wrap
);
613 status
= GdipDeleteBrush((GpBrush
*)texture
);
615 status
= GdipDisposeImage((GpImage
*)bitmap
);
617 status
= GdipDeleteGraphics(graphics
);
622 static void test_gradientgetrect(void)
626 LinearGradientMode mode
;
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
} },
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
} },
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
} },
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
} },
663 create_with_angle
[] =
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
} },
678 GpLineGradient
*brush
;
686 status
= GdipCreateMatrix(&transform
);
689 for (i
= 0; i
< ARRAY_SIZE(create_from_pt
); ++i
)
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
);
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");
699 status
= GdipGetLineTransform(brush
, transform
);
700 ok(status
== Ok
, "Failed to get brush transform, %d.\n", status
);
702 status
= GdipGetMatrixElements(transform
, elements
);
703 ok(status
== Ok
, "Failed to get matrix elements, %d.\n", status
);
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]);
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");
718 status
= GdipDeleteBrush((GpBrush
*)brush
);
719 ok(status
== Ok
, "Failed to delete a brush, %d.\n", status
);
722 /* zero height rect */
723 rectf
.X
= rectf
.Y
= 10.0;
726 status
= GdipCreateLineBrushFromRect(&rectf
, 0, 0, LinearGradientModeVertical
,
727 WrapModeTile
, &brush
);
728 expect(OutOfMemory
, status
);
730 /* zero width rect */
731 rectf
.X
= rectf
.Y
= 10.0;
733 rectf
.Height
= 100.0;
734 status
= GdipCreateLineBrushFromRect(&rectf
, 0, 0, LinearGradientModeHorizontal
,
735 WrapModeTile
, &brush
);
736 expect(OutOfMemory
, status
);
738 for (i
= 0; i
< ARRAY_SIZE(create_from_rect
); ++i
)
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
);
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");
752 status
= GdipGetLineTransform(brush
, transform
);
753 ok(status
== Ok
, "Failed to get brush transform, %d.\n", status
);
755 if (create_from_rect
[i
].mode
== LinearGradientModeHorizontal
)
757 status
= GdipIsMatrixIdentity(transform
, &ret
);
758 ok(status
== Ok
, "Unexpected ret value %d.\n", status
);
762 status
= GdipGetMatrixElements(transform
, elements
);
763 ok(status
== Ok
, "Failed to get matrix elements, %d.\n", status
);
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]);
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");
779 status
= GdipDeleteBrush((GpBrush
*)brush
);
780 ok(status
== Ok
, "Failed to delete a brush, %d.\n", status
);
783 for (i
= 0; i
< ARRAY_SIZE(create_with_angle
); ++i
)
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
);
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
);
798 status
= GdipGetLineTransform(brush
, transform
);
799 ok(status
== Ok
, "Failed to get brush transform, %d.\n", status
);
801 if (create_with_angle
[i
].angle
== 0.0f
)
803 status
= GdipIsMatrixIdentity(transform
, &ret
);
804 ok(status
== Ok
, "Unexpected ret value %d.\n", status
);
808 status
= GdipGetMatrixElements(transform
, elements
);
809 ok(status
== Ok
, "Failed to get matrix elements, %d.\n", status
);
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]);
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");
825 status
= GdipDeleteBrush((GpBrush
*)brush
);
826 ok(status
== Ok
, "Failed to delete a brush, %d.\n", status
);
829 GdipDeleteMatrix(transform
);
832 static void test_lineblend(void)
834 GpLineGradient
*brush
;
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};
847 pt1
.X
= pt1
.Y
= pt2
.Y
= pt2
.X
= 1.0;
848 status
= GdipCreateLineBrush(&pt1
, &pt2
, 0, 0, WrapModeTile
, &brush
);
849 expect(OutOfMemory
, status
);
852 pt2
.X
= pt2
.Y
= 100.0;
853 status
= GdipCreateLineBrush(&pt1
, &pt2
, 0, 0, WrapModeTile
, &brush
);
856 status
= GdipGetLineBlendCount(NULL
, &count
);
857 expect(InvalidParameter
, status
);
859 status
= GdipGetLineBlendCount(brush
, NULL
);
860 expect(InvalidParameter
, status
);
862 status
= GdipGetLineBlendCount(brush
, &count
);
866 status
= GdipGetLineBlend(NULL
, res_factors
, res_positions
, 1);
867 expect(InvalidParameter
, status
);
869 status
= GdipGetLineBlend(brush
, NULL
, res_positions
, 1);
870 expect(InvalidParameter
, status
);
872 status
= GdipGetLineBlend(brush
, res_factors
, NULL
, 1);
873 expect(InvalidParameter
, status
);
875 status
= GdipGetLineBlend(brush
, res_factors
, res_positions
, 0);
876 expect(InvalidParameter
, status
);
878 status
= GdipGetLineBlend(brush
, res_factors
, res_positions
, -1);
879 expect(InvalidParameter
, status
);
881 status
= GdipGetLineBlend(brush
, res_factors
, res_positions
, 1);
884 status
= GdipGetLineBlend(brush
, res_factors
, res_positions
, 2);
887 status
= GdipSetLineBlend(NULL
, factors
, positions
, 5);
888 expect(InvalidParameter
, status
);
890 status
= GdipSetLineBlend(brush
, NULL
, positions
, 5);
891 expect(InvalidParameter
, status
);
893 status
= GdipSetLineBlend(brush
, factors
, NULL
, 5);
894 expect(InvalidParameter
, status
);
896 status
= GdipSetLineBlend(brush
, factors
, positions
, 0);
897 expect(InvalidParameter
, status
);
899 status
= GdipSetLineBlend(brush
, factors
, positions
, -1);
900 expect(InvalidParameter
, status
);
902 /* leave off the 0.0 position */
903 status
= GdipSetLineBlend(brush
, &factors
[1], &positions
[1], 4);
904 expect(InvalidParameter
, status
);
906 /* leave off the 1.0 position */
907 status
= GdipSetLineBlend(brush
, factors
, positions
, 4);
908 expect(InvalidParameter
, status
);
910 status
= GdipSetLineBlend(brush
, factors
, positions
, 5);
913 status
= GdipGetLineBlendCount(brush
, &count
);
917 status
= GdipGetLineBlend(brush
, res_factors
, res_positions
, 4);
918 expect(InsufficientBuffer
, status
);
920 status
= GdipGetLineBlend(brush
, res_factors
, res_positions
, 5);
925 expectf(factors
[i
], res_factors
[i
]);
926 expectf(positions
[i
], res_positions
[i
]);
929 status
= GdipGetLineBlend(brush
, res_factors
, res_positions
, 6);
932 status
= GdipSetLineBlend(brush
, factors
, positions
, 1);
935 status
= GdipGetLineBlendCount(brush
, &count
);
939 status
= GdipGetLineBlend(brush
, res_factors
, res_positions
, 1);
942 status
= GdipGetLinePresetBlendCount(NULL
, &count
);
943 expect(InvalidParameter
, status
);
945 status
= GdipGetLinePresetBlendCount(brush
, NULL
);
946 expect(InvalidParameter
, status
);
948 status
= GdipGetLinePresetBlendCount(brush
, &count
);
952 status
= GdipGetLinePresetBlend(NULL
, res_colors
, res_positions
, 1);
953 expect(InvalidParameter
, status
);
955 status
= GdipGetLinePresetBlend(brush
, NULL
, res_positions
, 1);
956 expect(InvalidParameter
, status
);
958 status
= GdipGetLinePresetBlend(brush
, res_colors
, NULL
, 1);
959 expect(InvalidParameter
, status
);
961 status
= GdipGetLinePresetBlend(brush
, res_colors
, res_positions
, 0);
962 expect(InvalidParameter
, status
);
964 status
= GdipGetLinePresetBlend(brush
, res_colors
, res_positions
, -1);
965 expect(InvalidParameter
, status
);
967 status
= GdipGetLinePresetBlend(brush
, res_colors
, res_positions
, 1);
968 expect(InvalidParameter
, status
);
970 status
= GdipGetLinePresetBlend(brush
, res_colors
, res_positions
, 2);
971 expect(GenericError
, status
);
973 status
= GdipSetLinePresetBlend(NULL
, colors
, positions
, 5);
974 expect(InvalidParameter
, status
);
976 status
= GdipSetLinePresetBlend(brush
, NULL
, positions
, 5);
977 expect(InvalidParameter
, status
);
979 status
= GdipSetLinePresetBlend(brush
, colors
, NULL
, 5);
980 expect(InvalidParameter
, status
);
982 status
= GdipSetLinePresetBlend(brush
, colors
, positions
, 0);
983 expect(InvalidParameter
, status
);
985 status
= GdipSetLinePresetBlend(brush
, colors
, positions
, -1);
986 expect(InvalidParameter
, status
);
988 status
= GdipSetLinePresetBlend(brush
, colors
, positions
, 1);
989 expect(InvalidParameter
, status
);
991 /* leave off the 0.0 position */
992 status
= GdipSetLinePresetBlend(brush
, &colors
[1], &positions
[1], 4);
993 expect(InvalidParameter
, status
);
995 /* leave off the 1.0 position */
996 status
= GdipSetLinePresetBlend(brush
, colors
, positions
, 4);
997 expect(InvalidParameter
, status
);
999 status
= GdipSetLinePresetBlend(brush
, colors
, positions
, 5);
1002 status
= GdipGetLinePresetBlendCount(brush
, &count
);
1006 status
= GdipGetLinePresetBlend(brush
, res_colors
, res_positions
, 4);
1007 expect(InsufficientBuffer
, status
);
1009 status
= GdipGetLinePresetBlend(brush
, res_colors
, res_positions
, 5);
1014 expect(colors
[i
], res_colors
[i
]);
1015 expectf(positions
[i
], res_positions
[i
]);
1018 status
= GdipGetLinePresetBlend(brush
, res_colors
, res_positions
, 6);
1021 status
= GdipSetLinePresetBlend(brush
, colors
, two_positions
, 2);
1024 status
= GdipDeleteBrush((GpBrush
*)brush
);
1028 static void test_linelinearblend(void)
1030 GpLineGradient
*brush
;
1034 REAL res_factors
[3] = {0.3f
};
1035 REAL res_positions
[3] = {0.3f
};
1037 status
= GdipSetLineLinearBlend(NULL
, 0.6, 0.8);
1038 expect(InvalidParameter
, status
);
1040 pt1
.X
= pt1
.Y
= 1.0;
1041 pt2
.X
= pt2
.Y
= 100.0;
1042 status
= GdipCreateLineBrush(&pt1
, &pt2
, 0, 0, WrapModeTile
, &brush
);
1046 status
= GdipSetLineLinearBlend(brush
, 0.6, 0.8);
1049 status
= GdipGetLineBlendCount(brush
, &count
);
1053 status
= GdipGetLineBlend(brush
, res_factors
, res_positions
, 3);
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]);
1063 status
= GdipSetLineLinearBlend(brush
, 0.0, 0.8);
1066 status
= GdipGetLineBlendCount(brush
, &count
);
1070 status
= GdipGetLineBlend(brush
, res_factors
, res_positions
, 3);
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]);
1078 status
= GdipSetLineLinearBlend(brush
, 1.0, 0.8);
1081 status
= GdipGetLineBlendCount(brush
, &count
);
1085 status
= GdipGetLineBlend(brush
, res_factors
, res_positions
, 3);
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]);
1092 status
= GdipDeleteBrush((GpBrush
*)brush
);
1096 static void test_gradientsurroundcolorcount(void)
1099 GpPathGradient
*grad
;
1103 status
= GdipCreatePathGradient(blendcount_ptf
, 2, WrapModeClamp
, &grad
);
1107 status
= GdipGetPathGradientSurroundColorCount(grad
, &count
);
1111 color
[0] = color
[1] = color
[2] = 0xdeadbeef;
1113 status
= GdipGetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1116 expect(0xffffffff, color
[0]);
1117 expect(0xffffffff, color
[1]);
1118 expect(0xdeadbeef, color
[2]);
1120 color
[0] = color
[1] = color
[2] = 0xdeadbeef;
1122 status
= GdipGetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1125 expect(0xffffffff, color
[0]);
1126 expect(0xffffffff, color
[1]);
1127 expect(0xdeadbeef, color
[2]);
1129 color
[0] = color
[1] = color
[2] = 0xdeadbeef;
1131 status
= GdipGetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1132 expect(InvalidParameter
, status
);
1134 expect(0xdeadbeef, color
[0]);
1135 expect(0xdeadbeef, color
[1]);
1136 expect(0xdeadbeef, color
[2]);
1138 color
[0] = color
[1] = color
[2] = 0xdeadbeef;
1140 status
= GdipGetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1141 expect(InvalidParameter
, status
);
1143 expect(0xdeadbeef, color
[0]);
1144 expect(0xdeadbeef, color
[1]);
1145 expect(0xdeadbeef, color
[2]);
1148 status
= GdipSetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1149 expect(InvalidParameter
, status
);
1153 color
[0] = 0x00ff0000;
1154 color
[1] = 0x0000ff00;
1156 status
= GdipSetPathGradientSurroundColorsWithCount(NULL
, color
, &count
);
1157 expect(InvalidParameter
, status
);
1159 status
= GdipSetPathGradientSurroundColorsWithCount(grad
, NULL
, &count
);
1160 expect(InvalidParameter
, status
);
1162 /* WinXP crashes on this test */
1165 status
= GdipSetPathGradientSurroundColorsWithCount(grad
, color
, NULL
);
1166 expect(InvalidParameter
, status
);
1169 status
= GdipSetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1173 status
= GdipGetPathGradientSurroundColorCount(NULL
, &count
);
1174 expect(InvalidParameter
, status
);
1176 status
= GdipGetPathGradientSurroundColorCount(grad
, NULL
);
1177 expect(InvalidParameter
, status
);
1180 status
= GdipGetPathGradientSurroundColorCount(grad
, &count
);
1184 color
[0] = color
[1] = color
[2] = 0xdeadbeef;
1186 status
= GdipGetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1189 expect(0x00ff0000, color
[0]);
1190 expect(0x0000ff00, color
[1]);
1191 expect(0xdeadbeef, color
[2]);
1194 status
= GdipSetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1199 status
= GdipGetPathGradientSurroundColorCount(grad
, &count
);
1203 /* If all colors are the same, count is set to 1. */
1204 color
[0] = color
[1] = 0;
1206 status
= GdipSetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1210 color
[0] = color
[1] = color
[2] = 0xdeadbeef;
1212 status
= GdipGetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1215 expect(0x00000000, color
[0]);
1216 expect(0x00000000, color
[1]);
1217 expect(0xdeadbeef, color
[2]);
1219 color
[0] = color
[1] = 0xff00ff00;
1221 status
= GdipSetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1225 color
[0] = color
[1] = color
[2] = 0xdeadbeef;
1227 status
= GdipGetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1230 expect(0xff00ff00, color
[0]);
1231 expect(0xff00ff00, color
[1]);
1232 expect(0xdeadbeef, color
[2]);
1235 status
= GdipSetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1236 expect(InvalidParameter
, status
);
1239 GdipDeleteBrush((GpBrush
*)grad
);
1241 status
= GdipCreatePathGradient(getbounds_ptf
, 3, WrapModeClamp
, &grad
);
1244 color
[0] = color
[1] = color
[2] = 0xdeadbeef;
1246 status
= GdipGetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1249 expect(0xffffffff, color
[0]);
1250 expect(0xffffffff, color
[1]);
1251 expect(0xffffffff, color
[2]);
1253 color
[0] = color
[1] = color
[2] = 0xdeadbeef;
1255 status
= GdipGetPathGradientSurroundColorsWithCount(grad
, color
, &count
);
1256 expect(InvalidParameter
, status
);
1258 expect(0xdeadbeef, color
[0]);
1259 expect(0xdeadbeef, color
[1]);
1260 expect(0xdeadbeef, color
[2]);
1263 status
= GdipGetPathGradientSurroundColorCount(grad
, &count
);
1267 GdipDeleteBrush((GpBrush
*)grad
);
1270 static void test_pathgradientpath(void)
1274 GpPathGradient
*grad
=NULL
;
1276 status
= GdipCreatePathGradient(blendcount_ptf
, 2, WrapModeClamp
, &grad
);
1279 status
= GdipGetPathGradientPath(grad
, NULL
);
1280 expect(NotImplemented
, status
);
1282 status
= GdipCreatePath(FillModeWinding
, &path
);
1285 status
= GdipGetPathGradientPath(NULL
, path
);
1286 expect(NotImplemented
, status
);
1288 status
= GdipGetPathGradientPath(grad
, path
);
1289 expect(NotImplemented
, status
);
1291 status
= GdipDeletePath(path
);
1294 status
= GdipDeleteBrush((GpBrush
*)grad
);
1298 static void test_pathgradientcenterpoint(void)
1300 static const GpPointF path_points
[] = {{0,0}, {3,0}, {0,4}};
1302 GpPathGradient
*grad
;
1305 status
= GdipCreatePathGradient(path_points
+1, 2, WrapModeClamp
, &grad
);
1308 status
= GdipGetPathGradientCenterPoint(NULL
, &point
);
1309 expect(InvalidParameter
, status
);
1311 status
= GdipGetPathGradientCenterPoint(grad
, NULL
);
1312 expect(InvalidParameter
, status
);
1314 status
= GdipGetPathGradientCenterPoint(grad
, &point
);
1316 expectf(1.5, point
.X
);
1317 expectf(2.0, point
.Y
);
1319 status
= GdipSetPathGradientCenterPoint(NULL
, &point
);
1320 expect(InvalidParameter
, status
);
1322 status
= GdipSetPathGradientCenterPoint(grad
, NULL
);
1323 expect(InvalidParameter
, status
);
1327 status
= GdipSetPathGradientCenterPoint(grad
, &point
);
1330 point
.X
= point
.Y
= -1;
1331 status
= GdipGetPathGradientCenterPoint(grad
, &point
);
1333 expectf(10.0, point
.X
);
1334 expectf(15.0, point
.Y
);
1336 status
= GdipDeleteBrush((GpBrush
*)grad
);
1339 status
= GdipCreatePathGradient(path_points
, 3, WrapModeClamp
, &grad
);
1342 status
= GdipGetPathGradientCenterPoint(grad
, &point
);
1344 todo_wine
expectf(1.0, point
.X
);
1345 todo_wine
expectf(4.0/3.0, point
.Y
);
1347 status
= GdipDeleteBrush((GpBrush
*)grad
);
1351 static void test_pathgradientpresetblend(void)
1353 static const GpPointF path_points
[] = {{0,0}, {3,0}, {0,4}};
1355 GpPathGradient
*grad
;
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};
1364 status
= GdipCreatePathGradient(path_points
+1, 2, WrapModeClamp
, &grad
);
1367 status
= GdipGetPathGradientPresetBlendCount(NULL
, &count
);
1368 expect(InvalidParameter
, status
);
1370 status
= GdipGetPathGradientPresetBlendCount(grad
, NULL
);
1371 expect(InvalidParameter
, status
);
1373 status
= GdipGetPathGradientPresetBlendCount(grad
, &count
);
1377 status
= GdipGetPathGradientPresetBlend(NULL
, res_colors
, res_positions
, 1);
1378 expect(InvalidParameter
, status
);
1380 status
= GdipGetPathGradientPresetBlend(grad
, NULL
, res_positions
, 1);
1381 expect(InvalidParameter
, status
);
1383 status
= GdipGetPathGradientPresetBlend(grad
, res_colors
, NULL
, 1);
1384 expect(InvalidParameter
, status
);
1386 status
= GdipGetPathGradientPresetBlend(grad
, res_colors
, res_positions
, 0);
1387 expect(InvalidParameter
, status
);
1389 status
= GdipGetPathGradientPresetBlend(grad
, res_colors
, res_positions
, -1);
1390 expect(OutOfMemory
, status
);
1392 status
= GdipGetPathGradientPresetBlend(grad
, res_colors
, res_positions
, 1);
1393 expect(InvalidParameter
, status
);
1395 status
= GdipGetPathGradientPresetBlend(grad
, res_colors
, res_positions
, 2);
1396 expect(GenericError
, status
);
1398 status
= GdipSetPathGradientPresetBlend(NULL
, colors
, positions
, 5);
1399 expect(InvalidParameter
, status
);
1401 status
= GdipSetPathGradientPresetBlend(grad
, NULL
, positions
, 5);
1402 expect(InvalidParameter
, status
);
1406 /* crashes on windows xp */
1407 status
= GdipSetPathGradientPresetBlend(grad
, colors
, NULL
, 5);
1408 expect(InvalidParameter
, status
);
1411 status
= GdipSetPathGradientPresetBlend(grad
, colors
, positions
, 0);
1412 expect(InvalidParameter
, status
);
1414 status
= GdipSetPathGradientPresetBlend(grad
, colors
, positions
, -1);
1415 expect(InvalidParameter
, status
);
1417 status
= GdipSetPathGradientPresetBlend(grad
, colors
, positions
, 1);
1418 expect(InvalidParameter
, status
);
1420 /* leave off the 0.0 position */
1421 status
= GdipSetPathGradientPresetBlend(grad
, &colors
[1], &positions
[1], 4);
1422 expect(InvalidParameter
, status
);
1424 /* leave off the 1.0 position */
1425 status
= GdipSetPathGradientPresetBlend(grad
, colors
, positions
, 4);
1426 expect(InvalidParameter
, status
);
1428 status
= GdipSetPathGradientPresetBlend(grad
, colors
, positions
, 5);
1431 status
= GdipGetPathGradientPresetBlendCount(grad
, &count
);
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. */
1441 res_colors
[0] = 0xdeadbeef;
1442 res_positions
[0] = 0.3;
1444 status
= GdipGetPathGradientPresetBlend(grad
, &res_colors
[1], &res_positions
[1], 4);
1447 expect(0xdeadbeef, res_colors
[0]);
1448 expectf(0.3, res_positions
[0]);
1452 expect(colors
[i
], res_colors
[i
]);
1453 expectf(positions
[i
], res_positions
[i
]);
1456 status
= GdipGetPathGradientPresetBlend(grad
, res_colors
, res_positions
, 6);
1461 expect(colors
[i
], res_colors
[i
+1]);
1462 expectf(positions
[i
], res_positions
[i
+1]);
1466 status
= GdipGetPathGradientPresetBlend(grad
, res_colors
, res_positions
, 5);
1471 expect(colors
[i
], res_colors
[i
]);
1472 expectf(positions
[i
], res_positions
[i
]);
1475 status
= GdipGetPathGradientPresetBlend(grad
, res_colors
, res_positions
, 0);
1476 expect(InvalidParameter
, status
);
1478 status
= GdipGetPathGradientPresetBlend(grad
, res_colors
, res_positions
, -1);
1479 expect(OutOfMemory
, status
);
1481 status
= GdipGetPathGradientPresetBlend(grad
, res_colors
, res_positions
, 1);
1482 expect(InvalidParameter
, status
);
1484 status
= GdipSetPathGradientPresetBlend(grad
, colors
, two_positions
, 2);
1487 status
= GdipDeleteBrush((GpBrush
*)grad
);
1491 static void test_pathgradientblend(void)
1493 static const GpPointF path_points
[] = {{0,0}, {3,0}, {0,4}};
1494 GpPathGradient
*brush
;
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
};
1502 status
= GdipCreatePathGradient(path_points
, 3, WrapModeClamp
, &brush
);
1505 status
= GdipGetPathGradientBlendCount(NULL
, &count
);
1506 expect(InvalidParameter
, status
);
1508 status
= GdipGetPathGradientBlendCount(brush
, NULL
);
1509 expect(InvalidParameter
, status
);
1511 status
= GdipGetPathGradientBlendCount(brush
, &count
);
1515 status
= GdipGetPathGradientBlend(NULL
, res_factors
, res_positions
, 1);
1516 expect(InvalidParameter
, status
);
1518 status
= GdipGetPathGradientBlend(brush
, NULL
, res_positions
, 1);
1519 expect(InvalidParameter
, status
);
1521 status
= GdipGetPathGradientBlend(brush
, res_factors
, NULL
, 1);
1522 expect(InvalidParameter
, status
);
1524 status
= GdipGetPathGradientBlend(brush
, res_factors
, res_positions
, 0);
1525 expect(InvalidParameter
, status
);
1527 status
= GdipGetPathGradientBlend(brush
, res_factors
, res_positions
, -1);
1528 expect(InvalidParameter
, status
);
1530 status
= GdipGetPathGradientBlend(brush
, res_factors
, res_positions
, 1);
1533 status
= GdipGetPathGradientBlend(brush
, res_factors
, res_positions
, 2);
1536 status
= GdipSetPathGradientBlend(NULL
, factors
, positions
, 5);
1537 expect(InvalidParameter
, status
);
1539 status
= GdipSetPathGradientBlend(brush
, NULL
, positions
, 5);
1540 expect(InvalidParameter
, status
);
1542 status
= GdipSetPathGradientBlend(brush
, factors
, NULL
, 5);
1543 expect(InvalidParameter
, status
);
1545 status
= GdipSetPathGradientBlend(brush
, factors
, positions
, 0);
1546 expect(InvalidParameter
, status
);
1548 status
= GdipSetPathGradientBlend(brush
, factors
, positions
, -1);
1549 expect(InvalidParameter
, status
);
1551 /* leave off the 0.0 position */
1552 status
= GdipSetPathGradientBlend(brush
, &factors
[1], &positions
[1], 4);
1553 expect(InvalidParameter
, status
);
1555 /* leave off the 1.0 position */
1556 status
= GdipSetPathGradientBlend(brush
, factors
, positions
, 4);
1557 expect(InvalidParameter
, status
);
1559 status
= GdipSetPathGradientBlend(brush
, factors
, positions
, 5);
1562 status
= GdipGetPathGradientBlendCount(brush
, &count
);
1566 status
= GdipGetPathGradientBlend(brush
, res_factors
, res_positions
, 4);
1567 expect(InsufficientBuffer
, status
);
1569 status
= GdipGetPathGradientBlend(brush
, res_factors
, res_positions
, 5);
1574 expectf(factors
[i
], res_factors
[i
]);
1575 expectf(positions
[i
], res_positions
[i
]);
1578 status
= GdipGetPathGradientBlend(brush
, res_factors
, res_positions
, 6);
1581 status
= GdipSetPathGradientBlend(brush
, factors
, positions
, 1);
1584 status
= GdipGetPathGradientBlendCount(brush
, &count
);
1588 status
= GdipGetPathGradientBlend(brush
, res_factors
, res_positions
, 1);
1591 status
= GdipDeleteBrush((GpBrush
*)brush
);
1595 static void test_getHatchStyle(void)
1599 GpHatchStyle hatchStyle
;
1601 GdipCreateHatchBrush(HatchStyleHorizontal
, 11, 12, &brush
);
1603 status
= GdipGetHatchStyle(NULL
, &hatchStyle
);
1604 expect(InvalidParameter
, status
);
1606 status
= GdipGetHatchStyle(brush
, NULL
);
1607 expect(InvalidParameter
, status
);
1609 status
= GdipGetHatchStyle(brush
, &hatchStyle
);
1611 expect(HatchStyleHorizontal
, hatchStyle
);
1613 GdipDeleteBrush((GpBrush
*)brush
);
1618 struct GdiplusStartupInput gdiplusStartupInput
;
1619 ULONG_PTR gdiplusToken
;
1621 int (CDECL
* _controlfp_s
)(unsigned int *cur
, unsigned int newval
, unsigned int mask
);
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);
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");
1642 gdiplusStartupInput
.GdiplusVersion
= 1;
1643 gdiplusStartupInput
.DebugEventCallback
= NULL
;
1644 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
1645 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
1647 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
1649 test_constructor_destructor();
1650 test_createHatchBrush();
1651 test_createLineBrushFromRectWithAngle();
1653 test_gradientblendcount();
1659 test_gradientgetrect();
1661 test_linelinearblend();
1662 test_gradientsurroundcolorcount();
1663 test_pathgradientpath();
1664 test_pathgradientcenterpoint();
1665 test_pathgradientpresetblend();
1666 test_pathgradientblend();
1667 test_getHatchStyle();
1669 GdiplusShutdown(gdiplusToken
);
1670 DestroyWindow(hwnd
);