https://git.reactos.org/?p=reactos.git;a=commitdiff;h=daadcc61414330c909625…
commit daadcc61414330c909625c08fe2b909c0bf5621f
Author: Joachim Henze <Joachim.Henze(a)reactos.org>
AuthorDate: Sun Jan 13 17:14:41 2019 +0100
Commit: Joachim Henze <Joachim.Henze(a)reactos.org>
CommitDate: Sun Jan 13 17:14:41 2019 +0100
[GDIPLUS] Fix a regression painting gradient CORE-15479
patch is import of Wine commit 0937186f7d15fed60f77fa2014d650f4d0b6b20b
by Nikolay Sivov
---
dll/win32/gdiplus/brush.c | 67 ++++++++++++++++++++++++-----------------------
1 file changed, 34 insertions(+), 33 deletions(-)
diff --git a/dll/win32/gdiplus/brush.c b/dll/win32/gdiplus/brush.c
index d06832045a..f726023982 100644
--- a/dll/win32/gdiplus/brush.c
+++ b/dll/win32/gdiplus/brush.c
@@ -428,8 +428,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);
@@ -437,45 +437,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 LinearGradientModeHorizontal:
- 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);
+ angle = 90.0f;
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);
+ angle = 45.0f;
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);
+ 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;
+ 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,
@@ -503,9 +491,9 @@ 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);
@@ -544,12 +532,25 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST
GpRectF* rect
cos_angle = cosf(angle);
sin_cos_angle = sin_angle * cos_angle;
+ far_x = rect->X + rect->Width;
+ far_y = rect->Y + rect->Height;
+
if (sin_cos_angle >= 0)
- mode = 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);
+ }
else
- mode = 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);
+ }
- stat = GdipCreateLineBrushFromRect(rect, startcolor, endcolor, mode, wrap, line);
+ stat = GdipCreateLineBrush(&start, &end, startcolor, endcolor, wrap, line);
if (stat == Ok)
{