gdiplus: Reject linear gradients where the start and end points are equal.
This commit is contained in:
parent
bb5f5dba93
commit
2661ce79d6
@ -325,6 +325,9 @@ GpStatus WINGDIPAPI GdipCreateLineBrush(GDIPCONST GpPointF* startpoint,
|
|||||||
if(!line || !startpoint || !endpoint || wrap == WrapModeClamp)
|
if(!line || !startpoint || !endpoint || wrap == WrapModeClamp)
|
||||||
return InvalidParameter;
|
return InvalidParameter;
|
||||||
|
|
||||||
|
if (startpoint->X == endpoint->X && startpoint->Y == endpoint->Y)
|
||||||
|
return OutOfMemory;
|
||||||
|
|
||||||
*line = GdipAlloc(sizeof(GpLineGradient));
|
*line = GdipAlloc(sizeof(GpLineGradient));
|
||||||
if(!*line) return OutOfMemory;
|
if(!*line) return OutOfMemory;
|
||||||
|
|
||||||
|
@ -356,6 +356,20 @@ static void test_gradientgetrect(void)
|
|||||||
expectf(100.0, rectf.Width);
|
expectf(100.0, rectf.Width);
|
||||||
expectf(1.0, rectf.Height);
|
expectf(1.0, rectf.Height);
|
||||||
status = GdipDeleteBrush((GpBrush*)brush);
|
status = GdipDeleteBrush((GpBrush*)brush);
|
||||||
|
/* zero height rect */
|
||||||
|
rectf.X = rectf.Y = 10.0;
|
||||||
|
rectf.Width = 100.0;
|
||||||
|
rectf.Height = 0.0;
|
||||||
|
status = GdipCreateLineBrushFromRect(&rectf, 0, 0, LinearGradientModeVertical,
|
||||||
|
WrapModeTile, &brush);
|
||||||
|
expect(OutOfMemory, status);
|
||||||
|
/* zero width rect */
|
||||||
|
rectf.X = rectf.Y = 10.0;
|
||||||
|
rectf.Width = 0.0;
|
||||||
|
rectf.Height = 100.0;
|
||||||
|
status = GdipCreateLineBrushFromRect(&rectf, 0, 0, LinearGradientModeHorizontal,
|
||||||
|
WrapModeTile, &brush);
|
||||||
|
expect(OutOfMemory, status);
|
||||||
/* from rect with LinearGradientModeHorizontal */
|
/* from rect with LinearGradientModeHorizontal */
|
||||||
rectf.X = rectf.Y = 10.0;
|
rectf.X = rectf.Y = 10.0;
|
||||||
rectf.Width = rectf.Height = 100.0;
|
rectf.Width = rectf.Height = 100.0;
|
||||||
@ -401,6 +415,10 @@ static void test_lineblend(void)
|
|||||||
REAL res_positions[6] = {0.3f, 0.0f, 0.0f, 0.0f, 0.0f};
|
REAL res_positions[6] = {0.3f, 0.0f, 0.0f, 0.0f, 0.0f};
|
||||||
ARGB res_colors[6] = {0xdeadbeef, 0, 0, 0, 0};
|
ARGB res_colors[6] = {0xdeadbeef, 0, 0, 0, 0};
|
||||||
|
|
||||||
|
pt1.X = pt1.Y = pt2.Y = pt2.X = 1.0;
|
||||||
|
status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush);
|
||||||
|
expect(OutOfMemory, status);
|
||||||
|
|
||||||
pt1.X = pt1.Y = 1.0;
|
pt1.X = pt1.Y = 1.0;
|
||||||
pt2.X = pt2.Y = 100.0;
|
pt2.X = pt2.Y = 100.0;
|
||||||
status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush);
|
status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user