From 0937186f7d15fed60f77fa2014d650f4d0b6b20b Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Wed, 14 Nov 2018 13:40:56 +0300 Subject: [PATCH] gdiplus: Fix brush transform created with GdipCreateLineBrushFromRect(). Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/gdiplus/brush.c | 34 ++++++---------------------------- dlls/gdiplus/tests/brush.c | 4 ---- 2 files changed, 6 insertions(+), 32 deletions(-) diff --git a/dlls/gdiplus/brush.c b/dlls/gdiplus/brush.c index 808e021fa1a..42b7e8457c2 100644 --- a/dlls/gdiplus/brush.c +++ b/dlls/gdiplus/brush.c @@ -408,9 +408,7 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect, ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap, GpLineGradient **line) { - GpPointF start, end; - GpStatus stat; - float far_x, far_y; + float angle; TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode, wrap, line); @@ -418,45 +416,25 @@ 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; + angle = 0.0f; 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; 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, diff --git a/dlls/gdiplus/tests/brush.c b/dlls/gdiplus/tests/brush.c index bc6b57f9b22..bb645ffef93 100644 --- a/dlls/gdiplus/tests/brush.c +++ b/dlls/gdiplus/tests/brush.c @@ -764,15 +764,11 @@ static void test_gradientgetrect(void) #define expectf2(expected, got) ok(fabs(expected - got) < 0.001, "%u: expected %.3f, got %.3f.\n", i, expected, got) expectf2(create_from_rect[i].transform[0], elements[0]); - todo_wine_if(create_from_rect[i].mode == LinearGradientModeVertical) { expectf2(create_from_rect[i].transform[1], elements[1]); expectf2(create_from_rect[i].transform[2], elements[2]); - } expectf2(create_from_rect[i].transform[3], elements[3]); - todo_wine_if(create_from_rect[i].mode == LinearGradientModeVertical) { expectf2(create_from_rect[i].transform[4], elements[4]); expectf2(create_from_rect[i].transform[5], elements[5]); - } #undef expectf2 }