[0.4.7][GDIPLUS] Fix a regression painting gradient CORE-15479

patch is import of Wine commit 0937186f7d15fed60f77fa2014d650f4d0b6b20b
by Nikolay Sivov

regression was introduced by SVN r75872 == git 0.4.7-dev-344-g
c6f32e4a5f

fix cherry picked from 0.4.12-dev-360-g
daadcc6141
This commit is contained in:
Joachim Henze 2020-10-03 23:24:06 +02:00
parent b638ba6426
commit 25515885f3

View file

@ -409,8 +409,8 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect,
GpLineGradient **line)
{
GpPointF start, end;
float far_x, angle;
GpStatus stat;
float far_x, far_y;
TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode,
wrap, line);
@ -418,45 +418,33 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect,
if(!line || !rect)
return InvalidParameter;
far_x = rect->X + rect->Width;
far_y = rect->Y + rect->Height;
switch (mode)
{
case LinearGradientModeVertical:
angle = 90.0f;
break;
case LinearGradientModeForwardDiagonal:
angle = 45.0f;
break;
case LinearGradientModeBackwardDiagonal:
angle = 135.0f;
break;
case LinearGradientModeHorizontal:
far_x = rect->X + rect->Width;
start.X = min(rect->X, far_x);
start.Y = rect->Y;
end.X = max(rect->X, far_x);
end.Y = rect->Y;
break;
case LinearGradientModeVertical:
start.X = rect->X;
start.Y = min(rect->Y, far_y);
end.X = rect->X;
end.Y = max(rect->Y, far_y);
break;
case LinearGradientModeForwardDiagonal:
start.X = min(rect->X, far_x);
start.Y = min(rect->Y, far_y);
end.X = max(rect->X, far_x);
end.Y = max(rect->Y, far_y);
break;
case LinearGradientModeBackwardDiagonal:
start.X = max(rect->X, far_x);
start.Y = min(rect->Y, far_y);
end.X = min(rect->X, far_x);
end.Y = max(rect->Y, far_y);
break;
stat = GdipCreateLineBrush(&start, &end, startcolor, endcolor, wrap, line);
if (stat == Ok)
(*line)->rect = *rect;
return stat;
default:
return InvalidParameter;
}
stat = GdipCreateLineBrush(&start, &end, startcolor, endcolor, wrap, line);
if (stat == Ok)
(*line)->rect = *rect;
return stat;
return GdipCreateLineBrushFromRectWithAngle(rect, startcolor, endcolor, angle, TRUE, wrap, line);
}
GpStatus WINGDIPAPI GdipCreateLineBrushFromRectI(GDIPCONST GpRect* rect,
@ -484,16 +472,19 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect
GpLineGradient **line)
{
GpStatus stat;
LinearGradientMode mode;
REAL exofs, eyofs;
REAL exofs, eyofs, far_x, far_y;
REAL sin_angle, cos_angle, sin_cos_angle;
GpPointF start, end;
TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable,
wrap, line);
if (!rect || !rect->Width || !rect->Height)
if (!rect || !line || wrap == WrapModeClamp)
return InvalidParameter;
if (!rect->Width || !rect->Height)
return OutOfMemory;
angle = fmodf(angle, 360);
if (angle < 0)
angle += 360;
@ -522,12 +513,25 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect
cos_angle = cosf(angle);
sin_cos_angle = sin_angle * cos_angle;
if (sin_cos_angle >= 0)
mode = LinearGradientModeForwardDiagonal;
else
mode = LinearGradientModeBackwardDiagonal;
far_x = rect->X + rect->Width;
far_y = rect->Y + rect->Height;
stat = GdipCreateLineBrushFromRect(rect, startcolor, endcolor, mode, wrap, line);
if (sin_cos_angle >= 0)
{
start.X = min(rect->X, far_x);
start.Y = min(rect->Y, far_y);
end.X = max(rect->X, far_x);
end.Y = max(rect->Y, far_y);
}
else
{
start.X = max(rect->X, far_x);
start.Y = min(rect->Y, far_y);
end.X = min(rect->X, far_x);
end.Y = max(rect->Y, far_y);
}
stat = GdipCreateLineBrush(&start, &end, startcolor, endcolor, wrap, line);
if (stat == Ok)
{